aboutsummaryrefslogtreecommitdiff
path: root/coreutils/printf.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
committerRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
commit371c20c008254a36e7157df6c13dc2e4cf87d6fd (patch)
treea214c03f6617dffa60df2192b312a46c93b7c19f /coreutils/printf.c
parentab879a41ab674129ef1593cda181cc8b64d0dadf (diff)
parent3a5cc989025eefe03fda0552b253a4a8f015a761 (diff)
downloadbusybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.gz
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.bz2
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils/printf.c')
-rw-r--r--coreutils/printf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 3dd43a978..9ee7350d0 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -131,8 +131,8 @@ static double my_xstrtod(const char *arg)
131 return result; 131 return result;
132} 132}
133 133
134/* Handles %b */ 134/* Handles %b; return 1 if output is to be short-circuited by \c */
135static void print_esc_string(const char *str) 135static int print_esc_string(const char *str)
136{ 136{
137 char c; 137 char c;
138 while ((c = *str) != '\0') { 138 while ((c = *str) != '\0') {
@@ -145,6 +145,9 @@ static void print_esc_string(const char *str)
145 str++; 145 str++;
146 } 146 }
147 } 147 }
148 else if (*str == 'c') {
149 return 1;
150 }
148 { 151 {
149 /* optimization: don't force arg to be on-stack, 152 /* optimization: don't force arg to be on-stack,
150 * use another variable for that. */ 153 * use another variable for that. */
@@ -155,6 +158,8 @@ static void print_esc_string(const char *str)
155 } 158 }
156 putchar(c); 159 putchar(c);
157 } 160 }
161
162 return 0;
158} 163}
159 164
160static void print_direc(char *format, unsigned fmt_length, 165static void print_direc(char *format, unsigned fmt_length,
@@ -280,7 +285,8 @@ static char **print_formatted(char *f, char **argv, int *conv_err)
280 } 285 }
281 if (*f == 'b') { 286 if (*f == 'b') {
282 if (*argv) { 287 if (*argv) {
283 print_esc_string(*argv); 288 if (print_esc_string(*argv))
289 return saved_argv; /* causes main() to exit */
284 ++argv; 290 ++argv;
285 } 291 }
286 break; 292 break;