/*----- Output ------------------------------------------------------------*/
+/* --- @tvec_error@, @tvec_error_v@ --- *
+ *
+ * Arguments: @struct tvec_state *tv@ = test-vector state
+ * @const char *msg@, @va_list ap@ = error message
+ *
+ * Returns: @-1@.
+ *
+ * Use: Report an error. Errors are distinct from test failures,
+ * and indicate that a problem was encountered which compromised
+ * the activity of testing.
+ */
+
int tvec_error(struct tvec_state *tv, const char *msg, ...)
{
va_list ap;
va_start(ap, msg); tvec_error_v(tv, msg, &ap); va_end(ap);
- tv->f |= TVSF_ERROR; return (-1);
+ return (-1);
}
int tvec_error_v(struct tvec_state *tv, const char *msg, va_list *ap)
- { tv->output->ops->error(tv->output, msg, ap); return (-1); }
+{
+ tv->output->ops->error(tv->output, msg, ap);
+ tv->f |= TVSF_ERROR; return (-1);
+}
+
+/* --- @tvec_notice@, @tvec_notice_v@ --- *
+ *
+ * Arguments: @struct tvec_state *tv@ = test-vector state
+ * @const char *msg@, @va_list ap@ = message
+ *
+ * Returns: ---
+ *
+ * Use: Output a notice: essentially, some important information
+ * which doesn't fit into any of the existing categories.
+ */
void tvec_notice(struct tvec_state *tv, const char *msg, ...)
{
void tvec_notice_v(struct tvec_state *tv, const char *msg, va_list *ap)
{ tv->output->ops->notice(tv->output, msg, ap); }
-int tvec_syntax(struct tvec_state *tv, int ch, const char *expect, ...)
-{
- va_list ap;
-
- va_start(ap, expect); tvec_syntax_v(tv, ch, expect, &ap); va_end(ap);
- return (-1);
-}
-int tvec_syntax_v(struct tvec_state *tv, int ch,
- const char *expect, va_list *ap)
-{
- dstr d = DSTR_INIT;
- char found[8];
-
- switch (ch) {
- case EOF: strcpy(found, "#<eof>"); break;
- case '\n': strcpy(found, "#<eol>"); ungetc(ch, tv->fp); break;
- default:
- if (isprint(ch)) sprintf(found, "`%c'", ch);
- else sprintf(found, "#<\\x%02x>", ch);
- break;
- }
- dstr_vputf(&d, expect, ap);
- tvec_error(tv, "syntax error: expected %s but found %s", expect, found);
- return (-1);
-}
+/*----- Test processing ---------------------------------------------------*/
void tvec_skipgroup(struct tvec_state *tv, const char *excuse, ...)
{
va_list ap;
+
va_start(ap, excuse); tvec_skipgroup_v(tv, excuse, &ap); va_end(ap);
}
void tvec_skipgroup_v(struct tvec_state *tv, const char *excuse, va_list *ap)
}
}
-/*----- Main machinery ----------------------------------------------------*/
+/*----- Parsing -----------------------------------------------------------*/
-struct groupstate {
- void *ctx;
-};
-#define GROUPSTATE_INIT { 0 }
+int tvec_syntax(struct tvec_state *tv, int ch, const char *expect, ...)
+{
+ va_list ap;
+
+ va_start(ap, expect); tvec_syntax_v(tv, ch, expect, &ap); va_end(ap);
+ return (-1);
+}
+int tvec_syntax_v(struct tvec_state *tv, int ch,
+ const char *expect, va_list *ap)
+{
+ dstr d = DSTR_INIT;
+ char found[8];
+
+ switch (ch) {
+ case EOF: strcpy(found, "#eof"); break;
+ case '\n': strcpy(found, "#eol"); ungetc(ch, tv->fp); break;
+ default:
+ if (isprint(ch)) sprintf(found, "`%c'", ch);
+ else sprintf(found, "#\\x%02x", ch);
+ break;
+ }
+ dstr_vputf(&d, expect, ap);
+ tvec_error(tv, "syntax error: expected %s but found %s", d.buf, found);
+ dstr_destroy(&d); return (-1);
+}
void tvec_skipspc(struct tvec_state *tv)
{
return (0);
}
+/*----- Main machinery ----------------------------------------------------*/
+
+struct groupstate {
+ void *ctx;
+};
+#define GROUPSTATE_INIT { 0 }
+
void tvec_resetoutputs(struct tvec_state *tv)
{
const struct tvec_regdef *rd;