fix the lisp scanner to properly exit when EOF is reached. there are

two files in netbsd 'src' that trigger this bug, but now i can run 'mkid'
on all of 'src' again.
This commit is contained in:
mrg 2010-12-11 23:40:08 +00:00
parent 89642808bd
commit 5f39c75115
2 changed files with 155 additions and 1 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.4 2006/09/17 01:25:18 christos Exp $
$NetBSD: distinfo,v 1.5 2010/12/11 23:40:08 mrg Exp $
SHA1 (idutils-4.2.tar.gz) = 306f6e296768d494d771777647c04c8ceed66c1f
RMD160 (idutils-4.2.tar.gz) = cddc6ac3d26f8a836a4d8c5d7111b4439095abe8
@ -11,3 +11,4 @@ SHA1 (patch-ae) = b0a11f8172bede23e4f22f5ace819117f8f6a26d
SHA1 (patch-ai) = ee67a03e074820db342ffa6ec26c1440641b702e
SHA1 (patch-aj) = fba2812551631733c5faea8d2d0468ff2ea3d734
SHA1 (patch-ak) = 91a781f4908b34ab172268e74ae77e93fd0e2ab4
SHA1 (patch-al) = f0d2c84ae7f7becf6ccc3d47b956b0540ea92a88

View file

@ -0,0 +1,153 @@
--- libidu/scanners.c.orig 2010-12-11 15:27:10.000000000 -0800
+++ libidu/scanners.c 2010-12-11 15:26:59.000000000 -0800
@@ -1618,6 +1618,7 @@
switch (c)
{
case EOF:
+ out:
obstack_free (&tokens_obstack, obstack_finish (&tokens_obstack));
return 0;
@@ -1634,19 +1635,25 @@
case ';': /* comment */
do {
c = getc (in_FILE);
- } while ( (c != EOF) && (c != '\n'));
+ if (c == EOF)
+ goto out;
+ } while (c != '\n');
goto top;
case '"': /* string with or without ansi-C escapes */
string:
do {
c = getc (in_FILE);
+ if (c == EOF)
+ goto out;
if (c == '\\')
{
c = getc (in_FILE);
+ if (c == EOF)
+ goto out;
continue;
}
- } while ( (c != EOF) && (c != '"'));
+ } while (c != '"');
goto top;
case '.':
@@ -1654,11 +1661,12 @@
id = scanner_buffer;
*id++ = c;
c = getc (in_FILE);
+ if (c == EOF)
+ goto out;
if (is_DIGIT (c) ||
(scanner_buffer[0] != '.' && (c == '.' || c == 'i' || c == 'I')))
goto number;
- if (c != EOF)
- ungetc (c, in_FILE);
+ ungetc (c, in_FILE);
goto ident;
case '#':
@@ -1667,20 +1675,23 @@
c = getc (in_FILE);
if (c == EOF)
- goto top;
+ goto out;
else if (is_RADIX (c))
goto number;
else if (c == '\\') /* #\... literal Character */
{
*id++ = c;
c = getc (in_FILE);
+ if (c == EOF)
+ goto out;
*id++ = c;
if (is_LETTER (c))
{
while (is_LETTER (c = getc (in_FILE)))
*id++ = c;
- if (c != EOF)
- ungetc (c, in_FILE);
+ if (c == EOF)
+ goto out;
+ ungetc (c, in_FILE);
}
*flags = TOK_LITERAL;
obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
@@ -1694,8 +1705,9 @@
{
while (is_LETTER (c = getc (in_FILE)))
*id++ = c;
- if (c != EOF)
- ungetc (c, in_FILE);
+ if (c == EOF)
+ goto out;
+ ungetc (c, in_FILE);
*flags = TOK_LITERAL;
obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
@@ -1712,13 +1724,17 @@
break;
}
} while (c != EOF);
+ if (c == EOF)
+ goto out;
goto top;
}
else if (c == '@') /* #@LENGTH ...^_ EMACS byte-code comment */
{
do {
c = getc (in_FILE);
- } while ( (c != EOF) && (c != '\037'));
+ if (c == EOF)
+ goto out;
+ } while (c != '\037');
goto top;
}
else if (c == '[') /* #[ ... ] EMACS byte-code object */
@@ -1742,23 +1758,24 @@
{
while (is_IDENT (c = getc (in_FILE)))
*id++ = c;
+ if (c == EOF)
+ goto out;
if (c == '[')
{
c = getc (in_FILE);
+ if (c == EOF)
+ goto out;
if (c == ']')
{
*id++ = '[';
*id++ = ']';
continue;
}
- if (c != EOF)
- ungetc (c, in_FILE);
- ungetc ('[', in_FILE);
+ ungetc (c, in_FILE);
}
break;
}
- if (c != EOF)
- ungetc (c, in_FILE);
+ ungetc (c, in_FILE);
*flags = TOK_NAME | TOK_LITERAL;
obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);
@@ -1770,8 +1787,9 @@
*id++ = c;
while (is_NUMBER (c = getc (in_FILE)))
*id++ = c;
- if (c != EOF)
- ungetc (c, in_FILE);
+ if (c == EOF)
+ goto out;
+ ungetc (c, in_FILE);
*flags = TOK_NUMBER | TOK_LITERAL;
obstack_grow0 (&tokens_obstack, scanner_buffer, id - scanner_buffer);
return (struct token *) obstack_finish (&tokens_obstack);