* src/SDCC.lex, src/SDCCmain.c: fixed bug #1631895:
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 10 Jan 2007 14:35:37 +0000 (14:35 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 10 Jan 2007 14:35:37 +0000 (14:35 +0000)
  codeseg/constseg #pragma fail

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

ChangeLog
src/SDCC.lex
src/SDCCmain.c

index a4d561665f04d1f0bd99025ae2d890e38035fe4e..7408fd8eba5a9f1681a2e6e0d97f0e57ebf0b99c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-10 Borut Razem <borut.razem AT siol.net>
+
+       * src/SDCC.lex, src/SDCCmain.c: fixed bug #1631895:
+         codeseg/constseg #pragma fail
+
 2007-01-09 Borut Razem <borut.razem AT siol.net>
 
        * get rid of diagnistic.[ch], pretty-print.[ch],
index 201b1c9259290914ccd7a50683131794b1edfdf8..9288e1fee2bb02ba69b3aa9b55af13f2dbc81848 100644 (file)
@@ -5,21 +5,21 @@
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any
-   later version.
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-   In other words, you are welcome to use, share and improve this program.
-   You are forbidden to forbid anyone else to use, share and improve
-   what you give them.   Help stamp out software-hoarding!
+  In other words, you are welcome to use, share and improve this program.
+  You are forbidden to forbid anyone else to use, share and improve
+  what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
 D       [0-9]
@@ -372,7 +372,6 @@ static char *stringLiteral(void)
 #define STR_BUF_CHUNCK_LEN  1024
   int ch;
   static struct dbuf_s dbuf;
-  char buf[2];
 
   if (dbuf.alloc == 0)
     dbuf_init(&dbuf, STR_BUF_CHUNCK_LEN);
@@ -393,6 +392,8 @@ static char *stringLiteral(void)
         column = 0;
       }
       else {
+        char buf[2];
+
         buf[0] = '\\';
         buf[1] = ch;
         dbuf_append(&dbuf, buf, 2); /* get the escape char, no further check */
@@ -891,40 +892,9 @@ static int doPragma(int id, const char *name, const char *cp)
       break;
 
     case P_CODESEG:
-      {
-        const char *segname;
-
-        cp = get_pragma_token(cp, &token);
-        if (token.type == TOKEN_EOL)
-          {
-            err = 1;
-            break;
-          }
-        segname = get_pragma_string(&token);
-
-        cp = get_pragma_token(cp, &token);
-        if (token.type != TOKEN_EOL)
-          {
-            err = 1;
-            break;
-          }
-
-        if (strlen(segname) > 8)
-          {
-            err = 1;
-            break;
-          }
-        else
-          {
-            dbuf_append(&token.dbuf, "(CODE)", (sizeof "(CODE)") - 1);
-            options.code_seg = Safe_strdup(get_pragma_string(&token));
-          }
-      }
-      break;
-
     case P_CONSTSEG:
       {
-        const char *segname;
+        struct dbuf_s segname;
 
         cp = get_pragma_token(cp, &token);
         if (token.type == TOKEN_EOL)
@@ -932,25 +902,22 @@ static int doPragma(int id, const char *name, const char *cp)
             err = 1;
             break;
           }
-        segname = get_pragma_string(&token);
+
+        dbuf_init(&segname, 16);
+        dbuf_printf(&segname, "%-8s(CODE)", get_pragma_string(&token));
 
         cp = get_pragma_token(cp, &token);
         if (token.type != TOKEN_EOL)
           {
+            dbuf_destroy(&segname);
             err = 1;
             break;
           }
 
-        if (strlen(segname) > 8)
-          {
-            err = 1;
-            break;
-          }
+        if (id == P_CODESEG)
+          options.code_seg = dbuf_detach(&segname);
         else
-          {
-            dbuf_append(&token.dbuf, "(CODE)", (sizeof "(CODE)") - 1);
-            options.code_seg = Safe_strdup(get_pragma_string(&token));
-          }
+          options.const_seg = dbuf_detach(&segname);
       }
       break;
 
index 8b9f88012ed57b6d9fa7a6d2519b15e56bd84f1a..3460abbd496d31d2b9e7f339f5a943904455cf36 100644 (file)
@@ -32,6 +32,7 @@
 #include "common.h"
 #include <ctype.h>
 #include "newalloc.h"
+#include "dbuf_string.h"
 #include "SDCCerr.h"
 #include "BuildCmd.h"
 #include "MySystem.h"
@@ -1148,13 +1149,21 @@ parseCmdLine (int argc, char **argv)
 
           if (strcmp (argv[i], OPTION_CODE_SEG) == 0)
             {
-              options.code_seg = getStringArg(OPTION_CODE_SEG, argv, &i, argc);
+              struct dbuf_s segname;
+
+              dbuf_init(&segname, 16);
+              dbuf_printf(&segname, "%-8s(CODE)", getStringArg(OPTION_CODE_SEG, argv, &i, argc));
+              options.code_seg = dbuf_detach(&segname);
               continue;
             }
 
           if (strcmp (argv[i], OPTION_CONST_SEG) == 0)
             {
-              options.const_seg = getStringArg(OPTION_CONST_SEG, argv, &i, argc);
+              struct dbuf_s segname;
+
+              dbuf_init(&segname, 16);
+              dbuf_printf(&segname, "%-8s(CODE)", getStringArg(OPTION_CONST_SEG, argv, &i, argc));
+              options.const_seg = dbuf_detach(&segname);
               continue;
             }