diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2016-04-26 14:50:33 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2016-04-26 14:50:33 +1200 |
commit | f342f3019d38f0faf737bf89631651837a66cd06 (patch) | |
tree | a88850c0f0304d1dcc8f83c084ad643174248036 | |
parent | 94db04e182dc78df6fa75f8e9c97b81c59c15b4b (diff) | |
download | pgm-interlace-f342f3019d38f0faf737bf89631651837a66cd06.tar.xz |
Handle comments as whitespace
-rw-r--r-- | pgm-interlace.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/pgm-interlace.c b/pgm-interlace.c index 9c8e417..5f74daf 100644 --- a/pgm-interlace.c +++ b/pgm-interlace.c @@ -77,9 +77,23 @@ void read_whitespace(FILE *fd) do { c = fgetc(fd); - } while (isspace(c)); + if (isspace(c)) + continue; - ungetc(c, fd); + switch (c) + { + case '#': + /* suck up the current line of the file */ + while (c != '\n' && c != '\r' && c != EOF) + c = fgetc(fd); + break; + + default: + ungetc(c, fd); + case EOF: + break; + } + } while (isspace(c) || c == '#'); } int read_token(FILE *fd, char *token, size_t token_size, const char *allowable) |