Changeset 4240 for zzuf/trunk/test
- Timestamp:
- Jan 8, 2010, 1:48:33 AM (11 years ago)
- Location:
- zzuf/trunk/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/test/check-utils
r4233 r4240 57 57 check "$ZZOPTS" "$ZZCAT \"fread(1,33000) fseek(1,SEEK_SET) fread(1,1) fseek(4093,SEEK_CUR) fread(1,1) fseek(1,SEEK_CUR) fread(1,1)\" $file" \ 58 58 "eglibc (2.9-21) bug regression" 59 check "$ZZOPTS" "$ZZCAT \"repeat(33000,getc_unlocked() ungetc() getline() )\" $file" \59 check "$ZZOPTS" "$ZZCAT \"repeat(33000,getc_unlocked() ungetc() getline() feof(10))\" $file" \ 60 60 "sed getc_unlocked() bug regression" 61 61 # Misc tests … … 72 72 "fgetc() ungetc() fread(1,33000)" \ 73 73 "fgetc_unlocked() ungetc() fread(1,33000)" \ 74 "repeat(33000,getc() )" \75 "repeat(33000,getc_unlocked() )" \76 "repeat(33000,fgetc() )" \77 "repeat(33000,fgetc_unlocked() )" \74 "repeat(33000,getc(),feof(10))" \ 75 "repeat(33000,getc_unlocked(),feof(10))" \ 76 "repeat(33000,fgetc(),feof(10))" \ 77 "repeat(33000,fgetc_unlocked(),feof(10))" \ 78 78 "repeat(8000,getc()) fread(1,33000)" \ 79 79 "repeat(8000,getc_unlocked()) fread(1,33000)" \ … … 89 89 "fread(1,33000) rewind() repeat(10000,fseek(3,SEEK_CUR) fread(1,3))" \ 90 90 "fread(1,33000) rewind() repeat(10000,fseek(4,SEEK_CUR) fread(1,4))" \ 91 "repeat(33000,getc() ungetc() getline() )" \92 "repeat(33000,fgetc() ungetc() getline() )" \93 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,fread(1,2) )" \94 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,getc() )" \95 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,fgetc() )" \96 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,getc_unlocked() )" \91 "repeat(33000,getc() ungetc() getline() feof(10))" \ 92 "repeat(33000,fgetc() ungetc() getline() feof(10))" \ 93 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,fread(1,2),feof(10))" \ 94 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,getc(),feof(10))" \ 95 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,fgetc(),feof(10))" \ 96 "fread(1,33000) fseek(1000,SEEK_CUR) repeat(10000,getc_unlocked(),feof(10))" \ 97 97 ; do 98 98 check "$ZZOPTS" "$ZZCAT \"$n\" $file" "$n" -
zzuf/trunk/test/zzcat.c
r4121 r4240 1 1 /* 2 2 * zzcat - various cat reimplementations for testing purposes 3 * Copyright (c) 2006-20 09Sam Hocevar <sam@hocevar.net>3 * Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 105 105 } while(0) 106 106 107 #define FEOF() \ 108 do { \ 109 if (!f) \ 110 { \ 111 f = fopen(file, "r"); \ 112 if (!f) \ 113 { \ 114 fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \ 115 return EXIT_FAILURE; \ 116 } \ 117 } \ 118 if (feof(f)) \ 119 feofs++; \ 120 if (feofs >= l1) \ 121 finish = 1; \ 122 p = strchr(p, ')') + 1; \ 123 } while(0) 124 107 125 /* 108 126 * Command parser. We rewrite fmt by replacing the last character with … … 153 171 FILE *f = NULL; 154 172 size_t retlen = 0, retoff = 0; 155 int nloops = 0, fd = -1 ;173 int nloops = 0, fd = -1, feofs = 0, finish = 0; 156 174 157 175 /* Allocate 32MB for our temporary buffer. Any larger value will crash. */ … … 188 206 } 189 207 loops[nloops - 1].count--; 190 if (loops[nloops - 1].count <= 0 )208 if (loops[nloops - 1].count <= 0 || finish) 191 209 { 192 210 nloops--; … … 197 215 p = loops[nloops - 1].p; 198 216 } 217 218 finish = 0; 199 219 } 200 220 … … 220 240 FOPEN(f = __freopen64(file, "r", f)); 221 241 #endif 242 243 /* FILE * EOF detection */ 244 else if (PARSECMD("feof ( %li )", &l1)) 245 FEOF(); 222 246 223 247 /* FILE * closing functions */ … … 334 358 if (lineptr) 335 359 free(lineptr); 360 361 if (finish && !nloops) 362 break; 336 363 } 337 364
Note: See TracChangeset
for help on using the changeset viewer.