2 * A judge comparing two sequences of tokens
4 * (c) 2007 Martin Krulis <bobrik@matfyz.cz>
5 * (c) 2007 Martin Mares <mj@ucw.cz>
13 static int trailing_nl(struct tokenizer *t)
15 // Ignore empty lines at the end of file
18 t->flags &= ~TF_REPORT_LINES;
22 int main(int argc, char **argv)
24 struct tokenizer t1, t2;
27 if (argc != 3 && argc != 4)
28 die("Usage: judge-tok [-n] <file1> <file2>");
30 // Check for -n parameter
31 report_lines = !(argc == 4 && !strcmp(argv[1], "-n"));
33 tok_init(&t1, sopen_read(argv[argc-2]));
34 tok_init(&t2, sopen_read(argv[argc-1]));
36 t1.flags = t2.flags = TF_REPORT_LINES;
40 char *a = get_token(&t1), *b = get_token(&t2);
43 if (b && !trailing_nl(&t2))
44 tok_err(&t1, "Ends too early");
49 if (a && !trailing_nl(&t1))
50 tok_err(&t2, "Garbage at the end");
53 else if (strcmp(a, b))
54 tok_err(&t1, "Found <%s>, expected <%s>", a, b);