From ac9f3404ef9658dcd0682cacd56fd39b566d2560 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 28 Mar 2020 21:46:46 +0900 Subject: [PATCH] [qfcc] Improve string quoting when dumping strings Not knowing if a blank line is an empty string or spaces... --- tools/qfcc/source/dump_strings.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/source/dump_strings.c b/tools/qfcc/source/dump_strings.c index 77f3c0ae4..5f119e7cc 100644 --- a/tools/qfcc/source/dump_strings.c +++ b/tools/qfcc/source/dump_strings.c @@ -44,14 +44,14 @@ dump_string_block (const char *strblock, unsigned size) { const char *s = strblock; - printf ("%x ", 0); + printf ("%x \"", 0); while (s - strblock < size) { char c = *s++; switch (c) { case 0: - fputs ("\n", stdout); + fputs ("\"\n", stdout); if (s - strblock < size) - printf ("%lx ", s - strblock); + printf ("%lx \"", s - strblock); break; case 9: fputs ("\\t", stdout); @@ -62,6 +62,12 @@ dump_string_block (const char *strblock, unsigned size) case 13: fputs ("\\r", stdout); break; + case '\"': + fputs ("\\\"", stdout); + break; + case '\\': + fputs ("\\\\", stdout); + break; default: fputc (sys_char_map[(unsigned char)c], stdout); break;