diff --recursive --minimal --unified --new-file Old/SCOptions SCOptions --- Old/SCOptions +++ SCOptions Tue Apr 13 15:29:16 1993 @@ -0,0 +1,32 @@ +Ansi +Batch +Data=Far +Error=All +ErrorRexx +IncludeDir=A20: +MemSize=Huge +Modified +NoIcons +NoMultipleIncludes +NoStackCheck +OnError=Continue +Optimize +OptimizerComplexity=6 +OptimizerDepth=6 +OptimizerInlineLocal +OptimizerRecurDepth=6 +OptimizerTime +OptGo +OptPeep +Parameters=Registers +SmallCode +Startup=c +Strict +StringMerge +StripDebug +Verbose +Define USE_BUILTIN_MATH +Define AMIGA +Define STDC_HEADERS +Ignore 149 +Ignore 178 diff --recursive --minimal --unified --new-file Old/SMakefile SMakefile --- Old/SMakefile +++ SMakefile Tue Apr 13 15:29:16 1993 @@ -0,0 +1,59 @@ +# Makefile for gzip (GNU zip) -*- Indented-Text -*- +# This Makefile is for SAS/C 6.2 on the Amiga +# Made by Carsten Steger (carsten.steger@informatik.tu-muenchen.de) +# Modified by Jörg Plate + +# Some notes on gzip for the Amiga: +# Due to a broken implementation of readdir() in the SAS/C 6.2 library +# you should not use gzip -r on a directory in the RAM-Disk. To zip all +# files in a directory 'dir' in the RAM-Disk use something like +# gzip ram:dir/#? ram:dir/#?/#? ... +# where the number of '#?'s reflects the depth of the directory 'dir'. +# +# Alas, the program has it's full functionality only if you have +# Kickstart 2.0 or higher installed. This affects the expansion of +# wildcards and the preservation of file access times. You should use +# a shell that does wildcard expansion under Kickstart 1.3. + +CC = sc + +#OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \ +# crypt.o lzw.o unlzw.o unpack.o getopt.o alloca.o tailor.o match.o + +OBJS = gzip.o zip.o deflate.o trees.o bits.o unzip.o inflate.o util.o \ +lzw.o unlzw.o unpack.o getopt.o alloca.o tailor.o match.o + +.c.o: + $(CC) $< + +.a.o: + $(CC) $< + +all: gzip + +gzip: $(OBJS) + $(CC) link $(OBJS) TO $@ + +gzip.o: gzip.c gzip.h tailor.h revision.h lzw.h getopt.h +zip.o: zip.c gzip.h tailor.h crypt.h +deflate.o: deflate.c gzip.h tailor.h +bits.o: bits.c gzip.h tailor.h crypt.h +unzip.o: unzip.c gzip.h tailor.h crypt.h +inflate.o: inflate.c gzip.h tailor.h +util.o: util.c gzip.h tailor.h crypt.h +lzw.o: lzw.c lzw.h gzip.h tailor.h +unlzw.o: unlzw.c gzip.h tailor.h revision.h lzw.h +unpack.o: unpack.c gzip.h tailor.h +crypt.o: crypt.c gzip.h tailor.h +getopt.o: getopt.c getopt.h +tailor.o: tailor.c + +alloca.o: alloca.c + $(CC) DEF=STACK_DIRECTION=-1 $< + +match.o: match.a + +# Compile trees.c without optimization (produces incorrect code) + +trees.o: trees.c gzip.h tailor.h + $(CC) noopt $< diff --recursive --minimal --unified --new-file Old/alloca.c alloca.c --- Old/alloca.c Tue Apr 13 15:31:50 1993 +++ alloca.c Tue Apr 13 15:28:46 1993 @@ -56,8 +56,14 @@ #define NULL 0 /* null pointer constant */ +#ifdef __SASC_60 +pointer alloca (unsigned); +extern void free(pointer); +extern pointer xmalloc(unsigned); +#else extern void free(); extern pointer xmalloc(); +#endif /* Define STACK_DIRECTION if you know the direction of stack --- Old/getopt.c Tue Apr 13 15:31:53 1993 +++ getopt.c Tue Apr 13 16:31:19 1993 @@ -19,6 +19,18 @@ along with this program; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef __SASC_60 +static char * my_index(char const * string, int chr); +static void my_bcopy(char * from, char * to, int size); +static void exchange(char ** argv); +int _getopt_internal(int , char * const * , char const * , struct option const * , int * , int ); +int getopt(int argc, char * const * argv, char const * optstring); +int getopt_long(int , char * const * , char const * , struct option const * , int * ); +int getopt_long_only(int , char * const * , char const * , struct option const * , int * ); +extern void *alloca (int); +extern char *getenv (char *); +#endif + /* AIX requires this to be the first thing in the file. */ #ifdef __GNUC__ #define alloca __builtin_alloca @@ -29,8 +41,10 @@ #ifdef _AIX #pragma alloca #else +#ifndef __SASC_60 char *alloca (); #endif +#endif #endif /* alloca.h */ #endif /* not __GNUC__ */ @@ -152,6 +166,12 @@ #define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) #else +#ifdef __SASC_60 +#include +#define my_index strchr +#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) +#else + /* Avoid depending on library functions or files whose names are inconsistent. */ @@ -180,6 +200,7 @@ for (i = 0; i < size; i++) to[i] = from[i]; } +#endif #endif /* GNU C library. */ /* Handle permutation of arguments. */ diff --recursive --minimal --unified --new-file Old/match.a match.a --- Old/match.a +++ match.a Tue Apr 13 15:29:16 1993 @@ -0,0 +1,175 @@ +; match.a -- optional optimized asm version of longest match in deflate.c +; Copyright (C) 1992-1993 Jean-loup Gailly +; This is free software; you can redistribute it and/or modify it under the +; terms of the GNU General Public License, see the file COPYING. + +; $Id: match.a,v 1.1 1993/03/11 16:05:57 jloup Exp $ +; +; Adapted for the Amiga by Carsten Steger +; using the code in match.S. +; The major change in this code consists of removing all unaligned +; word accesses, because they cause 68000-based Amigas to crash. +; For maximum speed, UNALIGNED_OK can be defined in Makefile.sasc. +; The program will then only run on 68020-based Amigas, though. +; +; This code will run with registerized parameters too, unless SAS +; changes parameter passing conventions between new releases of SAS/C. + + +Cur_Match reg d0 ; Must be in d0! +Best_Len reg d1 +Loop_Counter reg d2 +Scan_Start reg d3 +Scan_End reg d4 +Limit reg d5 +Chain_Length reg d6 +Scan_Test reg d7 +Scan reg a0 +Match reg a1 +Prev_Address reg a2 +Scan_Ini reg a3 +Match_Ini reg a4 + +MAX_MATCH equ 258 +MIN_MATCH equ 3 +WSIZE equ 32768 +MAX_DIST equ WSIZE-MAX_MATCH-MIN_MATCH-1 + + + xref _max_chain_length + xref _prev_length + xref _prev + xref _window + xref _strstart + xref _good_match + xref _match_start + xref _nice_match + + + section match,code + + xdef _match_init + xdef @match_init + xdef _longest_match + xdef @longest_match + + +_match_init: +@match_init: + rts + + +_longest_match: + move.l 4(sp),Cur_Match +@longest_match: + ifd UNALIGNED_OK + movem.l d2-d6/a2-a4,-(sp) + else + movem.l d2-d7/a2-a4,-(sp) + endc + move.l _max_chain_length,Chain_Length + move.l _prev_length,Best_Len + lea _prev,Prev_Address + lea _window+MIN_MATCH,Match_Ini + move.l _strstart,Limit + move.l Match_Ini,Scan_Ini + add.l Limit,Scan_Ini + subi.w #MAX_DIST,Limit + bhi.b limit_ok + moveq #0,Limit +limit_ok: + cmp.l _good_match,Best_Len + bcs.b length_ok + lsr.l #2,Chain_Length +length_ok: + subq.l #1,Chain_Length + + ifd UNALIGNED_OK + + move.w -MIN_MATCH(Scan_Ini),Scan_Start + move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End + + else + + move.b -MIN_MATCH(Scan_Ini),Scan_Start + lsl.w #8,Scan_Start + move.b -MIN_MATCH+1(Scan_Ini),Scan_Start + move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End + lsl.w #8,Scan_End + move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End + + endc + + bra.b do_scan + +long_loop: + + ifd UNALIGNED_OK + + move.w -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End + + else + + move.b -MIN_MATCH-1(Scan_Ini,Best_Len),Scan_End + lsl.w #8,Scan_End + move.b -MIN_MATCH(Scan_Ini,Best_Len),Scan_End + + endc + +short_loop: + lsl.w #1,Cur_Match + move.w 0(Prev_Address,Cur_Match),Cur_Match + cmp.w Limit,Cur_Match + dbls Chain_Length,do_scan + bra.b return + +do_scan: + move.l Match_Ini,Match + add.l Cur_Match,Match + + ifd UNALIGNED_OK + + cmp.w -MIN_MATCH-1(Match,Best_Len),Scan_End + bne.b short_loop + cmp.w -MIN_MATCH(Match),Scan_Start + bne.b short_loop + + else + + move.b -MIN_MATCH-1(Match,Best_Len),Scan_Test + lsl.w #8,Scan_Test + move.b -MIN_MATCH(Match,Best_Len),Scan_Test + cmp.w Scan_Test,Scan_End + bne.b short_loop + move.b -MIN_MATCH(Match),Scan_Test + lsl.w #8,Scan_Test + move.b -MIN_MATCH+1(Match),Scan_Test + cmp.w Scan_Test,Scan_Start + bne.b short_loop + + endc + + move.w #(MAX_MATCH-MIN_MATCH),Loop_Counter + move.l Scan_Ini,Scan +scan_loop: + cmpm.b (Match)+,(Scan)+ + dbne Loop_Counter,scan_loop + + sub.l Scan_Ini,Scan + addq.l #(MIN_MATCH-1),Scan + cmp.l Best_Len,Scan + bls.b short_loop + move.l Scan,Best_Len + move.l Cur_Match,_match_start + cmp.l _nice_match,Best_Len + bcs.b long_loop +return: + move.l Best_Len,d0 + ifd UNALIGNED_OK + movem.l (sp)+,d2-d6/a2-a4 + else + movem.l (sp)+,d2-d7/a2-a4 + endc + rts + + end diff --recursive --minimal --unified --new-file Old/tailor.c tailor.c --- Old/tailor.c +++ tailor.c Tue Apr 13 15:28:50 1993 @@ -0,0 +1,183 @@ +/* tailor.c -- target dependent functions + * Copyright (C) 1993 Carsten Steger (carsten.steger@informatik.tu-muenchen.de) + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License, see the file COPYING. + */ + +/* + * This file contains Amiga specific functions for gzip. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAXPATH 1024 +#define MAXARGS 512 + +extern struct DosLibrary *DOSBase; + +extern void *xmalloc(unsigned int size); + +static char *expand_next_file (char *pattern); +static int in_prev_args (char *arg, char **argv, int argc); +extern void _expand_args (int *oargc, char ***oargv); + + +static char *expand_next_file (pattern) + char *pattern; +{ + long err; + char *pathname; + static struct AnchorPath *an = NULL; + + pathname = NULL; + if (pattern == NULL) + err = -1; + else + do + { + if (an == NULL) + { + an = xmalloc (sizeof (struct AnchorPath) + MAXPATH); + memset (an, 0, sizeof (struct AnchorPath) + MAXPATH); + an->ap_BreakBits = SIGBREAKF_CTRL_C; + an->ap_Strlen = MAXPATH; + an->ap_Flags = APF_DOWILD; + err = MatchFirst (pattern, an); + } + else + err = MatchNext (an); + + pathname = an->ap_Buf; + } while (err == 0 && pathname == NULL); + + if (err) + { + MatchEnd (an); + free (an); + an = NULL; + return NULL; + } + else + return pathname; +} + + +static int in_prev_args (arg, argv, argc) + char *arg, **argv; + int argc; +{ + int i, is_in_args; + + is_in_args = 0; + for (i = 1; i < argc - 1; i++) + if (stricmp (arg, argv[i]) == 0) + is_in_args = 1; + return is_in_args; +} + + +void _expand_args (oargc, oargv) + int *oargc; + char ***oargv; +{ + int i; + char *str, **argv; + static char buf[MAXPATH]; + int argc, no_match_at_all, num_matches, contains_wildcards; + + /* With Kickstart 1.3 wildcards can't be expanded. */ + if (DOSBase->dl_lib.lib_Version < 37) return; + + no_match_at_all = 1; + contains_wildcards = 0; + argc = 0; + argv = xmalloc (MAXARGS * sizeof (char *)); + + argv[argc++] = (*oargv)[0]; + for (i = 1; i < *oargc; i++) + { + if (ParsePattern ((*oargv)[i], buf, MAXPATH)) + { + contains_wildcards = 1; + num_matches = 0; + while (str = expand_next_file ((*oargv)[i])) + if (argc >= MAXARGS) + { + expand_next_file (NULL); + fprintf (stderr,"Too many files.\n"); + exit (20); + } + else + { + /* Avoid duplicate entries */ + if (!in_prev_args (str, argv, argc)) + { + argv[argc++] = strdup (str); + num_matches++; + } + } + if (num_matches != 0) + no_match_at_all = 0; + } + else + if (argc >= MAXARGS) + { + fprintf (stderr,"Too many files.\n"); + exit (20); + } + else + { + if (!in_prev_args ((*oargv)[i], argv, argc)) + argv[argc++] = (*oargv)[i]; + } + } + *oargc = argc; + *oargv = argv; + if (no_match_at_all && contains_wildcards) { + fprintf (stderr,"No match.\n"); + exit (20); + } +} + + +int utime (path, times) + char *path; + struct utimbuf *times; +{ + struct DateStamp date; + LONG error; + time_t modtime; + + /* With Kickstart 1.3 setting the filedate could be done, I guess. + * Maybe someone else will implement and test the code for this + * case (I don't have Kickstart 1.3). */ + if (DOSBase->dl_lib.lib_Version < 37) return 0; + + /* Amiga dates are counted from 1. Jan 1978 as opposed to 1. Jan 1970 + * on Unix. Therefore we have to subtract 2922 days (8*365+2). We also + * have to subtract the value of __timezone since SAS/C uses "CST+06" + * as the default value. */ + modtime = times->modtime - __timezone; + date.ds_Days = (modtime / 86400) - 2922; + modtime %= 86400; + date.ds_Minute = modtime / 60; + modtime %= 60; + date.ds_Tick = modtime * TICKS_PER_SECOND; + error = SetFileDate (path, &date); + if (error == DOSFALSE) + { + errno = EOSERR; + return -1; + } + return 0; +} diff --recursive --minimal --unified --new-file Old/unlzw.c unlzw.c --- Old/unlzw.c Tue Apr 13 15:32:04 1993 +++ unlzw.c Tue Apr 13 15:28:50 1993 @@ -146,12 +146,12 @@ }; #if BYTEORDER == 4321 && NOALLIGN == 1 -# define input(b,o,c,n,m){ \ +# define input(b,o,c,n,m) { \ (c) = (*(long *)(&(b)[(o)>>3])>>((o)&0x7))&(m); \ (o) += (n); \ } #else -# define input(b,o,c,n,m){ \ +# define input(b,o,c,n,m) { \ REG1 char_type *p = &(b)[(o)>>3]; \ (c) = ((((long)(p[0]))|((long)(p[1])<<8)| \ ((long)(p[2])<<16))>>((o)&0x7))&(m); \ diff --recursive --minimal --unified --new-file Old/utime.h utime.h --- Old/utime.h +++ utime.h Tue Apr 13 15:29:08 1993 @@ -0,0 +1,15 @@ +#ifndef _UTIME_H +#define _UTIME_H 1 + +#ifndef _TIME_H +#include +#endif + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime (char *path, struct utimbuf *times); + +#endif