* src/SDCCutil.c: fixed a bug in (get_pragma_token)
* src/pic16/main.c, src/SDCC.lex, src/z80/main.c:
small cosmetic changes
+ * src/SDCC.lex: (stringLiteral) fixed bug #1351710
+ * support/regression/tests/bug-1351710.c: added regression test
2006-12-18 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
- * doc/sdccman.lyx: added the long missed iCode table
+ * doc/sdccman.lyx: added the long missed iCode table
"<where is figure II?>", added links to wiki
2006-12-17 Borut Razem <borut.razem AT siol.net>
static void count(void);
static int process_pragma(const char *);
static int check_type(void);
-static int isTargetKeyword(char *s);
-static int checkCurrFile(char *s);
+static int isTargetKeyword(const char *s);
+static int checkCurrFile(const char *s);
%}
%x asm
#endif
-static int checkCurrFile (char *s)
+static int checkCurrFile (const char *s)
{
int lNum;
char *tptr;
s = tptr;
/* now see if we have a file name */
- while (*s != '\"' && *s)
- s++;
+ while (*s != '"' && *s)
+ ++s;
/* if we don't have a filename then */
/* set the current line number to */
/* if we have a filename then check */
/* if it is "standard in" if yes then */
/* get the currentfile name info */
- s++ ;
+ ++s;
/* in c1mode fullSrcFileName is NULL */
if (fullSrcFileName &&
strncmp(s, fullSrcFileName, strlen(fullSrcFileName)) == 0) {
lineno = mylineno = lNum;
currFname = fullSrcFileName;
- } else {
- char *sb = s;
- /* mark the end of the filename */
- while (*s != '"') s++;
- *s = '\0';
- currFname = strdup (sb);
- lineno = mylineno = lNum;
+ }
+ else {
+ const char *sb = s;
+
+ /* find the end of the filename */
+ while (*s && *s != '"')
+ ++s;
+ currFname = Safe_malloc(s - sb + 1);
+ memcpy(currFname, sb, s - sb);
+ currFname[s - sb] = '\0';
+ lineno = mylineno = lNum;
}
filename = currFname ;
return 0;
/* find the next non whitespace character */
/* if that is a double quote then carry on */
dbuf_append(&dbuf, "\"", 1); /* Pass end of this string or substring to evaluator */
- while ((ch = input()) && (isspace(ch) || ch == '\\')) {
+ while ((ch = input()) && (isspace(ch) || ch == '\\' || ch == '#')) {
switch (ch) {
case '\\':
if ((ch = input()) != '\n') {
break;
case '\n':
- mylineno++;
+ lineno = ++mylineno;
+ column = 0;
break;
+
+ case '#':
+ if (0 == column) {
+ /* # at the beginning of the line: collect the entire line */
+ struct dbuf_s linebuf;
+ const char *line;
+
+ dbuf_init(&linebuf, STR_BUF_CHUNCK_LEN);
+ dbuf_append(&linebuf, "#", 1);
+
+ while ((ch = input()) && ch != '\n') {
+ buf[0] = ch;
+ dbuf_append(&linebuf, buf, 1);
+ }
+
+ if (ch == '\n') {
+ lineno = ++mylineno;
+ column = 0;
+ }
+
+ line = dbuf_c_str(&linebuf);
+
+ /* process the line */
+ if (startsWith(line, "#pragma"))
+ process_pragma(line);
+ else
+ checkCurrFile(line);
+
+ dbuf_destroy(&linebuf);
+ }
}
}
if (!ch)
goto out;
- if (ch != '\"') {
+ if (ch != '"') {
unput(ch);
goto out;
}
/* will return 1 if the string is a part
of a target specific keyword */
-static int isTargetKeyword(char *s)
+static int isTargetKeyword(const char *s)
{
int i;