From 0615df6c9b1eadfcbd0e65a6ca1f4ae3947919ee Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sun, 8 Nov 2015 00:45:17 -0800 Subject: [PATCH] allows comments in pgm/ppm headers --- stb_image.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stb_image.h b/stb_image.h index 0a9de39..354807b 100644 --- a/stb_image.h +++ b/stb_image.h @@ -195,7 +195,7 @@ Omar Cornut (1/2/4-bit PNG) Ken Hamada Nicolas Guillemot (vertical flip) Cort Stratton Richard Mitton (16-bit PSD) Blazej Dariusz Roszkowski - Thibault Reuille + Junggon Kim (PNM comments) Thibault Reuille Paul Du Bois Guillaume George Jerry Jansson @@ -6222,8 +6222,16 @@ static int stbi__pnm_isspace(char c) static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { - while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) - *c = (char) stbi__get8(s); + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char) stbi__get8(s); + + if (stbi__at_eof(s) || *c != '#') + break; + + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) + *c = (char) stbi__get8(s); + } } static int stbi__pnm_isdigit(char c)