]> diplodocus.org Git - nmh/commitdiff
Fix bug in advertise("", "", "foo", ap).
authorRalph Corderoy <ralph@inputplus.co.uk>
Mon, 17 Apr 2017 09:57:54 +0000 (10:57 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Mon, 17 Apr 2017 09:57:54 +0000 (10:57 +0100)
A non-NULL but empty `what' would result in "fooerrno\n" without
separation.  Improve the function's comment to try and make it obvious
how its out of order parameters appear.

sbr/error.c

index 7b2f506459c90637173e8d087ec5565d33f2b70a..65055ecd901ba1c93f7b37f17d3ae363e43138a0 100644 (file)
@@ -71,13 +71,12 @@ admonish (char *what, char *fmt, ...)
 
 
 /* advertise prints fmt and ap to stderr after flushing stdout.
 
 
 /* advertise prints fmt and ap to stderr after flushing stdout.
- * If invo_name isn't NULL or empty, it precedes the output seperated by ": ".
- * If what isn't NULL, errno as a string is appended.
- * A non-empty what separates fmt from errno, surrounded by " " and ": ".
- * BUG: No space separator before errno if what is "".
- * If tail isn't NULL or empty then ", " and tail are appended
- * before the finishing "\n".
- * In summary: "invo_name: fmt what: errno, tail\n". */
+ * If invo_name isn't NULL or empty then "invo_name: " precedes fmt.
+ * If what isn't NULL or empty      then " what"   is appended.
+ * If what isn't NULL               then ": errno" is appended.
+ * If tail isn't NULL or empty      then ", tail"  is appended.
+ * A "\n" finishes the output to stderr.
+ * In summary: "[invo_name: ]fmt[[ what]: errno][, tail]\n". */
 void
 advertise (const char *what, char *tail, const char *fmt, va_list ap)
 {
 void
 advertise (const char *what, char *tail, const char *fmt, va_list ap)
 {
@@ -107,8 +106,8 @@ advertise (const char *what, char *tail, const char *fmt, va_list ap)
        if (*what) {
             ADD_LITERAL(" ");
             ADD_VAR((void *)what);
        if (*what) {
             ADD_LITERAL(" ");
             ADD_VAR((void *)what);
-            ADD_LITERAL(": ");
        }
        }
+        ADD_LITERAL(": ");
         err = strerror(eindex);
         if (!err) {
            /* this shouldn't happen, but we'll test for it just in case */
         err = strerror(eindex);
         if (!err) {
            /* this shouldn't happen, but we'll test for it just in case */