From: epetrich Date: Fri, 12 Dec 2003 07:51:29 +0000 (+0000) Subject: * src/ds390/main.c (PORT tininative_port): fixed bug #858416 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=de6f45c28b45d49189e124dd880902c1f5e43e0d;p=fw%2Fsdcc * src/ds390/main.c (PORT tininative_port): fixed bug #858416 * 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 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index e21105ca..3ad20980 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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;isyms; 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); diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 0347280d..b6a066d6 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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); } diff --git a/src/ds390/main.c b/src/ds390/main.c index 66577044..cbedd000 100644 --- a/src/ds390/main.c +++ b/src/ds390/main.c @@ -657,6 +657,7 @@ PORT tininative_port = "DS80C390", /* Target name */ NULL, /* processor */ { + glue, FALSE, /* Emit glue around main */ MODEL_FLAT24, MODEL_FLAT24