diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-05-30 19:40:34 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2011-05-30 19:40:34 +0000 |
commit | b6deb8939611b2aea5ca42c1d9effebd1ec4e671 (patch) | |
tree | e38046876433d6ef49122165850ebd892e2d6732 | |
parent | 178d7e26b40d60504c28879b5d4bd493e5c65327 (diff) | |
download | netpbm-mirror-b6deb8939611b2aea5ca42c1d9effebd1ec4e671.tar.gz netpbm-mirror-b6deb8939611b2aea5ca42c1d9effebd1ec4e671.tar.xz netpbm-mirror-b6deb8939611b2aea5ca42c1d9effebd1ec4e671.zip |
Fail gracefully when multiple inputs are Standard Input
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1493 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-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); } } |