On Thu, 8 Sep 2016, Martin Sebor wrote: > PS I used hexadecimal based on what c-format.c does but now that > I checked more carefully how %qE formats string literals I see it > uses octal. I think hexadecimal is preferable because it avoids > ambiguity but I'm open to changing it to octal if there's a strong
I'm not clear what you mean about ambiguity. In C strings, an octal escape sequence has up to three characters, so if it has three characters it's unambiguous, whereas a hex escape sequence can have any number of characters, so if the unprintable character is followed by a valid hex digit then in C you need to represent that as an escape (or use string constant concatenation, etc.). The patch doesn't try to do that as far as I can see. Now, presumably the output isn't intended to be interpreted as C strings anyway (if it was, you'd need to escape " and \ as well), so the patch is OK, but I don't think it avoids ambiguity (and there's a clear case that it shouldn't - that if the string passed to %qs is printable, it should be printed as-is even if it contains escape sequences that could also result from a non-printable string passed to %qs). -- Joseph S. Myers jos...@codesourcery.com