diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2018-08-08 15:25:01 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2018-08-08 15:25:01 +0000 |
commit | 702da35288ad1d3d97b4e3cacbfa83e494b74cf7 (patch) | |
tree | 6ea3c564e237833e96b3a2300cdd5f0ad05876c7 | |
parent | 94e460157dfd5f00a7e2eefce10137d3a5f8dd6e (diff) |
Notes
-rw-r--r-- | usr.bin/printf/printf.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 8482bb391b87a..024c3f0df0be5 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -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': { |