]> mj.ucw.cz Git - moe.git/blobdiff - judge/test-tok.c
Replaced FREE_PASCAL_RTE by a generic EXIT_CODE_HOOK.
[moe.git] / judge / test-tok.c
index 10e7b3b04c2a8a43ecc98274cd899f6d6a5c746b..8927e05f95710c9501749dcdd19f06b5f86d8394 100644 (file)
@@ -1,25 +1,47 @@
 #include <stdio.h>
+#include <string.h>
+#include <getopt.h>
 
 #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');
     }