Changeset 37 for trunk/src/gcc/fastjar
- Timestamp:
- Apr 25, 2003, 6:54:01 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gcc/fastjar/jargrep.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r36 r37 3 3 Copyright (C) 2002 Free Software Foundation 4 4 Copyright (C) 1999, 2000 Bryan Burns 5 Copyright (C) 2000 Cory Hollingsworth 6 7 Parts of this program are base on Bryan Burns work with fastjar 8 Copyright (C) 1999. 5 Copyright (C) 2000 Cory Hollingsworth 6 7 Parts of this program are base on Bryan Burns work with fastjar 8 Copyright (C) 1999. 9 9 10 10 This program is free software; you can redistribute it and/or … … 12 12 as published by the Free Software Foundation; either version 2 13 13 of the License, or (at your option) any later version. 14 14 15 15 This program is distributed in the hope that it will be useful, 16 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 18 GNU General Public License for more details. 19 19 20 20 You should have received a copy of the GNU General Public License 21 21 along with this program; if not, write to the Free Software … … 25 25 /* Id: jargrep.c,v 1.5 2002/01/03 04:57:56 rodrigc Exp 26 26 27 Log: jargrep.c,v 27 Log: jargrep.c,v 28 28 Revision 1.5 2002/01/03 04:57:56 rodrigc 29 29 2001-01-02 Craig Rodrigues <rodrigc@gcc.gnu.org> … … 106 106 #include <stdio.h> 107 107 #include <unistd.h> 108 #include <regex.h> 108 /* bird: use xregex to avoid linking trouble 109 * #include <regex.h> 110 */ 111 #include <xregex.h> 109 112 #include <errno.h> 110 113 #include <string.h> … … 140 143 int retflag; 141 144 142 if((options & JG_PRINT_COUNT) && 145 if((options & JG_PRINT_COUNT) && 143 146 (options & (JG_PRINT_BYTEOFFSET | JG_PRINT_LINE_NUMBER))) 144 147 { … … 152 155 /* 153 156 Function name: create_regexp 154 args: regstr String containing the uncompiled regular expression. This may be the 157 args: regstr String containing the uncompiled regular expression. This may be the 155 158 expression as is passed in through argv. 156 159 options This is the flag containing the commandline options that have been 157 160 parsed by getopt. 158 purpose: Handle the exception handling involved with setting upt a new regular 161 purpose: Handle the exception handling involved with setting upt a new regular 159 162 expression. 160 163 returns: Newly allocated compile regular expression ready to be used in an regexec call. … … 192 195 } 193 196 194 return exp; 197 return exp; 195 198 } 196 199 … … 211 214 signature = UNPACK_UB4(scratch, 0); 212 215 213 #ifdef DEBUG 216 #ifdef DEBUG 214 217 printf("signature is %x\n", signature); 215 218 #endif 216 219 if(signature == 0x08074b50){ 217 #ifdef DEBUG 220 #ifdef DEBUG 218 221 printf("skipping data descriptor\n"); 219 222 #endif … … 221 224 retflag = 2; 222 225 } else if(signature == 0x02014b50){ 223 #ifdef DEBUG 226 #ifdef DEBUG 224 227 printf("Central header reached.. we're all done!\n"); 225 228 #endif … … 229 232 retflag = 1; 230 233 } 231 234 232 235 return retflag; 233 236 } … … 247 250 static void decd_siz(ub4 *csize, ub4 *usize, ub2 *fnlen, ub2 *eflen, ub2 *flags, ub2 *method, ub1 *file_header) { 248 251 *csize = UNPACK_UB4(file_header, LOC_CSIZE); 249 #ifdef DEBUG 252 #ifdef DEBUG 250 253 printf("Compressed size is %u\n", *csize); 251 254 #endif … … 257 260 258 261 *fnlen = UNPACK_UB2(file_header, LOC_FNLEN); 259 #ifdef DEBUG 262 #ifdef DEBUG 260 263 printf("Filename length is %hu\n", *fnlen); 261 264 #endif 262 265 263 266 *eflen = UNPACK_UB2(file_header, LOC_EFLEN); 264 #ifdef DEBUG 267 #ifdef DEBUG 265 268 printf("Extra field length is %hu\n", *eflen); 266 269 #endif 267 270 268 271 *flags = UNPACK_UB2(file_header, LOC_EXTRA); 269 #ifdef DEBUG 272 #ifdef DEBUG 270 273 printf("Flags are %#hx\n", *flags); 271 274 #endif … … 296 299 filename[len] = '\0'; 297 300 298 #ifdef DEBUG 301 #ifdef DEBUG 299 302 printf("filename is %s\n", filename); 300 303 #endif … … 414 417 num Number of matches in pmatch array. 415 418 lines Number of lines in file. Not set if -n is not set on command line. 416 options Bitwise flag containing flags set to represent the command line 419 options Bitwise flag containing flags set to represent the command line 417 420 options. 418 421 purpose: Control output of jargrep. Output is controlled by which options have been … … 495 498 size_t i; 496 499 497 for(i = 0; i < usize; i++) 500 for(i = 0; i < usize; i++) 498 501 if(stream[i] != '\t' 499 502 && (iscntrl((unsigned char)stream[i]) … … 520 523 521 524 match_array = NULL; 522 for(*i = 0, regflag = regexec(exp, str_stream, 1, &match, 0); !regflag; 525 for(*i = 0, regflag = regexec(exp, str_stream, 1, &match, 0); !regflag; 523 526 regflag = regexec(exp, &(str_stream[match.rm_eo]), 1, &match, 0), (*i)++) 524 527 { 525 if((tmp = (regmatch_t *) 528 if((tmp = (regmatch_t *) 526 529 realloc(match_array, sizeof(regmatch_t) * ((*i) + 1)))) 527 530 { … … 538 541 exit(1); 539 542 } 540 } 543 } 541 544 542 545 return match_array; … … 582 585 lseek(fd, eflen, SEEK_CUR); 583 586 if(filename[fnlen - 1] != '/') { 584 str_stream = (method == 8 || (flags & 0x0008)) ? 585 (char *) inflate_string(pbf, &csize, &usize) : 587 str_stream = (method == 8 || (flags & 0x0008)) ? 588 (char *) inflate_string(pbf, &csize, &usize) : 586 589 read_string(pbf, csize); 587 590 if(flags & 0x008) check_crc(pbf, str_stream, usize); 588 591 mk_ascii(str_stream, usize); 589 592 match_array = fnd_match(exp, str_stream, &i); 590 if((options & JG_PRINT_LINE_NUMBER) && i) 593 if((options & JG_PRINT_LINE_NUMBER) && i) 591 594 nl_offsets = fnd_match(nl_exp, str_stream, &j); 592 595 prnt_mtchs(exp, filename, str_stream, match_array, nl_offsets, i, j, options); … … 604 607 Funtion name: jargrep 605 608 args: exp Pointer to compiled POSIX style regular expression of search target. 606 nl_exp Pointer to compiled regular expression for newlines or NULL. Only set 609 nl_exp Pointer to compiled regular expression for newlines or NULL. Only set 607 610 if -n option is present at command line. 608 611 jarfile Filename of jar file to be searched. -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.