diff options
Diffstat (limited to 'generator/pamtris/input.c')
-rw-r--r-- | generator/pamtris/input.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/generator/pamtris/input.c b/generator/pamtris/input.c index c35359b4..f38d4a39 100644 --- a/generator/pamtris/input.c +++ b/generator/pamtris/input.c @@ -10,6 +10,7 @@ #include <ctype.h> #include "netpbm/mallocvar.h" +#include "netpbm/pm.h" #include "limits_pamtris.h" #include "framebuffer.h" @@ -37,7 +38,7 @@ #define WARNING_EXCESS_ARGS "warning: ignoring excess arguments: line %lu." #define SYNTAX_ERROR "syntax error: line %lu." - + typedef struct { Xy v_xy; /* X- and Y-coordinates of the vertices for the current triangle. @@ -80,9 +81,8 @@ clear_attribs(state_info * const si, void init_input_processor(input_info * const ii) { - MALLOCARRAY_NOFAIL(ii->buffer, 128); - - ii->length = 128; + ii->buffer = NULL; + ii->length = 0; ii->number = 1; } @@ -90,7 +90,9 @@ init_input_processor(input_info * const ii) { void free_input_processor(input_info * const ii) { - free(ii->buffer); + + if (ii->buffer) + free(ii->buffer); } @@ -233,8 +235,14 @@ process_next_command(input_info * const line, state.initialized = true; } - if (getline(&line->buffer, &line->length, stdin) == -1) { - return 0; + { + int eof; + size_t lineLen; + + pm_getline(stdin, &line->buffer, &line->length, &eof, &lineLen); + + if (eof) + return 0; } remove_comments(line->buffer); |