Fixed octal and hex escape sequences in character and string constants
authorjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 May 2001 03:27:03 +0000 (03:27 +0000)
committerjtvolpe <jtvolpe@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 May 2001 03:27:03 +0000 (03:27 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@831 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.lex

index b335a917aaf958af396969789c558046a5d9867b..bb3e7a894f56f20d3d32216dd3676f91eaa299e8 100644 (file)
@@ -328,47 +328,67 @@ int check_type()
 
 char strLitBuff[2048]                  ;
 
+/*
+ * Change by JTV 2001-05-19 to not concantenate strings
+ * to support ANSI hex and octal escape sequences in string liteals 
+ */
+
 char *stringLiteral ()
+
 {
-       int ch;
-       char *str = strLitBuff                  ;
-       
-       *str++ = '\"'                   ;
-       /* put into the buffer till we hit the */
-       /* first \" */
-       while (1) {
-
-          ch = input()                 ;
-          if (!ch)         break       ; /* end of input */
-         /* if it is a \ then everything allowed */
-         if (ch == '\\') {
-            *str++ = ch     ; /* backslash in place */
-            *str++ = input()           ; /* following char in place */
-            continue                   ;      /* carry on */
-            }
-            
-        /* if new line we have a new line break */
-        if (ch == '\n') break          ;
-        
-        /* if this is a quote then we have work to do */
-        /* find the next non whitespace character     */
-        /* if that is a double quote then carry on    */
-        if (ch == '\"') {
-        
-            while ((ch = input()) && isspace(ch)) ;
-            if (!ch) break             ; 
-            if (ch != '\"') {
-                 unput(ch)                     ;
-                 break                 ;
-                 }
-                 
-                 continue              ;
-        }
-       *str++  = ch;     
-     }  
-     *str++ = '\"'                     ;
-     *str = '\0';
-     return strLitBuff                 ;
+int ch;
+char *str = strLitBuff                 ;
+
+*str++ = '\"'                  ;
+/* put into the buffer till we hit the */
+/* first \" */
+
+while (1) 
+  {
+  ch = input()                 ;
+
+  if (!ch)
+    break      ; /* end of input */
+
+  /* if it is a \ then everything allowed */
+
+  if (ch == '\\') 
+    {
+    *str++ = ch     ; /* backslash in place */
+    *str++ = input()           ; /* following char in place */
+    continue                   ;      /* carry on */
+    }
+
+  /* if new line we have a new line break */
+  if (ch == '\n') 
+    break              ;
+
+  /* if this is a quote then we have work to do */
+  /* find the next non whitespace character     */
+  /* if that is a double quote then carry on    */
+
+  if (ch == '\"') 
+    {
+    *str++  = ch ;     /* Pass end of this string or substring to evaluator */
+
+    while ((ch = input()) && isspace(ch)) ;
+
+    if (!ch) 
+      break ; 
+
+    if (ch != '\"') 
+      {
+      unput(ch) ;
+      break ;
+      }
+    }
+
+  *str++  = ch;              /* Put next substring introducer into output string */
+  }  
+
+*str = '\0';
+
+return strLitBuff                      ;
 }
 
 void doPragma (int op, char *cp)