diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-09 21:17:12 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-09 21:17:12 +0100 |
| commit | b5cd18739a64c8d923a55b61c89ae3900faafd84 (patch) | |
| tree | d192f7b25257ae9a8a4760c68f5314dcbc0d9b91 /bin/gzip | |
| parent | 119aed5bc787ccbf23d2f151759ec1f3a80977e1 (diff) | |
Fix include paths and formatting inconsistencies
Diffstat (limited to 'bin/gzip')
| -rw-r--r-- | bin/gzip/gzip.c | 35 | ||||
| -rw-r--r-- | bin/gzip/inflate.c | 33 | ||||
| -rw-r--r-- | bin/gzip/unzip.c | 3 | ||||
| -rw-r--r-- | bin/gzip/util.c | 39 |
4 files changed, 31 insertions, 79 deletions
diff --git a/bin/gzip/gzip.c b/bin/gzip/gzip.c index ddafcade..bc7a4bf2 100644 --- a/bin/gzip/gzip.c +++ b/bin/gzip/gzip.c @@ -49,7 +49,6 @@ static char *license_msg[] = { static char rcsid[] = "$Id: gzip.c,v 1.3 2005/02/12 21:03:28 olh Exp $"; #endif -#include <ctype.h> #include <sys/types.h> #include <signal.h> #include <sys/stat.h> @@ -230,9 +229,7 @@ local void version() } /* ======================================================================== */ -int main(argc, argv) -int argc; -char **argv; +int main(int argc, char **argv) { int file_count; /* number of files to precess */ int optc; /* current option */ @@ -489,7 +486,7 @@ local void treat_stdin() /* ======================================================================== * Compress or decompress the given file */ -local void treat_file(iname) char *iname; +local void treat_file(char *iname) { /* Accept "-" as synonym for stdin */ if (strequ(iname, "-")) { @@ -692,9 +689,7 @@ local int create_outfile() * Use lstat if available, except for -c or -f. Use stat otherwise. * This allows links when not removing the original file. */ -local int do_stat(name, sbuf) -char *name; -struct stat *sbuf; +local int do_stat(char *name, struct stat *sbuf) { errno = 0; if (!to_stdout && !force) { @@ -715,8 +710,7 @@ struct stat *sbuf; * On systems allowing multiple versions of the same file (such as VMS), * this function removes any version suffix in the given name. */ -local char *get_suffix(name) -char *name; +local char *get_suffix(char *name) { int nlen, slen; char suffix[MAX_SUFFIX + 3]; /* last chars of name, forced to lower case @@ -754,9 +748,7 @@ char *name; * For MSDOS, we try only z_suffix and z. * Return OK or ERROR. */ -local int get_istat(iname, sbuf) -char *iname; -struct stat *sbuf; +local int get_istat(char *iname, struct stat *sbuf) { int ilen; /* strlen(ifname) */ static char *suffixes[] = { z_suffix, ".gz", ".z", "-z", ".Z", NULL }; @@ -1019,9 +1011,7 @@ local int get_method() /* ======================================================================== * Return true if the two stat structures correspond to the same file. */ -local int same_file(stat1, stat2) -struct stat *stat1; -struct stat *stat2; +local int same_file(struct stat *stat1, struct stat *stat2) { return stat1->st_ino == stat2->st_ino && stat1->st_dev == stat2->st_dev @@ -1042,9 +1032,7 @@ struct stat *stat2; * Return true if a file name is ambiguous because the operating system * truncates file names. */ -local int name_too_long(name, statb) -char *name; /* file name to check */ -struct stat *statb; /* stat buf for this file name */ +local int name_too_long(char *name, struct stat *statb) { int s = strlen(name); char c = name[s - 1]; @@ -1068,7 +1056,7 @@ struct stat *statb; /* stat buf for this file name */ * * IN assertion: for compression, the suffix of the given name is z_suffix. */ -local void shorten_name(name) char *name; +local void shorten_name(char *name) { int len; /* length of name without z_suffix */ char *trunc = NULL; /* character to be truncated */ @@ -1215,8 +1203,7 @@ local int check_ofname() /* ======================================================================== * Set the access and modification times from the given stat buffer. */ -local void reset_times(name, statb) char *name; -struct stat *statb; +local void reset_times(char *name, struct stat *statb) { struct utimbuf timep; @@ -1236,7 +1223,7 @@ struct stat *statb; * Copy modes, times, ownership from input file to output file. * IN assertion: to_stdout is false. */ -local void copy_stat(ifstat) struct stat *ifstat; +local void copy_stat(struct stat *ifstat) { if (decompress && time_stamp != 0 && ifstat->st_mtime != time_stamp) { ifstat->st_mtime = time_stamp; @@ -1268,7 +1255,7 @@ local void copy_stat(ifstat) struct stat *ifstat; /* ======================================================================== * Free all dynamically allocated variables and exit with the given code. */ -local void do_exit(exitcode) int exitcode; +local void do_exit(int exitcode) { static int in_exit = 0; diff --git a/bin/gzip/inflate.c b/bin/gzip/inflate.c index a2235515..bf9774f0 100644 --- a/bin/gzip/inflate.c +++ b/bin/gzip/inflate.c @@ -159,7 +159,7 @@ static ush cplens[] = { /* Copy lengths for literal codes 257..285 */ static ush cplext[] = { /* Extra bits for literal codes 257..285 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 -}; /* 99==invalid */ +}; /* 99==invalid */ static ush cpdist[] = { /* Copy offsets for distance codes 0..29 */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, @@ -268,19 +268,8 @@ int dbits = 6; /* bits in base distance lookup table */ unsigned hufts; /* track memory usage */ -int huft_build(b, n, s, d, e, t, m) -unsigned *b; /* code lengths in bits (all assumed <= BMAX) */ -unsigned n; /* number of codes (assumed <= N_MAX) */ -unsigned s; /* number of simple-valued codes (0..s-1) */ -ush *d; /* list of base values for non-simple codes */ -ush *e; /* list of extra bits for non-simple codes */ -struct huft **t; /* result: starting table */ -int *m; /* maximum lookup bits, returns actual */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return zero on success, one if - the given code set is incomplete (the tables are still built in this - case), two if the input is invalid (all zero length codes or an - oversubscribed set of lengths), and three if not enough memory. */ +int huft_build(unsigned *b, unsigned n, unsigned s, ush *d, ush *e, + struct huft **t, int *m) { unsigned a; /* counter for codes of length k */ unsigned c[BMAX + 1]; /* bit length count table */ @@ -474,11 +463,7 @@ int *m; /* maximum lookup bits, returns actual */ return y != 0 && g != 1; } -int huft_free(t) -struct huft *t; /* table to free */ -/* Free the malloc'ed tables built by huft_build(), which makes a linked - list of the tables it made, with the links in a dummy first entry of - each table. */ +int huft_free(struct huft *t) { register struct huft *p, *q; @@ -492,11 +477,7 @@ struct huft *t; /* table to free */ return 0; } -int inflate_codes(tl, td, bl, bd) -struct huft *tl, *td; /* literal/length and distance decoder tables */ -int bl, bd; /* number of bits decoded by tl[] and td[] */ -/* inflate (decompress) the codes in a deflated (compressed) block. - Return an error code or zero if it all goes ok. */ +int inflate_codes(struct huft *tl, struct huft *td, int bl, int bd) { register unsigned e; /* table entry flag/number of extra bits */ unsigned n, d; /* length and index for copy */ @@ -837,9 +818,7 @@ int inflate_dynamic() return 0; } -int inflate_block(e) -int *e; /* last block flag */ -/* decompress an inflated block */ +int inflate_block(int *e) { unsigned t; /* block type */ register ulg b; /* bit buffer */ diff --git a/bin/gzip/unzip.c b/bin/gzip/unzip.c index 72855f8b..ba259afa 100644 --- a/bin/gzip/unzip.c +++ b/bin/gzip/unzip.c @@ -27,8 +27,7 @@ static char rcsid[] = "$Id: unzip.c,v 1.1 2002/08/18 00:59:21 hpa Exp $"; * the compressed data, from offsets inptr to insize-1 included. * The magic header has already been checked. The output buffer is cleared. */ -int unzip(in, out) -int in, out; /* input and output file descriptors */ +int unzip(int in, int out) { ulg orig_crc = 0; /* original crc */ ulg orig_len = 0; /* original uncompressed length */ diff --git a/bin/gzip/util.c b/bin/gzip/util.c index 841a0ce7..ce580ff9 100644 --- a/bin/gzip/util.c +++ b/bin/gzip/util.c @@ -26,8 +26,7 @@ extern ulg crc_32_tab[]; /* crc table, defined below */ * Copy input to output unchanged: zcat == cat with --force. * IN assertion: insize bytes have already been read in inbuf. */ -int copy(in, out) -int in, out; /* input and output file descriptors */ +int copy(int in, int out) { errno = 0; while (insize != 0 && (int)insize != EOF) { @@ -47,9 +46,7 @@ int in, out; /* input and output file descriptors */ * pointer, then initialize the crc shift register contents instead. * Return the current crc in either case. */ -ulg updcrc(s, n) -uch *s; /* pointer to bytes to pump through */ -unsigned n; /* number of bytes in s[] */ +ulg updcrc(uch *s, unsigned n) { register ulg c; /* temporary variable */ @@ -82,8 +79,7 @@ void clear_bufs() /* =========================================================================== * Fill the input buffer. This is called only when the buffer is empty. */ -int fill_inbuf(eof_ok) -int eof_ok; /* set if EOF acceptable as a result */ +int fill_inbuf(int eof_ok) { int len; @@ -142,9 +138,7 @@ void flush_window() * Does the same as write(), but also handles partial pipe writes and checks * for error return. */ -void write_buf(fd, buf, cnt) int fd; -voidp buf; -unsigned cnt; +void write_buf(int fd, voidp buf, unsigned cnt) { unsigned n; @@ -160,12 +154,11 @@ unsigned cnt; /* ======================================================================== * Put string s in lower case, return s. */ -char *strlwr(s) -char *s; +char *strlwr(char *s) { char *t; for (t = s; *t; t++) - *t = tolow(*t); + *t = tolower(*t); return s; } @@ -174,8 +167,7 @@ char *s; * any version suffix). For systems with file names that are not * case sensitive, force the base name to lower case. */ -char *basename(fname) -char *fname; +char *basename(char *fname) { char *p; @@ -183,6 +175,7 @@ char *fname; fname = p + 1; if (casemap('A') == 'a') strlwr(fname); + return fname; } @@ -193,10 +186,7 @@ char *fname; */ #define SEPARATOR " \t" /* separators in env variable */ -char *add_envopt(argcp, argvp, env) -int *argcp; /* pointer to argc */ -char ***argvp; /* pointer to argv */ -char *env; /* name of environment variable */ +char *add_envopt(int *argcp, char ***argvp, char *env) { char *p; /* running pointer through env variable */ char **oargv; /* runs through old argv array */ @@ -257,13 +247,13 @@ char *env; /* name of environment variable */ /* ======================================================================== * Error handlers. */ -void error(m) char *m; +void error(char *m) { fprintf(stderr, "\n%s: %s: %s\n", progname, ifname, m); abort_gzip(); } -void warn(a, b) char *a, *b; /* message strings juxtaposed in output */ +void warn(char *a, char *b) { WARN((stderr, "%s: %s: warning: %s%s\n", progname, ifname, a, b)); } @@ -289,9 +279,7 @@ void write_error() /* ======================================================================== * Display compression ratio on the given stream on 6 characters. */ -void display_ratio(num, den, file) long num; -long den; -FILE *file; +void display_ratio(long num, long den, FILE *file) { long ratio; /* 1000 times the compression ratio */ char sign; @@ -315,8 +303,7 @@ FILE *file; /* ======================================================================== * Semi-safe malloc -- never returns NULL. */ -voidp xmalloc(size) -unsigned size; +voidp xmalloc(unsigned size) { voidp cp = (voidp)malloc(size); |
