Author: pfg
Date: Tue Aug 14 22:57:28 2018
New Revision: 337823
URL: https://svnweb.freebsd.org/changeset/base/337823

Log:
  MFC r337458, r337618:
  Fix printf(1) ignores width and precision in %b format.
  
  The precision with the conversion specifier b is specified by POSIX: see
  point 7 in the reference documentation.
  
  Include fix from jilles@ to avoid breaking the testsuite.
  
  Reference: 
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
  
  PR:   229641
  Reported by:  Rudolf Cejka
  Submitted by: Garrett D'Amore (illumos)

Modified:
  stable/11/usr.bin/printf/printf.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/printf/printf.c
==============================================================================
--- stable/11/usr.bin/printf/printf.c   Tue Aug 14 20:45:43 2018        
(r337822)
+++ stable/11/usr.bin/printf/printf.c   Tue Aug 14 22:57:28 2018        
(r337823)
@@ -1,4 +1,5 @@
 /*-
+ * Copyright 2018 Staysail Systems, Inc. <i...@staysail.tech>
  * Copyright 2014 Garrett D'Amore <garr...@damore.org>
  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 1989, 1993
@@ -378,13 +379,16 @@ printf_doformat(char *fmt, int *rval)
                char *p;
                int getout;
 
-               p = strdup(getstr());
-               if (p == NULL) {
+               /* Convert "b" to "s" for output. */
+               start[strlen(start) - 1] = 's';
+               if ((p = strdup(getstr())) == NULL) {
                        warnx("%s", strerror(ENOMEM));
                        return (NULL);
                }
                getout = escape(p, 0, &len);
-               fputs(p, stdout);
+               PF(start, p);
+               /* Restore format for next loop. */
+
                free(p);
                if (getout)
                        return (end_fmt);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to