diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-10-07 02:26:12 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-10-07 02:26:12 +0000 |
commit | bb62d1024321fa0552ef5b9f27b91660ec370ea0 (patch) | |
tree | 1d17f34374904280c967bda6e4509c15475eca3f | |
parent | b3bcf33e9f1a9487c0bdbcc0507cc5fd22369af8 (diff) | |
download | netpbm-mirror-bb62d1024321fa0552ef5b9f27b91660ec370ea0.tar.gz netpbm-mirror-bb62d1024321fa0552ef5b9f27b91660ec370ea0.tar.xz netpbm-mirror-bb62d1024321fa0552ef5b9f27b91660ec370ea0.zip |
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
-rw-r--r-- | doc/HISTORY | 2 | ||||
-rw-r--r-- | generator/pamtris/input.c | 22 |
2 files changed, 17 insertions, 7 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index ce7707e3..0e679164 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -22,6 +22,8 @@ not yet BJH Release 10.85.00 pjtoppm, pbmtoppa: fix arithmetic overflow. + Build: fix reference to nonexistent getline on Mac OS X 10.6. + Build: fix reference to nonexistent strndup on Mac OS X 10.6. 18.09.29 BJH Release 10.84.00 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); |