From f6f7b82d4b8520e6fcfb82787f74e373cc4a3bbd Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Fri, 2 Feb 2018 16:15:48 +0100 Subject: [PATCH] Do not go full octal if the next char is '8' or '9' * util.c (string_quote): Change the upper limit for the next character in unabbreviated octal printing from '9' to '7'. * tests/print_quoted_string.c (print_quoted_memory): Likewise. --- tests/print_quoted_string.c | 2 +- util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/print_quoted_string.c b/tests/print_quoted_string.c index 4107e256..14a1f0fb 100644 --- a/tests/print_quoted_string.c +++ b/tests/print_quoted_string.c @@ -70,7 +70,7 @@ print_quoted_memory(const void *const instr, const size_t len) if (i < (len - 1) && str[i + 1] >= '0' && - str[i + 1] <= '9') { + str[i + 1] <= '7') { /* Print \octal */ putchar(c3); putchar(c2); diff --git a/util.c b/util.c index 6df1239a..8365f050 100644 --- a/util.c +++ b/util.c @@ -559,7 +559,7 @@ string_quote(const char *instr, char *outstr, const unsigned int size, *s++ = '\\'; if (i + 1 < size && ustr[i + 1] >= '0' - && ustr[i + 1] <= '9' + && ustr[i + 1] <= '7' ) { /* Print \ooo */ *s++ = '0' + (c >> 6); -- 2.50.1