From bb62d1024321fa0552ef5b9f27b91660ec370ea0 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 7 Oct 2018 02:26:12 +0000 Subject: Use pm_getline instead of getline for systems that don't have getline git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3392 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- generator/pamtris/input.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'generator') 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 #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); -- cgit 1.4.1