diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-08-07 09:40:46 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-08-07 09:40:46 +0000 |
commit | 8b7e4f1d418846b3681d1cc941d54451a9f2d9e7 (patch) | |
tree | ca6320b524a4b9c7598beb98a9b4bb6991ce5eb0 /Build/source/libs/potrace/potrace-src/src | |
parent | b3095594d0adae5c8c7311c0650f9f32814668de (diff) |
potrace 1.15
git-svn-id: svn://tug.org/texlive/trunk@44972 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/potrace/potrace-src/src')
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/Makefile.am | 6 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/backend_eps.c | 8 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/bitmap_io.c | 12 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/decompose.c | 8 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/getopt.c | 20 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/getopt1.c | 20 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/greymap.c | 12 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/greymap.h | 2 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/include/getopt/getopt.h (renamed from Build/source/libs/potrace/potrace-src/src/getopt.h) | 0 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/main.c | 26 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/mkbitmap.c | 12 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/potracelib.h | 2 | ||||
-rw-r--r-- | Build/source/libs/potrace/potrace-src/src/trace.c | 6 |
13 files changed, 59 insertions, 75 deletions
diff --git a/Build/source/libs/potrace/potrace-src/src/Makefile.am b/Build/source/libs/potrace/potrace-src/src/Makefile.am index 1f657e08897..e83bfc14fe1 100644 --- a/Build/source/libs/potrace/potrace-src/src/Makefile.am +++ b/Build/source/libs/potrace/potrace-src/src/Makefile.am @@ -32,6 +32,8 @@ potracelib_demo_SOURCES = potracelib_demo.c potracelib_demo_LDADD = libpotrace.la -lm potracelib_demo_DEPENDENCIES = libpotrace.la +AM_CPPFLAGS = @EXTRA_INCLUDES@ + #---------------------------------------------------------------------- # Potrace library: @@ -42,7 +44,7 @@ libsources = curve.c curve.h trace.c trace.h decompose.c \ lib_LTLIBRARIES = $(INSTLIBS) EXTRA_LTLIBRARIES = libpotrace.la libpotrace_la_SOURCES = $(libsources) -libpotrace_la_LDFLAGS = -version-info 0:4:0 -rpath '$(libdir)' \ +libpotrace_la_LDFLAGS = -version-info 0:5:0 -rpath '$(libdir)' \ -export-symbols $(srcdir)/libpotrace-export.sym -no-undefined libpotrace_la_LIBADD = -lm MOSTLYCLEANFILES = libpotrace.la @@ -54,4 +56,4 @@ EXTRA_HEADERS = potracelib.h #---------------------------------------------------------------------- # other stuff to distribute -EXTRA_DIST = getopt.c getopt1.c getopt.h libpotrace-export.sym +EXTRA_DIST = getopt.c getopt1.c include/getopt/getopt.h libpotrace-export.sym diff --git a/Build/source/libs/potrace/potrace-src/src/backend_eps.c b/Build/source/libs/potrace/potrace-src/src/backend_eps.c index 8cfb91ef218..d1f0cf3bec9 100644 --- a/Build/source/libs/potrace/potrace-src/src/backend_eps.c +++ b/Build/source/libs/potrace/potrace-src/src/backend_eps.c @@ -8,7 +8,13 @@ output. Postscript compression is optionally supplied via the functions in flate.c. */ -#define _XOPEN_SOURCE 500 +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE 1 +#endif #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/Build/source/libs/potrace/potrace-src/src/bitmap_io.c b/Build/source/libs/potrace/potrace-src/src/bitmap_io.c index 26c532e2b3c..f965b733212 100644 --- a/Build/source/libs/potrace/potrace-src/src/bitmap_io.c +++ b/Build/source/libs/potrace/potrace-src/src/bitmap_io.c @@ -689,11 +689,11 @@ static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; - BM_UPUT(bm, x, y, col[i&1]); + BM_PUT(bm, x, y, col[i&1]); x++; } } else if (c == 0) { @@ -719,7 +719,7 @@ static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; @@ -747,11 +747,11 @@ static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; - BM_UPUT(bm, x, y, COLTABLE(c)); + BM_PUT(bm, x, y, COLTABLE(c)); x++; } } else if (c == 0) { @@ -775,7 +775,7 @@ static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; diff --git a/Build/source/libs/potrace/potrace-src/src/decompose.c b/Build/source/libs/potrace/potrace-src/src/decompose.c index 060a53d28a3..5439ad51f3a 100644 --- a/Build/source/libs/potrace/potrace-src/src/decompose.c +++ b/Build/source/libs/potrace/potrace-src/src/decompose.c @@ -10,6 +10,9 @@ #include <stdlib.h> #include <string.h> #include <limits.h> +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif #include "potracelib.h" #include "curve.h" @@ -199,7 +202,8 @@ static void setbbox_path(bbox_t *bbox, path_t *p) { cannot have length 0). Sign is required for correct interpretation of turnpolicies. */ static path_t *findpath(potrace_bitmap_t *bm, int x0, int y0, int sign, int turnpolicy) { - int x, y, dirx, diry, len, size, area; + int x, y, dirx, diry, len, size; + uint64_t area; int c, d, tmp; point_t *pt, *pt1; path_t *p = NULL; @@ -276,7 +280,7 @@ static path_t *findpath(potrace_bitmap_t *bm, int x0, int y0, int sign, int turn p->priv->pt = pt; p->priv->len = len; - p->area = area; + p->area = area <= INT_MAX ? area : INT_MAX; /* avoid overflow */ p->sign = sign; return p; diff --git a/Build/source/libs/potrace/potrace-src/src/getopt.c b/Build/source/libs/potrace/potrace-src/src/getopt.c index 0c8fdd11bb3..d889c3c8686 100644 --- a/Build/source/libs/potrace/potrace-src/src/getopt.c +++ b/Build/source/libs/potrace/potrace-src/src/getopt.c @@ -41,25 +41,6 @@ #include <stdio.h> -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include <gnu-versions.h> -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#ifndef ELIDE_CODE - - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ @@ -986,7 +967,6 @@ getopt (argc, argv, optstring) 0); } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/Build/source/libs/potrace/potrace-src/src/getopt1.c b/Build/source/libs/potrace/potrace-src/src/getopt1.c index 8ffe0e6ad71..d983d120ac0 100644 --- a/Build/source/libs/potrace/potrace-src/src/getopt1.c +++ b/Build/source/libs/potrace/potrace-src/src/getopt1.c @@ -34,25 +34,6 @@ #include <stdio.h> -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ @@ -91,7 +72,6 @@ getopt_long_only (argc, argv, options, long_options, opt_index) } -#endif /* Not ELIDE_CODE. */ #ifdef TEST diff --git a/Build/source/libs/potrace/potrace-src/src/greymap.c b/Build/source/libs/potrace/potrace-src/src/greymap.c index 785774dd8da..0f97f12056e 100644 --- a/Build/source/libs/potrace/potrace-src/src/greymap.c +++ b/Build/source/libs/potrace/potrace-src/src/greymap.c @@ -845,11 +845,11 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; - GM_UPUT(gm, x, y, col[i&1]); + GM_PUT(gm, x, y, col[i&1]); x++; } } else if (c == 0) { @@ -875,7 +875,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; @@ -903,11 +903,11 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; - GM_UPUT(gm, x, y, COLTABLE(c)); + GM_PUT(gm, x, y, COLTABLE(c)); x++; } } else if (c == 0) { @@ -931,7 +931,7 @@ static int gm_readbody_bmp(FILE *f, greymap_t **gmp) { x=0; y++; } - if (y>=bmpinfo.h) { + if (x>=bmpinfo.w || y>=bmpinfo.h) { break; } realheight = y+1; diff --git a/Build/source/libs/potrace/potrace-src/src/greymap.h b/Build/source/libs/potrace/potrace-src/src/greymap.h index 7471ebf64bb..a1cea516338 100644 --- a/Build/source/libs/potrace/potrace-src/src/greymap.h +++ b/Build/source/libs/potrace/potrace-src/src/greymap.h @@ -41,7 +41,7 @@ typedef struct greymap_s greymap_t; #define GM_INC(gm, x, y, b) (gm_safe(gm, x, y) ? GM_UINC(gm, x, y, b) : 0) #define GM_INV(gm, x, y) (gm_safe(gm, x, y) ? GM_UINV(gm, x, y) : 0) #define GM_PUT(gm, x, y, b) (gm_safe(gm, x, y) ? GM_UPUT(gm, x, y, b) : 0) -#define GM_BGET(gm, x, y) GM_UGET(gm, gm_bound(x, gm->w), gm_bound(y, gm->h)) +#define GM_BGET(gm, x, y) ((gm)->w == 0 || (gm)->h == 0 ? 0 : GM_UGET(gm, gm_bound(x, (gm)->w), gm_bound(y, (gm)->h))) /* modes for cutting off out-of-range values. The following names refer to winding numbers. I.e., make a pixel black if winding diff --git a/Build/source/libs/potrace/potrace-src/src/getopt.h b/Build/source/libs/potrace/potrace-src/src/include/getopt/getopt.h index 20daef6168b..20daef6168b 100644 --- a/Build/source/libs/potrace/potrace-src/src/getopt.h +++ b/Build/source/libs/potrace/potrace-src/src/include/getopt/getopt.h diff --git a/Build/source/libs/potrace/potrace-src/src/main.c b/Build/source/libs/potrace/potrace-src/src/main.c index 1983f97b2c0..1722e69af19 100644 --- a/Build/source/libs/potrace/potrace-src/src/main.c +++ b/Build/source/libs/potrace/potrace-src/src/main.c @@ -2,7 +2,13 @@ This file is part of Potrace. It is free software and it is covered by the GNU General Public License. See the file COPYING for details. */ -#define _XOPEN_SOURCE 500 +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE 1 +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -101,12 +107,12 @@ struct backend_s { typedef struct backend_s backend_t; static backend_t backend[] = { + { "svg", ".svg", 0, 0, 0, NULL, page_svg, NULL, 1 }, + { "pdf", ".pdf", 0, 0, 1, init_pdf, page_pdf, term_pdf, 1 }, + { "pdfpage", ".pdf", 1, 0, 1, init_pdf, page_pdfpage, term_pdf, 1 }, { "eps", ".eps", 0, 0, 0, NULL, page_eps, NULL, 1 }, { "postscript", ".ps", 1, 0, 1, init_ps, page_ps, term_ps, 1 }, { "ps", ".ps", 1, 0, 1, init_ps, page_ps, term_ps, 1 }, - { "pdf", ".pdf", 0, 0, 1, init_pdf, page_pdf, term_pdf, 1 }, - { "pdfpage", ".pdf", 1, 0, 1, init_pdf, page_pdfpage, term_pdf, 1 }, - { "svg", ".svg", 0, 0, 0, NULL, page_svg, NULL, 1 }, { "dxf", ".dxf", 0, 1, 0, NULL, page_dxf, NULL, 1 }, { "geojson", ".json",0, 1, 0, NULL, page_geojson, NULL, 1 }, { "pgm", ".pgm", 0, 1, 1, NULL, page_pgm, NULL, 1 }, @@ -203,12 +209,12 @@ static void usage(FILE *f) { fprintf(f, " -- - end of options; 0 or more input filenames follow\n"); fprintf(f, "Backend selection:\n"); fprintf(f, " -b, --backend <name> - select backend by name\n"); - fprintf(f, " -e, --eps - EPS backend (encapsulated PostScript) (default)\n"); - fprintf(f, " -p, --postscript - PostScript backend\n"); - fprintf(f, " -s, --svg - SVG backend (scalable vector graphics)\n"); - fprintf(f, " -g, --pgm - PGM backend (portable greymap)\n"); + fprintf(f, " -b svg, -s, --svg - SVG backend (scalable vector graphics)\n"); fprintf(f, " -b pdf - PDF backend (portable document format)\n"); fprintf(f, " -b pdfpage - fixed page-size PDF backend\n"); + fprintf(f, " -b eps, -e, --eps - EPS backend (encapsulated PostScript) (default)\n"); + fprintf(f, " -b ps, -p, --postscript - PostScript backend\n"); + fprintf(f, " -b pgm, -g, --pgm - PGM backend (portable greymap)\n"); fprintf(f, " -b dxf - DXF backend (drawing interchange format)\n"); fprintf(f, " -b geojson - GeoJSON backend\n"); fprintf(f, " -b gimppath - Gimppath backend (GNU Gimp)\n"); @@ -613,8 +619,8 @@ static void dopts(int ac, char *av[]) { } parse_dimensions(optarg, &p, &dimx, &dimy); if (*p == 0) { - info.paperwidth = (int)rint(double_of_dim(dimx, DEFAULT_DIM)); - info.paperheight = (int)rint(double_of_dim(dimy, DEFAULT_DIM)); + info.paperwidth = (int)round(double_of_dim(dimx, DEFAULT_DIM)); + info.paperheight = (int)round(double_of_dim(dimy, DEFAULT_DIM)); break; } if (matches == 0) { diff --git a/Build/source/libs/potrace/potrace-src/src/mkbitmap.c b/Build/source/libs/potrace/potrace-src/src/mkbitmap.c index 34976591adb..4b1b1a3294d 100644 --- a/Build/source/libs/potrace/potrace-src/src/mkbitmap.c +++ b/Build/source/libs/potrace/potrace-src/src/mkbitmap.c @@ -7,7 +7,13 @@ filter (evening out background gradients), lowpass filter (smoothing foreground details), interpolated scaling, inversion. */ -#define _XOPEN_SOURCE 500 +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif + +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE 1 +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -332,9 +338,9 @@ static void *interpolate_cubic(greymap_t *gm, int s, int bilevel, double c) { v += window[k][i] * poly[l][i]; } if (bilevel) { - BM_UPUT(bm_out, x*s+l, y*s+k, v < c1); + BM_PUT(bm_out, x*s+l, y*s+k, v < c1); } else { - GM_UPUT(gm_out, x*s+l, y*s+k, v); + GM_PUT(gm_out, x*s+l, y*s+k, v); } } } diff --git a/Build/source/libs/potrace/potrace-src/src/potracelib.h b/Build/source/libs/potrace/potrace-src/src/potracelib.h index ed5a245ac4a..003297740af 100644 --- a/Build/source/libs/potrace/potrace-src/src/potracelib.h +++ b/Build/source/libs/potrace/potrace-src/src/potracelib.h @@ -121,7 +121,7 @@ potrace_param_t *potrace_param_default(void); /* free parameter set */ void potrace_param_free(potrace_param_t *p); -/* trace a bitmap*/ +/* trace a bitmap */ potrace_state_t *potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm); diff --git a/Build/source/libs/potrace/potrace-src/src/trace.c b/Build/source/libs/potrace/potrace-src/src/trace.c index 5be6dd3ec57..b0b9944ae6a 100644 --- a/Build/source/libs/potrace/potrace-src/src/trace.c +++ b/Build/source/libs/potrace/potrace-src/src/trace.c @@ -282,9 +282,9 @@ static int calc_sums(privpath_t *pp) { y = pp->pt[i].y - pp->y0; pp->sums[i+1].x = pp->sums[i].x + x; pp->sums[i+1].y = pp->sums[i].y + y; - pp->sums[i+1].x2 = pp->sums[i].x2 + x*x; - pp->sums[i+1].xy = pp->sums[i].xy + x*y; - pp->sums[i+1].y2 = pp->sums[i].y2 + y*y; + pp->sums[i+1].x2 = pp->sums[i].x2 + (double)x*x; + pp->sums[i+1].xy = pp->sums[i].xy + (double)x*y; + pp->sums[i+1].y2 = pp->sums[i].y2 + (double)y*y; } return 0; |