unified table driven pragma handling, pragma argument type checking
* support/Util/dbuf.c: (dbuf_set_size) allow to set size equal to the
current one - version 1.1.3
+ * src/SDCCmain.c: (setParseWithComma) substituted brain damaged strtok
2006-12-13 Raphael Neider <rneider AT web.de>
case P_CALLEE_SAVES:
/* append to the functions already listed
in callee-saves */
- setParseWithComma(&options.calleeSavesSet, (char *)cp);
+ setParseWithComma(&options.calleeSavesSet, cp);
err = -1;
break;
case P_EXCLUDE:
{
deleteSet(&options.excludeRegsSet);
- setParseWithComma(&options.excludeRegsSet, (char *)cp);
+ setParseWithComma(&options.excludeRegsSet, cp);
err = -1;
}
break;
if (0 != strcmp("#pragma", get_pragma_string(&token)))
{
/* Oops, womething went totally wrong - internal error */
+ wassertl(0, "pragma parser internal error");
}
/* skip spaces */
extern set *libPathsSet;
extern set *libDirsSet; /* list of lib search directories */
-void setParseWithComma (set **, char *);
+void setParseWithComma (set **, const char *);
/** Creates a temporary file a'la tmpfile which avoids the bugs
in cygwin wrt c:\tmp.
/* setParseWithComma - separates string with comma to a set */
/*-----------------------------------------------------------------*/
void
-setParseWithComma (set **dest, char *src)
+setParseWithComma (set **dest, const char *src)
{
- char *p;
- int length;
+ const char *p, *end;
+ struct dbuf_s dbuf;
/* skip the initial white spaces */
while (isspace((unsigned char)*src))
- src++;
+ ++src;
/* skip the trailing white spaces */
- length = strlen(src);
- while (length && isspace((unsigned char)src[length-1]))
- src[--length] = '\0';
+ end = &src[strlen(src) - 1];
+ while (end >= src && isspace((unsigned char)*end))
+ --end;
+ ++end;
+
+ dbuf_init(&dbuf, 16);
+
+ p = src;
+ while (src < end)
+ {
+ while (p < end && ',' != *p)
+ ++p;
+ dbuf_append(&dbuf, src, p - src);
+ addSet(dest, Safe_strdup(dbuf_c_str(&dbuf)));
+ dbuf_set_size(&dbuf, 0);
+ src = ++p;
+ }
- for (p = strtok(src, ","); p != NULL; p = strtok(NULL, ","))
- addSet(dest, Safe_strdup(p));
+ dbuf_destroy(&dbuf);
}
/*-----------------------------------------------------------------*/
dbuf_set_size(&token->dbuf, 0);
/* skip leading spaces */
- while (*s != '\n' && isspace(*s))
+ while ('\n' != *s && isspace(*s))
++s;
if ('\0' == *s || '\n' == *s)
{
token->type = TOKEN_EOL;
}
- else if (isdigit(*s))
+ else
{
char *end;
token->val.int_val = val;
token->type = TOKEN_INT;
dbuf_append(&token->dbuf, s, end - s);
+ s = end;
}
- s = end;
- }
- else
- {
- while ('\0' != *s && !isspace(*s))
+ else
{
- dbuf_append(&token->dbuf, s, 1);
- ++s;
- }
+ while ('\0' != *s && !isspace(*s))
+ {
+ dbuf_append(&token->dbuf, s, 1);
+ ++s;
+ }
- token->type = TOKEN_STR;
+ token->type = TOKEN_STR;
+ }
}
- return (char *)s;
+ return (char *)s;
}
const char *