diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-14 18:45:35 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-12-14 18:45:35 +0000 |
commit | 5ffd458b1af533f15abc805786882eb0df388dd1 (patch) | |
tree | 4038c59b8993142fec6dcdc3b59d41af2314c771 /fastjar/jargrep.c | |
parent | ad324c4ee9b461be706df7581810caddbd71565b (diff) | |
download | gcc-5ffd458b1af533f15abc805786882eb0df388dd1.tar.gz |
Warning fixes:
* compress.c: Include stdlib.h and compress.h.
(rcsid): Delete.
(report_str_error): Make static.
(ez_inflate_str): Delete unused variable. Add parens in if-stmt.
(hrd_inflate_str): Likewise.
* compress.h (init_compression, end_compression, init_inflation,
end_inflation): Prototype void arguments.
* dostime.c (rcsid): Delete.
* jargrep.c: Include ctype.h, stdlib.h, zlib.h and compress.h.
Make functions static. Cast ctype function argument to `unsigned
char'. Add parens in if-stmts. Constify.
(Usage): Change into a macro.
(jargrep): Remove unused parameter.
* jartool.c: Constify. Add parens in if-stmts. Align
signed/unsigned char pointers in functions calls using casts.
(rcsid): Delete.
(list_jar): Fix printf format specifier.
(usage): Chop long string into bits. Reformat.
* pushback.c (rcsid): Delete.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38254 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'fastjar/jargrep.c')
-rw-r--r-- | fastjar/jargrep.c | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/fastjar/jargrep.c b/fastjar/jargrep.c index 92461ac35b5..1f40eb3576d 100644 --- a/fastjar/jargrep.c +++ b/fastjar/jargrep.c @@ -21,9 +21,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: jargrep.c,v 1.1 2000/12/09 03:08:23 apbianco Exp $ +/* $Id: jargrep.c,v 1.2 2000/12/11 02:59:55 apbianco Exp $ $Log: jargrep.c,v $ +Revision 1.2 2000/12/11 02:59:55 apbianco +2000-12-10 Robert Lipe <robertlipe@usa.net> + + * jargrep.c (jargrep): Added null statement after case. + +2000-12-10 Alexandre Petit-Bianco <apbianco@cygnus.com> + + * Makefile: Removed. + * Makefile.in: Rebuilt with `-i' and `--enable-foreign'. + +(http://gcc.gnu.org/ml/gcc/2000-12/msg00294.html) + Revision 1.1 2000/12/09 03:08:23 apbianco 2000-12-08 Alexandre Petit-Bianco <apbianco@cygnus.com> @@ -49,12 +61,18 @@ will test some other platforms later. #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <ctype.h> +#ifdef STDC_HEADERS +#include <stdlib.h> +#endif #include "jargrep.h" #include "jartool.h" #include "pushback.h" #include "zipfile.h" +#include "zlib.h" +#include "compress.h" -char *Usage = { "Usage: %s [-bcinsw] <-e regexp | regexp> file(s)\n" }; +#define Usage "Usage: %s [-bcinsw] <-e regexp | regexp> file(s)\n" extern char *optarg; @@ -66,7 +84,7 @@ together. returns: TRUE if options are valid, FALSE otherwise. */ -int opt_valid(int options) { +static int opt_valid(int options) { int retflag; if((options & JG_PRINT_COUNT) && @@ -90,18 +108,17 @@ expression. returns: Newly allocated compile regular expression ready to be used in an regexec call. */ -regex_t *create_regexp(char *regstr, int options) { +static regex_t *create_regexp(const char *regstr, int options) { regex_t *exp; - int exp_flags = 0; int errcode; int msgsize; char *errmsg; - if(exp = (regex_t *) malloc(sizeof(regex_t))) + if((exp = (regex_t *) malloc(sizeof(regex_t)))) { - if(errcode = regcomp(exp, regstr, (options & JG_IGNORE_CASE) ? REG_ICASE : 0)) { + if((errcode = regcomp(exp, regstr, (options & JG_IGNORE_CASE) ? REG_ICASE : 0))) { fprintf(stderr, "regcomp of regex failed,\n"); - if(errmsg = (char *) malloc(msgsize = regerror(errcode, exp, NULL, 0) + 1)) { + if((errmsg = (char *) malloc(msgsize = regerror(errcode, exp, NULL, 0) + 1))) { regerror(errcode, exp, errmsg, msgsize); fprintf(stderr, "Error: %s\n", errmsg); free(exp); @@ -135,7 +152,7 @@ we have read beyound the embedded file list and can exit knowing we have read al relevent information. 2 means we still haven't reached embdedded file list and need to do some more reading. */ -int check_sig(ub1 *scratch, pb_file *pbfp) { +static int check_sig(ub1 *scratch, pb_file *pbfp) { ub4 signature; int retflag = 0; @@ -175,7 +192,7 @@ args csize Pointer to embedded file's compressed size. Purpose: Unpack the series of values from file_header. */ -void decd_siz(ub4 *csize, ub4 *usize, ub2 *fnlen, ub2 *eflen, ub2 *flags, ub2 *method, ub1 *file_header) { +static void decd_siz(ub4 *csize, ub4 *usize, ub2 *fnlen, ub2 *eflen, ub2 *flags, ub2 *method, ub1 *file_header) { *csize = UNPACK_UB4(file_header, LOC_CSIZE); #ifdef DEBUG printf("Compressed size is %u\n", *csize); @@ -216,7 +233,7 @@ purpose: Read in the embedded file name from jar file. returns: Pointer to newly allocated string containing file name. */ -char *new_filename(pb_file *pbf, ub4 len) { +static char *new_filename(pb_file *pbf, ub4 len) { char *filename; if(!(filename = (char *) malloc(len + 1))) { @@ -241,10 +258,10 @@ purpose: Create a string containing the contents of the embedded noncompressed f returns: Pointer to newly allocated string containing embedded file contents. */ -char *read_string(pb_file *pbf, int size) { +static char *read_string(pb_file *pbf, int size) { char *page; - if(page = (char *) malloc(size + 1)) { + if((page = (char *) malloc(size + 1))) { pb_read(pbf, page, size); page[size] = '\0'; } @@ -270,16 +287,16 @@ The matching line that is printed out by jargrep is generated by this function. returns: Pointer to newly allocated string containing matched expression. */ -char *extract_line(char *stream, regoff_t begin, regoff_t end, int *b) { +static char *extract_line(const char *stream, regoff_t begin, regoff_t end, int *b) { int e; int length; char *retstr; - for(*b = begin; *b >= 0 && !iscntrl(stream[*b]); (*b)--); + for(*b = begin; *b >= 0 && !iscntrl((unsigned char)stream[*b]); (*b)--); (*b)++; - for(e = end; stream[e] == '\t' || !iscntrl(stream[e]); e++); + for(e = end; stream[e] == '\t' || !iscntrl((unsigned char)stream[e]); e++); length = e - *b; - if(retstr = (char *) malloc(length + 1)) { + if((retstr = (char *) malloc(length + 1))) { sprintf(retstr, "%d:", *b); strncpy(retstr, &(stream[*b]), length); retstr[length] = '\0'; @@ -302,24 +319,26 @@ word and not a substring of another word. returns: TRUE if it is a word, FALSE of it is a substring. */ -int chk_wrd(regex_t *exp, char *str) { +static int chk_wrd(regex_t *exp, const char *str) { int wrd_fnd = FALSE; int regflag; int frnt_ok; int bck_ok; - char *str2; + const char *str2; regmatch_t match; str2 = str; frnt_ok = bck_ok = FALSE; while(!wrd_fnd && !(regflag = regexec(exp, str2, 1, &match, 0))) { if(!match.rm_so && (str2 == str)) frnt_ok = TRUE; - else if(!isalnum(str2[match.rm_so - 1]) && str2[match.rm_so - 1] != '_') + else if(!isalnum((unsigned char)str2[match.rm_so - 1]) + && str2[match.rm_so - 1] != '_') frnt_ok = TRUE; else frnt_ok = FALSE; if(frnt_ok) { if(str2[match.rm_eo] == '\0') bck_ok = TRUE; - else if(!isalnum(str2[match.rm_eo]) && str2[match.rm_eo] != '_') + else if(!isalnum((unsigned char)str2[match.rm_eo]) + && str2[match.rm_eo] != '_') bck_ok = TRUE; else bck_ok = FALSE; } @@ -348,7 +367,7 @@ purpose: Control output of jargrep. Output is controlled by which options have set at the command line. */ -void prnt_mtchs(regex_t *exp, char *filename, char *stream, regmatch_t *pmatch, regmatch_t *nl_offset, int num, int lines, int options) { +static void prnt_mtchs(regex_t *exp, const char *filename, const char *stream, regmatch_t *pmatch, regmatch_t *nl_offset, int num, int lines, int options) { int i; int j = 0; int ln_cnt; @@ -388,13 +407,13 @@ args: pbf Pointer to pushback file pointer for jar file. purpose: Verify the CRC matches that as what is stored in the jar file. */ -void check_crc(pb_file *pbf, char *stream, ub4 usize) { +static void check_crc(pb_file *pbf, const char *stream, ub4 usize) { ub4 crc; ub4 lcrc; ub1 scratch[16]; crc = crc32(crc, NULL, 0); - crc = crc32(crc, stream, usize); + crc = crc32(crc, (const unsigned char *)stream, usize); if(pb_read(pbf, scratch, 16) != 16) { perror("read"); exit(1); @@ -420,11 +439,13 @@ permits grepping of binary files as well by converting non ASCII and control cha into '\n'. */ -void mk_ascii(char *stream, int usize) { - int i; +static void mk_ascii(char *stream, size_t usize) { + size_t i; for(i = 0; i < usize; i++) - if(stream[i] != '\t' && (iscntrl(stream[i]) || (unsigned char) stream[i] >= 128)) + if(stream[i] != '\t' + && (iscntrl((unsigned char)stream[i]) + || (unsigned char) stream[i] >= 128)) stream[i] = '\n'; } @@ -439,7 +460,7 @@ returns: Pointer to newly allocated array of regmatch_t which gives indexes to and end of matches. NULL is returned upon no matches found. */ -regmatch_t *fnd_match(regex_t *exp, char *str_stream, int *i) { +static regmatch_t *fnd_match(regex_t *exp, const char *str_stream, int *i) { int regflag; regmatch_t match; regmatch_t *match_array; @@ -449,8 +470,8 @@ regmatch_t *fnd_match(regex_t *exp, char *str_stream, int *i) { for(*i = 0, regflag = regexec(exp, str_stream, 1, &match, 0); !regflag; regflag = regexec(exp, &(str_stream[match.rm_eo]), 1, &match, 0), (*i)++) { - if(tmp = (regmatch_t *) - realloc(match_array, sizeof(regmatch_t) * ((*i) + 1))) + if((tmp = (regmatch_t *) + realloc(match_array, sizeof(regmatch_t) * ((*i) + 1)))) { match_array = tmp; if(*i) { @@ -483,7 +504,7 @@ read and then the embeded file is extracted and grepped. returns: FALSE upon failure, TRUE otherwise. */ -int cont_grep(regex_t *exp, regex_t *nl_exp, int fd, char *jarfile, pb_file *pbf, int options) { +static int cont_grep(regex_t *exp, regex_t *nl_exp, int fd, pb_file *pbf, int options) { int retflag = TRUE; int i; int j; @@ -538,7 +559,7 @@ purpose: Open jar file. Check signatures. When right signature is found go to grep routine. */ -void jargrep(regex_t *exp, regex_t *nl_exp, char *jarfile, int options) { +static void jargrep(regex_t *exp, regex_t *nl_exp, const char *jarfile, int options){ int fd; int floop = TRUE; pb_file pbf; @@ -559,7 +580,7 @@ void jargrep(regex_t *exp, regex_t *nl_exp, char *jarfile, int options) { else { switch (check_sig(scratch, &pbf)) { case 0: - floop = cont_grep(exp, nl_exp, fd, jarfile, &pbf, options); + floop = cont_grep(exp, nl_exp, fd, &pbf, options); break; case 1: floop = FALSE; |