Fix printf(1) ignores width and precision in %b format.
The precision with behavior is "unspecified" by POSIX (as of 2018), but most implementations seem to have taken it to be treated the same as for "s"; applied after the unescaping. Adopt the same treatment on our printf. PR: 229641 Submitted by: Garrett D'Amore (illumos)
This commit is contained in:
parent
c3f26b2635
commit
2cfffa467b
@ -1,6 +1,7 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
|
||||
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
|
||||
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -375,16 +376,19 @@ 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);
|
||||
exit(*rval);
|
||||
break;
|
||||
}
|
||||
case 'c': {
|
||||
|
Loading…
Reference in New Issue
Block a user