/* -*-c-*-
*
- * $Id: testrig.c,v 1.5 1999/05/21 22:14:30 mdw Exp $
+ * $Id: testrig.c,v 1.7 1999/11/21 13:01:39 mdw Exp $
*
* Generic test driver
*
/*----- Revision history --------------------------------------------------*
*
* $Log: testrig.c,v $
+ * Revision 1.7 1999/11/21 13:01:39 mdw
+ * Allow more characters to start words in test vector files.
+ *
+ * Revision 1.6 1999/11/16 15:03:23 mdw
+ * Mark test types as constant.
+ *
* Revision 1.5 1999/05/21 22:14:30 mdw
* Take advantage of the new dynamic string macros.
*
return (TOK_WORD);
}
- /* --- Anything else is either a word or self-delimiting --- */
+ /* --- Self-delimiting things --- */
+
+ case ';':
+ case '{':
+ case '}':
+ return (ch);
+
+ /* --- Anything else is a word --- */
default:
- if (isalnum((unsigned char)ch)) {
- for (;;) {
- DPUTC(&tok, ch);
+ for (;;) {
+ DPUTC(&tok, ch);
+ ch = getc(fp);
+ switch (ch) {
+ case EOF:
+ case ';':
+ case '{':
+ case '}':
+ case '\"':
+ case '\'':
+ case '`':
+ goto done;
+ default:
+ if (isspace((unsigned char)ch))
+ goto done;
+ }
+ if (ch == '\\') {
ch = getc(fp);
- if (ch == EOF ||
- ch == ';' ||
- ch == '\"' || ch == '\'' || ch == '`' ||
- isspace((unsigned char)ch))
- break;
- if (ch == '\\') {
- ch = getc(fp);
- if (ch == EOF)
- ch = '\\';
- }
+ if (ch == EOF)
+ ch = '\\';
}
- ungetc(ch, fp);
- DPUTZ(&tok);
- return (TOK_WORD);
- } else
- return (ch);
+ }
+ done:
+ ungetc(ch, fp);
+ DPUTZ(&tok);
+ return (TOK_WORD);
}
}
fprintf(fp, "%02x", *(unsigned char *)p);
}
-test_type type_hex = { cvt_hex, dump_hex };
+const test_type type_hex = { cvt_hex, dump_hex };
/* --- @type_string@ --- */
DWRITE(d, fp);
}
-test_type type_string = { cvt_string, dump_string };
+const test_type type_string = { cvt_string, dump_string };
/* --- @type_int@ --- */
fprintf(fp, "%i", *(int *)(d->buf));
}
-test_type type_int = { cvt_int, dump_int };
+const test_type type_int = { cvt_int, dump_int };
/* --- @test_run@ --- *
*
/* --- Past the open brace to the first chunk --- */
if ((t = gettok(fp)) != '{')
- die(1, "expected '{'; found `%s'", decode(t));
+ die(1, "expected `{'; found `%s'", decode(t));
/* --- Start on the test data now --- */