X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/97d53f8c757d30584232e986cad3fa05b9f570f6..e5daa2731a82e643f1fbc292a29b82df750820fa:/wildtest.c diff --git a/wildtest.c b/wildtest.c index b5820993..b5df9a58 100644 --- a/wildtest.c +++ b/wildtest.c @@ -19,9 +19,6 @@ int wildmatch_errors = 0; typedef char bool; -#define false 0 -#define true 1 - int output_iterations = 0; static struct poptOption long_options[] = { @@ -59,8 +56,10 @@ run_test(int line, bool matches, bool same_as_fnmatch, fnmatch_errors++; } #endif - if (output_iterations) - printf("[%s] iterations = %d\n", pattern, wildmatch_iteration_count); + if (output_iterations) { + printf("%d: \"%s\" iterations = %d\n", line, pattern, + wildmatch_iteration_count); + } } int @@ -82,8 +81,14 @@ main(int argc, char **argv) } } - if ((fp = fopen("wildtest.txt", "r")) == NULL) { - fprintf(stderr, "Unable to open wildtest.txt.\n"); + argv = (char**)poptGetArgs(pc); + if (!argv || argv[1]) { + fprintf(stderr, "Usage: wildtest TESTFILE\n"); + exit(1); + } + + if ((fp = fopen(*argv, "r")) == NULL) { + fprintf(stderr, "Unable to open %s\n", *argv); exit(1); } @@ -102,8 +107,8 @@ main(int argc, char **argv) if (*++s != ' ' && *s != '\t') flag[i] = -1; if (flag[i] < 0) { - fprintf(stderr, "Invalid flag syntax on line %d of wildtest.txt:%s\n", - line, buf); + fprintf(stderr, "Invalid flag syntax on line %d of %s:\n%s", + line, *argv, buf); exit(1); } while (*++s == ' ' || *s == '\t') {} @@ -114,16 +119,16 @@ main(int argc, char **argv) string[i] = s; while (*s && *s != quote) s++; if (!*s) { - fprintf(stderr, "Unmatched quote on line %d of wildtest.txt:%s\n", - line, buf); + fprintf(stderr, "Unmatched quote on line %d of %s:\n%s", + line, *argv, buf); exit(1); } end[i] = s; } else { if (!*s || *s == '\n') { - fprintf(stderr, "Not enough strings on line %d of wildtest.txt:%s\n", - line, buf); + fprintf(stderr, "Not enough strings on line %d of %s:\n%s", + line, *argv, buf); exit(1); } string[i] = s; @@ -137,15 +142,17 @@ main(int argc, char **argv) } if (!wildmatch_errors) - printf("No wildmatch errors found.\n"); + fputs("No", stdout); else - printf("Found %d wildmatch errors.\n", wildmatch_errors); + printf("%d", wildmatch_errors); + printf(" wildmatch error%s found.\n", wildmatch_errors == 1? "" : "s"); #ifdef COMPARE_WITH_FNMATCH if (!fnmatch_errors) - printf("No fnmatch errors found.\n"); + fputs("No", stdout); else - printf("Found %d fnmatch errors.\n", fnmatch_errors); + printf("%d", fnmatch_errors); + printf(" fnmatch error%s found.\n", fnmatch_errors == 1? "" : "s"); #endif