diff --git a/.gitignore b/.gitignore index 47199cc..f61f893 100644 --- a/.gitignore +++ b/.gitignore @@ -24,13 +24,13 @@ m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 src/zzuf -src/zzcat +src/zzat test/zzero test/zznop test/zzone test/bug-div0 test/bug-memory test/bug-overflow -doc/zzcat.1 +doc/zzat.1 doc/zzuf.1 doc/libzzuf.3 diff --git a/configure.ac b/configure.ac index 08c5fa3..f20cb74 100644 --- a/configure.ac +++ b/configure.ac @@ -179,7 +179,7 @@ AC_CONFIG_FILES([ test/Makefile ]) AC_CONFIG_FILES([ - doc/zzcat.1 + doc/zzat.1 doc/zzuf.1 doc/libzzuf.3 ]) diff --git a/doc/Makefile.am b/doc/Makefile.am index ac940b5..8f9721f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,6 @@ # $Id: Makefile.am 871 2006-09-25 15:58:33Z sam $ -EXTRA_DIST = zzuf.1.in libzzuf.3.in zzcat.1.in +EXTRA_DIST = zzuf.1.in libzzuf.3.in zzat.1.in -man_MANS = zzuf.1 libzzuf.3 zzcat.1 +man_MANS = zzuf.1 libzzuf.3 zzat.1 diff --git a/doc/zzcat.1.in b/doc/zzat.1.in similarity index 78% rename from doc/zzcat.1.in rename to doc/zzat.1.in index bc95beb..b02dcc8 100644 --- a/doc/zzcat.1.in +++ b/doc/zzat.1.in @@ -1,22 +1,22 @@ -.TH zzcat 1 "2010-01-07" "zzcat @PACKAGE_VERSION@" +.TH zzat 1 "2010-01-07" "zzat @PACKAGE_VERSION@" .SH NAME -zzcat \- concatenate files using different instruction sequences +zzat \- concatenate files using different instruction sequences .SH SYNOPSIS -\fBzzcat\fR [\fB\-AbdeEntTv\fR] [\fB\-r\fR \fIloops\fR] +\fBzzat\fR [\fB\-AbdeEntTv\fR] [\fB\-r\fR \fIloops\fR] [\fB\-x\fR \fIsequence\fR] [\fIFILE\fR]... .br -\fBzzcat \-l\fR | \fB\-\-list\fR +\fBzzat \-l\fR | \fB\-\-list\fR .br -\fBzzcat \-h\fR | \fB\-\-help\fR +\fBzzat \-h\fR | \fB\-\-help\fR .br -\fBzzcat \-V\fR | \fB\-\-version\fR +\fBzzat \-V\fR | \fB\-\-version\fR .SH DESCRIPTION .PP -The \fBzzcat\fR utility reads files sequentially, writing them to the +The \fBzzat\fR utility reads files sequentially, writing them to the standard output. The user can decide which sequence of library calls is used to seek and read data. -\fBzzcat\fR is primarily used as a debugging tool for \fBzzuf\fR, because +\fBzzat\fR is primarily used as a debugging tool for \fBzzuf\fR, because it can emulate different programs' ways to read files. .SH OPTIONS .TP @@ -69,7 +69,7 @@ Instructions can be separated by spaces, commas or semicolons. A list of all available instructions and control keywords can be obtained using this command: -\fB zzcat \-l\fR +\fB zzat \-l\fR If no sequence is specified, the following default sequence is used: @@ -88,24 +88,24 @@ Output version information and exit. .PP Read the first 1000 bytes of f, then exit: .PP -\fB zzcat \-x \(aqfread(1,1000)\(aq f\fR +\fB zzat \-x \(aqfread(1,1000)\(aq f\fR .PP Read the first four bytes of f, using four different instructions: .PP -\fB zzcat \-x \(aqgetc(),fgetc(),getc_unlocked(),_IO_getc()\(aq f\fR +\fB zzat \-x \(aqgetc(),fgetc(),getc_unlocked(),_IO_getc()\(aq f\fR .PP Read f entirely, by calling \fBgetc()\fR repeatedly until end-of-file is reached: .PP -\fB zzcat \-x \(aqrepeat(\-1, getc(), feof(1))\(aq \fRf +\fB zzat \-x \(aqrepeat(\-1, getc(), feof(1))\(aq \fRf .PP Read f entirely, in chunks of 32768 bytes until end-of-file is reached: .PP -\fB zzcat \-x \(aqrepeat(\-1, fread(1,32768), feof(1))\(aq \fRf +\fB zzat \-x \(aqrepeat(\-1, fread(1,32768), feof(1))\(aq \fRf .\" .PP .\" Read only odd bytes, rewind file, then read all even bytes: .\" .PP -.\" \fB zzcat \-x \(aqrepeat(\-1, getc(), feof(1), fseek(1,SEEK_CUR)), +.\" \fB zzat \-x \(aqrepeat(\-1, getc(), feof(1), fseek(1,SEEK_CUR)), .\" \fB rewind(), .\" \fB repeat(\-1, fseek(1,SEEK_CUR), getc(), feof(1))\(aq .SH SEE ALSO @@ -115,7 +115,7 @@ Read f entirely, in chunks of 32768 bytes until end-of-file is reached: .PP Copyright \(co 2002\-2010 Sam Hocevar . .PP -\fBzzcat\fR and this manual page are free software. They come without any +\fBzzat\fR and this manual page are free software. They come without any warranty, to the extent permitted by applicable law. You can redistribute them and/or modify them under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See diff --git a/doc/zzuf.1.in b/doc/zzuf.1.in index 716260b..c46d40a 100644 --- a/doc/zzuf.1.in +++ b/doc/zzuf.1.in @@ -454,7 +454,7 @@ descriptor operations is undefined. multimedia stream corrupter used to find bugs in the VLC media player. .SH SEE ALSO .PP -\fBlibzzuf(3)\fR, \fBzzcat(1)\fR +\fBlibzzuf(3)\fR, \fBzzat(1)\fR .SH AUTHOR .PP Copyright \(co 2002\-2010 Sam Hocevar . diff --git a/src/Makefile.am b/src/Makefile.am index be8bda0..0928733 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,12 +1,12 @@ -bin_PROGRAMS = zzuf zzcat +bin_PROGRAMS = zzuf zzat pkglib_LTLIBRARIES = libzzuf.la ZZUF = \ zzuf.c opts.c opts.h md5.c md5.h timer.c timer.h myfork.c myfork.h -ZZCAT = \ - zzcat.c +ZZAT = \ + zzat.c LIBZZUF = \ libzzuf/libzzuf.c libzzuf/libzzuf.h \ @@ -32,7 +32,7 @@ zzuf_CFLAGS = -DLIBDIR=\"$(libdir)/zzuf\" -I$(srcdir)/common zzuf_LDFLAGS = $(MATH_LIBS) $(WINSOCK2_LIBS) zzuf_DEPENDENCIES = libzzuf.la -zzcat_SOURCES = $(ZZCAT) $(GETOPT) +zzat_SOURCES = $(ZZAT) $(GETOPT) libzzuf_la_SOURCES = $(LIBZZUF) $(COMMON) libzzuf_la_CFLAGS = -DLIBZZUF -I$(srcdir)/libzzuf -I$(srcdir)/common diff --git a/src/zzcat.c b/src/zzat.c similarity index 95% rename from src/zzcat.c rename to src/zzat.c index d28b495..9a5458f 100644 --- a/src/zzcat.c +++ b/src/zzat.c @@ -1,5 +1,5 @@ /* - * zzcat - various cat reimplementations for testing purposes + * zzat - various cat reimplementations for testing purposes * Copyright (c) 2006-2010 Sam Hocevar * All Rights Reserved * @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) if (myoptind >= argc) { - fprintf(stderr, "E: zzcat: too few arguments\n"); + fprintf(stderr, "E: zzat: too few arguments\n"); return EXIT_FAILURE; } @@ -259,7 +259,7 @@ static void output(char const *buf, size_t len) cmd; \ if (!f) \ { \ - fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \ + fprintf(stderr, "E: zzat: cannot open `%s'\n", file); \ return EXIT_FAILURE; \ } \ retoff = 0; \ @@ -284,7 +284,7 @@ static void output(char const *buf, size_t len) if (!retbuf || ROUNDUP(retlen) != ROUNDUP(retlen - _cnt)) \ { \ if (debug) \ - fprintf(stderr, "D: zzcat: allocating %i bytes for %i\n", \ + fprintf(stderr, "D: zzat: allocating %i bytes for %i\n", \ (int)ROUNDUP(retlen), (int)retlen); \ retbuf = realloc(retbuf, ROUNDUP(retlen)); \ } \ @@ -292,7 +292,7 @@ static void output(char const *buf, size_t len) if (_cnt > 0) \ { \ if (debug) \ - fprintf(stderr, "D: zzcat: writing %i byte%s at offset %i\n", \ + fprintf(stderr, "D: zzat: writing %i byte%s at offset %i\n", \ (int)_cnt, _cnt == 1 ? "" : "s", (int)retoff); \ memcpy(retbuf + retoff, address, _cnt); \ } \ @@ -309,7 +309,7 @@ static void output(char const *buf, size_t len) f = fopen(file, "r"); \ if (!f) \ { \ - fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \ + fprintf(stderr, "E: zzat: cannot open `%s'\n", file); \ return EXIT_FAILURE; \ } \ } \ @@ -326,7 +326,7 @@ static void output(char const *buf, size_t len) f = fopen(file, "r"); \ if (!f) \ { \ - fprintf(stderr, "E: zzcat: cannot open `%s'\n", file); \ + fprintf(stderr, "E: zzat: cannot open `%s'\n", file); \ return EXIT_FAILURE; \ } \ } \ @@ -422,7 +422,7 @@ static int run(char const *sequence, char const *file) { if (nloops == 0) { - fprintf(stderr, "E: zzcat: ')' outside a loop\n"); + fprintf(stderr, "E: zzat: ')' outside a loop\n"); return EXIT_FAILURE; } if (loops[nloops - 1].count == 1 || finish) @@ -572,7 +572,7 @@ static int run(char const *sequence, char const *file) char buf[16]; snprintf(buf, 16, strlen(sequence) < 16 ? "%s" : "%.12s...", sequence); - fprintf(stderr, "E: zzcat: syntax error near `%s'\n", buf); + fprintf(stderr, "E: zzat: syntax error near `%s'\n", buf); return EXIT_FAILURE; } @@ -599,7 +599,7 @@ static int run(char const *sequence, char const *file) #if 0 /* Only read() calls */ -static int zzcat_read(char const *name, unsigned char *data, int64_t len, +static int zzat_read(char const *name, unsigned char *data, int64_t len, int64_t chunk) { int i, fd = open(name, O_RDONLY); @@ -612,7 +612,7 @@ static int zzcat_read(char const *name, unsigned char *data, int64_t len, } /* Socket seeks and reads */ -static int zzcat_random_socket(char const *name, unsigned char *data, +static int zzat_random_socket(char const *name, unsigned char *data, int64_t len) { int i, j, fd = open(name, O_RDONLY); @@ -634,7 +634,7 @@ static int zzcat_random_socket(char const *name, unsigned char *data, } /* Standard stream seeks and reads */ -static int zzcat_random_stream(char const *name, unsigned char *data, +static int zzat_random_stream(char const *name, unsigned char *data, int64_t len) { FILE *stream = fopen(name, "r"); @@ -662,8 +662,8 @@ static int zzcat_random_stream(char const *name, unsigned char *data, #ifdef HAVE_MMAP /* mmap() followed by random memory reads */ -static int zzcat_random_mmap(char const *name, unsigned char *data, - int64_t len) +static int zzat_random_mmap(char const *name, unsigned char *data, + int64_t len) { int i, j, fd = open(name, O_RDONLY); if(fd < 0) @@ -787,7 +787,7 @@ static void syntax(void) static void version(void) { - printf("zzcat %s\n", PACKAGE_VERSION); + printf("zzat %s\n", PACKAGE_VERSION); printf("Copyright (C) 2002-2010 Sam Hocevar \n"); printf("This program is free software. It comes without any warranty, to the extent\n"); printf("permitted by applicable law. You can redistribute it and/or modify it under\n"); @@ -799,10 +799,10 @@ static void version(void) static void usage(void) { - printf("Usage: zzcat [AbdeEntTv] [-x sequence] [FILE...]\n"); - printf(" zzcat -l | --list\n"); - printf(" zzcat -h | --help\n"); - printf(" zzcat -V | --version\n"); + printf("Usage: zzat [AbdeEntTv] [-x sequence] [FILE...]\n"); + printf(" zzat -l | --list\n"); + printf(" zzat -h | --help\n"); + printf(" zzat -V | --version\n"); printf("Read FILE using a sequence of various I/O methods.\n"); printf("\n"); printf("Mandatory arguments to long options are mandatory for short options too.\n"); diff --git a/test/check-utils b/test/check-utils index 40a8a26..a1cad55 100755 --- a/test/check-utils +++ b/test/check-utils @@ -13,10 +13,10 @@ . "$(dirname "$0")/functions.inc" -HAVE_GETLINE=$("$ZZCAT" -l | grep >/dev/null 2>&1 '^ getline(' && echo "y") -HAVE_GETDELIM=$("$ZZCAT" -l | grep >/dev/null 2>&1 '^ getdelim(' && echo "y") -HAVE_GETC_UNLOCKED=$("$ZZCAT" -l | grep >/dev/null 2>&1 '^ getc_unlocked(' && echo "y") -HAVE_FGETC_UNLOCKED=$("$ZZCAT" -l | grep >/dev/null 2>&1 '^ fgetc_unlocked(' && echo "y") +HAVE_GETLINE=$("$ZZAT" -l | grep >/dev/null 2>&1 '^ getline(' && echo "y") +HAVE_GETDELIM=$("$ZZAT" -l | grep >/dev/null 2>&1 '^ getdelim(' && echo "y") +HAVE_GETC_UNLOCKED=$("$ZZAT" -l | grep >/dev/null 2>&1 '^ getc_unlocked(' && echo "y") +HAVE_FGETC_UNLOCKED=$("$ZZAT" -l | grep >/dev/null 2>&1 '^ fgetc_unlocked(' && echo "y") checkutils() { @@ -70,10 +70,10 @@ checkutils() ;; esac # Regression tests for stuff that used to break - check "$ZZOPTS" "$ZZCAT -x \"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" \ + check "$ZZOPTS" "$ZZAT -x \"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" \ "eglibc (2.9-21) bug regression" if [ "$HAVE_GET_UNLOCKED $HAVE_GETLINE" = "y y" ]; then - check "$ZZOPTS" "$ZZCAT -x \"repeat(33000,getc_unlocked(),feof(10),ungetc(),getline()))\" $file" \ + check "$ZZOPTS" "$ZZAT -x \"repeat(33000,getc_unlocked(),feof(10),ungetc(),getline()))\" $file" \ "sed getc_unlocked() bug regression" fi # Misc tests @@ -99,7 +99,7 @@ checkutils() "fread(1,33000) fseek(1000,SEEK_CUR) repeat(-1,getc(),feof(10))" \ "fread(1,33000) fseek(1000,SEEK_CUR) repeat(-1,fgetc(),feof(10))" \ ; do - check "$ZZOPTS" "$ZZCAT -x \"$n\" $file" "$n" + check "$ZZOPTS" "$ZZAT -x \"$n\" $file" "$n" done # Platform-specific tests if [ "$HAVE_GETLINE" = "y" ]; then @@ -108,7 +108,7 @@ checkutils() "repeat(-1,getc(),feof(10),ungetc(),getline())" \ "repeat(-1,fgetc(),feof(10),ungetc(),getline())" \ ; do - check "$ZZOPTS" "$ZZCAT -x \"$n\" $file" "$n" + check "$ZZOPTS" "$ZZAT -x \"$n\" $file" "$n" done fi if [ "$HAVE_GETDELIM" = "y" ]; then @@ -116,7 +116,7 @@ checkutils() "repeat(10,getdelim(0)) fread(1,33000)" \ "repeat(10,getdelim(' ')) fread(1,33000)" \ ; do - check "$ZZOPTS" "$ZZCAT -x \"$n\" $file" "$n" + check "$ZZOPTS" "$ZZAT -x \"$n\" $file" "$n" done fi if [ "$HAVE_GETC_UNLOCKED" = "y" ]; then @@ -127,7 +127,7 @@ checkutils() "repeat(8000,getc_unlocked()) fread(1,33000)" \ "fread(1,33000) fseek(1000,SEEK_CUR) repeat(-1,getc_unlocked(),feof(10))" \ ; do - check "$ZZOPTS" "$ZZCAT -x \"$n\" $file" "$n" + check "$ZZOPTS" "$ZZAT -x \"$n\" $file" "$n" done fi if [ "$HAVE_FGETC_UNLOCKED" = "y" ]; then @@ -137,7 +137,7 @@ checkutils() "repeat(-1,fgetc_unlocked(),feof(10))" \ "repeat(8000,fgetc_unlocked()) fread(1,33000)" \ ; do - check "$ZZOPTS" "$ZZCAT -x \"$n\" $file" "$n" + check "$ZZOPTS" "$ZZAT -x \"$n\" $file" "$n" done fi done diff --git a/test/check-zzuf-A-autoinc b/test/check-zzuf-A-autoinc index a17d377..23b696d 100755 --- a/test/check-zzuf-A-autoinc +++ b/test/check-zzuf-A-autoinc @@ -16,9 +16,9 @@ start_test "zzuf -A test" # Check -A with no fuzzing: output must match -new_test "zzuf -A -r0 zzcat file-random file-random" -m1=$($ZZUF -m -r0 $ZZCAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') -m2=$($ZZUF -m -A -r0 $ZZCAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') +new_test "zzuf -A -r0 zzat file-random file-random" +m1=$($ZZUF -m -r0 $ZZAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') +m2=$($ZZUF -m -A -r0 $ZZAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') if [ "$m1" = "$m2" ]; then pass_test "ok" else @@ -26,9 +26,9 @@ else fi # Check -A with fuzzing: output must be different -new_test "zzuf -A -r0.1 zzcat file-random file-random" -m1=$($ZZUF -m -r0.1 $ZZCAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') -m2=$($ZZUF -m -A -r0.1 $ZZCAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') +new_test "zzuf -A -r0.1 zzat file-random file-random" +m1=$($ZZUF -m -r0.1 $ZZAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') +m2=$($ZZUF -m -A -r0.1 $ZZAT "$DIR/file-random" "$DIR/file-random" | cut -f2 -d' ') if [ "$m1" != "$m2" ]; then pass_test "ok" else diff --git a/test/check-zzuf-s-seed b/test/check-zzuf-s-seed index 007ed31..f34ce7c 100755 --- a/test/check-zzuf-s-seed +++ b/test/check-zzuf-s-seed @@ -31,7 +31,7 @@ while : ; do passes=10 while test $zeroes -gt 0 -a $passes -lt 200000; do printf " doing $passes passes..." - zeroes=$($ZZUF -r $ratio -s $seed -A $ZZCAT -r $passes -x "fread(1,$bytes)" /dev/zero | $DIR/zzone $bytes $passes) + zeroes=$($ZZUF -r $ratio -s $seed -A $ZZAT -r $passes -x "fread(1,$bytes)" /dev/zero | $DIR/zzone $bytes $passes) echo " $zeroes" passes=$(expr '(' $passes '*' 7 + 3 ')' / 4) done diff --git a/test/functions.inc b/test/functions.inc index 6bb5a56..715fe07 100644 --- a/test/functions.inc +++ b/test/functions.inc @@ -15,9 +15,9 @@ DIR="$(dirname "$0")" ZZUF="$DIR/../src/zzuf -E [.]ilist$" -ZZCAT="$DIR/../src/zzcat" -if [ ! -f "$ZZCAT" ]; then - echo "error: src/zzcat is missing" +ZZAT="$DIR/../src/zzat" +if [ ! -f "$ZZAT" ]; then + echo "error: src/zzat is missing" exit 1 fi