texlive[43298] Build/source/libs: potrace 1.14

commits+kakuto at tug.org commits+kakuto at tug.org
Wed Feb 22 05:06:22 CET 2017


Revision: 43298
          http://tug.org/svn/texlive?view=revision&revision=43298
Author:   kakuto
Date:     2017-02-22 05:06:22 +0100 (Wed, 22 Feb 2017)
Log Message:
-----------
potrace 1.14

Modified Paths:
--------------
    trunk/Build/source/libs/README
    trunk/Build/source/libs/potrace/ChangeLog
    trunk/Build/source/libs/potrace/TLpatches/ChangeLog
    trunk/Build/source/libs/potrace/TLpatches/TL-Changes
    trunk/Build/source/libs/potrace/configure
    trunk/Build/source/libs/potrace/potrace-src/ChangeLog
    trunk/Build/source/libs/potrace/potrace-src/Makefile.am
    trunk/Build/source/libs/potrace/potrace-src/NEWS
    trunk/Build/source/libs/potrace/potrace-src/README
    trunk/Build/source/libs/potrace/potrace-src/config.h.in
    trunk/Build/source/libs/potrace/potrace-src/configure.ac
    trunk/Build/source/libs/potrace/potrace-src/src/Makefile.am
    trunk/Build/source/libs/potrace/potrace-src/src/auxiliary.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.h
    trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.c
    trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.h
    trunk/Build/source/libs/potrace/potrace-src/src/bbox.c
    trunk/Build/source/libs/potrace/potrace-src/src/bbox.h
    trunk/Build/source/libs/potrace/potrace-src/src/bitmap.h
    trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.c
    trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.h
    trunk/Build/source/libs/potrace/potrace-src/src/bitops.h
    trunk/Build/source/libs/potrace/potrace-src/src/curve.c
    trunk/Build/source/libs/potrace/potrace-src/src/curve.h
    trunk/Build/source/libs/potrace/potrace-src/src/decompose.c
    trunk/Build/source/libs/potrace/potrace-src/src/decompose.h
    trunk/Build/source/libs/potrace/potrace-src/src/flate.c
    trunk/Build/source/libs/potrace/potrace-src/src/flate.h
    trunk/Build/source/libs/potrace/potrace-src/src/greymap.c
    trunk/Build/source/libs/potrace/potrace-src/src/greymap.h
    trunk/Build/source/libs/potrace/potrace-src/src/lists.h
    trunk/Build/source/libs/potrace/potrace-src/src/lzw.c
    trunk/Build/source/libs/potrace/potrace-src/src/lzw.h
    trunk/Build/source/libs/potrace/potrace-src/src/main.c
    trunk/Build/source/libs/potrace/potrace-src/src/main.h
    trunk/Build/source/libs/potrace/potrace-src/src/mkbitmap.c
    trunk/Build/source/libs/potrace/potrace-src/src/platform.h
    trunk/Build/source/libs/potrace/potrace-src/src/potracelib.c
    trunk/Build/source/libs/potrace/potrace-src/src/potracelib.h
    trunk/Build/source/libs/potrace/potrace-src/src/potracelib_demo.c
    trunk/Build/source/libs/potrace/potrace-src/src/progress.h
    trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.c
    trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.h
    trunk/Build/source/libs/potrace/potrace-src/src/render.c
    trunk/Build/source/libs/potrace/potrace-src/src/render.h
    trunk/Build/source/libs/potrace/potrace-src/src/trace.c
    trunk/Build/source/libs/potrace/potrace-src/src/trace.h
    trunk/Build/source/libs/potrace/potrace-src/src/trans.c
    trunk/Build/source/libs/potrace/potrace-src/src/trans.h
    trunk/Build/source/libs/potrace/version.ac

Modified: trunk/Build/source/libs/README
===================================================================
--- trunk/Build/source/libs/README	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/README	2017-02-22 04:06:22 UTC (rev 43298)
@@ -52,7 +52,7 @@
 poppler 0.52.0 - checked 17feb17
   http://poppler.freedesktop.org/ - used by luatex and xetex
 
-potrace 1.13 - checked 28dec15
+potrace 1.14 - checked 22feb17
   http://potrace.sourceforge.net
 
 teckit 2.5.6 - checked 30dec16

Modified: trunk/Build/source/libs/potrace/ChangeLog
===================================================================
--- trunk/Build/source/libs/potrace/ChangeLog	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/ChangeLog	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,3 +1,8 @@
+2017-02-22  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Import potrace-1.14.
+	* version.ac: Adjust.
+
 2016-02-15  Karl Berry  <karl at tug.org>
 
 	* potrace-PATCHES: rename from potrace-src-PATCHES.

Modified: trunk/Build/source/libs/potrace/TLpatches/ChangeLog
===================================================================
--- trunk/Build/source/libs/potrace/TLpatches/ChangeLog	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/TLpatches/ChangeLog	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,3 +1,8 @@
+2017-02-22  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
+
+	Import potrace-1.14 source tree from:
+	  http://potrace.sourceforge.net
+
 2015-12-28  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	Import potrace-1.13 source tree from:

Modified: trunk/Build/source/libs/potrace/TLpatches/TL-Changes
===================================================================
--- trunk/Build/source/libs/potrace/TLpatches/TL-Changes	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/TLpatches/TL-Changes	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-Changes applied to the potrace-1.13/ tree as obtained from:
+Changes applied to the potrace-1.14/ tree as obtained from:
 	http://potrace.sourceforge.net
 
 Removed:

Modified: trunk/Build/source/libs/potrace/configure
===================================================================
--- trunk/Build/source/libs/potrace/configure	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/configure	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for potrace (TeX Live) 1.13.
+# Generated by GNU Autoconf 2.69 for potrace (TeX Live) 1.14.
 #
 # Report bugs to <tex-k at tug.org>.
 #
@@ -580,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='potrace (TeX Live)'
 PACKAGE_TARNAME='potrace--tex-live-'
-PACKAGE_VERSION='1.13'
-PACKAGE_STRING='potrace (TeX Live) 1.13'
+PACKAGE_VERSION='1.14'
+PACKAGE_STRING='potrace (TeX Live) 1.14'
 PACKAGE_BUGREPORT='tex-k at tug.org'
 PACKAGE_URL=''
 
@@ -1241,7 +1241,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures potrace (TeX Live) 1.13 to adapt to many kinds of systems.
+\`configure' configures potrace (TeX Live) 1.14 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1308,7 +1308,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of potrace (TeX Live) 1.13:";;
+     short | recursive ) echo "Configuration of potrace (TeX Live) 1.14:";;
    esac
   cat <<\_ACEOF
 
@@ -1405,7 +1405,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-potrace (TeX Live) configure 1.13
+potrace (TeX Live) configure 1.14
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1585,7 +1585,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by potrace (TeX Live) $as_me 1.13, which was
+It was created by potrace (TeX Live) $as_me 1.14, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3508,7 +3508,7 @@
 
 # Define the identity of the package.
  PACKAGE='potrace--tex-live-'
- VERSION='1.13'
+ VERSION='1.14'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5582,7 +5582,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by potrace (TeX Live) $as_me 1.13, which was
+This file was extended by potrace (TeX Live) $as_me 1.14, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5648,7 +5648,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-potrace (TeX Live) config.status 1.13
+potrace (TeX Live) config.status 1.14
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/libs/potrace/potrace-src/ChangeLog
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/ChangeLog	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/ChangeLog	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,5 +1,30 @@
 ChangeLog
 
+v1.14 2017/02/19
+	(2017/02/19) PS1 - speed: use clang as default compiler if
+	available, and no longer use -ffloat-store even with gcc.
+	(2017/02/18) PS1 - corrected some exit codes, added some missing
+	error handlers.
+	(2017/02/17) PS1 - mkbitmap: bugfixes and improvements in parsing
+	image files.
+	(2017/02/15) PS1 - truncate the image size when bitmap data ends
+	prematurely. This fixes CVE-2016-8686, where Potrace appeared to
+	be "hanging" on a crafted input file.
+	(2017/02/14) PS1 - test suite: added tests for plain pnm files.
+	(2017/01/08) PS1 - fixed potential compiler issues due to signed
+	arithmetic overflow and arithmetic shifting.
+	(2017/01/07) PS1 - enable use of negative dy in bitmap data.
+	(2017/01/07) PS1 - test suite: moved data files to a subdirectory.
+	(2017/01/07) PS1 - test suite: added a check for -i flag.
+	(2017/01/07) PS1 - fixed buffer overflow CVE-2016-8685, reported
+	by Agostino Sarubbo.
+	(2015/10/24) PS1 - portability: use const char * for string
+	constants, required by C++11. Reported by Martin Gieseking.
+	(2015/10/24) PS1 - portability: extra spaces around string macros,
+	required by C++11. Reported by Martin Gieseking.
+	(2015/10/24) PS1 - portability: added more potential C compilers
+	to autoconf. Suggested by Nelson Beebe.
+
 v1.13 2015/10/22
 	(2015/07/18) PS1 - fixed heap overflows, null pointer dereference
 	bugs and a memory leak. Reported by Agostino Sarubbo.
@@ -52,8 +77,8 @@
 	(2011/08/02) PS1 - new gimppath backend produces SVG output
 	suitable for current versions of Gimp.
 	(2011/08/02) PS1 - added a --flat option for the SVG backend.
-	(2011/07/31) PS1 - test suite: renamed *.out files to prevent make's
-	built-in implicit rules from accidentally overwriting them.
+	(2011/07/31) PS1 - test suite: renamed *.out files to prevent
+	make's built-in implicit rules from accidentally overwriting them.
 	(2011/07/26) PS1 - added DXF backend. Thanks to Jonas Benedett
 	Dorr for testing.
 	(2011/07/26) PS1 - use high resolution bounding box in EPS, PDF,

Modified: trunk/Build/source/libs/potrace/potrace-src/Makefile.am
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/Makefile.am	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/Makefile.am	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-## Copyright (C) 2001-2015 Peter Selinger.
+## Copyright (C) 2001-2017 Peter Selinger.
 ## 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.
 

Modified: trunk/Build/source/libs/potrace/potrace-src/NEWS
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/NEWS	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/NEWS	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,3 +1,15 @@
+February 19, 2017: Release 1.14
+
+ This release consists of bugfixes and minor portability improvements.
+ A number of bugs triggered by malformed BMP files have been fixed,
+ including CVE-2016-8685 and CVE-2016-8686. Error reporting has been
+ improved. The image size is now truncated when the bitmap data ends
+ prematurely. It is now possible to use negative dy in bitmap
+ data. Portability has been improved to encompass C++11. The default
+ compiler is now clang if available. Thanks to Nelson Beebe and Martin
+ Gieseking for reporting portability issues, and to Agostino Sarubbo
+ for reporting bugs.
+
 October 22, 2015: Release 1.13
 
  Some critical bugs in the processing of BMP files were fixed. These

Modified: trunk/Build/source/libs/potrace/potrace-src/README
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/README	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/README	2017-02-22 04:06:22 UTC (rev 43298)
@@ -157,7 +157,7 @@
 
 COPYRIGHT
 
- Copyright (C) 2001-2015 Peter Selinger
+ Copyright (C) 2001-2017 Peter Selinger
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by

Modified: trunk/Build/source/libs/potrace/potrace-src/config.h.in
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/config.h.in	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/config.h.in	2017-02-22 04:06:22 UTC (rev 43298)
@@ -42,8 +42,7 @@
 /* Do we have the zlib library? */
 #undef HAVE_ZLIB
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Name of the mkbitmap binary */

Modified: trunk/Build/source/libs/potrace/potrace-src/configure.ac
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/configure.ac	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/configure.ac	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2001-2015 Peter Selinger.
+dnl Copyright (C) 2001-2017 Peter Selinger.
 dnl This file is part of Potrace. It is free software and it is covered
 dnl by the GNU General Public License. See the file COPYING for details.
 
@@ -6,13 +6,13 @@
 
 dnl ----------------------------------------------------------------------
 dnl Package info
-AC_INIT([potrace],[1.13],[selinger at users.sourceforge.net])
+AC_INIT([potrace],[1.14],[selinger at users.sourceforge.net])
 AC_CONFIG_SRCDIR(src/trace.c)
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADER(config.h)
 AC_CONFIG_MACRO_DIR([m4])
 
-DATE="October 2015"
+DATE="February 2017"
 
 dnl ----------------------------------------------------------------------
 dnl The names of the installed executables are defined here, but
@@ -27,17 +27,9 @@
 dnl ----------------------------------------------------------------------
 dnl figure out compiler options
 
-dnl remember user's CFLAGS, if any
-iCFLAGS="$CFLAGS"
-
 dnl Check for compiler
-AC_PROG_CC
+AC_PROG_CC([clang gcc cc c99 mgcc c89 pcc opencc sunc99 suncc])
 
-dnl If compiler is gcc, add our own default CFLAGS if no others specified
-if test "$GCC" = "yes" && test "$iCFLAGS" = ""; then
-  CFLAGS="$CFLAGS -Wall -ffloat-store"
-fi
-
 dnl Also add CADD to the CFLAGS at configure time or compile time
 AC_SUBST(CADD)
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/Makefile.am
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/Makefile.am	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/Makefile.am	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-## Copyright (C) 2001-2015 Peter Selinger.
+## Copyright (C) 2001-2017 Peter Selinger.
 ## 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.
 
@@ -42,7 +42,7 @@
 lib_LTLIBRARIES = $(INSTLIBS)
 EXTRA_LTLIBRARIES = libpotrace.la
 libpotrace_la_SOURCES = $(libsources)
-libpotrace_la_LDFLAGS = -version-info 0:3:0 -rpath '$(libdir)' \
+libpotrace_la_LDFLAGS = -version-info 0:4:0 -rpath '$(libdir)' \
  -export-symbols $(srcdir)/libpotrace-export.sym -no-undefined
 libpotrace_la_LIBADD = -lm
 MOSTLYCLEANFILES = libpotrace.la

Modified: trunk/Build/source/libs/potrace/potrace-src/src/auxiliary.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/auxiliary.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/auxiliary.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -94,7 +94,7 @@
 }
 
 /* output the start of a polyline */
-static void ship_polyline(FILE *fout, char *layer, int closed) {
+static void ship_polyline(FILE *fout, const char *layer, int closed) {
   ship(fout, 0, "POLYLINE");
   ship(fout, 8, "%s", layer);
   ship(fout, 66, "%d", 1);
@@ -102,7 +102,7 @@
 }
 
 /* output a vertex */
-static void ship_vertex(FILE *fout, char *layer, dpoint_t v, double bulge) {
+static void ship_vertex(FILE *fout, const char *layer, dpoint_t v, double bulge) {
   ship(fout, 0, "VERTEX");
   ship(fout, 8, "%s", layer);
   ship(fout, 10, "%f", v.x);
@@ -116,12 +116,12 @@
 }
 
 /* output a comment */
-static void ship_comment(FILE *fout, char *comment) {
+static void ship_comment(FILE *fout, const char *comment) {
   ship(fout, 999, "%s", comment);
 }
 
 /* output the start of a section */
-static void ship_section(FILE *fout, char *name) {
+static void ship_section(FILE *fout, const char *name) {
   ship(fout, 0, "SECTION");
   ship(fout, 2, "%s", name);
 }
@@ -141,7 +141,7 @@
    circular arcs from A to B, tangent to AC at A and to CB at
    B. Segments are meant to be concatenated, so don't output the final
    vertex. */
-static void pseudo_quad(FILE *fout, char *layer, dpoint_t A, dpoint_t C, dpoint_t B) {
+static void pseudo_quad(FILE *fout, const char *layer, dpoint_t A, dpoint_t C, dpoint_t B) {
   dpoint_t v, w;
   double v2, w2, vw, vxw, nvw;
   double a, b, c, y;
@@ -185,7 +185,7 @@
    made up of up to 4 circular arcs. This is particularly intended for
    the case when AD and BC are parallel. Like arcs(), don't output the
    final vertex. */
-static void pseudo_bezier(FILE *fout, char *layer, dpoint_t A, dpoint_t B, dpoint_t C, dpoint_t D) {
+static void pseudo_bezier(FILE *fout, const char *layer, dpoint_t A, dpoint_t B, dpoint_t C, dpoint_t D) {
   dpoint_t E = interval(0.75, A, B);
   dpoint_t G = interval(0.75, D, C);
   dpoint_t F = interval(0.5, E, G);
@@ -199,7 +199,7 @@
 /* functions for converting a path to a DXF polyline */
 
 /* do one path. */
-static int dxf_path(FILE *fout, char *layer, potrace_curve_t *curve, trans_t t) {
+static int dxf_path(FILE *fout, const char *layer, potrace_curve_t *curve, trans_t t) {
   int i;
   dpoint_t *c, *c1;
   int n = curve->n;
@@ -230,7 +230,7 @@
 int page_dxf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) {
   potrace_path_t *p;
   trans_t t;
-  char *layer = "0";
+  const char *layer = "0";
 
   /* set up the coordinate transform (rotation) */
   t.bb[0] = imginfo->trans.bb[0]+imginfo->lmar+imginfo->rmar;
@@ -242,7 +242,7 @@
   t.y[0] = imginfo->trans.y[0];
   t.y[1] = imginfo->trans.y[1];
 
-  ship_comment(fout, "DXF data, created by "POTRACE" "VERSION", written by Peter Selinger 2001-2015");
+  ship_comment(fout, "DXF data, created by " POTRACE " " VERSION ", written by Peter Selinger 2001-2017");
 
   /* header section */
   ship_section(fout, "HEADER");

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_dxf.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -38,6 +38,8 @@
 #define green  0x008000
 #define blue   0x0000ff
 
+#define TRY(x) if (x) goto try_error
+
 /* ---------------------------------------------------------------------- */
 /* functions for interfacing with compression backend */
 
@@ -47,7 +49,7 @@
 
 /* print the token to f, but filtered through a compression
    filter in case filter!=0 */
-static int (*xship)(FILE *f, int filter, char *s, int len);
+static int (*xship)(FILE *f, int filter, const char *s, int len);
 static FILE *xship_file;
 
 /* ship postscript code, filtered */
@@ -67,7 +69,7 @@
 }  
 
 /* ship a postscript comment, unfiltered */
-static int shipcom(char *fmt, ...) {
+static int shipcom(const char *fmt, ...) {
   static char buf[4096];
   va_list args;
 
@@ -153,7 +155,7 @@
 }
 
 /* this procedure returns a statically allocated string */
-static char *eps_colorstring(const color_t col) {
+static const char *eps_colorstring(const color_t col) {
   double r, g, b;
   static char buf[100];
 
@@ -399,7 +401,7 @@
 /* postscript macros */
 
 /* special macros for size-optimized rendering of Bezier curves */
-static char *optimacros =
+static const char *optimacros =
   "/D{bind def}def\n"
   "/R{roll}D\n"
   "/K{copy}D\n"
@@ -427,7 +429,7 @@
   "/w{%s z fill}D\n";
 
 /* special macros for debug output */
-static char *debugmacros =
+static const char *debugmacros =
   "/unit { %f } def\n"
   "/box { newpath 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto closepath } def\n"
   "/circ { newpath 0 0 1 0 360 arc closepath } def\n"
@@ -451,7 +453,7 @@
   if (info.longcoding) {
     eps_setcolor(info.color);
     list_forall (p, plist) {
-      eps_path(p->priv->fcurve);
+      TRY(eps_path(p->priv->fcurve));
       ship("closepath\n");
       if (p->next == NULL || p->next->sign == '+') {
 	ship("fill\n");
@@ -459,7 +461,7 @@
     }
   } else {
     list_forall (p, plist) {
-      eps_path(p->priv->fcurve);
+      TRY(eps_path(p->priv->fcurve));
       if (p->next == NULL || p->next->sign == '+') {
 	ship("b\n");
       } else {
@@ -468,6 +470,9 @@
     }
   }
   return 0;
+
+ try_error:
+  return 1;
 }
 
 /* Opaque output: alternating black and white */
@@ -476,7 +481,7 @@
   
   if (info.longcoding) {
     list_forall (p, plist) {
-      eps_path(p->priv->fcurve);
+      TRY(eps_path(p->priv->fcurve));
       ship("closepath\n");
       eps_setcolor(p->sign=='+' ? info.color : info.fillcolor);
       ship("fill\n");
@@ -483,11 +488,14 @@
     }
   } else {
     list_forall (p, plist) {
-      eps_path(p->priv->fcurve);
+      TRY(eps_path(p->priv->fcurve));
       ship(p->sign=='+' ? "b\n" : "w\n");
     }
   }
   return 0;
+
+ try_error:
+  return 1;
 }
 
 /* Debug output type 1 (show optimal polygon) */
@@ -559,7 +567,7 @@
     /* output the path */
     eps_linewidth(.1);
     eps_setcolor(blue);
-    eps_path(&p->priv->curve);
+    TRY(eps_path(&p->priv->curve));
     ship("closepath\n");
     ship("stroke\n");
 
@@ -568,7 +576,7 @@
       /* output opticurve */
       eps_linewidth(.05);
       eps_setcolor(red);
-      eps_path(&p->priv->ocurve);
+      TRY(eps_path(&p->priv->ocurve));
       ship("closepath\n");
       ship("stroke\n");
       
@@ -580,6 +588,9 @@
     }
   }
   return 0;
+
+ try_error:
+  return 1;
 }
 
 /* Free-style debug output */
@@ -618,7 +629,7 @@
     /* output the path */
     eps_linewidth(.1);
     eps_setcolor(blue);
-    eps_path(&p->priv->curve);
+    TRY(eps_path(&p->priv->curve));
     ship("closepath\n");
     ship("stroke\n");
     
@@ -630,7 +641,7 @@
       /* output opticurve */
       eps_linewidth(.05);
       eps_setcolor(red);
-      eps_path(&p->priv->ocurve);
+      TRY(eps_path(&p->priv->ocurve));
       ship("closepath\n");
       ship("stroke\n");
       
@@ -648,6 +659,9 @@
     }
   }
   return 0;
+
+ try_error:
+  return 1;
 }
 
 /* select the appropriate rendering function from above */
@@ -686,7 +700,7 @@
   char *c0, *c1;
 
   shipcom("%%!PS-Adobe-3.0 EPSF-3.0\n");
-  shipcom("%%%%Creator: "POTRACE" "VERSION", written by Peter Selinger 2001-2015\n");
+  shipcom("%%%%Creator: " POTRACE " " VERSION ", written by Peter Selinger 2001-2017\n");
   shipcom("%%%%LanguageLevel: %d\n", info.pslevel);
   shipcom("%%%%BoundingBox: 0 0 %.0f %.0f\n", 
 	  ceil(imginfo->trans.bb[0]+imginfo->lmar+imginfo->rmar),
@@ -725,28 +739,22 @@
   return 0;
 }
 
-static int eps_term(void) {
+static void eps_term(void) {
   ship("restore\n");
   shipcom("%%%%EOF\n");
-  return 0;
 }
 
 /* public interface for EPS */
 int page_eps(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) {
-  int r;
-
   eps_callbacks(fout);
 
-  eps_init(imginfo);
-  
-  r = eps_render(plist);
-  if (r) {
-    return r;
-  }
-
+  TRY(eps_init(imginfo));
+  TRY(eps_render(plist));
   eps_term();
+  return 0;
 
-  return 0;
+ try_error:
+  return 1;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -761,7 +769,7 @@
   eps_callbacks(fout);
 
   shipcom("%%!PS-Adobe-3.0\n");
-  shipcom("%%%%Creator: "POTRACE" "VERSION", written by Peter Selinger 2001-2015\n");
+  shipcom("%%%%Creator: " POTRACE " " VERSION ", written by Peter Selinger 2001-2017\n");
   shipcom("%%%%LanguageLevel: %d\n", info.pslevel);
   shipcom("%%%%BoundingBox: 0 0 %d %d\n", info.paperwidth, info.paperheight);
   shipcom("%%%%Pages: (atend)\n");

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_eps.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -30,7 +30,7 @@
   return s*s*s*x0 + 3*(s*s*t)*x1 + 3*(t*t*s)*x2 + t*t*t*x3;
 }
 
-static char *format = "%f";
+static const char *format = "%f";
 
 /* Convert a floating-point number to a string, using a pre-determined
    format. The format must be previously set with set_format().

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_geojson.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -25,6 +25,8 @@
 
 typedef int color_t;
 
+#define TRY(x) if (x) goto try_error
+
 /* ---------------------------------------------------------------------- */
 /* auxiliary: growing arrays */
 
@@ -83,7 +85,7 @@
 
 /* print the token to f, but filtered through a compression
    filter in case filter!=0 */
-static int (*xship)(FILE *f, int filter, char *s, int len);
+static int (*xship)(FILE *f, int filter, const char *s, int len);
 static FILE *xship_file;
 
 /* ship PDF code, filtered */
@@ -103,7 +105,7 @@
 }  
 
 /* ship PDF code, unfiltered */
-static int shipclear(char *fmt, ...) {
+static int shipclear(const char *fmt, ...) {
   static char buf[4096];
   va_list args;
 
@@ -165,7 +167,7 @@
 }
 
 /* this procedure returns a statically allocated string */
-static char *pdf_colorstring(const color_t col) {
+static const char *pdf_colorstring(const color_t col) {
   double r, g, b;
   static char buf[100];
 
@@ -277,13 +279,13 @@
 
 	shipclear("%%PDF-1.3\n");
 
-	intarray_set(&xref, nxref++, outcount);
+	TRY(intarray_set(&xref, nxref++, outcount));
 	shipclear("1 0 obj\n<</Type/Catalog/Pages 3 0 R>>\nendobj\n");
 
-	intarray_set(&xref, nxref++, outcount);
+	TRY(intarray_set(&xref, nxref++, outcount));
 	shipclear("2 0 obj\n"
 		"<</Creator"
-		"("POTRACE" "VERSION", written by Peter Selinger 2001-2015)>>\n"
+		"(" POTRACE " " VERSION ", written by Peter Selinger 2001-2017)>>\n"
 		"endobj\n");
 
 	/* delay obj #3 (pages) until end */
@@ -291,6 +293,9 @@
 
 	fflush(fout);
 	return 0;
+
+ try_error:
+        return 1;
 }
 
 int term_pdf(FILE *fout)
@@ -300,7 +305,7 @@
 
 	pdf_callbacks(fout);
 
-	intarray_set(&xref, 2, outcount);
+	TRY(intarray_set(&xref, 2, outcount));
 	shipclear("3 0 obj\n"
 		"<</Type/Pages/Count %d/Kids[\n", npages);
 	for (i = 0; i < npages; i++)
@@ -321,10 +326,14 @@
 	intarray_term(&xref);
 	intarray_term(&pages);
 	return 0;
+
+ try_error:
+        return 1;
 }
 
-/* if largebbox is set, set bounding box to pagesize. */
-static void pdf_pageinit(imginfo_t *imginfo, int largebbox)
+/* if largebbox is set, set bounding box to pagesize. Return 0 on
+   success or 1 on error with errno set. */
+static int pdf_pageinit(imginfo_t *imginfo, int largebbox)
 {
 	double origx = imginfo->trans.orig[0] + imginfo->lmar;
 	double origy = imginfo->trans.orig[1] + imginfo->bmar;
@@ -338,7 +347,7 @@
 
 	pdf_color = -1;
 
-	intarray_set(&xref, nxref++, outcount);
+	TRY(intarray_set(&xref, nxref++, outcount));
 	shipclear("%d 0 obj\n", nxref);
 	shipclear("<</Type/Page/Parent 3 0 R/Resources<</ProcSet[/PDF]>>");
 	if (largebbox) {
@@ -349,9 +358,9 @@
 	shipclear("/Contents %d 0 R>>\n", nxref + 1);
 	shipclear("endobj\n");
 
-	intarray_set(&pages, npages++, nxref);
+	TRY(intarray_set(&pages, npages++, nxref));
 
-	intarray_set(&xref, nxref++, outcount);
+	TRY(intarray_set(&xref, nxref++, outcount));
 	shipclear("%d 0 obj\n", nxref);
 	if (info.compress)
 		shipclear("<</Filter/FlateDecode/Length %d 0 R>>\n", nxref + 1);
@@ -362,9 +371,14 @@
 	streamofs = outcount;
 
 	ship("%f %f %f %f %f %f cm\n", dxx, dxy, dyx, dyy, origx, origy);
+        return 0;
+
+       try_error:
+        return 1;
 }
 
-static void pdf_pageterm(void)
+/* Return 0 on success or 1 on error with errno set. */
+static int pdf_pageterm(void)
 {
 	int streamlen;
 
@@ -373,8 +387,12 @@
 	streamlen = outcount - streamofs;
 	shipclear("endstream\nendobj\n");
 	
-	intarray_set(&xref, nxref++, outcount);
+	TRY(intarray_set(&xref, nxref++, outcount));
 	shipclear("%d 0 obj\n%d\nendobj\n", nxref, streamlen);
+        return 0;
+
+       try_error:
+        return 1;
 }
 
 int page_pdf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo)
@@ -383,7 +401,7 @@
 
   pdf_callbacks(fout);
 
-  pdf_pageinit(imginfo, 0);
+  TRY(pdf_pageinit(imginfo, 0));
 
   r = pdf_render(plist);
   if (r) {
@@ -390,11 +408,13 @@
     return r;
   }
 
-  pdf_pageterm();
+  TRY(pdf_pageterm());
 
   fflush(fout);
+  return 0;
 
-  return 0;
+ try_error:
+  return 1;
 }
 
 int page_pdfpage(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo)
@@ -403,7 +423,7 @@
 
   pdf_callbacks(fout);
 
-  pdf_pageinit(imginfo, 1);
+  TRY(pdf_pageinit(imginfo, 1));
 
   r = pdf_render(plist);
   if (r) {
@@ -410,10 +430,12 @@
     return r;
   }
 
-  pdf_pageterm();
+  TRY(pdf_pageterm());
 
   fflush(fout);
+  return 0;
 
-  return 0;
+ try_error:
+  return 1;
 }
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_pdf.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -62,7 +62,7 @@
   int w, h;
   trans_t t;
   int mode;
-  char *comment = "created by "POTRACE" "VERSION", written by Peter Selinger 2001-2015";
+  const char *comment = "created by " POTRACE " " VERSION ", written by Peter Selinger 2001-2017";
 
   t.bb[0] = imginfo->trans.bb[0]+imginfo->lmar+imginfo->rmar;
   t.bb[1] = imginfo->trans.bb[1]+imginfo->tmar+imginfo->bmar;

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_pgm.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -38,7 +38,7 @@
 static int column = 0;
 static int newline = 1;
 
-static void shiptoken(FILE *fout, char *token) {
+static void shiptoken(FILE *fout, const char *token) {
   int c = strlen(token);
   if (!newline && column+c+1 > 75) {
     fprintf(fout, "\n");
@@ -53,7 +53,7 @@
   newline = 0;
 }
 
-static void ship(FILE *fout, char *fmt, ...) {
+static void ship(FILE *fout, const char *fmt, ...) {
   va_list args;
   static char buf[4096]; /* static string limit is okay here because
 			    we only use constant format strings - for
@@ -304,7 +304,7 @@
 
   /* metadata: creator */
   fprintf(fout, "<metadata>\n");
-  fprintf(fout, "Created by "POTRACE" "VERSION", written by Peter Selinger 2001-2015\n");
+  fprintf(fout, "Created by " POTRACE " " VERSION ", written by Peter Selinger 2001-2017\n");
   fprintf(fout, "</metadata>\n");
 
   /* use a "group" tag to establish coordinate system and style */

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_svg.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -26,7 +26,7 @@
 #endif
 
 struct pageformat_s {
-  char *name;
+  const char *name;
   int w, h;
 };
 typedef struct pageformat_s pageformat_t;
@@ -179,7 +179,7 @@
   trans_t t;
   double origx = imginfo->trans.orig[0] + imginfo->lmar;
   double origy = - imginfo->trans.orig[1] - imginfo->bmar + info.paperheight;
-  char *formatname;
+  const char *formatname;
   int best, penalty;
   pageformat_t *f;
   int i;
@@ -215,7 +215,7 @@
 
   /* header */
   fprintf(fout, "#FIG 3.2\n");
-  fprintf(fout, "#created by "POTRACE" "VERSION", written by Peter Selinger 2001-2015\n");
+  fprintf(fout, "#created by " POTRACE " " VERSION ", written by Peter Selinger 2001-2017\n");
   fprintf(fout, "Portrait\n");
   fprintf(fout, "Center\n");
   fprintf(fout, "Inches\n");

Modified: trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/backend_xfig.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bbox.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bbox.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bbox.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bbox.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bbox.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bbox.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bitmap.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bitmap.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bitmap.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -45,26 +45,71 @@
 #define BM_INV(bm, x, y) (bm_safe(bm, x, y) ? BM_UINV(bm, x, y) : 0)
 #define BM_PUT(bm, x, y, b) (bm_safe(bm, x, y) ? BM_UPUT(bm, x, y, b) : 0)
 
+/* calculate the size, in bytes, required for the data area of a
+   bitmap of the given dy and h. Assume h >= 0. Return -1 if the size
+   does not fit into the ptrdiff_t type. */
+static inline ptrdiff_t getsize(int dy, int h) {
+  ptrdiff_t size;
+
+  if (dy < 0) {
+    dy = -dy;
+  }
+  
+  size = (ptrdiff_t)dy * (ptrdiff_t)h * (ptrdiff_t)BM_WORDSIZE;
+
+  /* check for overflow error */
+  if (size < 0 || (h != 0 && dy != 0 && size / h / dy != BM_WORDSIZE)) {
+    return -1;
+  }
+
+  return size;
+}
+
+/* return the size, in bytes, of the data area of the bitmap. Return
+   -1 if the size does not fit into the ptrdiff_t type; however, this
+   cannot happen if the bitmap is well-formed, i.e., if created with
+   bm_new or bm_dup. */
+static inline ptrdiff_t bm_size(const potrace_bitmap_t *bm) {
+  return getsize(bm->dy, bm->h);
+}
+
+/* calculate the base address of the bitmap data. Assume that the
+   bitmap is well-formed, i.e., its size fits into the ptrdiff_t type.
+   This is the case if created with bm_new or bm_dup. The base address
+   may differ from bm->map if dy is negative */
+static inline potrace_word *bm_base(const potrace_bitmap_t *bm) {
+  int dy = bm->dy;
+
+  if (dy >= 0 || bm->h == 0) {
+    return bm->map;
+  } else {
+    return bm_scanline(bm, bm->h - 1);
+  }  
+}
+
 /* free the given bitmap. Leaves errno untouched. */
 static inline void bm_free(potrace_bitmap_t *bm) {
-  if (bm) {
-    free(bm->map);
+  if (bm && bm->map) {
+    free(bm_base(bm));
   }
   free(bm);
 }
 
-/* return new un-initialized bitmap. NULL with errno on error.
+/* return new bitmap initialized to 0. NULL with errno on error.
    Assumes w, h >= 0. */
 static inline potrace_bitmap_t *bm_new(int w, int h) {
   potrace_bitmap_t *bm;
   int dy = w == 0 ? 0 : (w - 1) / BM_WORDBITS + 1;
-  ptrdiff_t size = (ptrdiff_t)dy * (ptrdiff_t)h * (ptrdiff_t)BM_WORDSIZE;
+  ptrdiff_t size;
 
-  /* check for overflow error */
-  if (size < 0 || (h != 0 && dy != 0 && size / h / dy != BM_WORDSIZE)) {
+  size = getsize(dy, h);
+  if (size < 0) {
     errno = ENOMEM;
     return NULL;
   }
+  if (size == 0) {
+    size = 1; /* make sure calloc() doesn't return NULL */
+  } 
 
   bm = (potrace_bitmap_t *) malloc(sizeof(potrace_bitmap_t));
   if (!bm) {
@@ -73,7 +118,7 @@
   bm->w = w;
   bm->h = h;
   bm->dy = dy;
-  bm->map = (potrace_word *) malloc(size);
+  bm->map = (potrace_word *) calloc(1, size);
   if (!bm->map) {
     free(bm);
     return NULL;
@@ -81,33 +126,103 @@
   return bm;
 }
 
-/* clear the given bitmap. Set all bits to c. */
+/* clear the given bitmap. Set all bits to c. Assumes a well-formed
+   bitmap. */
 static inline void bm_clear(potrace_bitmap_t *bm, int c) {
   /* Note: if the bitmap was created with bm_new, then it is
      guaranteed that size will fit into the ptrdiff_t type. */
-  ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h * (ptrdiff_t)BM_WORDSIZE;
-  memset(bm->map, c ? -1 : 0, size);
+  ptrdiff_t size = bm_size(bm);
+  memset(bm_base(bm), c ? -1 : 0, size);
 }
 
-/* duplicate the given bitmap. Return NULL on error with errno set. */
+/* duplicate the given bitmap. Return NULL on error with errno
+   set. Assumes a well-formed bitmap. */
 static inline potrace_bitmap_t *bm_dup(const potrace_bitmap_t *bm) {
   potrace_bitmap_t *bm1 = bm_new(bm->w, bm->h);
-  ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h * (ptrdiff_t)BM_WORDSIZE;
+  int y;
+  
   if (!bm1) {
     return NULL;
   }
-  memcpy(bm1->map, bm->map, size);
+  for (y=0; y < bm->h; y++) {
+    memcpy(bm_scanline(bm1, y), bm_scanline(bm, y), (size_t)bm1->dy * (size_t)BM_WORDSIZE);
+  }
   return bm1;
 }
 
 /* invert the given bitmap. */
 static inline void bm_invert(potrace_bitmap_t *bm) {
-  ptrdiff_t i;
-  ptrdiff_t size = (ptrdiff_t)bm->dy * (ptrdiff_t)bm->h;
+  int dy = bm->dy;
+  int y;
+  int i;
+  potrace_word *p;
 
-  for (i = 0; i < size; i++) {
-    bm->map[i] ^= BM_ALLBITS;
+  if (dy < 0) {
+    dy = -dy;
   }
+  
+  for (y=0; y < bm->h; y++) {
+    p = bm_scanline(bm, y);
+    for (i=0; i < dy; i++) {
+      p[i] ^= BM_ALLBITS;
+    }
+  }
 }
 
+/* turn the given bitmap upside down. This does not move the bitmap
+   data or change the bm_base() address. */
+static inline void bm_flip(potrace_bitmap_t *bm) {
+  int dy = bm->dy;
+
+  if (bm->h == 0 || bm->h == 1) {
+    return;
+  }
+  
+  bm->map = bm_scanline(bm, bm->h - 1);
+  bm->dy = -dy;
+}
+
+/* resize the bitmap to the given new height. The bitmap data remains
+   bottom-aligned (truncated at the top) when dy >= 0 and top-aligned
+   (truncated at the bottom) when dy < 0. Return 0 on success, or 1 on
+   error with errno set. If the new height is <= the old one, no error
+   should occur. If the new height is larger, the additional bitmap
+   data is *not* initialized. */
+static inline int bm_resize(potrace_bitmap_t *bm, int h) {
+  int dy = bm->dy;
+  ptrdiff_t newsize;
+  potrace_word *newmap;
+
+  if (dy < 0) {
+    bm_flip(bm);
+  }
+  
+  newsize = getsize(dy, h);
+  if (newsize < 0) {
+    errno = ENOMEM;
+    goto error;
+  }
+  if (newsize == 0) {
+    newsize = 1; /* make sure realloc() doesn't return NULL */
+  }
+  
+  newmap = (potrace_word *)realloc(bm->map, newsize);
+  if (newmap == NULL) {
+    goto error;
+  }
+  bm->map = newmap;
+  bm->h = h;
+
+  if (dy < 0) {
+    bm_flip(bm);
+  }
+  return 0;
+  
+ error:
+  if (dy < 0) {
+    bm_flip(bm);
+  }
+  return 1;  
+}
+
 #endif /* BITMAP_H */

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -13,6 +13,7 @@
 
 #include "bitmap.h"
 #include "bitops.h"
+#include "bitmap_io.h"
 
 #define INTBITS (8*sizeof(int))
 
@@ -19,6 +20,10 @@
 static int bm_readbody_bmp(FILE *f, double threshold, potrace_bitmap_t **bmp);
 static int bm_readbody_pnm(FILE *f, double threshold, potrace_bitmap_t **bmp, int magic);
 
+#define TRY(x) if (x) goto try_error
+#define TRY_EOF(x) if (x) goto eof
+#define TRY_STD(x) if (x) goto std_error
+
 /* ---------------------------------------------------------------------- */
 /* routines for reading pnm streams */
 
@@ -111,7 +116,7 @@
    comments), -4 if wrong magic number. If the return value is >=0,
    *bmp is valid. */
 
-char *bm_read_error = NULL;
+const char *bm_read_error = NULL;
 
 int bm_read(FILE *f, double threshold, potrace_bitmap_t **bmp) {
   int magic[2];
@@ -144,7 +149,9 @@
   int x, y, i, b, b1, sum;
   int bpr; /* bytes per row (as opposed to 4*bm->c) */
   int w, h, max;
-
+  int realheight;  /* in case of incomplete file, keeps track of how
+                      many scan lines actually contain data */
+  
   bm = NULL;
 
   w = readnum(f);
@@ -160,12 +167,11 @@
   /* allocate bitmap */
   bm = bm_new(w, h);
   if (!bm) {
-    return -1;
+    goto std_error;
   }
 
-  /* zero it out */
-  bm_clear(bm, 0);
-
+  realheight = 0;
+  
   switch (magic) {
   default: 
     /* not reached */
@@ -174,7 +180,8 @@
   case '1':
     /* read P1 format: PBM ascii */
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
 	b = readbit(f);
 	if (b<0) {
@@ -193,7 +200,8 @@
       goto format_error;
     }
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         b = readnum(f);
         if (b<0) {
@@ -212,7 +220,8 @@
       goto format_error;
     }
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
 	sum = 0;
 	for (i=0; i<3; i++) {
@@ -237,7 +246,8 @@
 
     bpr = (w+7)/8;
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (i=0; i<bpr; i++) {
 	b = fgetc(f);
 	if (b==EOF) {
@@ -261,7 +271,8 @@
       goto format_error;
     }
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         b = fgetc(f);
         if (b==EOF)
@@ -291,7 +302,8 @@
       goto format_error;
     }
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         sum = 0;
         for (i=0; i<3; i++) {
@@ -314,10 +326,13 @@
     break;
   }
 
+  bm_flip(bm);
   *bmp = bm;
   return 0;
 
  eof:
+  TRY_STD(bm_resize(bm, realheight));
+  bm_flip(bm);
   *bmp = bm;
   return 1;
 
@@ -331,6 +346,10 @@
     bm_read_error = "invalid ppm file";
   }
   return -2;
+
+ std_error:
+  bm_free(bm);
+  return -1;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -377,7 +396,7 @@
     if (b==EOF) {
       return 1;
     }
-    sum += b << (8*i);
+    sum += (unsigned)b << (8*i);
   }
   bmp_count += n;
   bmp_pos += n;
@@ -422,12 +441,6 @@
   return 0;
 }
 
-#define TRY(x) if (x) goto try_error
-#define TRY_EOF(x) if (x) goto eof
-
-/* correct y-coordinate for top-down format */
-#define ycorr(y) (bmpinfo.topdown ? bmpinfo.h-1-y : y)
-
 /* safe colortable access */
 #define COLTABLE(c) ((c) < bmpinfo.ncolors ? coltable[(c)] : 0)
 
@@ -451,7 +464,9 @@
   unsigned int n;
   unsigned int redshift, greenshift, blueshift;
   int col1[2];
-
+  int realheight;  /* in case of incomplete file, keeps track of how
+                      many scan lines actually contain data */
+  
   bm_read_error = NULL;
   bm = NULL;
   coltable = NULL;
@@ -528,7 +543,7 @@
     goto format_error;  /* can't handle planes */
   }
   
-  if (bmpinfo.ncolors == 0) {
+  if (bmpinfo.ncolors == 0 && bmpinfo.bits <= 8) {
     bmpinfo.ncolors = 1 << bmpinfo.bits;
   }
 
@@ -560,10 +575,9 @@
   if (!bm) {
     goto std_error;
   }
+
+  realheight = 0;
   
-  /* zero it out */
-  bm_clear(bm, 0);
-
   switch (bmpinfo.bits + 0x100*bmpinfo.comp) {
     
   default:
@@ -579,11 +593,12 @@
     
     /* raster data */
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (i=0; 8*i<bmpinfo.w; i++) {
 	TRY_EOF(bmp_readint(f, 1, &b));
 	b ^= mask;
-	*bm_index(bm, i*8, ycorr(y)) |= ((potrace_word)b) << (8*(BM_WORDSIZE-1-(i % BM_WORDSIZE)));
+	*bm_index(bm, i*8, y) |= ((potrace_word)b) << (8*(BM_WORDSIZE-1-(i % BM_WORDSIZE)));
       }
       TRY(bmp_pad(f));
     }
@@ -597,6 +612,7 @@
   case 0x007: 
   case 0x008:
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       bitbuf = 0;  /* bit buffer: bits in buffer are high-aligned */
       n = 0;       /* number of bits currently in bitbuffer */
@@ -609,7 +625,7 @@
 	b = bitbuf >> (INTBITS - bmpinfo.bits);
 	bitbuf <<= bmpinfo.bits;
 	n -= bmpinfo.bits;
-	BM_UPUT(bm, x, ycorr(y), COLTABLE(b));
+	BM_UPUT(bm, x, y, COLTABLE(b));
       }
       TRY(bmp_pad(f));
     }
@@ -625,11 +641,12 @@
   case 0x018:  /* 24-bit encoding */
   case 0x020:  /* 32-bit encoding */
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (x=0; x<bmpinfo.w; x++) {
         TRY_EOF(bmp_readint(f, bmpinfo.bits/8, &c));
 	c = ((c>>16) & 0xff) + ((c>>8) & 0xff) + (c & 0xff);
-        BM_UPUT(bm, x, ycorr(y), c > 3 * threshold * 255 ? 0 : 1);
+        BM_UPUT(bm, x, y, c > 3 * threshold * 255 ? 0 : 1);
       }
       TRY(bmp_pad(f));
     }
@@ -636,16 +653,21 @@
     break;
 
   case 0x320:  /* 32-bit encoding with bitfields */
+    if (bmpinfo.RedMask == 0 || bmpinfo.GreenMask == 0 || bmpinfo.BlueMask == 0) {
+      goto format_error;
+    }      
+
     redshift = lobit(bmpinfo.RedMask);
     greenshift = lobit(bmpinfo.GreenMask);
     blueshift = lobit(bmpinfo.BlueMask);
 
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (x=0; x<bmpinfo.w; x++) {
         TRY_EOF(bmp_readint(f, bmpinfo.bits/8, &c));
 	c = ((c & bmpinfo.RedMask) >> redshift) + ((c & bmpinfo.GreenMask) >> greenshift) + ((c & bmpinfo.BlueMask) >> blueshift);
-        BM_UPUT(bm, x, ycorr(y), c > 3 * threshold * 255 ? 0 : 1);
+        BM_UPUT(bm, x, y, c > 3 * threshold * 255 ? 0 : 1);
       }
       TRY(bmp_pad(f));
     }
@@ -670,7 +692,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  BM_UPUT(bm, x, ycorr(y), col[i&1]);
+          realheight = y+1;
+	  BM_UPUT(bm, x, y, col[i&1]);
 	  x++;
 	}
       } else if (c == 0) {
@@ -699,7 +722,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  BM_PUT(bm, x, ycorr(y), COLTABLE((b>>(4-4*(i&1))) & 0xf));
+          realheight = y+1;
+	  BM_PUT(bm, x, y, COLTABLE((b>>(4-4*(i&1))) & 0xf));
 	  x++;
 	}
 	if ((c+1) & 2) {
@@ -726,7 +750,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  BM_UPUT(bm, x, ycorr(y), COLTABLE(c));
+          realheight = y+1;
+	  BM_UPUT(bm, x, y, COLTABLE(c));
 	  x++;
 	}
       } else if (c == 0) {
@@ -753,7 +778,8 @@
           if (y>=bmpinfo.h) {
             break;
           }
-	  BM_PUT(bm, x, ycorr(y), COLTABLE(b));
+          realheight = y+1;
+	  BM_PUT(bm, x, y, COLTABLE(b));
 	  x++;
 	}
 	if (c & 1) {
@@ -771,11 +797,18 @@
   bmp_forward(f, bmpinfo.FileSize);
 
   free(coltable);
+  if (bmpinfo.topdown) {
+    bm_flip(bm);
+  }
   *bmp = bm;
   return 0;
 
  eof:
+  TRY_STD(bm_resize(bm, realheight));
   free(coltable);
+  if (bmpinfo.topdown) {
+    bm_flip(bm);
+  }
   *bmp = bm;
   return 1;
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bitmap_io.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -13,7 +13,7 @@
 /* Note that bitmaps are stored bottom to top, i.e., the first
    scanline is the bottom-most one */
 
-extern char *bm_read_error;
+extern const char *bm_read_error;
 
 int bm_read(FILE *f, double blacklevel, potrace_bitmap_t **bmp);
 void bm_writepbm(FILE *f, potrace_bitmap_t *bm);

Modified: trunk/Build/source/libs/potrace/potrace-src/src/bitops.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/bitops.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/bitops.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/curve.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/curve.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/curve.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/curve.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/curve.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/curve.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/decompose.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/decompose.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/decompose.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -432,7 +432,7 @@
   x0 = (*xp) & ~(BM_WORDBITS-1);
 
   for (y=*yp; y>=0; y--) {
-    for (x=x0; x<bm->w; x+=BM_WORDBITS) {
+    for (x=x0; x<bm->w && x>=0; x+=(unsigned)BM_WORDBITS) {
       if (*bm_index(bm, x, y)) {
 	while (!BM_GET(bm, x, y)) {
 	  x++;

Modified: trunk/Build/source/libs/potrace/potrace-src/src/decompose.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/decompose.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/decompose.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/flate.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/flate.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/flate.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -42,7 +42,7 @@
 
 static int a85init(FILE *f);
 static int a85finish(FILE *f);
-static int a85write(FILE *f, char *buf, int n);
+static int a85write(FILE *f, const char *buf, int n);
 static int a85out(FILE *f, int n);
 static int a85spool(FILE *f, char c);
 
@@ -49,7 +49,7 @@
 /* ---------------------------------------------------------------------- */
 /* dummy interface: no encoding */
 
-int dummy_xship(FILE *f, int filter, char *s, int len) {
+int dummy_xship(FILE *f, int filter, const char *s, int len) {
   fwrite(s, 1, len, f);
   return len;
 }
@@ -59,7 +59,7 @@
 
 #ifdef HAVE_ZLIB
 
-int pdf_xship(FILE *f, int filter, char *s, int len) {
+int pdf_xship(FILE *f, int filter, const char *s, int len) {
 	static int fstate = 0;
 	static z_stream c_stream;
 	char outbuf[OUTSIZE];
@@ -74,7 +74,7 @@
     err = deflateInit(&c_stream, 9);
     if (err != Z_OK) {
       fprintf(stderr, "deflateInit: %s (%d)\n", c_stream.msg, err);
-      exit(1);
+      exit(2);
     }
     c_stream.avail_in = 0;
     fstate = 1;
@@ -88,7 +88,7 @@
       err = deflate(&c_stream, Z_FINISH);
       if (err != Z_OK && err != Z_STREAM_END) {
 	fprintf(stderr, "deflate: %s (%d)\n", c_stream.msg, err);
-	exit(1);
+	exit(2);
       }
       n += fwrite(outbuf, 1, OUTSIZE-c_stream.avail_out, f);
     } while (err != Z_STREAM_END);
@@ -111,7 +111,7 @@
     err = deflate(&c_stream, Z_NO_FLUSH);
     if (err != Z_OK) {
       fprintf(stderr, "deflate: %s (%d)\n", c_stream.msg, err);
-      exit(1);
+      exit(2);
     }
     n += fwrite(outbuf, 1, OUTSIZE-c_stream.avail_out, f);
   } while (!c_stream.avail_out);
@@ -120,7 +120,7 @@
 }
 
 /* ship len bytes from s using zlib compression. */
-int flate_xship(FILE *f, int filter, char *s, int len) {
+int flate_xship(FILE *f, int filter, const char *s, int len) {
   static int fstate = 0;
   static z_stream c_stream;
   char outbuf[OUTSIZE];
@@ -138,7 +138,7 @@
     err = deflateInit(&c_stream, 9);
     if (err != Z_OK) {
       fprintf(stderr, "deflateInit: %s (%d)\n", c_stream.msg, err);
-      exit(1);
+      exit(2);
     }
     c_stream.avail_in = 0;
     n += a85init(f);
@@ -153,7 +153,7 @@
       err = deflate(&c_stream, Z_FINISH);
       if (err != Z_OK && err != Z_STREAM_END) {
 	fprintf(stderr, "deflate: %s (%d)\n", c_stream.msg, err);
-	exit(1);
+	exit(2);
       }
       n += a85write(f, outbuf, OUTSIZE-c_stream.avail_out);
     } while (err != Z_STREAM_END);
@@ -178,7 +178,7 @@
     err = deflate(&c_stream, Z_NO_FLUSH);
     if (err != Z_OK) {
       fprintf(stderr, "deflate: %s (%d)\n", c_stream.msg, err);
-      exit(1);
+      exit(2);
     }
     n += a85write(f, outbuf, OUTSIZE-c_stream.avail_out);
   } while (!c_stream.avail_out);
@@ -188,11 +188,11 @@
 
 #else  /* HAVE_ZLIB */
 
-int pdf_xship(FILE *f, int filter, char *s, int len) {
+int pdf_xship(FILE *f, int filter, const char *s, int len) {
   return dummy_xship(f, filter, s, len);
 }
 
-int flate_xship(FILE *f, int filter, char *s, int len) {
+int flate_xship(FILE *f, int filter, const char *s, int len) {
   return dummy_xship(f, filter, s, len);
 }
 
@@ -203,7 +203,7 @@
    This relies on lzw.c/h to do the actual compression. */
 
 /* use Postscript level 2 compression. Ship len bytes from str. */
-int lzw_xship(FILE *f, int filter, char *str, int len) {
+int lzw_xship(FILE *f, int filter, const char *str, int len) {
   static int fstate = 0;
   static lzw_stream_t *s = NULL;
   char outbuf[OUTSIZE];
@@ -218,7 +218,7 @@
     s = lzw_init();
     if (s == NULL) {
       fprintf(stderr, "lzw_init: %s\n", strerror(errno));
-      exit(1);
+      exit(2);
     }
     n += a85init(f);
     fstate = 1;
@@ -234,7 +234,7 @@
       err = lzw_compress(s, LZW_EOD);
       if (err) {
 	fprintf(stderr, "lzw_compress: %s\n", strerror(errno));
-	exit(1);
+	exit(2);
       }
       n += a85write(f, outbuf, OUTSIZE - s->avail_out);
     } while (s->avail_out == 0);
@@ -262,7 +262,7 @@
     err = lzw_compress(s, LZW_NORMAL);
     if (err) {
       fprintf(stderr, "lzw_compress: %s\n", strerror(errno));
-      exit(1);
+      exit(2);
     }
     n += a85write(f, outbuf, OUTSIZE - s->avail_out);
   } while (s->avail_out == 0);
@@ -274,7 +274,7 @@
 /* a85 interface: a85 encoding without compression */
 
 /* ship len bytes from s using a85 encoding only. */
-int a85_xship(FILE *f, int filter, char *s, int len) {
+int a85_xship(FILE *f, int filter, const char *s, int len) {
   static int fstate = 0;
   int n=0;
 
@@ -324,7 +324,7 @@
   return r+2;
 }
 
-static int a85write(FILE *f, char *buf, int n) {
+static int a85write(FILE *f, const char *buf, int n) {
   int i;
   int r=0;
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/flate.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/flate.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/flate.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -6,10 +6,10 @@
 #ifndef FLATE_H
 #define FLATE_H
 
-int dummy_xship(FILE *f, int filter, char *s, int len);
-int flate_xship(FILE *f, int filter, char *s, int len);
-int pdf_xship(FILE *f, int filter, char *s, int len);
-int lzw_xship(FILE *f, int filter, char *s, int len);
-int a85_xship(FILE *f, int filter, char *s, int len);
+int dummy_xship(FILE *f, int filter, const char *s, int len);
+int flate_xship(FILE *f, int filter, const char *s, int len);
+int pdf_xship(FILE *f, int filter, const char *s, int len);
+int lzw_xship(FILE *f, int filter, const char *s, int len);
+int a85_xship(FILE *f, int filter, const char *s, int len);
 
 #endif /* FLATE_H */

Modified: trunk/Build/source/libs/potrace/potrace-src/src/greymap.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/greymap.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/greymap.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -26,21 +26,59 @@
 static int gm_readbody_pnm(FILE *f, greymap_t **gmp, int magic);
 static int gm_readbody_bmp(FILE *f, greymap_t **gmp);
 
+#define TRY(x) if (x) goto try_error
+#define TRY_EOF(x) if (x) goto eof
+#define TRY_STD(x) if (x) goto std_error
+
 /* ---------------------------------------------------------------------- */
 /* basic greymap routines */
 
-/* return new un-initialized greymap. NULL with errno on error.
+/* calculate the size, in bytes, required for the data area of a
+   greymap of the given dy and h. Assume h >= 0. Return -1 if the size
+   does not fit into the ptrdiff_t type. */
+static inline ptrdiff_t getsize(int dy, int h) {
+  ptrdiff_t size;
+
+  if (dy < 0) {
+    dy = -dy;
+  }
+  
+  size = (ptrdiff_t)dy * (ptrdiff_t)h * (ptrdiff_t)sizeof(gm_sample_t);
+
+  /* check for overflow error */
+  if (size < 0 || (h != 0 && dy != 0 && size / h / dy != sizeof(gm_sample_t))) {
+    return -1;
+  }
+
+  return size;
+}
+
+/* return the size, in bytes, of the data area of the greymap. Return
+   -1 if the size does not fit into the ptrdiff_t type; however, this
+   cannot happen if the bitmap is well-formed, i.e., if created with
+   gm_new or gm_dup. */
+static inline ptrdiff_t gm_size(const greymap_t *gm) {
+  return getsize(gm->dy, gm->h);
+}
+
+
+
+/* return new greymap initialized to 0. NULL with errno on error.
    Assumes w, h >= 0. */
 greymap_t *gm_new(int w, int h) {
   greymap_t *gm;
-  ptrdiff_t size = (ptrdiff_t)w * (ptrdiff_t)h * (ptrdiff_t)sizeof(signed short int);
-  
-  /* check for overflow error */
-  if (size < 0 || size / w / h != sizeof(signed short int)) {
+  int dy = w;
+  ptrdiff_t size;
+
+  size = getsize(dy, h);
+  if (size < 0) {
     errno = ENOMEM;
     return NULL;
   }
-
+  if (size == 0) {
+    size = 1; /* make surecmalloc() doesn't return NULL */
+  }
+  
   gm = (greymap_t *) malloc(sizeof(greymap_t));
   if (!gm) {
     return NULL;
@@ -47,11 +85,13 @@
   }
   gm->w = w;
   gm->h = h;
-  gm->map = (signed short int *) malloc(size);
-  if (!gm->map) {
+  gm->dy = dy;
+  gm->base = (gm_sample_t *) calloc(1, size);
+  if (!gm->base) {
     free(gm);
     return NULL;
   }
+  gm->map = gm->base;
   return gm;
 }
 
@@ -58,7 +98,7 @@
 /* free the given greymap */
 void gm_free(greymap_t *gm) {
   if (gm) {
-    free(gm->map);
+    free(gm->base);
   }
   free(gm);
 }
@@ -66,26 +106,91 @@
 /* duplicate the given greymap. Return NULL on error with errno set. */
 greymap_t *gm_dup(greymap_t *gm) {
   greymap_t *gm1 = gm_new(gm->w, gm->h);
+  int y;
+  
   if (!gm1) {
     return NULL;
   }
-  memcpy(gm1->map, gm->map, gm->w*gm->h*sizeof(signed short int));
+  for (y=0; y<gm->h; y++) {
+    memcpy(gm_scanline(gm1, y), gm_scanline(gm, y), (size_t)gm1->dy * sizeof(gm_sample_t));
+  }
   return gm1;
 }
 
 /* clear the given greymap to color b. */
 void gm_clear(greymap_t *gm, int b) {
-  int i;
-
+  ptrdiff_t size = gm_size(gm);
+  int x, y;
+  
   if (b==0) {
-    memset(gm->map, 0, gm->w*gm->h*sizeof(signed short int));
+    memset(gm->base, 0, size);
   } else {
-    for (i=0; i<gm->w*gm->h; i++) {
-      gm->map[i] = b;
+    for (y=0; y<gm->h; y++) {
+      for (x=0; x<gm->w; x++) {
+        GM_UPUT(gm, x, y, b);
+      }
     }
-  }    
+  }
 }
 
+/* turn the given greymap upside down. This does not move the pixel
+   data or change the base address. */
+static inline void gm_flip(greymap_t *gm) {
+  int dy = gm->dy;
+
+  if (gm->h == 0 || gm->h == 1) {
+    return;
+  }
+  
+  gm->map = gm_scanline(gm, gm->h - 1);
+  gm->dy = -dy;
+}
+
+/* resize the greymap to the given new height. The pixel data remains
+   bottom-aligned (truncated at the top) when dy >= 0 and top-aligned
+   (truncated at the bottom) when dy < 0. Return 0 on success, or 1 on
+   error with errno set. If the new height is <= the old one, no error
+   should occur. If the new height is larger, the additional pixel
+   data is *not* initialized. */
+static inline int gm_resize(greymap_t *gm, int h) {
+  int dy = gm->dy;
+  ptrdiff_t newsize;
+  gm_sample_t *newbase;
+
+  if (dy < 0) {
+    gm_flip(gm);
+  }
+  
+  newsize = getsize(dy, h);
+  if (newsize < 0) {
+    errno = ENOMEM;
+    goto error;
+  }
+  if (newsize == 0) {
+    newsize = 1; /* make sure realloc() doesn't return NULL */
+  }
+  
+  newbase = (gm_sample_t *)realloc(gm->base, newsize);
+  if (newbase == NULL) {
+    goto error;
+  }
+  gm->base = newbase;
+  gm->map = newbase;
+  gm->h = h;
+
+  if (dy < 0) {
+    gm_flip(gm);
+  }
+  return 0;
+  
+ error:
+  if (dy < 0) {
+    gm_flip(gm);
+  }
+  return 1;  
+}
+
+
 /* ---------------------------------------------------------------------- */
 /* routines for reading pnm streams */
 
@@ -178,7 +283,7 @@
    -4 if wrong magic number. If the return value is >=0, *gmp is
    valid. */
 
-char *gm_read_error = NULL;
+const char *gm_read_error = NULL;
 
 int gm_read(FILE *f, greymap_t **gmp) {
   int magic[2];
@@ -212,7 +317,9 @@
   int x, y, i, j, b, b1, sum;
   int bpr; /* bytes per row (as opposed to 4*gm->c) */
   int w, h, max;
-
+  int realheight;  /* in case of incomplete file, keeps track of how
+                      many scan lines actually contain data */
+  
   gm = NULL;
 
   w = readnum(f);
@@ -228,11 +335,10 @@
   /* allocate greymap */
   gm = gm_new(w, h);
   if (!gm) {
-    return -1;
+    goto std_error;
   }
 
-  /* zero it out */
-  gm_clear(gm, 0);
+  realheight = 0;
 
   switch (magic) {
   default: 
@@ -242,7 +348,8 @@
   case '1':
     /* read P1 format: PBM ascii */
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
 	b = readbit(f);
 	if (b<0) {
@@ -261,7 +368,8 @@
       goto format_error;
     }
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         b = readnum(f);
         if (b<0) {
@@ -280,7 +388,8 @@
       goto format_error;
     }
     
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
 	sum = 0;
 	for (i=0; i<3; i++) {
@@ -305,7 +414,8 @@
 
     bpr = (w+7)/8;
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (i=0; i<bpr; i++) {
 	b = fgetc(f);
 	if (b==EOF) {
@@ -331,7 +441,8 @@
       goto format_error;
     }
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         b = fgetc(f);
         if (b==EOF)
@@ -361,7 +472,8 @@
       goto format_error;
     }
 
-    for (y=h-1; y>=0; y--) {
+    for (y=0; y<h; y++) {
+      realheight = y+1;
       for (x=0; x<w; x++) {
         sum = 0;
         for (i=0; i<3; i++) {
@@ -384,10 +496,13 @@
     break;
   }
 
+  gm_flip(gm);
   *gmp = gm;
   return 0;
 
  eof:
+  TRY_STD(gm_resize(gm, realheight));
+  gm_flip(gm);
   *gmp = gm;
   return 1;
 
@@ -401,6 +516,10 @@
     gm_read_error = "invalid ppm file";
   }
   return -2;
+
+ std_error:
+  gm_free(gm);
+  return -1;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -447,7 +566,7 @@
     if (b==EOF) {
       return 1;
     }
-    sum += b << (8*i);
+    sum += (unsigned)b << (8*i);
   }
   bmp_count += n;
   bmp_pos += n;
@@ -492,12 +611,9 @@
   return 0;
 }
 
-#define TRY(x) if (x) goto try_error
-#define TRY_EOF(x) if (x) goto eof
+/* safe colortable access */
+#define COLTABLE(c) ((c) < bmpinfo.ncolors ? coltable[(c)] : 0)
 
-/* correct y-coordinate for top-down format */
-#define ycorr(y) (bmpinfo.topdown ? bmpinfo.h-1-y : y)
-
 /* read BMP stream after magic number. Return values as for gm_read.
    We choose to be as permissive as possible, since there are many
    programs out there which produce BMP. For instance, ppmtobmp can
@@ -516,6 +632,8 @@
   unsigned int bitbuf;
   unsigned int n;
   unsigned int redshift, greenshift, blueshift;
+  int realheight;  /* in case of incomplete file, keeps track of how
+                      many scan lines actually contain data */
 
   gm_read_error = NULL;
   gm = NULL;
@@ -581,6 +699,10 @@
     goto format_error;
   }
 
+  if (bmpinfo.comp > 3 || bmpinfo.bits > 32) {
+    goto format_error;
+  }
+  
   /* forward to color table (e.g., if bmpinfo.InfoSize == 64) */
   TRY(bmp_forward(f, 14+bmpinfo.InfoSize));
 
@@ -589,7 +711,7 @@
     goto format_error;  /* can't handle planes */
   }
   
-  if (bmpinfo.ncolors == 0) {
+  if (bmpinfo.ncolors == 0 && bmpinfo.bits <= 8) {
     bmpinfo.ncolors = 1 << bmpinfo.bits;
   }
 
@@ -618,10 +740,9 @@
   if (!gm) {
     goto std_error;
   }
+
+  realheight = 0;
   
-  /* zero it out */
-  gm_clear(gm, 0);
-
   switch (bmpinfo.bits + 0x100*bmpinfo.comp) {
     
   default:
@@ -632,11 +753,12 @@
 
     /* raster data */
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (i=0; 8*i<bmpinfo.w; i++) {
 	TRY_EOF(bmp_readint(f, 1, &b));
 	for (j=0; j<8; j++) {
-	  GM_PUT(gm, i*8+j, ycorr(y), b & (0x80 >> j) ? coltable[1] : coltable[0]);
+	  GM_PUT(gm, i*8+j, y, b & (0x80 >> j) ? COLTABLE(1) : COLTABLE(0));
 	}
       }
       TRY(bmp_pad(f));
@@ -651,6 +773,7 @@
   case 0x007: 
   case 0x008:
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       bitbuf = 0;  /* bit buffer: bits in buffer are high-aligned */
       n = 0;       /* number of bits currently in bitbuffer */
@@ -663,7 +786,7 @@
 	b = bitbuf >> (INTBITS - bmpinfo.bits);
 	bitbuf <<= bmpinfo.bits;
 	n -= bmpinfo.bits;
-	GM_UPUT(gm, x, ycorr(y), coltable[b]);
+	GM_UPUT(gm, x, y, COLTABLE(b));
       }
       TRY(bmp_pad(f));
     }
@@ -679,11 +802,12 @@
   case 0x018:  /* 24-bit encoding */
   case 0x020:  /* 32-bit encoding */
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (x=0; x<bmpinfo.w; x++) {
         TRY_EOF(bmp_readint(f, bmpinfo.bits/8, &c));
 	c = ((c>>16) & 0xff) + ((c>>8) & 0xff) + (c & 0xff);
-        GM_UPUT(gm, x, ycorr(y), c/3);
+        GM_UPUT(gm, x, y, c/3);
       }
       TRY(bmp_pad(f));
     }
@@ -695,11 +819,12 @@
     blueshift = lobit(bmpinfo.BlueMask);
 
     for (y=0; y<bmpinfo.h; y++) {
+      realheight = y+1;
       bmp_pad_reset();
       for (x=0; x<bmpinfo.w; x++) {
         TRY_EOF(bmp_readint(f, bmpinfo.bits/8, &c));
 	c = ((c & bmpinfo.RedMask) >> redshift) + ((c & bmpinfo.GreenMask) >> greenshift) + ((c & bmpinfo.BlueMask) >> blueshift);
-        GM_UPUT(gm, x, ycorr(y), c/3);
+        GM_UPUT(gm, x, y, c/3);
       }
       TRY(bmp_pad(f));
     }
@@ -713,8 +838,8 @@
       TRY_EOF(bmp_readint(f, 1, &c)); /* argument */
       if (b>0) {
 	/* repeat count */
-	col[0] = coltable[(c>>4) & 0xf];
-	col[1] = coltable[c & 0xf];
+	col[0] = COLTABLE((c>>4) & 0xf);
+	col[1] = COLTABLE(c & 0xf);
 	for (i=0; i<b && x<bmpinfo.w; i++) {
 	  if (x>=bmpinfo.w) {
 	    x=0;
@@ -723,7 +848,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  GM_UPUT(gm, x, ycorr(y), col[i&1]);
+          realheight = y+1;
+	  GM_UPUT(gm, x, y, col[i&1]);
 	  x++;
 	}
       } else if (c == 0) {
@@ -752,7 +878,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  GM_PUT(gm, x, ycorr(y), coltable[(b>>(4-4*(i&1))) & 0xf]);
+          realheight = y+1;
+	  GM_PUT(gm, x, y, COLTABLE((b>>(4-4*(i&1))) & 0xf));
 	  x++;
 	}
 	if ((c+1) & 2) {
@@ -779,7 +906,8 @@
 	  if (y>=bmpinfo.h) {
 	    break;
 	  }
-	  GM_UPUT(gm, x, ycorr(y), coltable[c]);
+          realheight = y+1;
+	  GM_UPUT(gm, x, y, COLTABLE(c));
 	  x++;
 	}
       } else if (c == 0) {
@@ -806,7 +934,8 @@
           if (y>=bmpinfo.h) {
             break;
           }
-	  GM_PUT(gm, x, ycorr(y), coltable[b]);
+          realheight = y+1;
+	  GM_PUT(gm, x, y, COLTABLE(b));
 	  x++;
 	}
 	if (c & 1) {
@@ -824,11 +953,18 @@
   bmp_forward(f, bmpinfo.FileSize);
 
   free(coltable);
+  if (bmpinfo.topdown) {
+    gm_flip(gm);
+  }
   *gmp = gm;
   return 0;
 
  eof:
+  TRY_STD(gm_resize(gm, realheight));
   free(coltable);
+  if (bmpinfo.topdown) {
+    gm_flip(gm);
+  }
   *gmp = gm;
   return 1;
 
@@ -835,7 +971,7 @@
  format_error:
  try_error:
   free(coltable);
-  free(gm);
+  gm_free(gm);
   if (!gm_read_error) {
     gm_read_error = "invalid bmp file";
   }
@@ -843,7 +979,7 @@
 
  std_error:
   free(coltable);
-  free(gm);
+  gm_free(gm);
   return -1;
 }
 
@@ -855,7 +991,7 @@
    if any (set to 2.2 if the image is to look optimal on a CRT monitor,
    2.8 for LCD). Set to 1.0 for no gamma correction */
 
-int gm_writepgm(FILE *f, greymap_t *gm, char *comment, int raw, int mode, double gamma) {
+int gm_writepgm(FILE *f, greymap_t *gm, const char *comment, int raw, int mode, double gamma) {
   int x, y, v;
   int gammatable[256];
   

Modified: trunk/Build/source/libs/potrace/potrace-src/src/greymap.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/greymap.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/greymap.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -10,14 +10,19 @@
 #include <stdlib.h>
 #include <stddef.h>
 
+/* type for greymap samples */
+typedef signed short int gm_sample_t;
+
 /* internal format for greymaps. Note: in this format, rows are
    ordered from bottom to top. The pixels in each row are given from
    left to right. */
-
 struct greymap_s {
-  int w;                 /* width, in pixels */
-  int h;                 /* height, in pixels */
-  signed short int *map;    /* raw data, w*h values */
+  int w;              /* width, in pixels */
+  int h;              /* height, in pixels */
+  int dy;             /* offset between scanlines (in samples); 
+                         can be negative */
+  gm_sample_t *base;  /* root of allocated data */
+  gm_sample_t *map;   /* points to the lower left pixel */
 };
 typedef struct greymap_s greymap_t;
 
@@ -24,13 +29,14 @@
 /* macros for accessing pixel at index (x,y). Note that the origin is
    in the *lower* left corner. U* macros omit the bounds check. */
 
-#define gm_index(gm, x, y) (&(gm)->map[(x)+(y)*(ptrdiff_t)(gm)->w])
+#define gm_scanline(gm, y) ((gm)->map + (ptrdiff_t)(y)*(ptrdiff_t)(gm)->dy)
+#define gm_index(gm, x, y) (gm_scanline(gm, y) + (x))
 #define gm_safe(gm, x, y) ((int)(x)>=0 && (int)(x)<(gm)->w && (int)(y)>=0 && (int)(y)<(gm)->h)
 #define gm_bound(x, m) ((x)<0 ? 0 : (x)>=(m) ? (m)-1 : (x))
 #define GM_UGET(gm, x, y) (*gm_index(gm, x, y))
-#define GM_UINC(gm, x, y, b) (*gm_index(gm, x, y) += (short int)(b))
+#define GM_UINC(gm, x, y, b) (*gm_index(gm, x, y) += (gm_sample_t)(b))
 #define GM_UINV(gm, x, y) (*gm_index(gm, x, y) = 255 - *gm_index(gm, x, y))
-#define GM_UPUT(gm, x, y, b) (*gm_index(gm, x, y) = (short int)(b))
+#define GM_UPUT(gm, x, y, b) (*gm_index(gm, x, y) = (gm_sample_t)(b))
 #define GM_GET(gm, x, y) (gm_safe(gm, x, y) ? GM_UGET(gm, x, y) : 0)
 #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)
@@ -46,7 +52,7 @@
 #define GM_MODE_POSITIVE 3
 #define GM_MODE_NEGATIVE 4
 
-extern char *gm_read_error;
+extern const char *gm_read_error;
 
 greymap_t *gm_new(int w, int h);
 greymap_t *gm_dup(greymap_t *gm);
@@ -53,7 +59,7 @@
 void gm_free(greymap_t *gm);
 void gm_clear(greymap_t *gm, int b);
 int gm_read(FILE *f, greymap_t **gmp);
-int gm_writepgm(FILE *f, greymap_t *gm, char *comment, int raw, int mode, double gamma);
+int gm_writepgm(FILE *f, greymap_t *gm, const char *comment, int raw, int mode, double gamma);
 int gm_print(FILE *f, greymap_t *gm);
 
 #endif /* GREYMAP_H */

Modified: trunk/Build/source/libs/potrace/potrace-src/src/lists.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/lists.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/lists.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/lzw.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/lzw.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/lzw.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -86,9 +86,9 @@
    created until it is accessed. */
 
 struct lzw_dict_s {
-  char c;      /* last character of string represented by this entry */
-  int code;    /* code for the string represented by this entry */
-  int freq;    /* how often searched? For optimization only */
+  char c;            /* last character of string represented by this entry */
+  unsigned int code; /* code for the string represented by this entry */
+  int freq;          /* how often searched? For optimization only */
   struct lzw_dict_s *children;  /* list of sub-entries */
   struct lzw_dict_s *next;      /* for making a linked list */
 };
@@ -104,8 +104,8 @@
 struct lzw_state_s {
   /* dictionary state */
   int n;           /* current size of the dictionary */
-  lzw_dict_t *d;     /* pointer to dictionary */
-  lzw_dict_t *s;     /* pointer to current string, or NULL at beginning */
+  lzw_dict_t *d;   /* pointer to dictionary */
+  lzw_dict_t *s;   /* pointer to current string, or NULL at beginning */
 
   /* buffers for pending output */
   BITBUF_TYPE buf; /* bits scheduled for output - left aligned, 0 padded */
@@ -143,7 +143,7 @@
 /* write the code to the bit buffer. Precondition st->bufsize <= 7.
    Note: this does not change the dictionary state; in particular,
    n must be updated between consecutive calls. */
-static inline void lzw_emit(int code, lzw_state_t *st) {
+static inline void lzw_emit(unsigned int code, lzw_state_t *st) {
   BITBUF_TYPE mask;
   int bits = hibit(st->n);
 
@@ -232,7 +232,7 @@
       return 1;
     }
     e->c = c;
-    e->code = (int)(unsigned char)c;
+    e->code = (unsigned char)c;
     e->freq = 0;
     e->children = NULL;
     list_prepend(st->d, e);

Modified: trunk/Build/source/libs/potrace/potrace-src/src/lzw.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/lzw.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/lzw.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -9,12 +9,12 @@
 /* user visible state */
 
 struct lzw_stream_s {
-  char *next_in;     /* pointer to next input character */
-  int avail_in;      /* number of input chars available */
-  char *next_out;    /* pointer to next free byte in output buffer */
-  int avail_out;     /* remaining size of output buffer */
+  const char *next_in; /* pointer to next input character */
+  int avail_in;        /* number of input chars available */
+  char *next_out;      /* pointer to next free byte in output buffer */
+  int avail_out;       /* remaining size of output buffer */
 
-  void *internal;    /* internal state, not user accessible */
+  void *internal;      /* internal state, not user accessible */
 };
 typedef struct lzw_stream_s lzw_stream_t;
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/main.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/main.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/main.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -45,7 +45,7 @@
 /* some data structures for option processing */
 
 struct pageformat_s {
-  char *name;
+  const char *name;
   int w, h;
 };
 typedef struct pageformat_s pageformat_t;
@@ -68,7 +68,7 @@
 };
 
 struct turnpolicy_s {
-  char *name;
+  const char *name;
   int n;
 };
 typedef struct turnpolicy_s turnpolicy_t;
@@ -87,8 +87,8 @@
 
 /* backends and their characteristics */
 struct backend_s {
-  char *name;       /* name of this backend */
-  char *ext;        /* file extension */
+  const char *name;       /* name of this backend */
+  const char *ext;        /* file extension */
   int fixed;        /* fixed page size backend? */
   int pixel;        /* pixel-based backend? */
   int multi;        /* multi-page backend? */
@@ -118,7 +118,7 @@
 /* look up a backend by name. If found, return 0 and set *bp. If not
    found leave *bp unchanged and return 1, or 2 on ambiguous
    prefix. */
-static int backend_lookup(char *name, backend_t **bp) {
+static int backend_lookup(const char *name, backend_t **bp) {
   int i;
   int m=0;  /* prefix matches */
   backend_t *b = NULL;
@@ -185,14 +185,14 @@
 }
 
 static void show_defaults(FILE *f) {
-  fprintf(f, "Default unit: "DEFAULT_DIM_NAME"\n");
-  fprintf(f, "Default page size: "DEFAULT_PAPERFORMAT"\n");
+  fprintf(f, "Default unit: " DEFAULT_DIM_NAME "\n");
+  fprintf(f, "Default page size: " DEFAULT_PAPERFORMAT "\n");
 }
 
 static void usage(FILE *f) {
   int j;
 
-  fprintf(f, "Usage: "POTRACE" [options] [filename...]\n");
+  fprintf(f, "Usage: " POTRACE " [options] [filename...]\n");
   fprintf(f, "General options:\n");
   fprintf(f, " -h, --help                 - print this help message and exit\n");
   fprintf(f, " -v, --version              - print version info and exit\n");
@@ -222,7 +222,7 @@
   fprintf(f, " -u, --unit <n>             - quantize output to 1/unit pixels (default 10)\n");
   fprintf(f, " -d, --debug <n>            - produce debugging output of type n (n=1,2,3)\n");
   fprintf(f, "Scaling and placement options:\n");
-  fprintf(f, " -P, --pagesize <format>    - page size (default is "DEFAULT_PAPERFORMAT")\n");
+  fprintf(f, " -P, --pagesize <format>    - page size (default is " DEFAULT_PAPERFORMAT ")\n");
   fprintf(f, " -W, --width <dim>          - width of output image\n");
   fprintf(f, " -H, --height <dim>         - height of output image\n");
   fprintf(f, " -r, --resolution <n>[x<n>] - resolution (in dpi) (dimension-based backends)\n");
@@ -259,7 +259,7 @@
   fprintf(f, " --tty <mode>               - progress bar rendering: vt100 or dumb\n");
   fprintf(f, "\n");
   fprintf(f, "Dimensions can have optional units, e.g. 6.5in, 15cm, 100pt.\n");
-  fprintf(f, "Default is "DEFAULT_DIM_NAME" (or pixels for pgm, dxf, and gimppath backends).\n");
+  fprintf(f, "Default is " DEFAULT_DIM_NAME " (or pixels for pgm, dxf, and gimppath backends).\n");
   fprintf(f, "Possible input file formats are: pnm (pbm, pgm, ppm), bmp.\n");
   j = fprintf(f, "Backends are: ");
   backend_list(f, j, 78);
@@ -431,7 +431,7 @@
   {0, 0, 0, 0}
 };
 
-static char *shortopts = "hvVlW:H:r:x:S:M:L:R:T:B:A:P:t:u:c23epsgb:d:C:z:G:nqa:O:o:k:i";
+static const char *shortopts = "hvVlW:H:r:x:S:M:L:R:T:B:A:P:t:u:c23epsgb:d:C:z:G:nqa:O:o:k:i";
 
 static void dopts(int ac, char *av[]) {
   int c;
@@ -465,8 +465,8 @@
   info.gamma = 2.2;
   info.param = potrace_param_default();
   if (!info.param) {
-    fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
-    exit(1);
+    fprintf(stderr, "" POTRACE ": %s\n", strerror(errno));
+    exit(2);
   }
   info.longcoding = 0;
   info.outfile = NULL;
@@ -481,19 +481,19 @@
   while ((c = getopt_long(ac, av, shortopts, longopts, NULL)) != -1) {
     switch (c) {
     case 'h':
-      fprintf(stdout, ""POTRACE" "VERSION". Transforms bitmaps into vector graphics.\n\n");
+      fprintf(stdout, "" POTRACE " " VERSION ". Transforms bitmaps into vector graphics.\n\n");
       usage(stdout);
       exit(0);
       break;
     case 'v':
     case 'V':
-      fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2015 Peter Selinger.\n");
+      fprintf(stdout, "" POTRACE " " VERSION ". Copyright (C) 2001-2017 Peter Selinger.\n");
       fprintf(stdout, "Library version: %s\n", potrace_version());
       show_defaults(stdout);
       exit(0);
       break;
     case 'l':
-      fprintf(stdout, ""POTRACE" "VERSION". Copyright (C) 2001-2015 Peter Selinger.\n\n");
+      fprintf(stdout, "" POTRACE " " VERSION ". Copyright (C) 2001-2017 Peter Selinger.\n\n");
       license(stdout);
       exit(0);
       break;
@@ -500,7 +500,7 @@
     case 'W':
       info.width_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -507,7 +507,7 @@
     case 'H':
       info.height_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -523,7 +523,7 @@
 	info.rx = info.ry = dim.x;
 	break;
       }
-      fprintf(stderr, ""POTRACE": invalid resolution -- %s\n", optarg);
+      fprintf(stderr, "" POTRACE ": invalid resolution -- %s\n", optarg);
       exit(1);
       break;
     case 'x':
@@ -538,7 +538,7 @@
 	info.sx = info.sy = dim.x;
 	break;
       }
-      fprintf(stderr, ""POTRACE": invalid scaling factor -- %s\n", optarg);
+      fprintf(stderr, "" POTRACE ": invalid scaling factor -- %s\n", optarg);
       exit(1);
       break;
     case 'S':
@@ -547,7 +547,7 @@
     case 'M':
       info.lmar_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       info.rmar_d = info.tmar_d = info.bmar_d = info.lmar_d;
@@ -555,7 +555,7 @@
     case 'L':
       info.lmar_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -562,7 +562,7 @@
     case 'R':
       info.rmar_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -569,7 +569,7 @@
     case 'T':
       info.tmar_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -576,7 +576,7 @@
     case 'B':
       info.bmar_d = parse_dimension(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid dimension -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid dimension -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -586,7 +586,7 @@
     case 'A':
       info.angle = strtod(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid angle -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid angle -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -618,9 +618,9 @@
 	break;
       }
       if (matches == 0) {
-	fprintf(stderr, ""POTRACE": unrecognized page format -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": unrecognized page format -- %s\n", optarg);
       } else {
-	fprintf(stderr, ""POTRACE": ambiguous page format -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": ambiguous page format -- %s\n", optarg);
       }
       j = fprintf(stderr, "Use one of: ");
       for (i=0; pageformat[i].name!=NULL; i++) {
@@ -639,7 +639,7 @@
     case 'u':
       info.unit = strtod(optarg, &p);
       if (*p) {
-        fprintf(stderr, ""POTRACE": invalid unit -- %s\n", optarg);
+        fprintf(stderr, "" POTRACE ": invalid unit -- %s\n", optarg);
         exit(1);
       }
       break;
@@ -656,7 +656,7 @@
       info.pslevel = 3;
       info.compress = 1;
 #else
-      fprintf(stderr, ""POTRACE": option -3 not supported, using -2 instead.\n");
+      fprintf(stderr, "" POTRACE ": option -3 not supported, using -2 instead.\n");
       fflush(stderr);
       info.pslevel = 2;
       info.compress = 1;
@@ -678,9 +678,9 @@
       r = backend_lookup(optarg, &info.backend);
       if (r==1 || r==2) {
 	if (r==1) {
-	  fprintf(stderr, ""POTRACE": unrecognized backend -- %s\n", optarg);
+	  fprintf(stderr, "" POTRACE ": unrecognized backend -- %s\n", optarg);
 	} else {
-	  fprintf(stderr, ""POTRACE": ambiguous backend -- %s\n", optarg);
+	  fprintf(stderr, "" POTRACE ": ambiguous backend -- %s\n", optarg);
 	}
 	j = fprintf(stderr, "Use one of: ");
 	backend_list(stderr, j, 70);
@@ -694,7 +694,7 @@
     case 'C':
       info.color = parse_color(optarg);
       if (info.color == -1) {
-	fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid color -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -701,7 +701,7 @@
     case OPT_FILLCOLOR:
       info.fillcolor = parse_color(optarg);
       if (info.fillcolor == -1) {
-	fprintf(stderr, ""POTRACE": invalid color -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid color -- %s\n", optarg);
 	exit(1);
       }
       info.opaque = 1;
@@ -724,9 +724,9 @@
 	break;
       }
       if (matches == 0) {
-	fprintf(stderr, ""POTRACE": unrecognized turnpolicy -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": unrecognized turnpolicy -- %s\n", optarg);
       } else {
-	fprintf(stderr, ""POTRACE": ambiguous turnpolicy -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": ambiguous turnpolicy -- %s\n", optarg);
       }
       j = fprintf(stderr, "Use one of: ");
       for (i=0; turnpolicy[i].name!=NULL; i++) {
@@ -751,7 +751,7 @@
     case 'a':
       info.param->alphamax = strtod(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid alphamax -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid alphamax -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -758,7 +758,7 @@
     case 'O':
       info.param->opttolerance = strtod(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid opttolerance -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid opttolerance -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -766,7 +766,7 @@
       free(info.outfile);
       info.outfile = strdup(optarg);
       if (!info.outfile) {
-	fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s\n", strerror(errno));
         exit(2);
       }
       break;
@@ -773,7 +773,7 @@
     case 'k':
       info.blacklevel = strtod(optarg, &p);
       if (*p) {
-	fprintf(stderr, ""POTRACE": invalid blacklevel -- %s\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid blacklevel -- %s\n", optarg);
 	exit(1);
       }
       break;
@@ -798,7 +798,7 @@
       } else if (strcmp(optarg, "vt100") == 0) {
 	info.progress_bar = progress_bar_vt100;
       } else {
-	fprintf(stderr, ""POTRACE": invalid tty mode -- %s. Try --help for more info\n", optarg);
+	fprintf(stderr, "" POTRACE ": invalid tty mode -- %s. Try --help for more info\n", optarg);
 	exit(1);
       }
       break;
@@ -807,7 +807,7 @@
       exit(1);
       break;
     default:
-      fprintf(stderr, ""POTRACE": Unimplemented option -- %c\n", c);
+      fprintf(stderr, "" POTRACE ": Unimplemented option -- %c\n", c);
       exit(1);
     }
   }
@@ -987,7 +987,7 @@
 /* auxiliary functions for file handling */
 
 /* open a file for reading. Return stdin if filename is NULL or "-" */ 
-static FILE *my_fopen_read(char *filename) {
+static FILE *my_fopen_read(const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return stdin;
   }
@@ -995,7 +995,7 @@
 }
 
 /* open a file for writing. Return stdout if filename is NULL or "-" */ 
-static FILE *my_fopen_write(char *filename) {
+static FILE *my_fopen_write(const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return stdout;
   }
@@ -1003,7 +1003,7 @@
 }
 
 /* close a file, but do nothing is filename is NULL or "-" */
-static void my_fclose(FILE *f, char *filename) {
+static void my_fclose(FILE *f, const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return;
   }
@@ -1011,7 +1011,7 @@
 }
 
 /* make output filename from input filename. Return an allocated value. */
-static char *make_outfilename(char *infile, char *ext) {
+static char *make_outfilename(const char *infile, const char *ext) {
   char *outfile;
   char *p;
 
@@ -1058,27 +1058,27 @@
     r = bm_read(fin, info.blacklevel, &bm);
     switch (r) {
     case -1:  /* system error */
-      fprintf(stderr, ""POTRACE": %s: %s\n", infile, strerror(errno));
+      fprintf(stderr, "" POTRACE ": %s: %s\n", infile, strerror(errno));
       exit(2);
     case -2:  /* corrupt file format */
-      fprintf(stderr, ""POTRACE": %s: file format error: %s\n", infile, bm_read_error);
+      fprintf(stderr, "" POTRACE ": %s: file format error: %s\n", infile, bm_read_error);
       exit(2);
     case -3:  /* empty file */
       if (count>0) {  /* end of file */
 	return;
       }
-      fprintf(stderr, ""POTRACE": %s: empty file\n", infile);
+      fprintf(stderr, "" POTRACE ": %s: empty file\n", infile);
       exit(2);
     case -4:  /* wrong magic */
       if (count>0) { 
-	fprintf(stderr, ""POTRACE": %s: warning: junk at end of file\n", infile);
+	fprintf(stderr, "" POTRACE ": %s: warning: junk at end of file\n", infile);
 	return;
       }
-      fprintf(stderr, ""POTRACE": %s: file format not recognized\n", infile);
+      fprintf(stderr, "" POTRACE ": %s: file format not recognized\n", infile);
       fprintf(stderr, "Possible input file formats are: pnm (pbm, pgm, ppm), bmp.\n");
       exit(2);
     case 1:  /* unexpected end of file */
-      fprintf(stderr, ""POTRACE": warning: %s: premature end of file\n", infile);
+      fprintf(stderr, "" POTRACE ": warning: %s: premature end of file\n", infile);
       eof_flag = 1;
       break;
     }
@@ -1087,7 +1087,7 @@
     if (info.progress) {
       r = info.progress_bar->init(&info.param->progress, infile, count);
       if (r) {
-	fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s\n", strerror(errno));
 	exit(2);
       }
     } else {
@@ -1101,7 +1101,7 @@
     /* process the image */
     st = potrace_trace(info.param, bm);
     if (!st || st->status != POTRACE_STATUS_OK) {
-      fprintf(stderr, ""POTRACE": %s: %s\n", infile, strerror(errno));
+      fprintf(stderr, "" POTRACE ": %s: %s\n", infile, strerror(errno));
       exit(2);
     }
 
@@ -1114,7 +1114,7 @@
 
     r = b->page_f(fout, st->plist, &imginfo);
     if (r) {
-      fprintf(stderr, ""POTRACE": %s: %s\n", outfile, strerror(errno));
+      fprintf(stderr, "" POTRACE ": %s: %s\n", outfile, strerror(errno));
       exit(2);
     }
 
@@ -1150,7 +1150,7 @@
 
   b = info.backend;
   if (b==NULL) {
-    fprintf(stderr, ""POTRACE": internal error: selected backend not found\n");
+    fprintf(stderr, "" POTRACE ": internal error: selected backend not found\n");
     exit(1);
   }
 
@@ -1175,7 +1175,7 @@
 
     fout = my_fopen_write(info.outfile);
     if (!fout) {
-      fprintf(stderr, ""POTRACE": %s: %s\n", info.outfile ? info.outfile : "stdout", strerror(errno));
+      fprintf(stderr, "" POTRACE ": %s: %s\n", info.outfile ? info.outfile : "stdout", strerror(errno));
       exit(2); 
     }
     if (b->init_f) {
@@ -1195,17 +1195,17 @@
     for (i=0; i<info.infilecount; i++) {
       outfile = make_outfilename(info.infiles[i], b->ext);
       if (!outfile) {
-	fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s\n", strerror(errno));
 	exit(2);
       }
       fin = my_fopen_read(info.infiles[i]);
       if (!fin) {
-	fprintf(stderr, ""POTRACE": %s: %s\n", info.infiles[i], strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s: %s\n", info.infiles[i], strerror(errno));
 	exit(2);
       }
       fout = my_fopen_write(outfile);
       if (!fout) {
-	fprintf(stderr, ""POTRACE": %s: %s\n", outfile, strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s: %s\n", outfile, strerror(errno));
 	exit(2);
       }
       if (b->init_f) {
@@ -1225,17 +1225,17 @@
   } else {                                   /* infiles to single outfile */
 
     if (!b->multi && info.infilecount >= 2) {
-      fprintf(stderr, ""POTRACE": cannot use multiple input files with -o in %s mode\n", b->name);
+      fprintf(stderr, "" POTRACE ": cannot use multiple input files with -o in %s mode\n", b->name);
       exit(1);
     }
     if (info.infilecount == 0) {
-      fprintf(stderr, ""POTRACE": cannot use empty list of input files with -o\n");
+      fprintf(stderr, "" POTRACE ": cannot use empty list of input files with -o\n");
       exit(1);
     }
     
     fout = my_fopen_write(info.outfile);
     if (!fout) {
-      fprintf(stderr, ""POTRACE": %s: %s\n", info.outfile, strerror(errno));
+      fprintf(stderr, "" POTRACE ": %s: %s\n", info.outfile, strerror(errno));
       exit(2);
     }
     if (b->init_f) {
@@ -1244,7 +1244,7 @@
     for (i=0; i<info.infilecount; i++) {
       fin = my_fopen_read(info.infiles[i]);
       if (!fin) {
-	fprintf(stderr, ""POTRACE": %s: %s\n", info.infiles[i], strerror(errno));
+	fprintf(stderr, "" POTRACE ": %s: %s\n", info.infiles[i], strerror(errno));
 	exit(2);
       }
       process_file(b, info.infiles[i], info.outfile, fin, fout);
@@ -1263,6 +1263,6 @@
   /* not reached */
 
  try_error:
-  fprintf(stderr, ""POTRACE": %s\n", strerror(errno));
+  fprintf(stderr, "" POTRACE ": %s\n", strerror(errno));
   exit(2);
 }

Modified: trunk/Build/source/libs/potrace/potrace-src/src/main.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/main.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/main.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/mkbitmap.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/mkbitmap.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/mkbitmap.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -29,19 +29,19 @@
 
 /* structure to hold command line options */
 struct info_s {
-  char *outfile;     /* output file */
-  char **infiles;    /* input files */
-  int infilecount;   /* how many input files? */
-  int invert;        /* invert input? */
-  int highpass;      /* use highpass filter? */
-  double lambda;     /* highpass filter radius */
-  int lowpass;       /* use lowpass filter? */
-  double lambda1;    /* lowpass filter radius */
-  int scale;         /* scaling factor */
-  int linear;        /* linear scaling? */
-  int bilevel;       /* convert to bilevel? */
-  double level;      /* cutoff grey level */
-  char *outext;      /* default output file extension */
+  char *outfile;      /* output file */
+  char **infiles;     /* input files */
+  int infilecount;    /* how many input files? */
+  int invert;         /* invert input? */
+  int highpass;       /* use highpass filter? */
+  double lambda;      /* highpass filter radius */
+  int lowpass;        /* use lowpass filter? */
+  double lambda1;     /* lowpass filter radius */
+  int scale;          /* scaling factor */
+  int linear;         /* linear scaling? */
+  int bilevel;        /* convert to bilevel? */
+  double level;       /* cutoff grey level */
+  const char *outext; /* default output file extension */
 };
 typedef struct info_s info_t;
 
@@ -56,6 +56,10 @@
   double B;
   int x, y;
 
+  if (gm->h == 0 || gm->w == 0) {
+    return;
+  }
+  
   /* calculate filter coefficients from given lambda */
   B = 1+2/(lambda*lambda);
   c = B-sqrt(B*B-1);
@@ -125,6 +129,10 @@
   double f;
   int x, y;
 
+  if (gm->h == 0 || gm->w == 0) {
+    return 0;
+  }
+
   /* create a copy */
   gm1 = gm_dup(gm);
   if (!gm1) {
@@ -201,7 +209,6 @@
     if (!bm_out) {
       return NULL;
     }
-    bm_clear(bm_out, 0);
     c1 = c * 255;
   } else {
     gm_out = gm_new(w*s, h*s);
@@ -286,7 +293,6 @@
     if (!bm_out) {
       goto calloc_error;
     }
-    bm_clear(bm_out, 0);
     c1 = c * 255;
   } else {
     gm_out = gm_new(w*s, h*s);
@@ -375,7 +381,7 @@
    print error message to stderr and exit with code 2. On warning,
    print warning message to stderr. */
 
-static void process_file(FILE *fin, FILE *fout, char *infile, char *outfile) {
+static void process_file(FILE *fin, FILE *fout, const char *infile, const char *outfile) {
   int r;
   greymap_t *gm;
   potrace_bitmap_t *bm;
@@ -387,27 +393,27 @@
     r = gm_read(fin, &gm);
     switch (r) {
     case -1:  /* system error */
-      fprintf(stderr, ""MKBITMAP": %s: %s\n", infile, strerror(errno));
+      fprintf(stderr, "" MKBITMAP ": %s: %s\n", infile, strerror(errno));
       exit(2);
     case -2:  /* corrupt file format */
-      fprintf(stderr, ""MKBITMAP": %s: file format error: %s\n", infile, gm_read_error);
+      fprintf(stderr, "" MKBITMAP ": %s: file format error: %s\n", infile, gm_read_error);
       exit(2);
     case -3:  /* empty file */
       if (count>0) {  /* end of file */
 	return;
       }
-      fprintf(stderr, ""MKBITMAP": %s: empty file\n", infile);
+      fprintf(stderr, "" MKBITMAP ": %s: empty file\n", infile);
       exit(2);
     case -4:  /* wrong magic */
       if (count>0) {
-	fprintf(stderr, ""MKBITMAP": %s: warning: junk at end of file\n", infile);
+	fprintf(stderr, "" MKBITMAP ": %s: warning: junk at end of file\n", infile);
 	return;
       }
-      fprintf(stderr, ""MKBITMAP": %s: file format not recognized\n", infile);
+      fprintf(stderr, "" MKBITMAP ": %s: file format not recognized\n", infile);
       fprintf(stderr, "Possible input file formats are: pnm (pbm, pgm, ppm), bmp.\n");
       exit(2);
     case 1:  /* unexpected end of file */
-      fprintf(stderr, ""MKBITMAP": %s: warning: premature end of file\n", infile);
+      fprintf(stderr, "" MKBITMAP ": %s: warning: premature end of file\n", infile);
       break;
     }
     
@@ -422,7 +428,7 @@
     if (info.highpass) {
       r = highpass(gm, info.lambda);
       if (r) {
-	fprintf(stderr, ""MKBITMAP": %s: %s\n", infile, strerror(errno));
+	fprintf(stderr, "" MKBITMAP ": %s: %s\n", infile, strerror(errno));
 	exit(2);
       }
     }
@@ -444,7 +450,7 @@
       gm_free(gm);
     }
     if (!sm) {
-      fprintf(stderr, ""MKBITMAP": %s: %s\n", infile, strerror(errno));
+      fprintf(stderr, "" MKBITMAP ": %s: %s\n", infile, strerror(errno));
       exit(2);
     }
     
@@ -483,7 +489,7 @@
 }
 
 static int usage(FILE *f) {
-  fprintf(f, "Usage: "MKBITMAP" [options] [file...]\n");
+  fprintf(f, "Usage: " MKBITMAP " [options] [file...]\n");
   fprintf(f, "Options:\n");
   fprintf(f, " -h, --help           - print this help message and exit\n");
   fprintf(f, " -v, --version        - print version info and exit\n");
@@ -529,7 +535,7 @@
   {0, 0, 0, 0}
 };
 
-static char *shortopts = "hvlo:xif:nb:s:13gt:";
+static const char *shortopts = "hvlo:xif:nb:s:13gt:";
 
 /* process options. On error, print error message to stderr and exit
    with code 1 */
@@ -555,16 +561,16 @@
   while ((c = getopt_long(ac, av, shortopts, longopts, NULL)) != -1) {
     switch (c) {
     case 'h':
-      fprintf(stdout, ""MKBITMAP" "VERSION". Transforms images into bitmaps with scaling and filtering.\n\n");
+      fprintf(stdout, "" MKBITMAP " " VERSION ". Transforms images into bitmaps with scaling and filtering.\n\n");
       usage(stdout);
       exit(0);
       break;
     case 'v':
-      fprintf(stdout, ""MKBITMAP" "VERSION". Copyright (C) 2001-2015 Peter Selinger.\n");
+      fprintf(stdout, "" MKBITMAP " " VERSION ". Copyright (C) 2001-2017 Peter Selinger.\n");
       exit(0);
       break;
     case 'l':
-      fprintf(stdout, ""MKBITMAP" "VERSION". Copyright (C) 2001-2015 Peter Selinger.\n\n");
+      fprintf(stdout, "" MKBITMAP " " VERSION ". Copyright (C) 2001-2017 Peter Selinger.\n\n");
       license(stdout);
       exit(0);
       break;
@@ -572,7 +578,7 @@
       free(info.outfile);
       info.outfile = strdup(optarg);
       if (!info.outfile) {
-        fprintf(stderr, ""MKBITMAP": %s\n", strerror(errno));
+        fprintf(stderr, "" MKBITMAP ": %s\n", strerror(errno));
         exit(2);
       }
       break;
@@ -590,7 +596,7 @@
       info.highpass = 1;
       info.lambda = strtod(optarg, &p);
       if (*p || info.lambda<0) {
-	fprintf(stderr, ""MKBITMAP": invalid filter radius -- %s\n", optarg);
+	fprintf(stderr, "" MKBITMAP ": invalid filter radius -- %s\n", optarg);
         exit(1);
       }
       break;
@@ -601,7 +607,7 @@
       info.lowpass = 1;
       info.lambda1 = strtod(optarg, &p);
       if (*p || info.lambda1<0) {
-	fprintf(stderr, ""MKBITMAP": invalid filter radius -- %s\n", optarg);
+	fprintf(stderr, "" MKBITMAP ": invalid filter radius -- %s\n", optarg);
         exit(1);
       }
       break;
@@ -608,7 +614,7 @@
     case 's':
       info.scale = strtol(optarg, &p, 0);
       if (*p || info.scale<=0) {
-	fprintf(stderr, ""MKBITMAP": invalid scaling factor -- %s\n", optarg);
+	fprintf(stderr, "" MKBITMAP ": invalid scaling factor -- %s\n", optarg);
         exit(1);
       }
       break;
@@ -627,7 +633,7 @@
       info.outext = ".pbm";
       info.level = strtod(optarg, &p);
       if (*p || info.level<0) {
-	fprintf(stderr, ""MKBITMAP": invalid threshold -- %s\n", optarg);
+	fprintf(stderr, "" MKBITMAP ": invalid threshold -- %s\n", optarg);
         exit(1);
       }
       break;
@@ -636,7 +642,7 @@
       exit(1);
       break;
     default:
-      fprintf(stderr, ""MKBITMAP": Unimplemented option -- %c\n", c);
+      fprintf(stderr, "" MKBITMAP ": Unimplemented option -- %c\n", c);
       exit(1);
     }
   }
@@ -649,7 +655,7 @@
 /* auxiliary functions for file handling */
 
 /* open a file for reading. Return stdin if filename is NULL or "-" */ 
-static FILE *my_fopen_read(char *filename) {
+static FILE *my_fopen_read(const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return stdin;
   }
@@ -657,7 +663,7 @@
 }
 
 /* open a file for writing. Return stdout if filename is NULL or "-" */ 
-static FILE *my_fopen_write(char *filename) {
+static FILE *my_fopen_write(const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return stdout;
   }
@@ -665,7 +671,7 @@
 }
 
 /* close a file, but do nothing is filename is NULL or "-" */
-static void my_fclose(FILE *f, char *filename) {
+static void my_fclose(FILE *f, const char *filename) {
   if (filename == NULL || strcmp(filename, "-") == 0) {
     return;
   }
@@ -673,7 +679,7 @@
 }
 
 /* make output filename from input filename. Return an allocated value. */
-static char *make_outfilename(char *infile, char *ext) {
+static char *make_outfilename(const char *infile, const char *ext) {
   char *outfile;
   char *p;
 
@@ -731,7 +737,7 @@
 
     fout = my_fopen_write(info.outfile);
     if (!fout) {
-      fprintf(stderr, ""MKBITMAP": %s: %s\n", info.outfile, strerror(errno));
+      fprintf(stderr, "" MKBITMAP ": %s: %s\n", info.outfile, strerror(errno));
       exit(2);
     }
     process_file(stdin, fout, "stdin", info.outfile);
@@ -744,17 +750,17 @@
     for (i=0; i<info.infilecount; i++) {
       outfile = make_outfilename(info.infiles[i], info.outext);
       if (!outfile) {
-	fprintf(stderr, ""MKBITMAP": %s\n", strerror(errno));
+	fprintf(stderr, "" MKBITMAP ": %s\n", strerror(errno));
         exit(2);
       }
       fin = my_fopen_read(info.infiles[i]);
       if (!fin) {
-	fprintf(stderr, ""MKBITMAP": %s: %s\n", info.infiles[i], strerror(errno));
+	fprintf(stderr, "" MKBITMAP ": %s: %s\n", info.infiles[i], strerror(errno));
 	exit(2);
       }
       fout = my_fopen_write(outfile);
       if (!fout) {
-	fprintf(stderr, ""MKBITMAP": %s: %s\n", outfile, strerror(errno));
+	fprintf(stderr, "" MKBITMAP ": %s: %s\n", outfile, strerror(errno));
 	exit(2);
       }
       process_file(fin, fout, info.infiles[i], outfile);
@@ -768,13 +774,13 @@
 
     fout = my_fopen_write(info.outfile);
     if (!fout) {
-      fprintf(stderr, ""MKBITMAP": %s: %s\n", info.outfile, strerror(errno));
+      fprintf(stderr, "" MKBITMAP ": %s: %s\n", info.outfile, strerror(errno));
       exit(2);
     }
     for (i=0; i<info.infilecount; i++) {
       fin = my_fopen_read(info.infiles[i]);
       if (!fin) {
-	fprintf(stderr, ""MKBITMAP": %s: %s\n", info.infiles[i], strerror(errno));
+	fprintf(stderr, "" MKBITMAP ": %s: %s\n", info.infiles[i], strerror(errno));
 	exit(2);
       }
       process_file(fin, fout, info.infiles[i], info.outfile);

Modified: trunk/Build/source/libs/potrace/potrace-src/src/platform.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/platform.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/platform.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/potracelib.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/potracelib.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/potracelib.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -109,6 +109,6 @@
   free(p);
 }
 
-char *potrace_version(void) {
-  return "potracelib "VERSION"";
+const char *potrace_version(void) {
+  return "potracelib " VERSION "";
 }

Modified: trunk/Build/source/libs/potrace/potrace-src/src/potracelib.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/potracelib.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/potracelib.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -130,7 +130,7 @@
 
 /* return a static plain text version string identifying this version
    of potracelib */
-char *potrace_version(void);
+const char *potrace_version(void);
 
 #ifdef  __cplusplus
 } /* end of extern "C" */

Modified: trunk/Build/source/libs/potrace/potrace-src/src/potracelib_demo.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/potracelib_demo.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/potracelib_demo.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/progress.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/progress.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/progress.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -44,7 +44,7 @@
   if (d >= p->dnext) {
     tick = (int) floor(d*40+0.01);
     perc = (int) floor(d*100+0.025);
-    fprintf(stderr, "%-21s |%-40s| %d%% "COL0"", p->name, b+40-tick, perc);
+    fprintf(stderr, "%-21s |%-40s| %d%% " COL0 "", p->name, b+40-tick, perc);
     fflush(stderr);
     p->dnext = (tick+0.995) / 40.0;
   }

Modified: trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/progress_bar.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/render.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/render.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/render.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 
@@ -60,7 +60,6 @@
     free(rm);
     return NULL;
   }
-  memset(rm->incrow_buf, 0, gm->h * sizeof(int));
   return rm;
 }
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/render.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/render.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/render.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/trace.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/trace.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/trace.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/trace.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/trace.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/trace.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/trans.c
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/trans.c	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/trans.c	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/potrace-src/src/trans.h
===================================================================
--- trunk/Build/source/libs/potrace/potrace-src/src/trans.h	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/potrace-src/src/trans.h	2017-02-22 04:06:22 UTC (rev 43298)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2015 Peter Selinger.
+/* Copyright (C) 2001-2017 Peter Selinger.
    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. */
 

Modified: trunk/Build/source/libs/potrace/version.ac
===================================================================
--- trunk/Build/source/libs/potrace/version.ac	2017-02-22 01:06:17 UTC (rev 43297)
+++ trunk/Build/source/libs/potrace/version.ac	2017-02-22 04:06:22 UTC (rev 43298)
@@ -8,4 +8,4 @@
 dnl --------------------------------------------------------
 dnl
 dnl  m4-include this file to define the current potrace version
-m4_define([potrace_version], [1.13])
+m4_define([potrace_version], [1.14])



More information about the tex-live-commits mailing list