X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=judge%2Ftest-tok.c;h=8927e05f95710c9501749dcdd19f06b5f86d8394;hb=107b5e8dc73f0180e2b3f35f8ed031662bbc57fb;hp=10e7b3b04c2a8a43ecc98274cd899f6d6a5c746b;hpb=a3cb81d88eb514af15ba6bd5279a1549c0ba5266;p=moe.git diff --git a/judge/test-tok.c b/judge/test-tok.c index 10e7b3b..8927e05 100644 --- a/judge/test-tok.c +++ b/judge/test-tok.c @@ -1,25 +1,47 @@ #include +#include +#include #include "judge.h" -int main(void) +int main(int argc, char **argv) { struct stream *i = sopen_fd("stdin", 0); struct tokenizer t; tok_init(&t, i); - t.flags = TF_REPORT_LINES; + + int opt, verbose = 0; + while ((opt = getopt(argc, argv, "lsv")) >= 0) + switch (opt) + { + case 'l': + t.flags = TF_REPORT_LINES; + break; + case 's': + t.maxsize = 16; + break; + case 'v': + verbose++; + break; + default: + return 42; + } + char *tok; while (tok = get_token(&t)) { printf("<%s>", tok); #define T(f, type, fmt) { type x; if (to_##f(&t, &x)) printf(" = " #f " " fmt, x); } - T(int, int, "%d"); - T(uint, unsigned int, "%u"); - T(long, long int, "%ld"); - T(ulong, unsigned long int, "%lu"); - T(double, double, "%f"); - T(long_double, long double, "%Lf"); + if (verbose) + { + T(int, int, "%d"); + T(uint, unsigned int, "%u"); + T(long, long int, "%ld"); + T(ulong, unsigned long int, "%lu"); + T(double, double, "%f"); + T(long_double, long double, "%Lf"); + } #undef T putchar('\n'); }