]> git.gag.com Git - fw/sdcc/commitdiff
* src/ds390/main.c (PORT tininative_port): fixed bug #858416
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 12 Dec 2003 07:51:29 +0000 (07:51 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 12 Dec 2003 07:51:29 +0000 (07:51 +0000)
* src/SDCCglue.c (printChar, printIvalChar, emitStaticSeg),
* src/SDCCast.c (createIvalCharPtr, stringToSymbol): handle strings
with embedded nulls (fixed bug #753752)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3048 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c
src/ds390/main.c

index e21105ca710c613f11c4dcd0f8b50945e006bf64..3ad209808c7b92cf87df7308aff8e0b166eb6af3 100644 (file)
@@ -985,8 +985,9 @@ createIvalCharPtr (ast * sym, sym_link * type, ast * iexpr)
       /* to the array element */
       char *s = SPEC_CVAL (iexpr->etype).v_char;
       int i = 0;
+      int size = getSize (iexpr->ftype);
 
-      while (*s)
+      for (i=0;i<size;i++)
        {
          rast = newNode (NULLOP,
                          rast,
@@ -994,15 +995,8 @@ createIvalCharPtr (ast * sym, sym_link * type, ast * iexpr)
                                   newNode ('[', sym,
                                   newAst_VALUE (valueFromLit ((float) i))),
                                   newAst_VALUE (valueFromLit (*s))));
-         i++;
          s++;
        }
-      rast = newNode (NULLOP,
-                     rast,
-                     newNode ('=',
-                              newNode ('[', sym,
-                                  newAst_VALUE (valueFromLit ((float) i))),
-                              newAst_VALUE (valueFromLit (*s))));
 
       // now WE don't need iexpr's symbol anymore
       freeStringSymbol(AST_SYMBOL(iexpr));
@@ -1194,12 +1188,14 @@ stringToSymbol (value * val)
   static int charLbl = 0;
   symbol *sym;
   set *sp;
+  int size;
 
   // have we heard this before?
   for (sp=statsg->syms; sp; sp=sp->next) {
     sym=sp->item;
-    if (sym->isstrlit && 
-       !strcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char)) {
+    size = getSize (sym->type);
+    if (sym->isstrlit && size == getSize (val->type) &&
+       !memcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char, size)) {
       // yes, this is old news. Don't publish it again.
       sym->isstrlit++; // but raise the usage count
       return symbolVal(sym);
index 0347280d6f284fcd9356ddcf18a25997d27097c4..b6a066d65c2d5f43d1b7f26e379ece604aa4547e 100644 (file)
@@ -512,7 +512,7 @@ printChar (FILE * ofile, char *s, int plen)
   while (len && pplen < plen)
     {
       i = 60;
-      while (i && *s && pplen < plen)
+      while (i && pplen < plen)
        {
          if (*s < ' ' || *s == '\"' || *s=='\\')
            {
@@ -543,7 +543,6 @@ printChar (FILE * ofile, char *s, int plen)
       else
        len = 0;
     }
-  tfprintf (ofile, "\t!db !constbyte\n", 0);
 }
 
 /*-----------------------------------------------------------------*/
@@ -765,7 +764,6 @@ int
 printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s)
 {
   value *val;
-  int remain;
 
   if (!s)
     {
@@ -779,10 +777,6 @@ printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s)
 
          printChar (oFile, SPEC_CVAL (val->etype).v_char, DCL_ELEM (type));
 
-         if ((remain = (DCL_ELEM (type) - strlen (SPEC_CVAL (val->etype).v_char) - 1)) > 0)
-           while (remain--)
-             tfprintf (oFile, "\t!db !constbyte\n", 0);
-
          return 1;
        }
       else
@@ -1268,7 +1262,7 @@ emitStaticSeg (memmap * map, FILE * out)
                  SPEC_CVAL (sym->etype).v_char)
                  printChar (out,
                             SPEC_CVAL (sym->etype).v_char,
-                            strlen (SPEC_CVAL (sym->etype).v_char) + 1);
+                            size);
              else
                  tfprintf (out, "\t!ds\n", (unsigned int) size & 0xffff);
            }
index 665770448d03ea9430efeacf14f06b3a87152d63..cbedd000d2af0131c52343ec98191aa02c510f79 100644 (file)
@@ -657,6 +657,7 @@ PORT tininative_port =
   "DS80C390",                  /* Target name */
        NULL,                   /* processor */
   {
+    glue,
     FALSE,                     /* Emit glue around main */
     MODEL_FLAT24,
     MODEL_FLAT24