>Number:         187728
>Category:       bin
>Synopsis:       bc(1) should print error message to stderr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 19 09:50:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Makoto Kishimoto
>Release:        9.2-STABLE
>Organization:
N/A
>Environment:
FreeBSD norikura.localdomain 9.2-STABLE FreeBSD 9.2-STABLE #1 r257235: Mon Oct 
28 19:56:00 JST 2013     
[email protected]:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
bc(1) should prints error message to stderr. For example,

UNIX (Heirloom) bc prints to stderr
$ echo ':' | /usr/local/heirloom/usr/5bin/bc > /dev/null
syntax error on line 1, teletype
$ echo ':' | /usr/local/heirloom/usr/5bin/bc 2> /dev/null
$

GNU bc prints to stderr
$ echo ':' | /usr/local/bin/bc > /dev/null
(standard_in) 1: illegal character: :
$ echo ':' | /usr/local/bin/bc 2> /dev/null
$

FreeBSD (OpenBSD) bc prints to stdout
$ echo ':' | /usr/bin/bc > /dev/null
$ echo ':' | /usr/bin/bc 2> /dev/null
bc: stdin:1: illegal character: : unexpected
$

>How-To-Repeat:
see Full Description
>Fix:
see attached patch

Patch attached with submission follows:

Index: bc.y
===================================================================
--- bc.y        (revision 263333)
+++ bc.y        (working copy)
@@ -969,25 +969,19 @@
        int n;
 
        if (yyin != NULL && feof(yyin))
-               n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF",
+               n = asprintf(&str, "%s: %s:%d: %s: unexpected EOF\n",
                    __progname, filename, lineno, s);
        else if (isspace(yytext[0]) || !isprint(yytext[0]))
                n = asprintf(&str,
-                   "%s: %s:%d: %s: ascii char 0x%02x unexpected",
+                   "%s: %s:%d: %s: ascii char 0x%02x unexpected\n",
                    __progname, filename, lineno, s, yytext[0]);
        else
-               n = asprintf(&str, "%s: %s:%d: %s: %s unexpected",
+               n = asprintf(&str, "%s: %s:%d: %s: %s unexpected\n",
                    __progname, filename, lineno, s, yytext);
        if (n == -1)
                err(1, NULL);
 
-       fputs("c[", stdout);
-       for (p = str; *p != '\0'; p++) {
-               if (*p == '[' || *p == ']' || *p =='\\')
-                       putchar('\\');
-               putchar(*p);
-       }
-       fputs("]pc\n", stdout);
+       fputs(str, stderr);
        free(str);
 }
 


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to