diff --git a/tools/qfcc/include/strpool.h b/tools/qfcc/include/strpool.h
index 10b99f336..e6e065cb8 100644
--- a/tools/qfcc/include/strpool.h
+++ b/tools/qfcc/include/strpool.h
@@ -55,6 +55,7 @@ const char *save_string (const char *str);
const char *make_string (char *token, char **end);
+const char *html_string (const char *str);
const char *quote_string (const char *str);
#endif//__strpool_h
diff --git a/tools/qfcc/source/dot_flow.c b/tools/qfcc/source/dot_flow.c
index 4207c56e7..76245de55 100644
--- a/tools/qfcc/source/dot_flow.c
+++ b/tools/qfcc/source/dot_flow.c
@@ -53,10 +53,10 @@ static void
flow_statement (dstring_t *dstr, statement_t *s)
{
dasprintf (dstr, "
");
- dasprintf (dstr, "%s | ", quote_string (s->opcode));
- dasprintf (dstr, "%s | ", operand_string (s->opa));
- dasprintf (dstr, "%s | ", operand_string (s->opb));
- dasprintf (dstr, "%s | ", operand_string (s->opc));
+ dasprintf (dstr, "%s | ", html_string(quote_string (s->opcode)));
+ dasprintf (dstr, "%s | ", html_string(operand_string (s->opa)));
+ dasprintf (dstr, "%s | ", html_string(operand_string (s->opb)));
+ dasprintf (dstr, "%s | ", html_string(operand_string (s->opc)));
dasprintf (dstr, "
\n");
}
diff --git a/tools/qfcc/source/strpool.c b/tools/qfcc/source/strpool.c
index a715c87ce..3f0e1cc9d 100644
--- a/tools/qfcc/source/strpool.c
+++ b/tools/qfcc/source/strpool.c
@@ -360,7 +360,7 @@ make_string (char *token, char **end)
}
const char *
-quote_string (const char *str)
+html_string (const char *str)
{
static dstring_t *q;
char c[2] = {0, 0};
@@ -372,9 +372,6 @@ quote_string (const char *str)
dstring_clearstr (q);
while ((c[0] = *str++)) {
switch (c[0]) {
- case '\n':
- dstring_appendstr (q, "\\\\n");
- break;
case '<':
dstring_appendstr (q, "<");
break;
@@ -387,6 +384,54 @@ quote_string (const char *str)
case '"':
dstring_appendstr (q, """);
break;
+ default:
+ dstring_appendstr (q, c);
+ break;
+ }
+ }
+ return q->str;
+}
+
+const char *
+quote_string (const char *str)
+{
+ static dstring_t *q;
+ char c[2] = {0, 0};
+
+ if (!str)
+ return "(null)";
+ if (!q)
+ q = dstring_new ();
+ dstring_clearstr (q);
+ while ((c[0] = *str++)) {
+ switch (c[0]) {
+ case '\a':
+ dstring_appendstr (q, "\\a");
+ break;
+ case '\b':
+ dstring_appendstr (q, "\\b");
+ break;
+ case '\f':
+ dstring_appendstr (q, "\\f");
+ break;
+ case '\n':
+ dstring_appendstr (q, "\\n");
+ break;
+ case '\r':
+ dstring_appendstr (q, "\\r");
+ break;
+ case '\t':
+ dstring_appendstr (q, "\\t");
+ break;
+ case '\\':
+ dstring_appendstr (q, "\\\\");
+ break;
+ case '\'':
+ dstring_appendstr (q, "\\'");
+ break;
+ case '\"':
+ dstring_appendstr (q, "\\\"");
+ break;
default:
if (c[0] >= 127 || c[0] < 32)
dasprintf (q, "\\\\x%02d", (byte) c[0]);