diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-30 00:39:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-30 00:39:22 +0000 |
commit | dcbd350ccfe7eaa4feab038f97a382684f2adea9 (patch) | |
tree | b06da24101aa74d8dd25b1c51461bda52d675388 /coreutils | |
parent | a2dcb5017503acea97547e4c538a47f920d752f7 (diff) | |
download | busybox-w32-dcbd350ccfe7eaa4feab038f97a382684f2adea9.tar.gz busybox-w32-dcbd350ccfe7eaa4feab038f97a382684f2adea9.tar.bz2 busybox-w32-dcbd350ccfe7eaa4feab038f97a382684f2adea9.zip |
echo: fix echo -e -n "msg\n\0"
(by "Pinedo, David" <david.pinedo AT hp.com>)
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/echo.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c index 6e25db62c..cc9b9e6f4 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -108,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
108 | } | 108 | } |
109 | #if !ENABLE_FEATURE_FANCY_ECHO | 109 | #if !ENABLE_FEATURE_FANCY_ECHO |
110 | /* SUSv3 specifies that octal escapes must begin with '0'. */ | 110 | /* SUSv3 specifies that octal escapes must begin with '0'. */ |
111 | if ( (((unsigned char)*arg) - '1') >= 7) | 111 | if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */ |
112 | #endif | 112 | #endif |
113 | { | 113 | { |
114 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals | 114 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals |
115 | * of the form \0### are accepted. */ | 115 | * of the form \0### are accepted. */ |
116 | if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) { | 116 | if (*arg == '0') { |
117 | arg++; | 117 | /* NB: don't turn "...\0" into "...\" */ |
118 | if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) { | ||
119 | arg++; | ||
120 | } | ||
118 | } | 121 | } |
119 | /* bb_process_escape_sequence can handle nul correctly */ | 122 | /* bb_process_escape_sequence handles NUL correctly |
123 | * ("...\" case). */ | ||
120 | c = bb_process_escape_sequence(&arg); | 124 | c = bb_process_escape_sequence(&arg); |
121 | } | 125 | } |
122 | } | 126 | } |