diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-02-03 06:51:32 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2021-02-03 06:51:32 +0000 |
commit | c8c75c6ba1679cf8c1811b484701d8b0a261b5d8 (patch) | |
tree | 7a6eeed210d8eaa215e70b3d486ed4e3ffa28247 /Build/source/libs/gd/libgd-src/src | |
parent | 5f9f8fe99e68c0ef1fbd129019404a3c52e37e8a (diff) |
libgd 2.3.1
git-svn-id: svn://tug.org/texlive/trunk@57607 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src')
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/config.h.cmake | 2 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd.c | 12 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd.h | 5 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_bmp.c | 28 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_crop.c | 8 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_interpolation.c | 5 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_io.c | 16 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_io.h | 7 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd_nnquant.c | 32 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gdft.c | 34 |
11 files changed, 69 insertions, 86 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/CMakeLists.txt b/Build/source/libs/gd/libgd-src/src/CMakeLists.txt index 629e0fc745e..35ff4a06573 100644 --- a/Build/source/libs/gd/libgd-src/src/CMakeLists.txt +++ b/Build/source/libs/gd/libgd-src/src/CMakeLists.txt @@ -143,6 +143,12 @@ if (BUILD_STATIC_LIBS) target_link_libraries(${GD_LIB_STATIC} ${LIBGD_DEP_LIBS}) endif() +SET(LIBS_PRIVATES + ${ICONV_LIBRARIES} + ${LIQ_LIBRARIES} + ${WEBP_LIBRARIES} +) + set(GD_PROGRAMS gdcmpgif) if (PNG_FOUND) diff --git a/Build/source/libs/gd/libgd-src/src/config.h.cmake b/Build/source/libs/gd/libgd-src/src/config.h.cmake index 54f3a528907..836be470010 100644 --- a/Build/source/libs/gd/libgd-src/src/config.h.cmake +++ b/Build/source/libs/gd/libgd-src/src/config.h.cmake @@ -4,7 +4,7 @@ #cmakedefine BGDWIN32 /* Whether to support gd image formats */ -#define ENABLE_GD_FORMATS @ENABLE_GD_FORMATS@ +#cmakedefine01 ENABLE_GD_FORMATS /* Define to 1 if you have the <dirent.h> header file. */ #cmakedefine HAVE_DIRENT_H diff --git a/Build/source/libs/gd/libgd-src/src/gd.c b/Build/source/libs/gd/libgd-src/src/gd.c index 4eb2c351c30..3375eed89ef 100644 --- a/Build/source/libs/gd/libgd-src/src/gd.c +++ b/Build/source/libs/gd/libgd-src/src/gd.c @@ -1884,6 +1884,8 @@ BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->w) ? INT_MAX : x + f->w; + const int yuppper = (y > INT_MAX - f->h) ? INT_MAX : y + f->h; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1893,8 +1895,8 @@ BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; (py < (y + f->h)); py++) { - for (px = x; (px < (x + f->w)); px++) { + for (py = y; py < yuppper; py++) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel (im, px, py, color); } @@ -1913,6 +1915,8 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c int cx, cy; int px, py; int fline; + const int xuppper = (x > INT_MAX - f->h) ? INT_MAX : x + f->h; + const int ylower = (y < INT_MIN + f->w) ? INT_MIN : y - f->w; cx = 0; cy = 0; #ifdef CHARSET_EBCDIC @@ -1922,8 +1926,8 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c return; } fline = (c - f->offset) * f->h * f->w; - for (py = y; (py > (y - f->w)); py--) { - for (px = x; (px < (x + f->h)); px++) { + for (py = y; py > ylower; py--) { + for (px = x; px < xuppper; px++) { if (f->data[fline + cy * f->w + cx]) { gdImageSetPixel (im, px, py, color); } diff --git a/Build/source/libs/gd/libgd-src/src/gd.h b/Build/source/libs/gd/libgd-src/src/gd.h index 27c663edad8..4ff13a243c2 100644 --- a/Build/source/libs/gd/libgd-src/src/gd.h +++ b/Build/source/libs/gd/libgd-src/src/gd.h @@ -13,7 +13,7 @@ extern "C" { * trailing comment. */ #define GD_MAJOR_VERSION 2 /*version605b5d1778*/ #define GD_MINOR_VERSION 3 /*version605b5d1778*/ -#define GD_RELEASE_VERSION 0 /*version605b5d1778*/ +#define GD_RELEASE_VERSION 1 /*version605b5d1778*/ #define GD_EXTRA_VERSION "" /*version605b5d1778*/ /* End parsable section. */ @@ -1523,7 +1523,8 @@ BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im); BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im); BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im); -#define GD_FLIP_HORINZONTAL 1 +#define GD_FLIP_HORINZONTAL 1 /* typo, kept for BC */ +#define GD_FLIP_HORIZONTAL 1 #define GD_FLIP_VERTICAL 2 #define GD_FLIP_BOTH 3 diff --git a/Build/source/libs/gd/libgd-src/src/gd_bmp.c b/Build/source/libs/gd/libgd-src/src/gd_bmp.c index 5bef2d2ab29..e186ac951be 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_bmp.c +++ b/Build/source/libs/gd/libgd-src/src/gd_bmp.c @@ -223,10 +223,10 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) /* 8-bit colours */ if (!im->trueColor) { for(i = 0; i< im->colorsTotal; ++i) { - Putchar(gdImageBlue(im, i), out); - Putchar(gdImageGreen(im, i), out); - Putchar(gdImageRed(im, i), out); - Putchar(0, out); + gdPutC(gdImageBlue(im, i), out); + gdPutC(gdImageGreen(im, i), out); + gdPutC(gdImageRed(im, i), out); + gdPutC(0, out); } if (compression) { @@ -247,14 +247,14 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) if (compression) { *uncompressed_row++ = (unsigned char)gdImageGetPixel(im, xpos, row); } else { - Putchar(gdImageGetPixel(im, xpos, row), out); + gdPutC(gdImageGetPixel(im, xpos, row), out); } } if (!compression) { /* Add padding to make sure we have n mod 4 == 0 bytes per row */ for (xpos = padding; xpos > 0; --xpos) { - Putchar('\0', out); + gdPutC('\0', out); } } else { int compressed_size = 0; @@ -267,8 +267,8 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) gdPutBuf(uncompressed_row, compressed_size, out); - Putchar(BMP_RLE_COMMAND, out); - Putchar(BMP_RLE_ENDOFLINE, out); + gdPutC(BMP_RLE_COMMAND, out); + gdPutC(BMP_RLE_ENDOFLINE, out); bitmap_size += 2; } } @@ -279,8 +279,8 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) goto cleanup; } /* Update filesize based on new values and set compression flag */ - Putchar(BMP_RLE_COMMAND, out); - Putchar(BMP_RLE_ENDOFBITMAP, out); + gdPutC(BMP_RLE_COMMAND, out); + gdPutC(BMP_RLE_ENDOFBITMAP, out); bitmap_size += 2; /* Write new total bitmap size */ @@ -297,14 +297,14 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression) for (xpos = 0; xpos < im->sx; xpos++) { pixel = gdImageGetPixel(im, xpos, row); - Putchar(gdTrueColorGetBlue(pixel), out); - Putchar(gdTrueColorGetGreen(pixel), out); - Putchar(gdTrueColorGetRed(pixel), out); + gdPutC(gdTrueColorGetBlue(pixel), out); + gdPutC(gdTrueColorGetGreen(pixel), out); + gdPutC(gdTrueColorGetRed(pixel), out); } /* Add padding to make sure we have n mod 4 == 0 bytes per row */ for (xpos = padding; xpos > 0; --xpos) { - Putchar('\0', out); + gdPutC('\0', out); } } } diff --git a/Build/source/libs/gd/libgd-src/src/gd_crop.c b/Build/source/libs/gd/libgd-src/src/gd_crop.c index 68f58c695cc..05a1dce1701 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_crop.c +++ b/Build/source/libs/gd/libgd-src/src/gd_crop.c @@ -290,10 +290,10 @@ static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color) } else { register int r,b,g,a; - r = (int)(0.5f + (gdImageRed(im, tl) + gdImageRed(im, tr) + gdImageRed(im, bl) + gdImageRed(im, br)) / 4); - g = (int)(0.5f + (gdImageGreen(im, tl) + gdImageGreen(im, tr) + gdImageGreen(im, bl) + gdImageGreen(im, br)) / 4); - b = (int)(0.5f + (gdImageBlue(im, tl) + gdImageBlue(im, tr) + gdImageBlue(im, bl) + gdImageBlue(im, br)) / 4); - a = (int)(0.5f + (gdImageAlpha(im, tl) + gdImageAlpha(im, tr) + gdImageAlpha(im, bl) + gdImageAlpha(im, br)) / 4); + r = (2 + gdImageRed(im, tl) + gdImageRed(im, tr) + gdImageRed(im, bl) + gdImageRed(im, br)) / 4; + g = (2 + gdImageGreen(im, tl) + gdImageGreen(im, tr) + gdImageGreen(im, bl) + gdImageGreen(im, br)) / 4; + b = (2 + gdImageBlue(im, tl) + gdImageBlue(im, tr) + gdImageBlue(im, bl) + gdImageBlue(im, br)) / 4; + a = (2 + gdImageAlpha(im, tl) + gdImageAlpha(im, tr) + gdImageAlpha(im, bl) + gdImageAlpha(im, br)) / 4; *color = gdImageColorClosestAlpha(im, r, g, b, a); return 0; } diff --git a/Build/source/libs/gd/libgd-src/src/gd_interpolation.c b/Build/source/libs/gd/libgd-src/src/gd_interpolation.c index 21f7315f10a..73407fdd1f3 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_interpolation.c +++ b/Build/source/libs/gd/libgd-src/src/gd_interpolation.c @@ -1988,7 +1988,8 @@ BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst, static int getPixelRgbInterpolated(gdImagePtr im, const int tcolor) { unsigned char r, g, b, a; - int ct, i; + int ct; + int i; b = (unsigned char)tcolor; g = (unsigned char)(tcolor >> 8); @@ -2001,7 +2002,7 @@ static int getPixelRgbInterpolated(gdImagePtr im, const int tcolor) a = CLAMP(a, 0, 127); for (i = 0; i < im->colorsTotal; i++) { - if (im->red[i] == r && im->green[i] == g && im->blue[i] == b && im->alpha[i] == a) { + if (im->red[i] == r && im->green[i] == g && im->blue[i] == b && im->alpha[i] == a) { return i; } } diff --git a/Build/source/libs/gd/libgd-src/src/gd_io.c b/Build/source/libs/gd/libgd-src/src/gd_io.c index 4cb1adefcdb..94032771efc 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_io.c +++ b/Build/source/libs/gd/libgd-src/src/gd_io.c @@ -28,22 +28,6 @@ return 0; \ } -/* - * Write out a word to the I/O context pointer - */ -void Putword(int w, gdIOCtx *ctx) -{ - unsigned char buf[2]; - buf[0] = w & 0xff; - buf[1] = (w / 256) & 0xff; - (ctx->putBuf)(ctx, (char *)buf, 2); -} - -void Putchar(int c, gdIOCtx *ctx) -{ - (ctx->putC)(ctx, c & 0xff); -} - void gdPutC(const unsigned char c, gdIOCtx *ctx) { (ctx->putC)(ctx, c); diff --git a/Build/source/libs/gd/libgd-src/src/gd_io.h b/Build/source/libs/gd/libgd-src/src/gd_io.h index c7a5025591f..df37fccb8d5 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_io.h +++ b/Build/source/libs/gd/libgd-src/src/gd_io.h @@ -7,10 +7,6 @@ extern "C" { #endif -#ifdef VMS -# define Putchar gdPutchar -#endif - /* Group: Types @@ -74,9 +70,6 @@ typedef struct gdIOCtx { typedef struct gdIOCtx *gdIOCtxPtr; -void Putword(int w, gdIOCtx *ctx); -void Putchar(int c, gdIOCtx *ctx); - void gdPutC(const unsigned char c, gdIOCtx *ctx); int gdPutBuf(const void *, int, gdIOCtx *); void gdPutWord(int w, gdIOCtx *ctx); diff --git a/Build/source/libs/gd/libgd-src/src/gd_nnquant.c b/Build/source/libs/gd/libgd-src/src/gd_nnquant.c index 9129d84f354..8b9aa7945b8 100644 --- a/Build/source/libs/gd/libgd-src/src/gd_nnquant.c +++ b/Build/source/libs/gd/libgd-src/src/gd_nnquant.c @@ -65,7 +65,6 @@ /* defs for decreasing alpha factor */ #define alphabiasshift 10 /* alpha starts at 1.0 */ #define initalpha (((int) 1)<<alphabiasshift) -int alphadec; /* radbias and alpharadbias used for radpower calculation */ #define radbiasshift 8 @@ -113,7 +112,7 @@ typedef struct { /* Initialise network in range (0,0,0,0) to (255,255,255,255) and set parameters ----------------------------------------------------------------------- */ -void initnet(nnq, thepic, len, sample, colours) +static void initnet(nnq, thepic, len, sample, colours) nn_quant *nnq; unsigned char *thepic; int len; @@ -147,7 +146,7 @@ int colours; */ /* -------------------------- */ -void unbiasnet(nn_quant *nnq) +static void unbiasnet(nn_quant *nnq) { int i,j,temp; @@ -163,21 +162,8 @@ void unbiasnet(nn_quant *nnq) } } -/* Output colour map - ----------------- */ -void writecolourmap(nnq, f) -nn_quant *nnq; -FILE *f; -{ - int i,j; - - for (i=3; i>=0; i--) - for (j=0; j < nnq->netsize; j++) - putc(nnq->network[j][i], f); -} - /* Output colormap to unsigned char ptr in RGBA format */ -void getcolormap(nnq, map) +static void getcolormap(nnq, map) nn_quant *nnq; unsigned char *map; { @@ -192,7 +178,7 @@ unsigned char *map; /* Insertion sort of network and building of netindex[0..255] (to do after unbias) ------------------------------------------------------------------------------- */ -void inxbuild(nn_quant *nnq) +static void inxbuild(nn_quant *nnq) { register int i,j,smallpos,smallval; register int *p,*q; @@ -246,7 +232,7 @@ void inxbuild(nn_quant *nnq) /* Search for ABGR values 0..255 (after net is unbiased) and return colour index ---------------------------------------------------------------------------- */ -unsigned int inxsearch(nnq, al,b,g,r) +static unsigned int inxsearch(nnq, al,b,g,r) nn_quant *nnq; register int al, b, g, r; { @@ -320,7 +306,7 @@ register int al, b, g, r; /* Search for biased ABGR values ---------------------------- */ -int contest(nnq, al,b,g,r) +static int contest(nnq, al,b,g,r) nn_quant *nnq; register int al,b,g,r; { @@ -376,7 +362,7 @@ register int al,b,g,r; /* Move neuron i towards biased (a,b,g,r) by factor alpha ---------------------------------------------------- */ -void altersingle(nnq, alpha,i,al,b,g,r) +static void altersingle(nnq, alpha,i,al,b,g,r) nn_quant *nnq; register int alpha,i,al,b,g,r; { @@ -396,7 +382,7 @@ register int alpha,i,al,b,g,r; /* Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|] --------------------------------------------------------------------------------- */ -void alterneigh(nnq, rad,i,al,b,g,r) +static void alterneigh(nnq, rad,i,al,b,g,r) nn_quant *nnq; int rad,i; register int al,b,g,r; @@ -443,7 +429,7 @@ register int al,b,g,r; /* Main Learning Loop ------------------ */ -void learn(nnq, verbose) /* Stu: N.B. added parameter so that main() could control verbosity. */ +static void learn(nnq, verbose) /* Stu: N.B. added parameter so that main() could control verbosity. */ nn_quant *nnq; int verbose; { diff --git a/Build/source/libs/gd/libgd-src/src/gdft.c b/Build/source/libs/gd/libgd-src/src/gdft.c index 98e74fa346c..f84cada6840 100644 --- a/Build/source/libs/gd/libgd-src/src/gdft.c +++ b/Build/source/libs/gd/libgd-src/src/gdft.c @@ -441,14 +441,23 @@ typedef struct { uint32_t cluster; } glyphInfo; -static size_t +static ssize_t textLayout(uint32_t *text, int len, FT_Face face, gdFTStringExtraPtr strex, glyphInfo **glyph_info) { +#ifndef HAVE_LIBRAQM + FT_UInt glyph_index = 0, previous = 0; + FT_Vector delta; + FT_Error err; +#endif size_t count; glyphInfo *info; + if (!len) { + return 0; + } + #ifdef HAVE_LIBRAQM size_t i; raqm_glyph_t *glyphs; @@ -459,19 +468,19 @@ textLayout(uint32_t *text, int len, !raqm_set_par_direction (rq, RAQM_DIRECTION_DEFAULT) || !raqm_layout (rq)) { raqm_destroy (rq); - return 0; + return -1; } glyphs = raqm_get_glyphs (rq, &count); if (!glyphs) { raqm_destroy (rq); - return 0; + return -1; } info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * count); if (!info) { raqm_destroy (rq); - return 0; + return -1; } for (i = 0; i < count; i++) { @@ -484,12 +493,9 @@ textLayout(uint32_t *text, int len, raqm_destroy (rq); #else - FT_UInt glyph_index = 0, previous = 0; - FT_Vector delta; - FT_Error err; info = (glyphInfo*) gdMalloc (sizeof (glyphInfo) * len); if (!info) { - return 0; + return -1; } for (count = 0; count < len; count++) { /* Convert character code to glyph index */ @@ -508,7 +514,7 @@ textLayout(uint32_t *text, int len, err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT); if (err) { gdFree (info); - return 0; + return -1; } info[count].index = glyph_index; info[count].x_offset = 0; @@ -527,7 +533,7 @@ textLayout(uint32_t *text, int len, #endif *glyph_info = info; - return count; + return count <= SSIZE_MAX ? count : -1; } /********************************************************************/ @@ -1108,7 +1114,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const c char *tmpstr = 0; uint32_t *text; glyphInfo *info = NULL; - size_t count; + ssize_t count; int render = (im && (im->trueColor || (fg <= 255 && fg >= -255))); FT_BitmapGlyph bm; /* 2.0.13: Bob Ostermann: don't force autohint, that's just for testing @@ -1409,7 +1415,7 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const c count = textLayout (text , i, face, strex, &info); - if (!count) { + if (count < 0) { gdFree (text); gdFree (tmpstr); gdCacheDelete (tc_cache); @@ -1568,7 +1574,9 @@ BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const c } gdFree(text); - gdFree(info); + if (info) { + gdFree(info); + } /* Save the (unkerned) advance from the last character in the xshow vector */ if (strex && (strex->flags & gdFTEX_XSHOW) && strex->xshow) { |