diff options
-rw-r--r-- | doc/HISTORY | 3 | ||||
-rw-r--r-- | editor/pnmcat.c | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/doc/HISTORY b/doc/HISTORY index 57e0c69f..4d1a53b0 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -22,6 +22,9 @@ not yet BJH Release 10.55.00 pnmtops: fix floating point exception or bogus width/height too large error. Introduced in 10.53. + pnmcat: Fix garbage output when multiple input image are from + Standard Input (now it just fails gracefully). + Build: Pnmtopng, Pamrgbatopng compile with newer libpng, as they no longer refer to private members of the pnginfo structure. diff --git a/editor/pnmcat.c b/editor/pnmcat.c index 8e29f52a..6d970c8f 100644 --- a/editor/pnmcat.c +++ b/editor/pnmcat.c @@ -16,6 +16,7 @@ #include "mallocvar.h" #include "shhopt.h" #include "bitarith.h" +#include "nstring.h" #include "pnm.h" #define LEFTBITS pm_byteLeftBits @@ -153,12 +154,20 @@ parseCommandLine(int argc, const char ** const argv, cmdlineP->nfiles = 1; } else { unsigned int i; + unsigned int stdinCt; + /* Number of input files user specified as Standard Input */ MALLOCARRAY_NOFAIL(cmdlineP->inputFilespec, argc-1); - for (i = 0; i < argc-1; ++i) + for (i = 0, stdinCt = 0; i < argc-1; ++i) { cmdlineP->inputFilespec[i] = argv[1+i]; + if (streq(argv[1+i], "-")) + ++stdinCt; + } cmdlineP->nfiles = argc-1; + if (stdinCt > 1) + pm_error("At most one input image can come from Standard Input. " + "You specified %u", stdinCt); } } |