Strip \r and whitespace from input; fixes bug 3454.
This commit is contained in:
parent
69a3fc78e2
commit
cf5cf4cadb
|
@ -1,5 +1,10 @@
|
||||||
2006-02-21 Patrick Lam <plam@mit.edu>
|
2006-02-21 Patrick Lam <plam@mit.edu>
|
||||||
* fc-lang/fc-lang.c:
|
* fc-lang/fc-lang.c (scan):
|
||||||
|
|
||||||
|
Strip \r and whitespace from input; fixes bug 3454.
|
||||||
|
|
||||||
|
2006-02-21 Patrick Lam <plam@mit.edu>
|
||||||
|
* fc-lang/fc-lang.c (main):
|
||||||
|
|
||||||
Allocate large arrays statically in fc-lang to fix crashes under
|
Allocate large arrays statically in fc-lang to fix crashes under
|
||||||
MinGW/MSYS.
|
MinGW/MSYS.
|
||||||
|
|
|
@ -80,12 +80,18 @@ static char *
|
||||||
get_line (FILE *f, char *line, int *lineno)
|
get_line (FILE *f, char *line, int *lineno)
|
||||||
{
|
{
|
||||||
char *hash;
|
char *hash;
|
||||||
|
int end;
|
||||||
if (!fgets (line, 1024, f))
|
if (!fgets (line, 1024, f))
|
||||||
return 0;
|
return 0;
|
||||||
++(*lineno);
|
++(*lineno);
|
||||||
hash = strchr (line, '#');
|
hash = strchr (line, '#');
|
||||||
if (hash)
|
if (hash)
|
||||||
*hash = '\0';
|
*hash = '\0';
|
||||||
|
|
||||||
|
end = strlen (line);
|
||||||
|
while (end > 0 && isspace (line[end-1]))
|
||||||
|
line[--end] = '\0';
|
||||||
|
|
||||||
if (line[0] == '\0' || line[0] == '\n' || line[0] == '\032' || line[0] == '\r')
|
if (line[0] == '\0' || line[0] == '\n' || line[0] == '\032' || line[0] == '\r')
|
||||||
return get_line (f, line, lineno);
|
return get_line (f, line, lineno);
|
||||||
return line;
|
return line;
|
||||||
|
@ -134,11 +140,8 @@ scan (FILE *f, char *file)
|
||||||
if (!strncmp (line, "include", 7))
|
if (!strncmp (line, "include", 7))
|
||||||
{
|
{
|
||||||
file = strchr (line, ' ');
|
file = strchr (line, ' ');
|
||||||
while (*file == ' ')
|
while (isspace(*file))
|
||||||
file++;
|
file++;
|
||||||
end = strlen (file);
|
|
||||||
if (file[end-1] == '\n')
|
|
||||||
file[end-1] = '\0';
|
|
||||||
f = scanopen (file);
|
f = scanopen (file);
|
||||||
if (!f)
|
if (!f)
|
||||||
fatal (file, 0, "can't open");
|
fatal (file, 0, "can't open");
|
||||||
|
|
Loading…
Reference in New Issue