Date: Thu, 2 Nov 1995 11:57:06 +0900 From: kato@eclogite.eps.nagoya-u.ac.jp To: FreeBSD-gnats-submit@freebsd.org Subject: bin/809: printf goroup bug [`.' optional precision] Message-ID: <199511020257.LAA00678@marble.eps.nagoya-u.ac.jp> Resent-Message-ID: <199511020300.TAA08421@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 809 >Category: bin >Synopsis: `.' gives the minimum number of (DIGITS+SIGN) >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Nov 1 19:00:01 PST 1995 >Last-Modified: >Originator: KATO Takenori >Organization: Dept. Earth Planet. Sci. Nagoya Univ. Nagoya 464-01, JAPAN >Release: FreeBSD 2.2-CURRENT i386 >Environment: All FreeBSD 2.X box >Description: The C library functions, printf group may violate ANSI standard. The optional precision `.' gives the minimun number of not digits but DIGITS+SIGN. That is, vfprintf routine assumes digit = [0-9] & [+-]. I think `digit' should not include sign flag. This may be a 4.4BSD-derived bug, because other *BSD box shows same synopsis (not including NetBSD 1.1). This affect many of programs, which assume digit consists of [0-9]. One of the examples is libI77. >How-To-Repeat: The C code, #include <stdio.h> void main(void) { printf("%.2d\n", 1); printf("%+.2d\n", 1); printf("%+.3d\n", 1); } gives following result: 01 +1 +01 On the contrary, NEWS, Sun, OSF/1 and Borland C++ 3.1 give following: 01 +01 +001 >Fix: not known. (maybe bug stays in /usr/src/lib/libc/stdio/vfprintf.c?) >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511020257.LAA00678>