From fa4545635551d3d5551448b43c116fa21babbe17 Mon Sep 17 00:00:00 2001 From: borutr Date: Wed, 10 Jan 2007 14:35:37 +0000 Subject: [PATCH] * src/SDCC.lex, src/SDCCmain.c: fixed bug #1631895: codeseg/constseg #pragma fail git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4568 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 ++++ src/SDCC.lex | 77 +++++++++++++++----------------------------------- src/SDCCmain.c | 13 +++++++-- 3 files changed, 38 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4d56166..7408fd8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-01-10 Borut Razem + + * src/SDCC.lex, src/SDCCmain.c: fixed bug #1631895: + codeseg/constseg #pragma fail + 2007-01-09 Borut Razem * get rid of diagnistic.[ch], pretty-print.[ch], diff --git a/src/SDCC.lex b/src/SDCC.lex index 201b1c92..9288e1fe 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -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; diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 8b9f8801..3460abbd 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -32,6 +32,7 @@ #include "common.h" #include #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; } -- 2.47.2