1. spencercw
  2. gb_emulator

Commits

spencercw  committed 7fef0a7

Fix SDCC crash caused by character literals that are greater than 127.

This is ripped from revision 6942 of the SDCC repository.

  • Participants
  • Parent commits ac89bc2
  • Branches default

Comments (0)

Files changed (2)

File third_party/sdcc/patches/SDCCglue.c.patch

View file
  • Ignore whitespace
+--- src/SDCCglue.c	2010-09-12 09:08:46 +0100
++++ src/SDCCglue.c	2011-11-23 17:45:10 +0000
+@@ -680,6 +680,7 @@
+ printIvalType (symbol *sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf)
+ {
+   value *val;
++  unsigned long ulVal = 0;
+ 
+   /* if initList is deep */
+   if (ilist && (ilist->type == INIT_DEEP))
+@@ -701,6 +702,9 @@
+     val = valCastLiteral(type, floatFromVal(val));
+   }
+ 
++  if (IS_INTEGRAL (val->type))
++    ulVal = ulFromVal (val);
++
+   switch (getSize (type)) {
+   case 1:
+     if (!val)
+@@ -714,8 +718,8 @@
+         dbuf_tprintf (oBuf, "\t!dbs\t; % d",
+                 aopLiteral (val, 0), (int)floatFromVal (val) );
+       }
+-      if( isalpha ((char)floatFromVal (val)) )
+-        dbuf_tprintf (oBuf, "\t%c\n", (char)floatFromVal (val) );
++      if (isalnum ((int) ulVal))
++        dbuf_tprintf (oBuf, "\t'%c'\n", (int) ulVal);
+       else
+         dbuf_tprintf (oBuf, "\n");
+     }

File third_party/sdcc/src/SDCCglue.c

View file
  • Ignore whitespace
 printIvalType (symbol *sym, sym_link * type, initList * ilist, struct dbuf_s * oBuf)
 {
   value *val;
+  unsigned long ulVal = 0;
 
   /* if initList is deep */
   if (ilist && (ilist->type == INIT_DEEP))
     val = valCastLiteral(type, floatFromVal(val));
   }
 
+  if (IS_INTEGRAL (val->type))
+    ulVal = ulFromVal (val);
+
   switch (getSize (type)) {
   case 1:
     if (!val)
         dbuf_tprintf (oBuf, "\t!dbs\t; % d",
                 aopLiteral (val, 0), (int)floatFromVal (val) );
       }
-      if( isalpha ((char)floatFromVal (val)) )
-        dbuf_tprintf (oBuf, "\t%c\n", (char)floatFromVal (val) );
+      if (isalnum ((int) ulVal))
+        dbuf_tprintf (oBuf, "\t'%c'\n", (int) ulVal);
       else
         dbuf_tprintf (oBuf, "\n");
     }