summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Lam <plam@MIT.EDU>2006-02-22 04:50:16 +0000
committerPatrick Lam <plam@MIT.EDU>2006-02-22 04:50:16 +0000
commitcf5cf4cadb35c7ebabf025bf6781f69c390548c8 (patch)
tree7902e02333065a807d04da4b4b8e0e6bc2f9d217
parent69a3fc78e233957f9e1f6737eccada1494a937ae (diff)
Strip \r and whitespace from input; fixes bug 3454.
-rw-r--r--ChangeLog7
-rw-r--r--fc-lang/fc-lang.c11
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5265c6d9..4aec46da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
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
MinGW/MSYS.
diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c
index ebb85395..1efd0c1f 100644
--- a/fc-lang/fc-lang.c
+++ b/fc-lang/fc-lang.c
@@ -80,12 +80,18 @@ static char *
get_line (FILE *f, char *line, int *lineno)
{
char *hash;
+ int end;
if (!fgets (line, 1024, f))
return 0;
++(*lineno);
hash = strchr (line, '#');
if (hash)
*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')
return get_line (f, line, lineno);
return line;
@@ -134,11 +140,8 @@ scan (FILE *f, char *file)
if (!strncmp (line, "include", 7))
{
file = strchr (line, ' ');
- while (*file == ' ')
+ while (isspace(*file))
file++;
- end = strlen (file);
- if (file[end-1] == '\n')
- file[end-1] = '\0';
f = scanopen (file);
if (!f)
fatal (file, 0, "can't open");