From: Eugene Syromyatnikov Date: Thu, 1 Feb 2018 19:08:08 +0000 (+0100) Subject: util.c: fix switch statement indentation in string_quote X-Git-Tag: v4.22~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c0be8d36dbf72948cd4865836775c068b699341;p=strace util.c: fix switch statement indentation in string_quote While we are here, let's also remove unnecessary break statement in the default case. --- diff --git a/util.c b/util.c index 77cc5acc..ddba53ca 100644 --- a/util.c +++ b/util.c @@ -524,54 +524,53 @@ string_quote(const char *instr, char *outstr, const unsigned int size, (style & QUOTE_OMIT_TRAILING_0) && (c == '\0')) goto asciz_ended; switch (c) { - case '\"': case '\\': - *s++ = '\\'; + case '\"': case '\\': + *s++ = '\\'; + *s++ = c; + break; + case '\f': + *s++ = '\\'; + *s++ = 'f'; + break; + case '\n': + *s++ = '\\'; + *s++ = 'n'; + break; + case '\r': + *s++ = '\\'; + *s++ = 'r'; + break; + case '\t': + *s++ = '\\'; + *s++ = 't'; + break; + case '\v': + *s++ = '\\'; + *s++ = 'v'; + break; + default: + if (c >= ' ' && c <= 0x7e) *s++ = c; - break; - case '\f': - *s++ = '\\'; - *s++ = 'f'; - break; - case '\n': - *s++ = '\\'; - *s++ = 'n'; - break; - case '\r': - *s++ = '\\'; - *s++ = 'r'; - break; - case '\t': - *s++ = '\\'; - *s++ = 't'; - break; - case '\v': + else { + /* Print \octal */ *s++ = '\\'; - *s++ = 'v'; - break; - default: - if (c >= ' ' && c <= 0x7e) - *s++ = c; - else { - /* Print \octal */ - *s++ = '\\'; - if (i + 1 < size - && ustr[i + 1] >= '0' - && ustr[i + 1] <= '9' - ) { - /* Print \ooo */ - *s++ = '0' + (c >> 6); + if (i + 1 < size + && ustr[i + 1] >= '0' + && ustr[i + 1] <= '9' + ) { + /* Print \ooo */ + *s++ = '0' + (c >> 6); + *s++ = '0' + ((c >> 3) & 0x7); + } else { + /* Print \[[o]o]o */ + if ((c >> 3) != 0) { + if ((c >> 6) != 0) + *s++ = '0' + (c >> 6); *s++ = '0' + ((c >> 3) & 0x7); - } else { - /* Print \[[o]o]o */ - if ((c >> 3) != 0) { - if ((c >> 6) != 0) - *s++ = '0' + (c >> 6); - *s++ = '0' + ((c >> 3) & 0x7); - } } - *s++ = '0' + (c & 0x7); } - break; + *s++ = '0' + (c & 0x7); + } } } }