@@@ remote works?
[mLib] / test / tvec-output.c
index 9ca4f29..e92ea69 100644 (file)
@@ -110,7 +110,7 @@ static int getenv_boolean(const char *var, int dflt)
 static int register_maxnamelen(const struct tvec_state *tv)
 {
   const struct tvec_regdef *rd;
-  int maxlen = 6, n;
+  int maxlen = 10, n;
 
   for (rd = tv->test->regs; rd->name; rd++)
     { n = strlen(rd->name); if (n > maxlen) maxlen = n; }
@@ -216,7 +216,6 @@ static void init_fmt(struct format *fmt, FILE *fp, const char *prefix)
     fmt->prefix = prefix;
     l = fmt->pfxlim = prefix + strlen(prefix);
     SPLIT_RANGE(q, prefix, l); fmt->pfxtail = q;
-    DPUTM(&fmt->w, q, l - q);
   }
 }
 
@@ -343,11 +342,11 @@ static int format_string(struct format *fmt, const char *p, size_t sz)
      * need to write that.  Otherwise, there's only blank stuff, which we
      * accumulate in the buffer.
      *
-     * If we're at the start of a line here, then
+     * If we're at the start of a line here, then    
      */
 
     if (r > p) {
-      if (fmt->f&FMTF_NEWL) { PUT_PFXINB; fmt->f &= ~FMTF_NEWL; }
+      if (fmt->f&FMTF_NEWL) { PUT_PREFIX; fmt->f &= ~FMTF_NEWL; }
       PUT_SAVED; PUT_NONBLANK; DRESET(&fmt->w);
     }
     SAVE_TAIL;
@@ -357,8 +356,11 @@ static int format_string(struct format *fmt, const char *p, size_t sz)
   /* There is at least one more segment, so we know that there'll be a line
    * to output.
    */
-  if (fmt->f&FMTF_NEWL) PUT_PFXINB;
-  if (r > p) { PUT_SAVED; PUT_NONBLANK; }
+  if (r > p) {
+    if (fmt->f&FMTF_NEWL) PUT_PREFIX;
+    PUT_SAVED; PUT_NONBLANK;
+  } else if (fmt->f&FMTF_NEWL)
+    PUT_PFXINB;
   PUT_NEWLINE; DRESET(&fmt->w);
   SPLIT_SEGMENT;
 
@@ -367,7 +369,9 @@ static int format_string(struct format *fmt, const char *p, size_t sz)
    * newline, so we write the initial prefix and drop the trailing blanks.
    */
   while (q) {
-    PUT_PREFIX; PUT_NONBLANK; PUT_NEWLINE;
+    if (r > p) { PUT_PREFIX; PUT_NONBLANK; }
+    else PUT_PFXINB;
+    PUT_NEWLINE;
     SPLIT_SEGMENT;
   }
 
@@ -660,6 +664,7 @@ static void human_skipgroup(struct tvec_output *o,
 
   if (!(~h->f&(HOF_TTY | HOF_PROGRESS))) {
     h->f &= ~HOF_PROGRESS;
+    putc(' ', h->fmt.fp);
     setattr(h, HA_SKIP); fputs("skipped", h->fmt.fp); setattr(h, 0);
   } else {
     fprintf(h->fmt.fp, "%s: ", h->tv->test->name);
@@ -780,7 +785,8 @@ static void human_ebench(struct tvec_output *o,
   fputc('\n', h->fmt.fp);
 }
 
-static void human_report(struct tvec_output *o, const char *msg, va_list *ap)
+static void human_report(struct tvec_output *o, unsigned level,
+                        const char *msg, va_list *ap)
 {
   struct human_output *h = (struct human_output *)o;
   struct tvec_state *tv = h->tv;
@@ -814,7 +820,7 @@ static const struct tvec_outops human_ops = {
   human_bgroup, human_skipgroup, human_egroup,
   human_btest, human_skip, human_fail, human_dumpreg, human_etest,
   human_bbench, human_ebench,
-  human_report, human_report,
+  human_report,
   human_destroy
 };
 
@@ -1007,31 +1013,23 @@ static void tap_ebench(struct tvec_output *o,
   format_char(&t->fmt, '\n');
 }
 
-static void tap_report(struct tap_output *t,
-                      const struct gprintf_ops *gops, void *go,
+static void tap_report(struct tvec_output *o, unsigned level,
                       const char *msg, va_list *ap)
 {
+  struct tap_output *t = (struct tap_output *)o;
   struct tvec_state *tv = t->tv;
+  const struct gprintf_ops *gops; void *go;
 
+  if (level >= TVLEV_ERR) {
+    fputs("Bail out!  ", t->fmt.fp);
+    gops = &file_printops; go = t->fmt.fp;
+  } else {
+    gops = &tap_printops; go = t;
+  }
   if (tv->infile) gprintf(gops, go, "%s:%u: ", tv->infile, tv->lno);
   gprintf(gops, go, msg, ap); gops->putch(go, '\n');
 }
 
-static void tap_error(struct tvec_output *o, const char *msg, va_list *ap)
-{
-  struct tap_output *t = (struct tap_output *)o;
-
-  fputs("Bail out!  ", t->fmt.fp);
-  tap_report(t, &file_printops, t->fmt.fp, msg, ap);
-}
-
-static void tap_notice(struct tvec_output *o, const char *msg, va_list *ap)
-{
-  struct tap_output *t = (struct tap_output *)o;
-
-  tap_report(t, &tap_printops, t, msg, ap);
-}
-
 static void tap_destroy(struct tvec_output *o)
 {
   struct tap_output *t = (struct tap_output *)o;
@@ -1046,7 +1044,7 @@ static const struct tvec_outops tap_ops = {
   tap_bgroup, tap_skipgroup, tap_egroup,
   tap_btest, tap_skip, tap_fail, tap_dumpreg, tap_etest,
   tap_bbench, tap_ebench,
-  tap_error, tap_notice,
+  tap_report,
   tap_destroy
 };