Fix emission of string initializers.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 17 Aug 2011 13:44:43 +0000 (15:44 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 17 Aug 2011 14:42:05 +0000 (16:42 +0200)
Non-printable characters are emitted as octal sequences, e.g. \0 for 0.
Always pad them to three digits, so they do not accidently join with a following ASCII digit.
E.g. "\0""7" was emitted as "\07", correct is "\0007".

ir/be/begnuas.c

index 72b46aa..1fc3f31 100644 (file)
@@ -884,7 +884,7 @@ static void emit_string_cst(const ir_entity *ent)
                        if (isprint(c))
                                be_emit_char(c);
                        else
-                               be_emit_irprintf("\\%o", c);
+                               be_emit_irprintf("\\%03o", c);
                        break;
                }
        }
@@ -929,7 +929,7 @@ static size_t emit_string_initializer(const ir_initializer_t *initializer)
                        if (isprint(c))
                                be_emit_char(c);
                        else
-                               be_emit_irprintf("\\%o", c);
+                               be_emit_irprintf("\\%03o", c);
                        break;
                }
        }