From 433a4f29899099a809c34db7239059993a74995b Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 5 May 2009 17:46:51 +0000 Subject: [PATCH] skip comments in pnm header --- panda/src/pnmimagetypes/pnmFileTypePNM.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index a0ffa74b94..9b075f1d46 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -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");