libbb/process_escape_sequence.c: fix recently broken handling of \\

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2010-10-25 12:14:21 +02:00
parent b507cc3ace
commit a2d27a1919

View File

@ -75,8 +75,8 @@ char FAST_FUNC bb_process_escape_sequence(const char **ptr)
* Manpages tend to support coreutils way. * Manpages tend to support coreutils way.
* Update: coreutils added support for \e on 28 Oct 2009. */ * Update: coreutils added support for \e on 28 Oct 2009. */
static const char charmap[] ALIGN1 = { static const char charmap[] ALIGN1 = {
'a', 'b', 'e', 'f', 'n', 'r', 't', 'v', '\\', 'a', 'b', 'e', 'f', 'n', 'r', 't', 'v', '\\', '\0',
'\a', '\b', 27, '\f', '\n', '\r', '\t', '\v', '\\', '\a', '\b', 27, '\f', '\n', '\r', '\t', '\v', '\\', '\\',
}; };
const char *p = charmap; const char *p = charmap;
do { do {
@ -84,8 +84,8 @@ char FAST_FUNC bb_process_escape_sequence(const char **ptr)
q++; q++;
break; break;
} }
} while (*++p != '\\'); } while (*++p != '\0');
/* p points to found escape char or '\', /* p points to found escape char or NUL,
* advance it and find what it translates to. * advance it and find what it translates to.
* Note that \NUL and unrecognized sequence \z return '\' * Note that \NUL and unrecognized sequence \z return '\'
* and leave ptr pointing to NUL or z. */ * and leave ptr pointing to NUL or z. */