skip comments in pnm header

This commit is contained in:
David Rose 2009-05-05 17:46:51 +00:00
parent be1213fa71
commit 433a4f2989
1 changed files with 10 additions and 2 deletions

View File

@ -191,11 +191,19 @@ pm_getuint(istream * const ifP) {
-----------------------------------------------------------------------------*/
char ch;
unsigned int i;
// skip whitespace
do {
ch = ifP->get();
} while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
if (ch == '#') {
// Skip a comment
do {
ch = ifP->get();
} while (ch != EOF && ch != '\n');
}
} while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r');
if (ch < '0' || ch > '9')
pm_error("junk in file where an unsigned integer should be");