Message ID | ZxXmIzmhdNq-08Xo@gondor.apana.org.au (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Herbert Xu |
Headers | show |
Series | builtin: Keep backslash on undefined escape sequences | expand |
diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 2c18e93..46c6295 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -339,8 +339,8 @@ unsigned conv_escape(char *str0, char *out0, bool mbchar) switch (ch) { default: if (!isodigit(ch)) { - value = ch ?: '\\'; - str -= !ch; + value = '\\'; + str--; break; } @@ -428,6 +428,12 @@ hex: ch = 8; goto hex; + case '\\': + case '\"': + case '\'': + value = ch; + break; + case 'a': value = '\a'; break; /* alert */ case 'b': value = '\b'; break; /* backspace */ case 'e': value = '\033'; break; /* <ESC> */