projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
The previous fix for 's/a/1/;s/b/2/;t one;p;:one;p' broke the case of
[oweals/busybox.git]
/
archival
/
gzip.c
diff --git
a/archival/gzip.c
b/archival/gzip.c
index 60ff1f31163984ee8e749e2fa6e26141d03dbd82..bc4c7badd10118b6edf0162850e0f9ebcde0493a 100644
(file)
--- a/
archival/gzip.c
+++ b/
archival/gzip.c
@@
-9,8
+9,8
@@
* only standard in to standard out with -9 compression. It also requires
* the zcat module for some important functions."
*
* only standard in to standard out with -9 compression. It also requires
* the zcat module for some important functions."
*
- * Adjusted further by Erik Andersen <andersen@
lineo.com>, <andersee@debian.org>
- *
to support files as well as stdin/stdout, and to generally behave itself wrt
+ * Adjusted further by Erik Andersen <andersen@
codepoet.org> to support
+ *
files as well as stdin/stdout, and to generally behave itself wrt
* command line handling.
*
* This program is free software; you can redistribute it and/or modify
* command line handling.
*
* This program is free software; you can redistribute it and/or modify
@@
-71,7
+71,6
@@
typedef unsigned long ulg;
#define STORED 0
/* methods 4 to 7 reserved */
#define DEFLATED 8
#define STORED 0
/* methods 4 to 7 reserved */
#define DEFLATED 8
-static int method; /* compression method */
/* To save memory for 16 bit systems, some arrays are overlaid between
* the various modules:
/* To save memory for 16 bit systems, some arrays are overlaid between
* the various modules:
@@
-112,7
+111,7
@@
static int method; /* compression method */
# define ALLOC(type, array, size) { \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
# define ALLOC(type, array, size) { \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
-# define FREE(array) {
if (array != NULL)
free(array), array=NULL;}
+# define FREE(array) {free(array), array=NULL;}
#else
# define DECLARE(type, array, size) static type array[size]
# define ALLOC(type, array, size)
#else
# define DECLARE(type, array, size) static type array[size]
# define ALLOC(type, array, size)
@@
-188,7
+187,7
@@
typedef int file_t; /* Do not use stdio */
/* Diagnostic functions */
#ifdef DEBUG
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
+# define Assert(cond,msg) {if(!(cond))
bb_
error_msg(msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
@@
-353,10
+352,10
@@
static void clear_bufs(void)
bytes_in = 0L;
}
bytes_in = 0L;
}
-static void write_error_msg(void)
+static void write_
bb_
error_msg(void)
{
{
- fp
rintf(stderr, "\n"
);
-
perror(""
);
+ fp
utc('\n', stderr
);
+
bb_perror_nomsg(
);
abort_gzip();
}
abort_gzip();
}
@@
-370,7
+369,7
@@
static void write_buf(int fd, void *buf, unsigned cnt)
while ((n = write(fd, buf, cnt)) != cnt) {
if (n == (unsigned) (-1)) {
while ((n = write(fd, buf, cnt)) != cnt) {
if (n == (unsigned) (-1)) {
- write_error_msg();
+ write_
bb_
error_msg();
}
cnt -= n;
buf = (void *) ((char *) buf + n);
}
cnt -= n;
buf = (void *) ((char *) buf + n);
@@
-978,12
+977,11
@@
static void check_match(IPos start, IPos match, int length)
/* check that the match is indeed a match */
if (memcmp((char *) window + match,
(char *) window + start, length) != EQUAL) {
/* check that the match is indeed a match */
if (memcmp((char *) window + match,
(char *) window + start, length) != EQUAL) {
- fprintf(stderr,
- " start %d, match %d, length %d\n", start, match, length);
- error_msg("invalid match");
+ bb_error_msg(" start %d, match %d, length %d", start, match, length);
+ bb_error_msg("invalid match");
}
if (verbose > 1) {
}
if (verbose > 1) {
-
fprintf(stderr,
"\\[%d,%d]", start - match, length);
+
bb_error_msg(
"\\[%d,%d]", start - match, length);
do {
putc(window[start++], stderr);
} while (--length != 0);
do {
putc(window[start++], stderr);
} while (--length != 0);
@@
-1234,7
+1232,7
@@
int gzip_main(int argc, char **argv)
return gunzip_main(argc, argv);
#endif
default:
return gunzip_main(argc, argv);
#endif
default:
- show_usage();
+
bb_
show_usage();
}
}
}
}
@@
-1284,7
+1282,7
@@
int gzip_main(int argc, char **argv)
} else {
inFileNum = open(argv[i], O_RDONLY);
if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0)
} else {
inFileNum = open(argv[i], O_RDONLY);
if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0)
- perror_msg_and_die("%s", argv[i]);
+
bb_
perror_msg_and_die("%s", argv[i]);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
@@
-1301,7
+1299,7
@@
int gzip_main(int argc, char **argv)
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL);
#endif
if (outFileNum < 0) {
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL);
#endif
if (outFileNum < 0) {
- perror_msg("%s", path);
+
bb_
perror_msg("%s", path);
free(path);
continue;
}
free(path);
continue;
}
@@
-1313,7
+1311,7
@@
int gzip_main(int argc, char **argv)
}
if (path == NULL && isatty(outFileNum) && force == 0) {
}
if (path == NULL && isatty(outFileNum) && force == 0) {
- error_msg
+
bb_
error_msg
("compressed data not written to a terminal. Use -f to force compression.");
free(path);
continue;
("compressed data not written to a terminal. Use -f to force compression.");
free(path);
continue;
@@
-1332,7
+1330,7
@@
int gzip_main(int argc, char **argv)
delFileName = path;
if (unlink(delFileName) < 0)
delFileName = path;
if (unlink(delFileName) < 0)
- perror_msg("%s", delFileName);
+
bb_
perror_msg("%s", delFileName);
}
free(path);
}
free(path);
@@
-1657,7
+1655,7
@@
static void set_file_type(void);
#else /* DEBUG */
# define send_code(c, tree) \
#else /* DEBUG */
# define send_code(c, tree) \
- { if (verbose>1)
fprintf(stderr,
"\ncd %3d ",(c)); \
+ { if (verbose>1)
bb_error_msg(
"\ncd %3d ",(c)); \
send_bits(tree[c].Code, tree[c].Len); }
#endif
send_bits(tree[c].Code, tree[c].Len); }
#endif
@@
-2037,7
+2035,7
@@
static void build_tree(tree_desc * desc)
tree[n].Dad = tree[m].Dad = (ush) node;
#ifdef DUMP_BL_TREE
if (tree == bl_tree) {
tree[n].Dad = tree[m].Dad = (ush) node;
#ifdef DUMP_BL_TREE
if (tree == bl_tree) {
-
fprintf(stderr,
"\nnode %d(%d), sons %d(%d) %d(%d)",
+
bb_error_msg(
"\nnode %d(%d), sons %d(%d) %d(%d)",
node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
}
#endif
node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
}
#endif
@@
-2275,7
+2273,7
@@
static ulg flush_block(char *buf, ulg stored_len, int eof)
if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
- error_msg("block vanished");
+
bb_
error_msg("block vanished");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
@@
-2444,7
+2442,7
@@
static void set_file_type()
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) {
- error_msg("-l used on binary file");
+
bb_
error_msg("-l used on binary file");
}
}
}
}