commit c6196297f75179fffe9568c550b8c40334daa38f
parent 66e21a355a05fd5571ee548e9db238d8bb0a56ea
Author: vaplv <vaplv@free.fr>
Date: Thu, 2 Oct 2014 15:52:11 +0200
Fix mtl comment parsing
Diffstat:
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/aw_mtl.c b/src/aw_mtl.c
@@ -460,7 +460,9 @@ parse_mtl_line(struct aw_mtl* mtl, char* line)
word = strtok_r(line, " \t", &word_tk);
if(word) {
- if(!strcmp(word, "newmtl")) { /* Material name declaration */
+ if(word[0] == '#') { /* Comment */
+ goto exit;
+ } else if(!strcmp(word, "newmtl")) { /* Material name declaration */
res = parse_newmtl(mtl, &word_tk);
} else if(mtl->newmtl == NULL) {
res = R_BAD_ARG;
diff --git a/src/aw_obj.c b/src/aw_obj.c
@@ -438,9 +438,9 @@ parse_obj_line(struct aw_obj* obj, char* line)
ASSERT(obj && line);
word = strtok_r(line, " \t", &word_tk);
- while(word) {
+ if(word) {
if(word[0] == '#') { /* Comment */
- break;
+ goto exit;
} else if(!strcmp(word, "v")) { /* Vertex position */
res = parse_floatX_in_darray(&obj->positions, 3, 4, 1.f, &word_tk);
} else if(!strcmp(word, "vn")) { /* Vertex normal */
diff --git a/src/test_aw_mtl.c b/src/test_aw_mtl.c
@@ -25,6 +25,7 @@ static void
test_common(struct aw_mtl* mtl)
{
static const char* mtl_common =
+ "#!\n"
"newmtl my_mtl\n"
"\n"
"Ka 0.0435 0.0436 0.0437\n"