b89b6a95fa
#include "foo.h" ..or.. #include <foo.h> would cause mkid to happily loop forever. Fix this, making the scanner properly detect EOL/EOF and defined name tokens in #include statements, as well. Merge all libidu/scanners.c patches into a single patch file. Bump package revision to nb3.
241 lines
5.7 KiB
Text
241 lines
5.7 KiB
Text
$NetBSD: patch-ac,v 1.4 2003/01/08 02:36:00 thorpej Exp $
|
|
|
|
--- libidu/scanners.c.orig Tue Jan 7 18:24:27 2003
|
|
+++ libidu/scanners.c Tue Jan 7 18:24:29 2003
|
|
@@ -44,6 +44,19 @@
|
|
extern void usage __P((void));
|
|
extern char *program_name;
|
|
|
|
+static char *id_0;
|
|
+static size_t id_0_len;
|
|
+#define APPEND_CHAR(C) do { \
|
|
+ if(id_0 == NULL || id == id_0 + id_0_len) { \
|
|
+ size_t __pos = id_0 ? id - id_0 : 0; \
|
|
+ id_0 = xrealloc(id_0, id_0_len + BUFSIZ); \
|
|
+ id_0_len += BUFSIZ; \
|
|
+ id = id_0 + __pos; \
|
|
+ } \
|
|
+ *id++ = (C); \
|
|
+ } while(0);
|
|
+
|
|
+
|
|
/****************************************************************************/
|
|
|
|
struct lang_args **parse_language_map_file __P((char const *file_name, struct lang_args **next_ptr));
|
|
@@ -65,8 +78,14 @@
|
|
struct language languages_0[] =
|
|
{
|
|
{ "C", parse_args_c, get_token_c, help_me_c },
|
|
+ { "C++", parse_args_c, get_token_c, help_me_c },
|
|
+ { "cpp", parse_args_c, get_token_c, help_me_c },
|
|
+ { "cc", parse_args_c, get_token_c, help_me_c },
|
|
{ "asm", parse_args_asm, get_token_asm, help_me_asm },
|
|
+ { "S", parse_args_asm, get_token_asm, help_me_asm },
|
|
+ { "s", parse_args_asm, get_token_asm, help_me_asm },
|
|
{ "text", parse_args_text, get_token_text, help_me_text },
|
|
+ { "make", parse_args_text, get_token_text, help_me_text },
|
|
};
|
|
struct language const *languages_N = &languages_0[cardinalityof (languages_0)];
|
|
|
|
@@ -482,7 +501,6 @@
|
|
#define ARGS ((struct args_c const *) args)
|
|
static int new_line = 1;
|
|
unsigned short const *rct = &ARGS->ctype[1];
|
|
- char id_0[BUFSIZ];
|
|
char *id = id_0;
|
|
int c;
|
|
|
|
@@ -501,10 +519,10 @@
|
|
if (!ISID1ST (c))
|
|
goto next;
|
|
id = id_0;
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
- *id = '\0';
|
|
+ APPEND_CHAR(c);
|
|
+ APPEND_CHAR('\0');
|
|
if (strequ (id_0, "include"))
|
|
{
|
|
while (c == ' ' || c == '\t')
|
|
@@ -520,7 +538,7 @@
|
|
c = getc (in_FILE);
|
|
while (c != '\n' && c != EOF && c != '"')
|
|
{
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
c = getc (in_FILE);
|
|
}
|
|
*flags = TOK_STRING;
|
|
@@ -530,16 +548,16 @@
|
|
c = getc (in_FILE);
|
|
while (c != '\n' && c != EOF && c != '>')
|
|
{
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
c = getc (in_FILE);
|
|
}
|
|
*flags = TOK_STRING;
|
|
}
|
|
else if (ISID1ST (c))
|
|
{
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
*flags = TOK_NAME;
|
|
}
|
|
else
|
|
@@ -574,14 +592,14 @@
|
|
{
|
|
case '"':
|
|
id = id_0;
|
|
- *id++ = c = getc (in_FILE);
|
|
+ APPEND_CHAR(c = getc (in_FILE));
|
|
for (;;)
|
|
{
|
|
while (ISQ2BORING (c))
|
|
- *id++ = c = getc (in_FILE);
|
|
+ APPEND_CHAR(c = getc (in_FILE));
|
|
if (c == '\\')
|
|
{
|
|
- *id++ = c = getc (in_FILE);
|
|
+ APPEND_CHAR(c = getc (in_FILE));
|
|
continue;
|
|
}
|
|
else if (c != '"')
|
|
@@ -662,18 +680,18 @@
|
|
return 0;
|
|
}
|
|
id = id_0;
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
if (ISID1ST (c))
|
|
{
|
|
*flags = TOK_NAME;
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else if (ISDIGIT (c))
|
|
{
|
|
*flags = TOK_NUMBER;
|
|
while (ISNUMBER (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else
|
|
{
|
|
@@ -868,7 +886,6 @@
|
|
#define ARGS ((struct args_asm const *) args)
|
|
static int new_line = 1;
|
|
unsigned char const *rct = &ARGS->ctype[1];
|
|
- char id_0[BUFSIZ];
|
|
char *id = id_0;
|
|
int c;
|
|
|
|
@@ -886,18 +903,25 @@
|
|
if (!ISID1ST (c))
|
|
goto next;
|
|
id = id_0;
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
- *id = '\0';
|
|
+ APPEND_CHAR(c);
|
|
+ APPEND_CHAR('\0');
|
|
if (strequ (id_0, "include"))
|
|
{
|
|
- while (c != '"' && c != '<')
|
|
+ while (c == ' ' || c == '\t')
|
|
c = getc (in_FILE);
|
|
+ if (c == '\n' || ISEOF(c))
|
|
+ {
|
|
+ new_line = 1;
|
|
+ goto top;
|
|
+ }
|
|
+ if (c != '"' && c != '<')
|
|
+ goto next;
|
|
id = id_0;
|
|
- *id++ = c = getc (in_FILE);
|
|
+ APPEND_CHAR(c = getc (in_FILE));
|
|
while ((c = getc (in_FILE)) != '"' && c != '>')
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
*flags = TOK_STRING;
|
|
obstack_grow0 (&tokens_obstack, id_0, id - id_0);
|
|
return (struct token *) obstack_finish (&tokens_obstack);
|
|
@@ -906,7 +930,7 @@
|
|
|| strequ (id_0, "define")
|
|
|| strequ (id_0, "undef"))
|
|
goto next;
|
|
- while (c != '\n')
|
|
+ while ((c != '\n') && !ISEOF(c))
|
|
c = getc (in_FILE);
|
|
new_line = 1;
|
|
goto top;
|
|
@@ -967,18 +991,18 @@
|
|
obstack_grow0 (&tokens_obstack, "_", 1);
|
|
return (struct token *) obstack_finish (&tokens_obstack);
|
|
}
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
if (ISID1ST (c))
|
|
{
|
|
*flags = TOK_NAME;
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else if (ISNUMBER (c))
|
|
{
|
|
*flags = TOK_NUMBER;
|
|
while (ISNUMBER (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else
|
|
{
|
|
@@ -989,7 +1013,7 @@
|
|
goto next;
|
|
}
|
|
|
|
- *id = '\0';
|
|
+ APPEND_CHAR('\0');
|
|
for (id = id_0; *id; id++)
|
|
if (ISIGNORE (*id))
|
|
goto next;
|
|
@@ -1153,7 +1177,6 @@
|
|
get_token_text (FILE *in_FILE, void const *args, int *flags)
|
|
{
|
|
#define ARGS ((struct args_text const *) args)
|
|
- static char id_0[BUFSIZ];
|
|
unsigned char const *rct = &ARGS->ctype[1];
|
|
int c;
|
|
char *id = id_0;
|
|
@@ -1170,19 +1193,19 @@
|
|
return 0;
|
|
}
|
|
id = id_0;
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
if (ISID1ST (c))
|
|
{
|
|
*flags = TOK_NAME;
|
|
while (ISIDREST (c = getc (in_FILE)))
|
|
if (!ISIDSQUEEZE (c))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else if (ISNUMBER (c))
|
|
{
|
|
*flags = TOK_NUMBER;
|
|
while (ISNUMBER (c = getc (in_FILE)))
|
|
- *id++ = c;
|
|
+ APPEND_CHAR(c);
|
|
}
|
|
else
|
|
{
|