diff options
Diffstat (limited to 'coreutils/echo.c')
-rw-r--r-- | coreutils/echo.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c index fd6c950ea..cc9b9e6f4 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -27,10 +27,8 @@ | |||
27 | 27 | ||
28 | /* This is a NOFORK applet. Be very careful! */ | 28 | /* This is a NOFORK applet. Be very careful! */ |
29 | 29 | ||
30 | /* argc is unused, but removing it precludes compiler from | 30 | /* NB: can be used by shell even if not enabled as applet */ |
31 | * using call -> jump optimization */ | ||
32 | 31 | ||
33 | int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
34 | int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) | 32 | int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) |
35 | { | 33 | { |
36 | const char *arg; | 34 | const char *arg; |
@@ -110,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
110 | } | 108 | } |
111 | #if !ENABLE_FEATURE_FANCY_ECHO | 109 | #if !ENABLE_FEATURE_FANCY_ECHO |
112 | /* SUSv3 specifies that octal escapes must begin with '0'. */ | 110 | /* SUSv3 specifies that octal escapes must begin with '0'. */ |
113 | if ( (((unsigned char)*arg) - '1') >= 7) | 111 | if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */ |
114 | #endif | 112 | #endif |
115 | { | 113 | { |
116 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals | 114 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals |
117 | * of the form \0### are accepted. */ | 115 | * of the form \0### are accepted. */ |
118 | if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) { | 116 | if (*arg == '0') { |
119 | arg++; | 117 | /* NB: don't turn "...\0" into "...\" */ |
118 | if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) { | ||
119 | arg++; | ||
120 | } | ||
120 | } | 121 | } |
121 | /* bb_process_escape_sequence can handle nul correctly */ | 122 | /* bb_process_escape_sequence handles NUL correctly |
123 | * ("...\" case). */ | ||
122 | c = bb_process_escape_sequence(&arg); | 124 | c = bb_process_escape_sequence(&arg); |
123 | } | 125 | } |
124 | } | 126 | } |