C23 does not allow K&R style function definitions. Use protyped definitions. However, don't bother with (void) in function definitions since C23 prefers (); so prefer () to (void) as this will work with older compilers anyway. --- NEWS | 3 ++ bits.c | 37 ++++++++++++------------ deflate.c | 7 ++--- dfltcc.c | 4 +-- gzip.c | 44 +++++++++++++--------------- inflate.c | 8 +++--- sample/add.c | 3 +- sample/makecrc.c | 3 +- sample/sub.c | 5 ++-- sample/zread.c | 5 ++-- trees.c | 74 +++++++++++++++++++++++++++--------------------- unlzh.c | 32 +++++++++------------ unlzw.c | 5 ++-- unpack.c | 8 ++++-- unzip.c | 11 ++++--- util.c | 61 ++++++++++++++++----------------------- zip.c | 10 +++---- 17 files changed, 158 insertions(+), 162 deletions(-)
diff --git a/NEWS b/NEWS index 364811a..918fcf2 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ GNU gzip NEWS -*- outline -*- that uses a dictionary distance outside the input window. [bug present since the beginning] + Port to C23, which does not allow K&R-style function definitions + with parameters. + * Noteworthy changes in release 1.12 (2022-04-07) [stable] diff --git a/bits.c b/bits.c index 86599ca..0c4a6aa 100644 --- a/bits.c +++ b/bits.c @@ -55,7 +55,7 @@ * Reverse the bits of a bit string, taking the source bits left to * right and emitting them right to left. * - * void bi_windup (void) + * void bi_windup () * Write out any remaining bits in an incomplete byte. * * void copy_block(char *buf, unsigned len, int header) @@ -108,9 +108,10 @@ int (*read_buf) (char *buf, unsigned size); /* =========================================================================== * Initialize the bit string routines. + * ZIPFILE is the output zip file; it is NO_FILE for in-memory compression. */ -void bi_init (zipfile) - file_t zipfile; /* output zip file, NO_FILE for in-memory compression */ +void +bi_init (file_t zipfile) { zfile = zipfile; bi_buf = 0; @@ -128,12 +129,11 @@ void bi_init (zipfile) } /* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. + * Send VALUE on LENGTH bits. + * IN assertion: LENGTH <= 16 and VALUE fits in LENGTH bits. */ -void send_bits(value, length) - int value; /* value to send */ - int length; /* number of bits */ +void +send_bits (int value, int length) { #ifdef DEBUG Tracev ((stderr, " l %2d v %4x ", length, value + 0u)); @@ -156,13 +156,12 @@ void send_bits(value, length) } /* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster + * Reverse the first LEN bits of CODE, using straightforward code (a faster * method would use a table) - * IN assertion: 1 <= len <= 15 + * IN assertion: 1 <= LEN <= 15 */ -unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ +unsigned +bi_reverse (unsigned code, int len) { register unsigned res = 0; do { @@ -175,7 +174,8 @@ unsigned bi_reverse(code, len) /* =========================================================================== * Write out any remaining bits in an incomplete byte. */ -void bi_windup() +void +bi_windup () { if (bi_valid > 8) { put_short(bi_buf); @@ -191,12 +191,11 @@ void bi_windup() /* =========================================================================== * Copy a stored block to the zip file, storing first the length and its - * one's complement if requested. + * one's complement if requested. BUF is the input data of length + * LEN; HEADER is true if block header must be written. */ -void copy_block(buf, len, header) - char *buf; /* the input data */ - unsigned len; /* its length */ - int header; /* true if block header must be written */ +void +copy_block (char *buf, unsigned len, int header) { bi_windup(); /* align on byte boundary */ diff --git a/deflate.c b/deflate.c index 7d19ef5..1a47bc6 100644 --- a/deflate.c +++ b/deflate.c @@ -68,7 +68,7 @@ * void lm_init (int pack_level, ush *flags) * Initialize the "longest match" routines for a new file * - * off_t deflate (void) + * off_t deflate () * Processes a new input file and return its compressed length. Sets * the compressed length, crc, deflate flags and internal file * attributes. @@ -500,9 +500,8 @@ longest_match(IPos cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(start, match, length) - IPos start, match; - int length; +static void +check_match (IPos start, IPos match, int length) { /* check that the match is indeed a match */ if (memcmp((char*)window + match, diff --git a/dfltcc.c b/dfltcc.c index 442f6e2..0c14ad5 100644 --- a/dfltcc.c +++ b/dfltcc.c @@ -147,7 +147,7 @@ is_bit_set (const char *bits, int n) } static int -is_dfltcc_enabled (void) +is_dfltcc_enabled () { char facilities[(DFLTCC_FACILITY / 64 + 1) * 8]; @@ -415,7 +415,7 @@ dfltcc_deflate (int pack_level) /* Decompress ifd into ofd in hardware or fall back to software. */ int -dfltcc_inflate (void) +dfltcc_inflate () { /* Check whether we can use hardware decompression. */ if (!is_dfltcc_enabled ()) diff --git a/gzip.c b/gzip.c index eee5910..fb1a089 100644 --- a/gzip.c +++ b/gzip.c @@ -706,7 +706,7 @@ input_eof () } static void -get_input_size_and_time (void) +get_input_size_and_time () { ifile_size = -1; time_stamp.tv_nsec = -1; @@ -868,8 +868,8 @@ atdir_set (char const *dir, ptrdiff_t dirlen) /* ======================================================================== * Compress or decompress the given file */ -local void treat_file(iname) - char *iname; +static void +treat_file (char *iname) { /* Accept "-" as synonym for stdin */ if (strequ(iname, "-")) { @@ -1169,8 +1169,8 @@ local int create_outfile() * .??z suffix as indicating a compressed file; some people use .xyz * to denote volume data. */ -local char *get_suffix(name) - char *name; +static char * +get_suffix (char *name) { int nlen, slen; char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */ @@ -1285,9 +1285,7 @@ open_and_stat (char *name, int flags, struct stat *st) * Return an open file descriptor or -1. */ static int -open_input_file (iname, sbuf) - char *iname; - struct stat *sbuf; +open_input_file (char *iname, struct stat *sbuf) { int ilen; /* strlen(ifname) */ int z_suffix_errno = 0; @@ -1466,9 +1464,7 @@ local int make_ofname() zero byte if NBYTES == (size_t) -1. If FLAGS say that the header CRC should be computed, update the CRC accordingly. */ static void -discard_input_bytes (nbytes, flags) - size_t nbytes; - unsigned int flags; +discard_input_bytes (size_t nbytes, unsigned int flags) { while (nbytes != 0) { @@ -1490,11 +1486,12 @@ discard_input_bytes (nbytes, flags) * Updates time_stamp if there is one and neither -m nor -n is used. * This function may be called repeatedly for an input file consisting * of several contiguous gzip'ed members. + * 'in' is the input file descriptor. * IN assertions: there is at least one remaining compressed member. * If the member is a zip file, it must be the only one. */ -local int get_method(in) - int in; /* input file descriptor */ +static int +get_method (int in) { uch flags; /* compression flags */ uch magic[10]; /* magic header */ @@ -1816,8 +1813,8 @@ do_list (int method) * * IN assertion: for compression, the suffix of the given name is z_suffix. */ -local void shorten_name(name) - char *name; +static void +shorten_name (char *name) { int len; /* length of name without z_suffix */ char *trunc = NULL; /* character to be truncated */ @@ -1921,8 +1918,8 @@ do_chown (int fd, char const *name, uid_t uid, gid_t gid) * Copy modes, times, ownership from input file to output file. * IN assertion: to_stdout is false. */ -local void copy_stat(ifstat) - struct stat *ifstat; +static void +copy_stat (struct stat *ifstat) { mode_t mode = ifstat->st_mode & S_IRWXUGO; int r; @@ -1986,9 +1983,8 @@ local void copy_stat(ifstat) /* ======================================================================== * Recurse through the given directory. */ -local void treat_dir (fd, dir) - int fd; - char *dir; +static void +treat_dir (int fd, char *dir) { DIR *dirp; char nbuf[MAX_PATH_LEN]; @@ -2066,8 +2062,8 @@ install_signal_handlers () /* ======================================================================== * Free all dynamically allocated variables and exit with the given code. */ -local void do_exit(exitcode) - int exitcode; +static void +do_exit (int exitcode) { static int in_exit = 0; @@ -2089,7 +2085,7 @@ local void do_exit(exitcode) } static void -finish_out (void) +finish_out () { if (fclose (stdout) != 0) write_error (); @@ -2124,7 +2120,7 @@ remove_output_file (bool signals_already_blocked) * Error handler. */ void -abort_gzip (void) +abort_gzip () { remove_output_file (false); do_exit(ERROR); diff --git a/inflate.c b/inflate.c index 4fbb1be..f90cab5 100644 --- a/inflate.c +++ b/inflate.c @@ -627,7 +627,7 @@ inflate_codes(struct huft *tl, struct huft *td, int bl, int bd) /* "decompress" an inflated type 0 (stored) block. */ static int -inflate_stored(void) +inflate_stored () { unsigned n; /* number of bytes in block */ unsigned w; /* current window position */ @@ -683,7 +683,7 @@ inflate_stored(void) either replace this with a custom decoder, or at least precompute the Huffman tables. */ static int -inflate_fixed(void) +inflate_fixed () { int i; /* temporary variable */ struct huft *tl; /* literal/length code table */ @@ -733,7 +733,7 @@ inflate_fixed(void) /* decompress an inflated type 2 (dynamic Huffman codes) block. */ static int -inflate_dynamic(void) +inflate_dynamic () { int i; /* temporary variables */ unsigned j; @@ -956,7 +956,7 @@ static int inflate_block(int *e) int -inflate(void) +inflate () /* decompress an inflated entry */ { int e; /* last block flag */ diff --git a/sample/add.c b/sample/add.c index cadbc3a..d51288c 100644 --- a/sample/add.c +++ b/sample/add.c @@ -16,7 +16,8 @@ char a[MAX_DIST]; /* last byte buffer for up to MAX_DIST differences */ -int main() +int +main () { int n; /* number of differences */ int i; /* difference counter */ diff --git a/sample/makecrc.c b/sample/makecrc.c index 8fa2959..bf789d3 100644 --- a/sample/makecrc.c +++ b/sample/makecrc.c @@ -3,7 +3,8 @@ #include <config.h> #include <stdio.h> -main() +int +main () /* Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. diff --git a/sample/sub.c b/sample/sub.c index a06cc9b..ce83a98 100644 --- a/sample/sub.c +++ b/sample/sub.c @@ -43,9 +43,8 @@ char a[MAX_DIST]; /* last byte buffer for up to MAX_DIST differences */ -int main(argc, argv) - int argc; - char **argv; +int +main (int argc, char **argv) { int n = 1; /* number of differences */ int i; /* difference counter */ diff --git a/sample/zread.c b/sample/zread.c index e20de49..e38095c 100644 --- a/sample/zread.c +++ b/sample/zread.c @@ -10,9 +10,8 @@ * Usage: zread [file[.gz]] * This programs assumes that gzip is somewhere in your path. */ -int main(argc, argv) - int argc; - char **argv; +int +main (int argc, char **argv) { FILE *infile; char cmd[256]; diff --git a/trees.c b/trees.c index b88a1b9..14c6191 100644 --- a/trees.c +++ b/trees.c @@ -337,10 +337,11 @@ local void set_file_type (void); * Allocate the match buffer, initialize the various tables and save the * location of the internal file attribute (ascii/binary) and method * (DEFLATE/STORE). + * ATTR points to internal file attribute. + * METHODP points to the compression method. */ -void ct_init(attr, methodp) - ush *attr; /* pointer to internal file attribute */ - int *methodp; /* pointer to compression method */ +void +ct_init (ush *attr, int *methodp) { int n; /* iterates over tree elements */ int bits; /* bit counter */ @@ -456,10 +457,11 @@ local void init_block() * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). + * TREE is the tree to restore. + * K is the node to move down. */ -local void pqdownheap(tree, k) - ct_data near *tree; /* the tree to restore */ - int k; /* node to move down */ +static void +pqdownheap (ct_data near *tree, int k) { int v = heap[k]; int j = k << 1; /* left son of k */ @@ -488,9 +490,10 @@ local void pqdownheap(tree, k) * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. + * DESC is the tree descriptor. */ -local void gen_bitlen(desc) - tree_desc near *desc; /* the tree descriptor */ +static void +gen_bitlen (tree_desc near *desc) { ct_data near *tree = desc->dyn_tree; int near *extra = desc->extra_bits; @@ -573,10 +576,11 @@ local void gen_bitlen(desc) * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. + * TREE is the tree to decorate. + * MAX_CODE is the largest code with non zero frequency. */ -local void gen_codes (tree, max_code) - ct_data near *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ +static void +gen_codes (ct_data near *tree, int max_code) { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ @@ -614,9 +618,10 @@ local void gen_codes (tree, max_code) * OUT assertions: the fields len and code are set to the optimal bit length * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. + * DESC is the tree descriptor. */ -local void build_tree(desc) - tree_desc near *desc; /* the tree descriptor */ +static void +build_tree(tree_desc near *desc) { ct_data near *tree = desc->dyn_tree; ct_data near *stree = desc->static_tree; @@ -701,10 +706,11 @@ local void build_tree(desc) * in the bit length tree. Updates opt_len to take into account the repeat * counts. (The contribution of the bit length codes will be added later * during the construction of bl_tree.) + * TREE is the tree to be scanned. + * MAX_CODE is its largest code of non zero frequency. */ -local void scan_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ +static void +scan_tree (ct_data near *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ @@ -745,10 +751,11 @@ local void scan_tree (tree, max_code) /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. + * TREE is the tree to be scanned. + * MAX_CODE is its largest code of non zero frequency. */ -local void send_tree (tree, max_code) - ct_data near *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ +static void +send_tree (ct_data near *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ @@ -828,9 +835,10 @@ local int build_bl_tree() * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + * LCODES, DCODES and BLCODES are the number of codes for each tree. */ -local void send_all_trees(lcodes, dcodes, blcodes) - int lcodes, dcodes, blcodes; /* number of codes for each tree */ +static void +send_all_trees (int lcodes, int dcodes, int blcodes) { int rank; /* index in bl_order */ @@ -855,12 +863,13 @@ local void send_all_trees(lcodes, dcodes, blcodes) * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. This function * returns the total compressed length for the file so far. + * BUF is the input block, or NULL if too old. + * STORED_LEN is BUF's length. + * PAD means pad output to byte boundary. + * EOF means this is the last block for a file. */ -off_t flush_block(buf, stored_len, pad, eof) - char *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int pad; /* pad output to byte boundary */ - int eof; /* true if this is the last block for a file */ +off_t +flush_block (char *buf, ulg stored_len, int pad, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex; /* index of last bit length code of non zero freq */ @@ -964,10 +973,11 @@ off_t flush_block(buf, stored_len, pad, eof) /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. + * DIST is the distance of matched string. + * LC is match length - MIN_MATCH or unmatched char (if DIST==0). */ -int ct_tally (dist, lc) - int dist; /* distance of matched string */ - int lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ +int +ct_tally (int dist, int lc) { l_buf[last_lit++] = (uch)lc; if (dist == 0) { @@ -1017,10 +1027,10 @@ int ct_tally (dist, lc) /* =========================================================================== * Send the block data compressed using the given Huffman trees + * LTREE is the literal tree, DTREE the distance tree. */ -local void compress_block(ltree, dtree) - ct_data near *ltree; /* literal tree */ - ct_data near *dtree; /* distance tree */ +static void +compress_block (ct_data near *ltree, ct_data near *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ diff --git a/unlzh.c b/unlzh.c index f018922..0fb45e0 100644 --- a/unlzh.c +++ b/unlzh.c @@ -99,8 +99,9 @@ local ush bitbuf; local unsigned subbitbuf; local int bitcount; -local void fillbuf(n) /* Shift bitbuf n bits left, read n bits */ - int n; +/* Shift bitbuf N bits left, read N bits. */ +static void +fillbuf (int n) { bitbuf <<= n; while (n > bitcount) { @@ -112,8 +113,8 @@ local void fillbuf(n) /* Shift bitbuf n bits left, read n bits */ bitbuf |= subbitbuf >> (bitcount -= n); } -local unsigned getbits(n) - int n; +static unsigned +getbits (int n) { unsigned x; @@ -131,11 +132,8 @@ local void init_getbits() maketbl.c -- make table for decoding ***********************************************************/ -local void make_table(nchar, bitlen, tablebits, table) - int nchar; - uch bitlen[]; - int tablebits; - ush table[]; +static void +make_table (int nchar, uch bitlen[], int tablebits, ush table[]) { ush count[17], weight[17], start[18], *p; unsigned i, k, len, ch, jutbits, avail, nextcode, mask; @@ -197,10 +195,8 @@ local void make_table(nchar, bitlen, tablebits, table) huf.c -- static Huffman ***********************************************************/ -local void read_pt_len(nn, nbit, i_special) - int nn; - int nbit; - int i_special; +static void +read_pt_len (int nn, int nbit, int i_special) { int i, c, n; unsigned mask; @@ -333,9 +329,8 @@ local void decode_start() /* Decode the input and return the number of decoded bytes put in buffer */ -local unsigned decode(count, buffer) - unsigned count; - uch buffer[]; +static unsigned +decode (unsigned count, uch buffer[]) /* The calling function must keep the number of bytes to be processed. This function decodes either 'count' bytes or 'DICSIZ' bytes, whichever @@ -379,9 +374,8 @@ local unsigned decode(count, buffer) /* =========================================================================== * Unlzh in to out. Return OK or ERROR. */ -int unlzh(in, out) - int in; - int out; +int +unlzh (int in, int out) { unsigned n; ifd = in; diff --git a/unlzw.c b/unlzw.c index ba824e4..ed77970 100644 --- a/unlzw.c +++ b/unlzw.c @@ -96,9 +96,10 @@ static int block_mode = BLOCK_MODE; * the compressed data, from offsets iptr to insize-1 included. * The magic header has already been checked and skipped. * bytes_in and bytes_out have been initialized. + * 'in' and 'out' are the input and output file descriptors. */ -int unlzw(in, out) - int in, out; /* input and output file descriptors */ +int +unlzw (int in, int out) { char_type *stackp; code_int code; diff --git a/unpack.c b/unpack.c index 26874eb..2a87457 100644 --- a/unpack.c +++ b/unpack.c @@ -78,7 +78,7 @@ local int valid; /* number of valid bits in bitbuf */ /* Read an input byte, reporting an error at EOF. */ static unsigned char -read_byte (void) +read_byte () { int b = get_byte (); if (b < 0) @@ -209,9 +209,11 @@ local void build_tree() * IN assertions: the buffer inbuf contains already the beginning of * the compressed data, from offsets inptr to insize-1 included. * The magic header has already been checked. The output buffer is cleared. + * + * 'in' and 'out' are the input and output file descriptors. */ -int unpack(in, out) - int in, out; /* input and output file descriptors */ +int +unpack (int in, int out) { int len; /* Bit length of current code */ unsigned eob; /* End Of Block code */ diff --git a/unzip.c b/unzip.c index 5f90076..4cf0eb7 100644 --- a/unzip.c +++ b/unzip.c @@ -60,9 +60,10 @@ static int ext_header = 0; /* set if extended local header */ /* =========================================================================== * Check zip file and advance inptr to the start of the compressed data. * Get ofname from the local header if necessary. + * IN is the input file descriptor. */ -int check_zipfile(in) - int in; /* input file descriptors */ +int +check_zipfile (int in) { uch *h = inbuf + inptr; /* first local header */ @@ -108,9 +109,11 @@ int check_zipfile(in) * IN assertions: the buffer inbuf contains already the beginning of * the compressed data, from offsets inptr to insize-1 included. * The magic header has already been checked. The output buffer is cleared. + * + * 'in' and 'out' are the input and output file descriptors. */ -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/util.c b/util.c index 4f904b4..193cb8f 100644 --- a/util.c +++ b/util.c @@ -103,9 +103,10 @@ static ulg crc = 0xffffffffL; * Copy input to output unchanged: zcat == cat with --force. * IN assertion: insize bytes have already been read in inbuf and inptr bytes * already processed or copied. + * 'in' and 'out' are the input and output file descriptors. */ -int copy(in, out) - int in, out; /* input and output file descriptors */ +int +copy (int in, int out) { int got; @@ -126,10 +127,10 @@ int copy(in, out) * Run a set of bytes through the crc shift register. If s is a NULL * pointer, then initialize the crc shift register contents instead. * Return the current crc in either case. + * S points to N bytes to pump through. */ -ulg updcrc(s, n) - const uch *s; /* pointer to bytes to pump through */ - unsigned n; /* number of bytes in s[] */ +ulg +updcrc (uch const *s, unsigned n) { register ulg c; /* temporary variable */ @@ -147,7 +148,7 @@ ulg updcrc(s, n) /* Return a current CRC value. */ ulg -getcrc (void) +getcrc () { return crc ^ 0xffffffffL; } @@ -173,9 +174,10 @@ void clear_bufs() /* =========================================================================== * Fill the input buffer. This is called only when the buffer is empty. + * EOF_OK is set if EOF acceptable as a result. */ -int fill_inbuf(eof_ok) - int eof_ok; /* set if EOF acceptable as a result */ +int +fill_inbuf (int eof_ok) { int len; @@ -205,10 +207,7 @@ int fill_inbuf(eof_ok) /* Like the standard read function, except do not attempt to read more than INT_MAX bytes at a time. */ int -read_buffer (fd, buf, cnt) - int fd; - voidp buf; - unsigned int cnt; +read_buffer (int fd, voidp buf, unsigned int cnt) { int len; if (INT_MAX < cnt) @@ -236,10 +235,7 @@ read_buffer (fd, buf, cnt) /* Likewise for 'write'. */ static int -write_buffer (fd, buf, cnt) - int fd; - voidp buf; - unsigned int cnt; +write_buffer (int fd, voidp buf, unsigned int cnt) { if (INT_MAX < cnt) cnt = INT_MAX; @@ -275,10 +271,8 @@ void flush_window() * Update the count of output bytes. If testing, do not do any * output. Otherwise, write the buffer, checking for errors. */ -void write_buf(fd, buf, cnt) - int fd; - voidp buf; - unsigned cnt; +void +write_buf (int fd, voidp buf, unsigned cnt) { unsigned n; @@ -298,8 +292,8 @@ void write_buf(fd, buf, 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++) @@ -313,8 +307,7 @@ char *strlwr(s) * case sensitive, force the base name to lower case. */ char * -gzip_base_name (fname) - char *fname; +gzip_base_name (char *fname) { fname = last_component (fname); if (casemap('A') == 'a') strlwr(fname); @@ -324,8 +317,8 @@ gzip_base_name (fname) /* ======================================================================== * Unlink a file, working around the unlink readonly bug (if present). */ -int xunlink (filename) - char *filename; +int +xunlink (char *filename) { int r = unlink (filename); @@ -355,8 +348,8 @@ int xunlink (filename) * MAKE_LEGAL_NAME in tailor.h and providing the function in a target * dependent module. */ -void make_simple_name(name) - char *name; +void +make_simple_name (char *name) { char *p = strrchr(name, '.'); if (p == NULL) return; @@ -474,10 +467,8 @@ void write_error() /* ======================================================================== * Display compression ratio on the given stream on 6 characters. */ -void display_ratio(num, den, file) - off_t num; - off_t den; - FILE *file; +void +display_ratio (off_t num, off_t den, FILE *file) { fprintf(file, "%5.1f%%", den == 0 ? 0 : 100.0 * num / den); } @@ -486,10 +477,8 @@ void display_ratio(num, den, file) * Print an off_t. There's no completely portable way to use printf, * so we do it ourselves. */ -void fprint_off(file, offset, width) - FILE *file; - off_t offset; - int width; +void +fprint_off (FILE *file, off_t offset, int width) { char buf[CHAR_BIT * sizeof (off_t)]; char *p = buf + sizeof buf; diff --git a/zip.c b/zip.c index c47c175..4d61707 100644 --- a/zip.c +++ b/zip.c @@ -32,9 +32,10 @@ enum { SLOW = 2, FAST = 4 }; * Deflate in to out. * IN assertions: the input and output buffers are cleared. * The variables time_stamp and save_orig_name are initialized. + * 'in' and 'out' are input and output file descriptors. */ -int zip(in, out) - int in, out; /* input and output file descriptors */ +int +zip (int in, int out) { uch flags = 0; /* general purpose bit flags */ ush attr = 0; /* ascii/binary flag */ @@ -121,9 +122,8 @@ int zip(in, out) * translation, and update the crc and input file size. * IN assertion: size >= 2 (for end-of-line translation) */ -int file_read(buf, size) - char *buf; - unsigned size; +int +file_read (char *buf, unsigned size) { unsigned len; -- 2.38.1