Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2012 21:02:38 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244407 - in head: tools/regression/usr.bin/printf usr.bin/printf
Message-ID:  <201212182102.qBIL2cqj027595@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Tue Dec 18 21:02:38 2012
New Revision: 244407
URL: http://svnweb.freebsd.org/changeset/base/244407

Log:
  POSIX requires that non-existent or null arguments be treated as if a
  zero argument were supplied.
  
  Add a regression test to catch this case as well.
  
  PR:		bin/174521
  Submitted by:	Daniel Shahaf <danielsh@elego.de> (pr)
  Submitted by:	Mark Johnston <markjdb@gmail.com> (initial patch)
  Reviewed by:	jilles
  Approved by:	cperciva (implicit)
  MFC after:	3 weeks

Added:
  head/tools/regression/usr.bin/printf/regress.zero.out   (contents, props changed)
Modified:
  head/tools/regression/usr.bin/printf/regress.sh
  head/usr.bin/printf/printf.c

Modified: head/tools/regression/usr.bin/printf/regress.sh
==============================================================================
--- head/tools/regression/usr.bin/printf/regress.sh	Tue Dec 18 20:47:23 2012	(r244406)
+++ head/tools/regression/usr.bin/printf/regress.sh	Tue Dec 18 21:02:38 2012	(r244407)
@@ -2,7 +2,7 @@
 
 REGRESSION_START($1)
 
-echo '1..11'
+echo '1..12'
 
 REGRESSION_TEST(`b', `printf "abc%b%b" "def\n" "\cghi"')
 REGRESSION_TEST(`d', `printf "%d,%5d,%.5d,%0*d,%.*d\n" 123 123 123 5 123 5 123')
@@ -15,5 +15,6 @@ REGRESSION_TEST(`m3', `printf "%%%s\n" a
 REGRESSION_TEST(`m4', `printf "%d,%f,%c,%s\n"')
 REGRESSION_TEST(`m5', `printf -- "-d\n"')
 REGRESSION_TEST(`s', `printf "%.3s,%-5s\n" abcd abc')
+REGRESSION_TEST('zero', `printf "%u%u\n" 15')
 
 REGRESSION_END()

Added: head/tools/regression/usr.bin/printf/regress.zero.out
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/usr.bin/printf/regress.zero.out	Tue Dec 18 21:02:38 2012	(r244407)
@@ -0,0 +1 @@
+150

Modified: head/usr.bin/printf/printf.c
==============================================================================
--- head/usr.bin/printf/printf.c	Tue Dec 18 20:47:23 2012	(r244406)
+++ head/usr.bin/printf/printf.c	Tue Dec 18 21:02:38 2012	(r244407)
@@ -473,7 +473,7 @@ getnum(intmax_t *ip, uintmax_t *uip, int
 	int rval;
 
 	if (!*gargv) {
-		*ip = 0;
+		*ip = *uip = 0;
 		return (0);
 	}
 	if (**gargv == '"' || **gargv == '\'') {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212182102.qBIL2cqj027595>