From 2468696c1739c475cb95a49813599a567f65219f Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 28 Dec 2023 19:47:49 +0000 Subject: Release 10.86.40 git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@4823 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- doc/HISTORY | 14 ++++++++++++ editor/pnmconvol.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++- editor/pnmpad.c | 8 +++++-- lib/util/nstring.c | 1 + version.mk | 2 +- 5 files changed, 83 insertions(+), 4 deletions(-) diff --git a/doc/HISTORY b/doc/HISTORY index 5e548f31..8efa7be7 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,20 @@ Netpbm. CHANGE HISTORY -------------- +23.12.28 BJH Release 10.86.40 + + pnmconvol: Restore ability of convolution matrix to be a + pseudo-plain-PNM with samples that exceed the maxval. Lost in + 10.30 (October 2005) because maxval-checking code was added to + libnetpbm. (Was fixed in 10.47.08 in November 2010, but only in + the 10.47 series). + + pnmpad: fix wrong results with old-style options (e.g. "-t50"). + + pnmpad: fix behavior with -left, -right, and -width together or + -top, -bottom, -height together: ignores -width where it should + fail. Broken in Netpbm 10.72 (September 2015). + 23.09.27 BJH Release 10.86.39 pamtosvg: fix hang. diff --git a/editor/pnmconvol.c b/editor/pnmconvol.c index b1d8e025..ffcdc15d 100644 --- a/editor/pnmconvol.c +++ b/editor/pnmconvol.c @@ -616,6 +616,64 @@ normalizeKernel(struct ConvKernel * const convKernelP) { +static void +readPseudoPnmKernel(FILE * const fileP, + struct pam * const pamP, + tuple *** const tuplesP) { +/*---------------------------------------------------------------------------- + Read in the pseudo-PNM that is the convolution matrix. + + This is essentially pnm_readpam(), except that it can take sample values + that exceed the maxval, which is not legal in PNM. That's why it's + psuedo-PNM and not true PNM. +-----------------------------------------------------------------------------*/ + + /* pm_getuint() is supposed to be internal to libnetpbm, but since we're + doing this backward compatibility hack here, we use it anyway. + */ + + unsigned int + pm_getuint(FILE * const file); + + tuple ** tuples; + unsigned int row; + + pnm_readpaminit(fileP, pamP, PAM_STRUCT_SIZE(tuple_type)); + + tuples = pnm_allocpamarray(pamP); + + for (row = 0; row < pamP->height; ++row) { + if (pamP->format == PGM_FORMAT || pamP->format == PPM_FORMAT) { + /* Plain format -- can't use pnm_readpnmrow() because it will + reject a sample > maxval + */ + unsigned int col; + for (col = 0; col < pamP->width; ++col) { + switch (pamP->format) { + case PGM_FORMAT: + tuples[row][col][0] = pm_getuint(fileP); + break; + case PPM_FORMAT: + tuples[row][col][PAM_RED_PLANE] = pm_getuint(fileP); + tuples[row][col][PAM_GRN_PLANE] = pm_getuint(fileP); + tuples[row][col][PAM_BLU_PLANE] = pm_getuint(fileP); + break; + default: + assert(false); + } + } + } else { + /* Raw or PBM format -- pnm_readpnmrow() won't do any maxval + checking + */ + pnm_readpamrow(pamP, tuples[row]); + } + } + *tuplesP = tuples; +} + + + static void getKernelPnm(const char * const fileName, unsigned int const depth, @@ -639,12 +697,14 @@ getKernelPnm(const char * const fileName, cifP = pm_openr(fileName); /* Read in the convolution matrix. */ - ctuples = pnm_readpam(cifP, &cpam, PAM_STRUCT_SIZE(tuple_type)); + readPseudoPnmKernel(cifP, &cpam, &ctuples); pm_close(cifP); validateKernelDimensions(cpam.width, cpam.height); convKernelCreatePnm(&cpam, ctuples, depth, offset, convKernelPP); + + pnm_freepamarray(ctuples, &cpam); } diff --git a/editor/pnmpad.c b/editor/pnmpad.c index 7cc53b69..d7c31142 100644 --- a/editor/pnmpad.c +++ b/editor/pnmpad.c @@ -186,6 +186,10 @@ parseCommandLineOld(int argc, const char ** argv, cmdlineP->left = cmdlineP->right = cmdlineP->top = cmdlineP->bottom = 0; cmdlineP->xalign = cmdlineP->yalign = 0.5; cmdlineP->white = cmdlineP->verbose = FALSE; + cmdlineP->reportonly = FALSE; + cmdlineP->topSpec = cmdlineP->bottomSpec = + cmdlineP->leftSpec = cmdlineP->rightSpec = TRUE; + cmdlineP->mwidth = cmdlineP->mheight = 1; while (argc >= 2 && argv[1][0] == '-') { if (strcmp(argv[1]+1,"black") == 0) cmdlineP->white = FALSE; @@ -297,8 +301,8 @@ computePadSizeBeforeMult(unsigned int const unpaddedSize, -----------------------------------------------------------------------------*/ if (sizeSpec) { if (begPadSpec && endPadSpec) { - if (begPadReq + unpaddedSize + endPadReq < unpaddedSize) { - pm_error("Beginning adding (%u), and end " + if (begPadReq + unpaddedSize + endPadReq < sizeReq) { + pm_error("Beginning padding (%u), and end " "padding (%u) are insufficient to bring the " "image size of %u up to %u.", begPadReq, endPadReq, unpaddedSize, sizeReq); diff --git a/lib/util/nstring.c b/lib/util/nstring.c index aff90ff3..d546ff2b 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -106,6 +106,7 @@ #define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ +#define _C99_SOURCE /* Make sure snprintf() is in stdio.h */ #define _XOPEN_SOURCE 500 /* Make sure strdup() is in string.h */ #define _BSD_SOURCE /* Make sure strdup() is in string.h */ #define _GNU_SOURCE diff --git a/version.mk b/version.mk index abcc52cd..e899f7f3 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 86 -NETPBM_POINT_RELEASE = 39 +NETPBM_POINT_RELEASE = 40 -- cgit 1.4.1