diff options
author | Denis Vlasenko | 2008-05-08 15:26:06 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-05-08 15:26:06 +0000 |
commit | a3087ca7495e33b19b122869d17defeb9c933d19 (patch) | |
tree | fa652fe429d78c0b2fad2c42c52c98e92bb3288d /coreutils/echo.c | |
parent | 0abe9d96eee3bcdcdd766a863eb711ec004f2f4f (diff) | |
download | busybox-a3087ca7495e33b19b122869d17defeb9c933d19.zip busybox-a3087ca7495e33b19b122869d17defeb9c933d19.tar.gz |
Apply post-1.10.1 patches
Bump version to 1.10.2
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 fd6c950..cc9b9e6 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c @@ -27,10 +27,8 @@ /* This is a NOFORK applet. Be very careful! */ -/* argc is unused, but removing it precludes compiler from - * using call -> jump optimization */ +/* NB: can be used by shell even if not enabled as applet */ -int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) { const char *arg; @@ -110,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) } #if !ENABLE_FEATURE_FANCY_ECHO /* SUSv3 specifies that octal escapes must begin with '0'. */ - if ( (((unsigned char)*arg) - '1') >= 7) + if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */ #endif { /* Since SUSv3 mandates a first digit of 0, 4-digit octals * of the form \0### are accepted. */ - if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) { - arg++; + if (*arg == '0') { + /* NB: don't turn "...\0" into "...\" */ + if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) { + arg++; + } } - /* bb_process_escape_sequence can handle nul correctly */ + /* bb_process_escape_sequence handles NUL correctly + * ("...\" case). */ c = bb_process_escape_sequence(&arg); } } |