* Add slightly more complex modes to zzcat.

This commit is contained in:
Sam Hocevar
2008-07-18 09:28:06 +00:00
committed by sam
parent d45a5121ef
commit 9810cc153f
2 changed files with 30 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ checkutils()
else
check "$ZZOPTS" "< $file" "zzuf"
fi
for n in 0 10 11 12 20 21 22; do
for n in 0 20 21 22 30 31 40 41 42; do
check "$ZZOPTS" "$ZZCAT $n $file" "zzcat $n"
done
if [ "$STATIC_CAT" = "" ]; then

View File

@@ -75,6 +75,8 @@ int main(int argc, char *argv[])
/* Read shit here and there, using different methods */
switch(atoi(argv[1]))
{
/* 0x: simple fd calls
* 1x: complex fd calls */
case 0: /* only read() calls */
fd = open(name, O_RDONLY);
if(fd < 0)
@@ -83,7 +85,9 @@ int main(int argc, char *argv[])
read(fd, data + i, 1);
close(fd);
break;
case 10: /* only fread() calls */
/* 2x: simple stdio calls
* 3x: complex stdio calls */
case 20: /* only fread() calls */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
@@ -91,7 +95,7 @@ int main(int argc, char *argv[])
fread(data + i, 1, 1, stream);
fclose(stream);
break;
case 11: /* only getc() calls */
case 21: /* only getc() calls */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
@@ -99,7 +103,7 @@ int main(int argc, char *argv[])
data[i] = getc(stream);
fclose(stream);
break;
case 12: /* only fgetc() calls */
case 22: /* only fgetc() calls */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
@@ -107,7 +111,26 @@ int main(int argc, char *argv[])
data[i] = fgetc(stream);
fclose(stream);
break;
case 20: /* socket seeks and reads */
case 30: /* one fread(), then only getc() calls */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
fread(data, 1, 10, stream);
for(i = 10; i < len; i++)
data[i] = getc(stream);
fclose(stream);
break;
case 31: /* one fread(), then only fgetc() calls */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
fread(data, 1, 10, stream);
for(i = 10; i < len; i++)
data[i] = fgetc(stream);
fclose(stream);
break;
/* 4x: complex, random stuff */
case 40: /* socket seeks and reads */
fd = open(name, O_RDONLY);
if(fd < 0)
return EXIT_FAILURE;
@@ -124,7 +147,7 @@ int main(int argc, char *argv[])
}
close(fd);
break;
case 21: /* std streams seeks and reads */
case 41: /* std streams seeks and reads */
stream = fopen(name, "r");
if(!stream)
return EXIT_FAILURE;
@@ -145,7 +168,7 @@ int main(int argc, char *argv[])
}
fclose(stream);
break;
case 22: /* mmap() */
case 42: /* mmap() */
fd = open(name, O_RDONLY);
if(fd < 0)
return EXIT_FAILURE;