diff options
Diffstat (limited to 'editor/pamdice.c')
-rw-r--r-- | editor/pamdice.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/editor/pamdice.c b/editor/pamdice.c index f4b05a8d..32881129 100644 --- a/editor/pamdice.c +++ b/editor/pamdice.c @@ -84,7 +84,9 @@ parseCommandLine(int argc, char ** argv, /* Uses and sets argc, argv, and some of *cmdline_p and others. */ if (cmdlineP->sliceVertically) { - if (hoverlapSpec) { + if (cmdlineP->width < 1) + pm_error("-width value must not be zero"); + else if (hoverlapSpec) { if (cmdlineP->hoverlap > cmdlineP->width - 1) pm_error("-hoverlap value must be less than -width (%u). " "You specified %u.", @@ -93,7 +95,9 @@ parseCommandLine(int argc, char ** argv, cmdlineP->hoverlap = 0; } if (cmdlineP->sliceHorizontally) { - if (voverlapSpec) { + if (cmdlineP->height < 1) + pm_error("-height value must not be zero"); + else if (voverlapSpec) { if (cmdlineP->voverlap > cmdlineP->height - 1) pm_error("-voverlap value must be less than -height (%u). " "You specified %u.", @@ -209,7 +213,6 @@ ndigits(unsigned int const arg) { static void computeOutputFilenameFormat(int const format, - char const outstem[], unsigned int const nHorizSlice, unsigned int const nVertSlice, const char ** const filenameFormatP) { @@ -224,9 +227,8 @@ computeOutputFilenameFormat(int const format, default: filenameSuffix = ""; break; } - pm_asprintf(filenameFormatP, "%s_%%0%uu_%%0%uu.%s", - outstem, ndigits(nHorizSlice), ndigits(nVertSlice), - filenameSuffix); + pm_asprintf(filenameFormatP, "%%s_%%0%uu_%%0%uu.%s", + ndigits(nHorizSlice), ndigits(nVertSlice), filenameSuffix); if (*filenameFormatP == NULL) pm_error("Unable to allocate memory for filename format string"); @@ -253,13 +255,13 @@ openOutStreams(struct pam const inpam, const char * filenameFormat; unsigned int vertSlice; - computeOutputFilenameFormat(inpam.format, outstem, nHorizSlice, nVertSlice, + computeOutputFilenameFormat(inpam.format, nHorizSlice, nVertSlice, &filenameFormat); for (vertSlice = 0; vertSlice < nVertSlice; ++vertSlice) { const char * filename; - pm_asprintf(&filename, filenameFormat, horizSlice, vertSlice); + pm_asprintf(&filename, filenameFormat, outstem, horizSlice, vertSlice); if (filename == NULL) pm_error("Unable to allocate memory for output filename"); |