Fixed to properly escape quotes in strings.
authorNick Hildenbrandt <hldnbrnd@uiuc.edu>
Mon, 30 Sep 2002 21:11:55 +0000 (21:11 +0000)
committerNick Hildenbrandt <hldnbrnd@uiuc.edu>
Mon, 30 Sep 2002 21:11:55 +0000 (21:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3991 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index e54d45751255fa11c388b2d541e755ebf7f08eba..8b7aba9398ac1d3bcb0ee0aec5d2c5caa1e4b7d4 100644 (file)
@@ -287,7 +287,10 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
         (unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
       
       if (isprint(C)) {
-        Out << C;
+        if (C == '"')
+          Out << "\\\"";
+        else
+          Out << C;
       } else {
         switch (C) {
         case '\n': Out << "\\n"; break;
@@ -295,6 +298,8 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
         case '\r': Out << "\\r"; break;
         case '\v': Out << "\\v"; break;
         case '\a': Out << "\\a"; break;
+        case '\"': Out << "\\\""; break;
+        case '\'': Out << "\\\'"; break;           
         default:
           Out << "\\x";
           Out << ( C/16  < 10) ? ( C/16 +'0') : ( C/16 -10+'A');
index e54d45751255fa11c388b2d541e755ebf7f08eba..8b7aba9398ac1d3bcb0ee0aec5d2c5caa1e4b7d4 100644 (file)
@@ -287,7 +287,10 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
         (unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
       
       if (isprint(C)) {
-        Out << C;
+        if (C == '"')
+          Out << "\\\"";
+        else
+          Out << C;
       } else {
         switch (C) {
         case '\n': Out << "\\n"; break;
@@ -295,6 +298,8 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
         case '\r': Out << "\\r"; break;
         case '\v': Out << "\\v"; break;
         case '\a': Out << "\\a"; break;
+        case '\"': Out << "\\\""; break;
+        case '\'': Out << "\\\'"; break;           
         default:
           Out << "\\x";
           Out << ( C/16  < 10) ? ( C/16 +'0') : ( C/16 -10+'A');