/* testmatch.c */ /* Copyright 1997 by Eberhard Mattes Donated to the public domain. No warranty. 1997-08-03 Initial version */ #include #include #include #include #include "libemfw.h" static void usage (void) ATTR_NORETURN; static void usage (void) { fputs ("Usage: testmatch\n", stderr); exit (1); } int main (int argc, char *argv[]) { static char line[1024]; char *pattern, *name, *p; int match, lineno, pattern_length, name_length; if (argc != 1) usage (); lineno = 0; while (fgets (line, sizeof (line), stdin) != NULL) { ++lineno; pattern = line; p = strchr (pattern, '\t'); if (p == NULL) { fprintf (stderr, "Missing HT in line %d\n", lineno); exit (1); } pattern_length = p++ - pattern; name = p; p = strchr (name, '\t'); if (p == NULL) { fprintf (stderr, "Missing HT in line %d\n", lineno); exit (1); } name_length = p++ - name; if ((*p != '0' && *p != '1') || p[1] != '\n') { fprintf (stderr, "Bad value in line %d\n", lineno); exit (1); } match = lower_match (pattern, pattern_length, name, name_length); if (match + '0' != *p) { fprintf (stderr, "Error in line %d\n", lineno); exit (1); } } return 0; }