NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59749: awk bad test to see if printf supports the %a format
>Number: 59749
>Category: bin
>Synopsis: awk bad test to see if printf supports the %a format
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 06 13:35:00 +0000 2025
>Originator: Trevor Zacks
>Release: netbsd 10.1
>Organization:
>Environment:
>Description:
usr/src/external/historical/nawk/dist/run.c
int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like conversions */
{
. . . . . .
if (first) {
char xbuf[100];
snprintf(xbuf, sizeof(xbuf), "%a", 42.0);
have_a_format = (strcmp(xbuf, "0x1.5p+5") == 0);
first = false;
}
Will never match "0x1.5p+5" unless the default printf() precision is 1
>How-To-Repeat:
>Fix:
change
snprintf(xbuf, sizeof(xbuf), "%a", 42.0);
to
snprintf(xbuf, sizeof(xbuf), "%.1a", 42.0);
or just check for "0x" as does GNU
Home |
Main Index |
Thread Index |
Old Index