[gnuplot] 01/04: Merge.

Anton Gladky gladk at moszumanska.debian.org
Sat Oct 22 14:16:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

gladk pushed a commit to branch master
in repository gnuplot.

commit cc5bec8d411209736763375f7a78bd74905c5647
Author: Anton Gladky <gladk at debian.org>
Date:   Sat Oct 22 16:11:46 2016 +0200

    Merge.
---
 ChangeLog                         | 313 ++++++++++++++++++++++++++++++++++++++
 NEWS                              |  22 +++
 PATCHLEVEL                        |   2 +-
 RELEASE_NOTES                     |  66 ++++----
 config/config.nt                  |  27 +++-
 config/config.oww                 |   1 +
 configure.in                      |   4 +-
 demo/Makefile.am                  |  69 ++++-----
 demo/Makefile.in                  |  69 ++++-----
 demo/all.dem                      |   6 +-
 demo/enhanced_utf8.dem            |   3 +-
 demo/rotate_labels.dem            |  33 ++++
 docs/gnuplot.doc                  | 198 ++++++++++++++++++------
 docs/titlepag.tex                 |   4 +-
 src/color.c                       |  13 +-
 src/command.c                     |  10 +-
 src/datafile.c                    |  61 ++++++--
 src/datafile.h                    |   5 +-
 src/eval.c                        |   7 +-
 src/eval.h                        |   8 +-
 src/gadgets.c                     |   4 +-
 src/gadgets.h                     |   2 +
 src/graph3d.c                     |  15 +-
 src/graphics.c                    |   2 +-
 src/misc.c                        |  12 +-
 src/plot2d.c                      |  39 +++--
 src/pm3d.c                        |  12 +-
 src/qtterminal/QtGnuplotItems.cpp |  11 +-
 src/qtterminal/QtGnuplotItems.h   |   1 +
 src/qtterminal/QtGnuplotScene.cpp |   1 +
 src/qtterminal/qt_conversion.cpp  |   2 +-
 src/readline.c                    |  30 ++--
 src/save.c                        |   8 +-
 src/set.c                         |  55 ++++++-
 src/show.c                        |  31 +++-
 src/stats.c                       |  90 +++++++----
 src/tables.c                      |   5 +-
 src/tables.h                      |   4 +-
 src/tabulate.c                    |  45 +++++-
 src/term_api.h                    |   2 +-
 src/unset.c                       |  15 +-
 src/util.c                        |  58 ++++++-
 src/util.h                        |  12 +-
 src/version.c                     |   6 +-
 src/wxterminal/wxt_gui.cpp        |  60 ++++----
 src/wxterminal/wxt_gui.h          |   7 +-
 term/js/canvasmath.js             |   3 +-
 term/post.trm                     |  22 ++-
 term/pslatex.trm                  |  14 +-
 term/qt.trm                       |   4 +-
 term/svg.trm                      |  30 ++--
 51 files changed, 1171 insertions(+), 352 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a3384af..9ed8d67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,316 @@
+2016-10-09  Ethan A Merritt  <merritt at u.washington.edu>
+
+	PATCHLEVEL etc:  Bump versioning to 5.0.5 for release
+
+2016-10-01  Daniel J Sebald <daniel.sebald at ieee.org>
+
+	* QtGnuplotItems.{h|cpp} (QtGnuplotEnhancedFragment::width):
+	Introduce a true string width function rather than using boundingBox(),
+	which ignores leading or trailing whitespace.  This repairs enhanced
+	text overprint and place-holder markup in the qt terminal.
+	Bug #1863
+
+2016-09-27  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/plot2d.c (eval_plots):  Initialize fillcolor.
+
+	* src/stats.c: Do not use columnheader as a prefix for "stats" unless it
+	is specifically requested. 
+
+2016-09-25  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/pm3d.c (set_plot_with_palette): When checking for plot elements 
+	that refer to palette coloring, go through the list of objects also.
+
+2016-09-15  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/set.c docs/gnuplot.doc:  Ignore "set termopt {dashed|solid}".
+	Remove use of this option from the manual.
+
+2016-09-14  Bastian Maerkisch  <bmaerkisch at web.de>
+
+	* src/win/wgraph.c (drawgraph):  Fix a GDI resource leak which is
+	only important when opening and closing a massive number of different
+	graph windows.
+
+2016-09-13  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/graph3d.c (setup_3d_box_corners):  2016-09-06 revision to which
+	plot edges have tic labels attached should not have been applied to
+	"set view map" mode.
+
+2016-09-12  Bastian Maerkisch  <bmaerkisch at web.de>
+
+	* config/config.nt (HAVE_ERF, HAVE_ERFC, HAVE_STDBOOL_H, isnan
+	EAM_OBJECTS):  Version dependent macros to enable compilation
+	with at least VS2012 or newer.
+
+	* src/win/wgnuplib.rc:  Change (nominal) font size of most dialogs to
+	8pt in order to match Windows default settings.
+
+	* src/win/wgraph.c src/win/wgdiplus.cpp (W_hypertext):  Use the
+	encoding which was active while plotting (not the current one) to
+	display hypertext.
+
+	* src/win/wgdiplus.cpp:  Fix a resource and memory leak.
+
+	* src/win/wpause.c:  Use default GUI font (not the archaic system font).
+	Match the size of the dialog box to the actual length of the message.
+
+	* src/win/wtext.c (UpdateScrollBars):  The size of the scroll bar
+	thumb reflects the length or width of the scrollable area.
+
+	* src/win/wtext.c:  Ctrl-C copies to clipboard if there's selected text
+	or sets the Ctrl-C (break) flag otherwise.
+
+	* src/win/wgraph.c src/win/wmenu.c:  Use TB_ADDBUTTON instead of
+	TB_LOADIMAGES to load standard icons as this somehow eliminates
+	a resource leak.
+
+2016-09-07  Daniel J Sebald <daniel.sebald at ieee.org>
+
+	* src/graph3d.c (setup_3d_box_corners): Add quandrant processing for
+	surface_rot_x similar to that for surface_rot_z.  This fixes
+	inconsistent borders drawn when the base is upside down.
+	Bug #1810
+
+2016-09-06  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/tabulate.c( imploded ): The smoothing routine cp_implode()
+	creates a new set of plots separated by dummy UNDEFINED points.
+	However data files use a blank line to separate curves.  Thus
+	  "set table foo; plot ... smooth freq"
+	creates a file foo that is not in standard format, creating problems
+	if it is read back in to plot later.  This patch replaces each
+	UNDEFINED point with a blank line when smoothed data is tabulated.
+	Bug #1274
+
+	* src/stats.c: In the case of 'stats foo prefix columnhead' check that
+	the string found in the column header is a legal identifier (i.e. rule
+	out numbers and punctuation).
+
+2016-09-03  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/stats.c:  Track and report number of lines treated as column 
+	headers rather than as data.
+
+	* src/show.c:  Show state of 'autotitle columnheaders' even if the key
+	is currently unset.
+
+	* docs/gnuplot.doc:  Update sections referring to columnheaders.
+	Note that the effect of `set key autotitle columnhead` extends to
+	stats and fit commands, and applies even if the key is unset.
+
+	* src/datafile.c (df_open):  Guarantee that first line of data is
+	skipped if 'set key autotitle columnhead' is in effect regardless of
+	whether the column headers are used.
+	Bug #1751
+
+2016-09-02  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/datafile.c (df_generate_pseudodata):
+	Grid coordinates generated by splot '++' are subject to round-off error.
+	This error is most noticeable at the plot boundary, where it may be that
+	(sample_min + nsteps * stepsize != sample_max). This is more likely to
+	be visible on 32-bit systems than on 64-bit systems.
+	Force the final grid coordinate to be exactly sample_max.
+	Bug #1850
+
+2016-09-01  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* term/pslatex.trm:  The begin/end of plot bookkeeping of internal state
+	that would otherwise be done by PS_layer() needs to be done instead by
+	the replacement routine PSLATEX_layer().  In particular the final line
+	a plot needs to be stroked and the linetype reset.
+	Bug #1852
+
+2016-08-25  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/wxterminal/wxt_gui.cpp (wxtFrame::OnExport):  Revisit the file
+	export widget. I misread the code previously, thinking there was only a
+	single global command list. Actually there is a global pointer but each
+	window has its own command list.  So we really can export inactive plots
+	as well as the active plot.  The global command list pointer is now
+	unused so get rid of it.
+	Bug #1843
+
+	* src/color.c src/set.c src/gadgets.c src/gadgets.h src/tables.c
+	src/tables.h src/save.c docs/gnuplot.doc:  New keyword
+	"set colorbox {{no}invert" flips the top/bottom orientation of a
+	vertical gradient; i.e. the same color maps to the same numerical value
+	but the orientation of the sample is inverted.  Display of horizontal
+	gradients is not affected.
+	Tracker issue #1808
+
+2016-08-24  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/plot2d.c (refresh_bounds box_range_fiddling): Improved autoscaling
+	of plots "with boxes". Extend y range to 0. Distinguish between absolute
+	and relative boxwidth.
+	Bug #1827
+
+	* src/datafile.h src/datafile.c src/stats.c docs/gnuplot.doc:
+	Rearrange the order in which we parse the "stats" command.
+	This allows passing "columnheader" or "columnheader(N)" to the 
+	"name" option rather than a fixed character string.
+	Bug #1841
+
+2016-08-21  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/wxterminal/wxt_gui.cpp (wxtFrame::OnExport):  The Export widget
+	on a plot window should dump a copy of the plot in that window, not a
+	copy of the currently active plot.  Modify the OnExport function 
+	accordingly.  Unfortunately to generate PDF or SVG files we want to
+	reexecute the list of commands that generated the plot, but we only 
+	keep such a list for the currently active plot.  So Export from 
+	inactive windows is limited to the clipboard or PNG files.
+	Bug #1843
+	
+	* src/readline.c (getc_wrapper):  Clear errno before reading next
+	character.  This fix contributed anonymously.
+	Bug #1846
+
+2016-08-19  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/util.c (squash_spaces) src/util.h src/command.c:
+	Modify squash_spaces() utility routine to optionally leave a single
+	space in place of whitespace or remove whitespace altogether.
+
+2016-08-18  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/eval.c src/eval.h (free_at): afl-fuzz found multiple crashes
+	caused by trying to evaluate a defunct action table.  This patch wraps
+	free_at() in a macro that clears the pointer to an action table after
+	freeing it.
+
+2016-08-17  AMD  <allanduncan at sf.net>
+
+	* term/post.trm: Different treatment of simplex/duplex option 
+	depending on whether the PostScript support is limited to Level 1.
+
+2016-08-16  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/misc.c (lp_parse) src/plot2d.c (eval_plots): Remove order
+	dependence of the "fillcolor" keyword and confusion with line style.
+	For example these commands were not working:
+	    plot 'silver.dat' with boxes fs solid 1.0 border -1 fc "cyan"
+	    plot 'silver.dat' with boxes fc "cyan" fs solid 1.0 border -1 lw 2
+
+2016-08-11  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/plot2d.c (box_range_fiddling):  afl-fuzz found a crash caused by
+	 an incorrect test for no data points.
+
+	* src/set.c (encoding_minus):  Comment out replacement of the SJIS minus
+	sign character.  The character itself is correct but it is a full-width
+	glyph so it does not mix well with half-width digits in a number.
+	This problem is specific to SJIS.
+
+2016-08-09  Hans-Bernhard Broeker  <broeker at physik.rwth-aachen.de>
+
+	* config/config.oww (ftruncate): Definition needed to compile on
+	Open Watcom.
+
+	* config/config.nt (HAVE_ERF, HAVE_ERFC, HAVE_STDBOOL_H)
+	(HAVE_STDINT_H, isnan): Update some flage to match current version
+	of MSVC (VS 2015).
+
+2016-08-07  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/save.c src/set.c src/show.c src/tables.c src/tables.h src/unset.c
+	src/util.c src/util.h src/eval.c docs/gnuplot.doc term/js/canvasmath.js:
+
+	New command "set minussign" tells gprintf() to use an encoding-specific
+	minus sign character for numeric output rather than the ascii hyphen
+	character produced by sprintf().
+	    UTF-8:	Unicode U+2212 "minus sign"
+	    CP1252:	ALT+150 "en dash"
+	    SJIS:	0x817c
+	    default:	ascii \055 "hyphen"
+
+	The substitution of minus sign for hyphen is not made during tabular
+	output ("set table") or when the current terminal is a LaTeX terminal.
+	It affects only numbers formatted by gprint().  Other hyphens are 
+	not affected even if they are in a gprintf format string.
+
+	* PATCHLEVEL: increment to 5pre to distinguish test builds from 5.0.4
+
+2016-08-06  Tatsuro MATSUOKA  <tmacchant3 at yahoo.co.jp>
+
+	* src/wxterminal/wxt_gui.h:  Correct spelling of include file name.
+	Bug #1836
+
+2016-08-04  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* term/svg.trm:  Better vertical justification of rotated text.
+
+	* src/qtterminal/QtGnuplotScene.cpp src/qtterminal/QtGnuplotItems.cpp:
+	*.pcf (bitmap) fonts are non-rotatable. Furthermore Qt can die horribly
+	while trying (seen with Qt 5.4.2). To make matters worse, requesting
+	font "Times" may give you the Adobe pcf font Times (perfect name match)
+	rather than a rotatable ttf or odf font like TimesNewRoman.  This patch
+	adds style strategy QFont::ForceOutline to forbid selection of a
+	bitmap font.
+
+2016-08-03  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/datafile.c:  Matrix dimensions were not being adjusted to account
+	for subsampling by "every" in the using specifier, so "with image"
+	plots came out mangled.  This was a regression from 4.6.6 and 5.0.1.
+	Bug #1835
+
+	* src/set.c src/gadgets.h src/plot2d.c demo/rotate_labels.dem
+	docs/gnuplot.doc demo/all.dem:  New option `rotate variable` to assign
+	a separate rotation angle for each point in a 2D `plot with labels` 
+	using the contents of the 4th entry in the using specifier.
+	    plot foo using 1:2:3:4 with labels rotate variable
+
+2016-08-01  Ethan A Merritt  <merritt at u.washington.edu>
+
+	* src/unset.c:  "unset y2mtics" was clearing the setting for x, not y2.
+
+2016-07-31  Shigeharu Takeno  <shige at iee.niit.ac.jp>
+
+	* src/win/wgnuplot-ja.mnu src/win/README.win-ja:  Update Japanese
+	menu translations and help text.
+
+2016-07-31  Bastian Maerkisch  <bmaerkisch at web.de>
+
+	Backport bug-fixes from 5.1
+
+	* src/wxterminal/wxt_gui.cpp:  Handle errors when creating a cairo
+	surface.
+	Bug #1621
+
+	* win/gnuplot.iss:  Enforce inclusion of directory and program group
+	pages since the default changed in Inno setup version 5.5.7.
+	Bug #1831
+
+	* src/win/wgraph.c (drawgraph) src/win/wgdiplus.cpp(drawgraph_gdiplus):
+	Missing cleanup of cached point symbols caused a sizeable resource
+	leak. Bugfix.
+
+	* src/readline.c (fn_completion):  Allow filename completion for system
+	commands '!' and after pipe symbols '<', '|'.
+	Bug #1747
+
+	* src/readline.c:  The return value of the *_getch() functions should
+	be int, not char, in order to avoid confusion between EOF (-1) and
+	(char)0xff.
+	Bug 1558
+
+	* src/qtterminal/qtconversion.cpp:  Avoid use of isnan() in C++ code.
+	The C++11 standard has it as a function in the std namespace, whereas
+	older compilers provude it as a macro or as ::isnan(). Use (var != var)
+	instead.
+
 2016-07-21  Ethan A Merritt  <merritt at u.washington.edu>
 
 	* src/term_api.h:  Define TERM_POLYGON_PIXELS.
 	* src/graphics.c (plot_image_or_update_axes):  If this flag is set,
 	implement "plot ... with image pixels" using term->filled_polygon()
 	rather than term->fillbox().
+	* term/qt.trm: Set TERM_POLYGON_PIXELS to avoid aliasing artifacts.
 
 2016-07-19  Jun Takimoto <takimoto-j at kba.biglobe.ne.jp>
 
@@ -13,6 +320,12 @@
 	TERM_POLYGON_PIXELS so that the image processing code will call
 	term->filled_polygon() in preference to term->fillbox().
 
+2016-07-15  Bastian Maerkisch  <bmaerkisch at web.de>
+
+	* src/win/wgdiplus.cpp (W_enhanced_text):  Apply text color to enhanced
+	text.
+	Bug #1829
+
 2016-07-09  Ethan A Merritt  <merritt at u.washington.edu>
 
 	* Bump PATCHLEVEL to 5.0.4
diff --git a/NEWS b/NEWS
index f63f623..55d84e6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,24 @@
+Changes in 5.0.5
+================
+* NEW allow filename completion for system commands and pipes (backport from 5.1)
+* NEW option to plot "with labels ... {rotate variable}"
+* NEW command "set minussign"
+* NEW stats command "name" option now accepts "columnheader" or "columnheader(N)"
+* NEW command option "set colorbox invert"
+* CHANGE qt terminal force selection of outline font rather than bitmap font
+* CHANGE post terminal simplex/duplex output depends on PostScript level setting
+* CHANGE improved autoscaling of plot "with boxes"
+* CHANGE qt terminal sets TERM_POLYGON_PIXELS to avoid aliasing artifacts
+* CHANGE all stats and fit commands skip header records if "autotitle columnhead"
+* FIX Do not confuse EOF with 8-bit character 0x177 (E.g. in Cyrillic encodings).
+* FIX use blank line rather than 'u' flag in "set table" output of smoothed data
+* FIX order dependence of "fillcolor" keyword in plot commands
+* FIX svg - better vertical justification of rotated text
+* FIX wxt - file export widget correctly handles inactive plots
+* FIX epslatex - reset linetype between plots (needed if plotted "notitle")
+* FIX qt - leading or trailing whitespace in enhanced text was being ignored
+* FIX regression in rendering 'plot ... matrix every ... with image'
+
 Changes in 5.0.4
 ================
 * CHANGE minimum linewidth of all cairo terminals is now 0.2 pt
@@ -22,6 +43,7 @@ Changes in 5.0.4
 * FIX bad plot iteration with negative increment, e.g. plot for [i=9:1:-1] foo(i)
 * FIX smoothed curves could not be plotted as filledcurves; now they can be
 * FIX win terminal apply color to enhanced text
+* FIX aquaterm slow rendering of images with keyword "pixels"
 
 Changes in 5.0.3
 ================
diff --git a/PATCHLEVEL b/PATCHLEVEL
index b8626c4..7ed6ff8 100644
--- a/PATCHLEVEL
+++ b/PATCHLEVEL
@@ -1 +1 @@
-4
+5
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 620ec99..c0bd78d 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -1,47 +1,44 @@
-		GNUPLOT Version 5.0.4 Release Notes
+		GNUPLOT Version 5.0.5 Release Notes
 		===================================
 
 Gnuplot version 5.0 was initially released in January 2015.
 Please see the NEWS and ChangeLog files for a complete list of bug fixes
 and minor changes accummulated since then.
 
-These release notes are for version 5.0 patchlevel 4 (5.0.4).
-This release contains bug-fixes and a few changes back-ported from the
-development version.
+These release notes are for version 5.0 patchlevel 5 (5.0.5).
+This release contains bug-fixes, a few changes back-ported from the
+development version, and a few new features.
 
-Release Notes date: 15-Jul-2016
+Release Notes date: 10-Oct-2016
 
-This patchlevel 5.0.4 incremental release includes
+This patchlevel 5.0.5 incremental release includes
 ==================================================
 
-* CHANGE minimum linewidth of all cairo terminals is now 0.2 pt
-* CHANGE in-line datablock lines are not limited to 1024 characters
-* CHANGE do not truncate or renumber history items in the active session
-* CHANGE (Windows only) open piped output using mode "wb" rather than "w"
-* CHANGE backport 5.1 use of "lc variable" to color boxplot factors
-* CHANGE gnuplot_svg.js now remaps coords for svg image embedded in larger object
-* CHANGE disallow "set palette maxcolors 1" (which has never worked)
-* CHANGE data-input errors in "stats" now generate a warning rather than an error
-* FIX placement of objects and labels using linked secondary axis coordinates
-* FIX 'set term qt <N> close' acts immediately rather than after next mouse event
-* FIX emf terminal could lose track of bold/italic/etc font properties
-* FIX emf terminal text placement of UTF-8 strings
-* FIX regression that caused "set log x; plot '-'; replot" to mess up autoscaling
-* FIX regression in v5 that mangled 3D arrows defined by "from ... rto ..."
-* FIX transposition of row/column count in plotting ascii x/y/z data "with image"
-* FIX 7-column input to "splot ... with vectors"
-* FIX ignore incomplete "every" spec for image plots
-* FIX placement of xyplane does not depend on having tics or grid lines enabled
-* FIX early program exit on replot+resize with inline data
-* FIX bad plot iteration with negative increment, e.g. plot for [i=9:1:-1] foo(i)
-* FIX smoothed curves could not be plotted as filledcurves; now they can be
-* FIX win terminal apply color to enhanced text
-
-
-NOTABLE NEW FEATURES IN PATCHLEVEL 5.0.4
+* NEW allow filename completion for system commands and pipes (backport from 5.1)
+* NEW option to plot with labels {rotate variable}
+* NEW command "set minussign"
+* NEW stats command "name" option now accepts "columnheader" or "columnheader(N)"
+* NEW command option "set colorbox invert"
+* CHANGE qt terminal force selection of outline font rather than bitmap font
+* CHANGE post terminal simplex/duplex output depends on PostScript level setting
+* CHANGE improved autoscaling of plot "with boxes"
+* CHANGE qt terminal sets TERM_POLYGON_PIXELS to avoid aliasing artifacts
+* CHANGE all stats and fit commands skip header records if "autotitle columnhead"
+* FIX Do not confuse EOF with 8-bit character 0x177 (E.g. in Cyrillic encodings).
+* FIX use blank line rather than 'u' flag in "set table" output of smoothed data
+* FIX order dependence of "fillcolor" keyword in plot commands
+* FIX svg - better vertical justification of rotated text
+* FIX wxt - file export widget correctly handles inactive plots
+* FIX qt - preserve leading and trailing whitespace in enhanced text strings
+* FIX various bugs affecting matrix data plotted "with image"
+
+
+NOTABLE NEW FEATURES IN PATCHLEVEL 5.0.5
 ========================================
 
-None.
+New command "set minussign" uses unicode character U+2122 "MINUS SIGN" rather
+than an ascii hyphen when formatting numerical output.
+
 Incremental releases 5.0.1, 5.0.2, etc are primarily intended to provide
 bug fixes rather than new features.
 
@@ -183,6 +180,7 @@ KNOWN ISSUES
 * If you configure in the wxt terminal without also configuring in X11,
   you may need to set the environmental variable TERMLIBS:
     TERMLIBS="-lX11"  ./configure
+  Version 3.0.0 of the wxgtk library is buggy; please use a newer version.
 
 * Compilation on Solaris may require adding -liconv to LIB_FLAGS
   Building the plugin demo with a SunPro Compiler requires changing the
@@ -293,7 +291,7 @@ Options for generating interactive plots for web display
 Installation
 ------------
 
-You can download a source tarball for gnuplot version 5.0.4 from the 
+You can download a source tarball for gnuplot version 5.0.5 from the 
 gnuplot development site on SourceForge.
 	http://sourceforge.net/projects/gnuplot
 
@@ -301,7 +299,7 @@ Installation instructions are available in the source itself; the short
 version for linux/unix-like systems is to unpack the tarball and then
 <PRE>
 build it:
-      cd gnuplot-5.0.4 ; ./configure ; make
+      cd gnuplot-5.0.5 ; ./configure ; make
 test it:
       make check
 install it:
diff --git a/config/config.nt b/config/config.nt
index 09e8ad3..7ff1237 100644
--- a/config/config.nt
+++ b/config/config.nt
@@ -13,6 +13,7 @@
 
 /* Provide contact info for gnuplot develoment */
 /* #undef DEVELOPMENT_VERSION */
+/* Don't change it here -- this define is set in config/msvc/Makefile. */
 
 /* Define to treat spacebar like any other keystroke. */
 /* #undef DISABLE_SPACE_RAISES_CONSOLE */
@@ -27,8 +28,10 @@
 /* #undef DOS32 */
 
 /* Define to allow placement of rectangles and other objects */
-/* Warning: Uses union initializers which VC++ does not like */
-/* undef EAM_OBJECTS */
+/* Warning: Uses union initializers which earlier versions of VC did not support */
+#if _MSC_VER >= 1900
+# define EAM_OBJECTS 1
+#endif
 
 /* Define if color information should be passed for each vertex. */
 /* #undef EXTENDED_COLOR_SPECS */
@@ -86,10 +89,14 @@
 /* #undef HAVE_EDITLINE_READLINE_H */
 
 /* Define to 1 if you have the `erf' function. */
-/* #undef HAVE_ERF */
+#if _MSC_VER >= 1800
+# define HAVE_ERF 1
+#endif
 
 /* Define to 1 if you have the `erfc' function. */
-/* #undef HAVE_ERFC */
+#if _MSC_VER >= 1800
+# define HAVE_ERFC 1
+#endif
 
 /* Define to 1 if you have the <errno.h> header file. */
 #define HAVE_ERRNO_H 1
@@ -279,10 +286,13 @@
 #define HAVE_SNPRINTF 1
 
 /* Define to 1 if stdbool.h conforms to C99. */
-/* #undef HAVE_STDBOOL_H */
+/* Available since VS 2013 only */ 
+#if _MSC_VER >= 1800
+# define HAVE_STDBOOL_H 1
+#endif
 
 /* Define to 1 if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
+#define HAVE_STDINT_H 1
 
 /* Define to 1 if you have the <stdlib.h> header file. */
 #define HAVE_STDLIB_H 1
@@ -594,7 +604,10 @@
 #define GP_INLINE __inline
 #define GP_EXCEPTION_NAME _exception
 #define GP_MATHERR _matherr
-#define isnan _isnan
+/* no longer needed with VS2015: */
+#if _MSC_VER < 1900
+# define isnan _isnan
+#endif
 #define ftruncate _chsize
 #define strtoll _strtoi64
 #define isblank isspace
diff --git a/config/config.oww b/config/config.oww
index 020fcdb..0089f9c 100644
--- a/config/config.oww
+++ b/config/config.oww
@@ -574,6 +574,7 @@
 
 #define popen _popen
 #define strnlen strnlen_s
+#define ftruncate _chsize
 
 /* gnuplot.gih is not used by wgnuplot */
 #define NO_GIH 1
diff --git a/configure.in b/configure.in
index 03719da..c8c669b 100755
--- a/configure.in
+++ b/configure.in
@@ -1,12 +1,12 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl configure.in for gnuplot on Unix.
 dnl
-dnl $Id: configure.in,v 1.370.2.15 2016/07/13 18:32:27 sfeam Exp $
+dnl $Id: configure.in,v 1.370.2.16 2016/09/07 04:14:29 sfeam Exp $
 dnl
 dnl this is actually major.minor ...
 dnl note that for a non-beta release, we need to disable DEVELOPMENT_RELEASE
 dnl
-AC_INIT(gnuplot, 5.0.4)
+AC_INIT(gnuplot, 5.0.5)
 AC_CONFIG_SRCDIR(src/graphics.c)
 AC_PREREQ(2.60)
 AC_CONFIG_HEADERS(config.h:config.hin)
diff --git a/demo/Makefile.am b/demo/Makefile.am
index 69d6b14..b3c4dfa 100644
--- a/demo/Makefile.am
+++ b/demo/Makefile.am
@@ -64,40 +64,41 @@ epslatex:
 	dvips epslatex
 
 ##m4-files-begin
-EXTRA_DIST = Makefile.am.in lena-keypoints.bin scatter2.bin sine.bin \
-using.bin gnuplot.cfg world.cor 1.dat 2.dat 3.dat arrowstyle.dat \
-asciimat.dat battery.dat big_peak.dat candlesticks.dat cities.dat \
-clip14in.dat ctg-y2.dat delaunay-edges.dat ellipses.dat empty-circles.dat \
-energy_circles.dat finance.dat fit3.dat glass.dat hemisphr.dat \
-histerror.dat histopt.dat immigration.dat klein.dat lcdemo.dat moli3.dat \
-optimize.dat orbital_elements.dat rgb_variable.dat scatter2.dat \
-silver.dat soundvel.dat srl.dat steps.dat table.dat timedat.dat \
-triangle.dat using.dat whale.dat world.dat airfoil.dem all.dem \
-animate2.dem animate.dem approximate.dem arrowstyle.dem autoscale.dem \
-barchart_art.dem binary.dem bivariat.dem bolditalic.dem borders.dem \
-boxplot.dem callargs.dem candlesticks.dem cerf.dem charset.dem circles.dem \
-cities.dem clipobject.dem colorscheme.dem colorwheel.dem complex_trig.dem \
-contours.dem controls.dem dashcolor.dem dashtypes.dem datastrings.dem \
-dgrid3d.dem discrete.dem electron.dem ellipse.dem ellipses_style.dem \
-enhancedtext.dem enhanced_utf8.dem epslatex.dem fillbetween.dem \
-fillcrvs.dem fillstyle.dem finance.dem fit.dem fitmulti.dem \
-fontfile.dem fontfile_latex.dem gantt.dem heatmaps.dem hidden2.dem \
-hidden.dem histograms2.dem histograms.dem hypertext.dem image2.dem \
-image.dem imageNaN.dem iterate.dem kdensity2d.dem key.dem layout.dem \
-lines_arrows.dem linkedaxes.dem macros.dem margins.dem matrix_index.dem \
-mgr.dem molecule.dem mouselab_1.dem mouselab_2.dem mouselabels.dem \
-mousevariables.dem multiaxis.dem multimsh.dem multipalette.dem \
-multiplt.dem named_var.dem nokey.dem orbits.dem parallel.dem param.dem \
-piecewise.dem pm3dcolors.dem pm3d.dem pm3dgamma.dem pointsize.dem \
-polar.dem poldat.dem prob2.dem prob.dem rainbow.dem random.dem \
-rectangle.dem rgba_lines.dem rgbalpha.dem rgb_variable.dem rugplot.dem \
-running_avg.dem scatter.dem simple.dem singulr.dem smooth.dem spline.dem \
-stats.dem steps.dem stringvar.dem surface1.dem surface2.dem textcolor.dem \
-textrotate.dem tics.dem timedat.dem transparent.dem transparent_solids.dem \
-using.dem utf8.dem varcolor.dem vector.dem world2.dem world.dem demo.edf \
-density.fnc hexa.fnc line.fnc reflect.fnc gen-random.inc stat.inc \
-GM1_sugar.pdb bldg.png GM1_bonds.r3d blutux.rgb lena.rgb sound.par \
-sound2.par start.par gnuplot.rot gnu-valley random-points gpdemos.tcl html 
+EXTRA_DIST = Makefile.am.in lena-keypoints.bin scatter2.bin \
+sine.bin using.bin gnuplot.cfg world.cor 1.dat 2.dat 3.dat \
+arrowstyle.dat asciimat.dat battery.dat big_peak.dat candlesticks.dat \
+cities.dat clip14in.dat ctg-y2.dat delaunay-edges.dat ellipses.dat \
+empty-circles.dat energy_circles.dat finance.dat fit3.dat glass.dat \
+hemisphr.dat histerror.dat histopt.dat immigration.dat klein.dat \
+lcdemo.dat moli3.dat optimize.dat orbital_elements.dat rgb_variable.dat \
+scatter2.dat silver.dat soundvel.dat srl.dat steps.dat table.dat \
+timedat.dat triangle.dat using.dat whale.dat world.dat airfoil.dem \
+all.dem animate2.dem animate.dem approximate.dem arrowstyle.dem \
+autoscale.dem barchart_art.dem binary.dem bivariat.dem bolditalic.dem \
+borders.dem boxplot.dem callargs.dem candlesticks.dem cerf.dem charset.dem \
+circles.dem cities.dem clipobject.dem colorscheme.dem colorwheel.dem \
+complex_trig.dem contours.dem controls.dem dashcolor.dem dashtypes.dem \
+datastrings.dem dgrid3d.dem discrete.dem electron.dem ellipse.dem \
+ellipses_style.dem enhancedtext.dem enhanced_utf8.dem epslatex.dem \
+fillbetween.dem fillcrvs.dem fillstyle.dem finance.dem fit.dem \
+fitmulti.dem fontfile.dem fontfile_latex.dem gantt.dem heatmaps.dem \
+hidden2.dem hidden.dem histograms2.dem histograms.dem hypertext.dem \
+image2.dem image.dem imageNaN.dem iterate.dem kdensity2d.dem key.dem \
+layout.dem lines_arrows.dem linkedaxes.dem macros.dem margins.dem \
+matrix_index.dem mgr.dem molecule.dem mouselab_1.dem mouselab_2.dem \
+mouselabels.dem mousevariables.dem multiaxis.dem multimsh.dem \
+multipalette.dem multiplt.dem named_var.dem nokey.dem orbits.dem \
+parallel.dem param.dem piecewise.dem pm3dcolors.dem pm3d.dem pm3dgamma.dem \
+pointsize.dem polar.dem poldat.dem prob2.dem prob.dem rainbow.dem \
+random.dem rectangle.dem rgba_lines.dem rgbalpha.dem rgb_variable.dem \
+rotate_labels.dem rugplot.dem running_avg.dem scatter.dem simple.dem \
+singulr.dem smooth.dem spline.dem stats.dem steps.dem stringvar.dem \
+surface1.dem surface2.dem textcolor.dem textrotate.dem tics.dem \
+timedat.dem transparent.dem transparent_solids.dem using.dem utf8.dem \
+varcolor.dem vector.dem world2.dem world.dem demo.edf density.fnc \
+hexa.fnc line.fnc reflect.fnc gen-random.inc stat.inc GM1_sugar.pdb \
+bldg.png GM1_bonds.r3d blutux.rgb lena.rgb sound.par sound2.par start.par \
+gnuplot.rot gnu-valley random-points gpdemos.tcl html 
 ##m4-files-end
 
 Makefile.am: Makefile.am.in
diff --git a/demo/Makefile.in b/demo/Makefile.in
index 11f29a3..9428199 100644
--- a/demo/Makefile.in
+++ b/demo/Makefile.in
@@ -331,40 +331,41 @@ SUBDIRS = $(PLUGIN_DIR)
 DIST_SUBDIRS = plugin
 DEMO = all.dem
 GNUPLOT = gnuplot
-EXTRA_DIST = Makefile.am.in lena-keypoints.bin scatter2.bin sine.bin \
-using.bin gnuplot.cfg world.cor 1.dat 2.dat 3.dat arrowstyle.dat \
-asciimat.dat battery.dat big_peak.dat candlesticks.dat cities.dat \
-clip14in.dat ctg-y2.dat delaunay-edges.dat ellipses.dat empty-circles.dat \
-energy_circles.dat finance.dat fit3.dat glass.dat hemisphr.dat \
-histerror.dat histopt.dat immigration.dat klein.dat lcdemo.dat moli3.dat \
-optimize.dat orbital_elements.dat rgb_variable.dat scatter2.dat \
-silver.dat soundvel.dat srl.dat steps.dat table.dat timedat.dat \
-triangle.dat using.dat whale.dat world.dat airfoil.dem all.dem \
-animate2.dem animate.dem approximate.dem arrowstyle.dem autoscale.dem \
-barchart_art.dem binary.dem bivariat.dem bolditalic.dem borders.dem \
-boxplot.dem callargs.dem candlesticks.dem cerf.dem charset.dem circles.dem \
-cities.dem clipobject.dem colorscheme.dem colorwheel.dem complex_trig.dem \
-contours.dem controls.dem dashcolor.dem dashtypes.dem datastrings.dem \
-dgrid3d.dem discrete.dem electron.dem ellipse.dem ellipses_style.dem \
-enhancedtext.dem enhanced_utf8.dem epslatex.dem fillbetween.dem \
-fillcrvs.dem fillstyle.dem finance.dem fit.dem fitmulti.dem \
-fontfile.dem fontfile_latex.dem gantt.dem heatmaps.dem hidden2.dem \
-hidden.dem histograms2.dem histograms.dem hypertext.dem image2.dem \
-image.dem imageNaN.dem iterate.dem kdensity2d.dem key.dem layout.dem \
-lines_arrows.dem linkedaxes.dem macros.dem margins.dem matrix_index.dem \
-mgr.dem molecule.dem mouselab_1.dem mouselab_2.dem mouselabels.dem \
-mousevariables.dem multiaxis.dem multimsh.dem multipalette.dem \
-multiplt.dem named_var.dem nokey.dem orbits.dem parallel.dem param.dem \
-piecewise.dem pm3dcolors.dem pm3d.dem pm3dgamma.dem pointsize.dem \
-polar.dem poldat.dem prob2.dem prob.dem rainbow.dem random.dem \
-rectangle.dem rgba_lines.dem rgbalpha.dem rgb_variable.dem rugplot.dem \
-running_avg.dem scatter.dem simple.dem singulr.dem smooth.dem spline.dem \
-stats.dem steps.dem stringvar.dem surface1.dem surface2.dem textcolor.dem \
-textrotate.dem tics.dem timedat.dem transparent.dem transparent_solids.dem \
-using.dem utf8.dem varcolor.dem vector.dem world2.dem world.dem demo.edf \
-density.fnc hexa.fnc line.fnc reflect.fnc gen-random.inc stat.inc \
-GM1_sugar.pdb bldg.png GM1_bonds.r3d blutux.rgb lena.rgb sound.par \
-sound2.par start.par gnuplot.rot gnu-valley random-points gpdemos.tcl html 
+EXTRA_DIST = Makefile.am.in lena-keypoints.bin scatter2.bin \
+sine.bin using.bin gnuplot.cfg world.cor 1.dat 2.dat 3.dat \
+arrowstyle.dat asciimat.dat battery.dat big_peak.dat candlesticks.dat \
+cities.dat clip14in.dat ctg-y2.dat delaunay-edges.dat ellipses.dat \
+empty-circles.dat energy_circles.dat finance.dat fit3.dat glass.dat \
+hemisphr.dat histerror.dat histopt.dat immigration.dat klein.dat \
+lcdemo.dat moli3.dat optimize.dat orbital_elements.dat rgb_variable.dat \
+scatter2.dat silver.dat soundvel.dat srl.dat steps.dat table.dat \
+timedat.dat triangle.dat using.dat whale.dat world.dat airfoil.dem \
+all.dem animate2.dem animate.dem approximate.dem arrowstyle.dem \
+autoscale.dem barchart_art.dem binary.dem bivariat.dem bolditalic.dem \
+borders.dem boxplot.dem callargs.dem candlesticks.dem cerf.dem charset.dem \
+circles.dem cities.dem clipobject.dem colorscheme.dem colorwheel.dem \
+complex_trig.dem contours.dem controls.dem dashcolor.dem dashtypes.dem \
+datastrings.dem dgrid3d.dem discrete.dem electron.dem ellipse.dem \
+ellipses_style.dem enhancedtext.dem enhanced_utf8.dem epslatex.dem \
+fillbetween.dem fillcrvs.dem fillstyle.dem finance.dem fit.dem \
+fitmulti.dem fontfile.dem fontfile_latex.dem gantt.dem heatmaps.dem \
+hidden2.dem hidden.dem histograms2.dem histograms.dem hypertext.dem \
+image2.dem image.dem imageNaN.dem iterate.dem kdensity2d.dem key.dem \
+layout.dem lines_arrows.dem linkedaxes.dem macros.dem margins.dem \
+matrix_index.dem mgr.dem molecule.dem mouselab_1.dem mouselab_2.dem \
+mouselabels.dem mousevariables.dem multiaxis.dem multimsh.dem \
+multipalette.dem multiplt.dem named_var.dem nokey.dem orbits.dem \
+parallel.dem param.dem piecewise.dem pm3dcolors.dem pm3d.dem pm3dgamma.dem \
+pointsize.dem polar.dem poldat.dem prob2.dem prob.dem rainbow.dem \
+random.dem rectangle.dem rgba_lines.dem rgbalpha.dem rgb_variable.dem \
+rotate_labels.dem rugplot.dem running_avg.dem scatter.dem simple.dem \
+singulr.dem smooth.dem spline.dem stats.dem steps.dem stringvar.dem \
+surface1.dem surface2.dem textcolor.dem textrotate.dem tics.dem \
+timedat.dem transparent.dem transparent_solids.dem using.dem utf8.dem \
+varcolor.dem vector.dem world2.dem world.dem demo.edf density.fnc \
+hexa.fnc line.fnc reflect.fnc gen-random.inc stat.inc GM1_sugar.pdb \
+bldg.png GM1_bonds.r3d blutux.rgb lena.rgb sound.par sound2.par start.par \
+gnuplot.rot gnu-valley random-points gpdemos.tcl html 
 
 @BUILD_PLUGIN_TRUE at PLUGIN_DIR = plugin
 all: all-recursive
diff --git a/demo/all.dem b/demo/all.dem
index 9ecb1cd..0ade64a 100644
--- a/demo/all.dem
+++ b/demo/all.dem
@@ -1,5 +1,5 @@
 #
-# $Id: all.dem,v 1.60 2014/05/01 18:17:09 sfeam Exp $
+# $Id: all.dem,v 1.60.2.1 2016/08/04 04:27:44 sfeam Exp $
 #
 # Executes all demos (OK, MOST demos) in this directory.
 # This serves as a series of unit tests for non-interactive capabilities.
@@ -246,6 +246,10 @@ print "********************** file hypertext.dem *********************"
 load "hypertext.dem"
 reset
 
+print "********************** file rotate_labels.dem *****************"
+load "rotate_labels.dem"
+reset
+
 print "********************** file stats.dem *********************"
 load "stats.dem"
 reset
diff --git a/demo/enhanced_utf8.dem b/demo/enhanced_utf8.dem
index 04eca4e..dca33ef 100644
--- a/demo/enhanced_utf8.dem
+++ b/demo/enhanced_utf8.dem
@@ -2,7 +2,8 @@
 # Test page for enhanced text mode in UTF-8 encoding
 #
 # Suggested PostScript font test
-# set term post color fontfile /usr/local/fonts/'l_10646.ttf' font "LucidaSansUnicode,12"
+# set fontpath "/usr/local/share/fonts"
+# set term post color adobeglyphnames fontfile 'l_10646.ttf' font "LucidaSansUnicode,12"
 # set output 'enhanced_utf8.ps'
 #
 set termoption enhanced
diff --git a/demo/rotate_labels.dem b/demo/rotate_labels.dem
new file mode 100644
index 0000000..5bb8e6f
--- /dev/null
+++ b/demo/rotate_labels.dem
@@ -0,0 +1,33 @@
+#
+# Additional data columns can be used to hold text rotation or color
+# for plot style "with labels"
+#
+$Data <<EOD
+1 one -30
+2 two -60
+3 three -90
+4 four -120
+5 five -150
+6 six -180
+7 seven -210
+8 eight -240
+9 nine -270
+10 ten -300
+11 eleven -330
+12 twelve -360
+EOD
+
+set angle degrees
+unset key
+set title "variable color and orientation in plotstyle 'with labels'" offset 0,-2
+
+set xrange [0:13]
+set yrange [0:13]
+set xtics 1,1,12 nomirror
+set ytics 1,1,12 nomirror
+set border 3
+
+plot $Data using 1:1:2:3:0 with labels rotate variable tc variable font ",20"
+
+pause -1 "<cr> to continue"
+reset
diff --git a/docs/gnuplot.doc b/docs/gnuplot.doc
index 8cc5a22..a3f8cdd 100644
--- a/docs/gnuplot.doc
+++ b/docs/gnuplot.doc
@@ -1,4 +1,4 @@
-C RCS $Id: gnuplot.doc,v 1.902.2.58 2016/07/06 04:43:57 sfeam Exp $
+C RCS $Id: gnuplot.doc,v 1.902.2.71 2016/09/21 20:56:56 sfeam Exp $
 C
 C Copyright (C) 1986 - 1993, 1998, 1999, 2000, 2001, 2004   Thomas Williams, Colin Kelley et al.
 C
@@ -249,6 +249,12 @@ C
  * Shell invocation of gnuplot can pass parameters to a gnuplot script.
  gnuplot -c scriptfile.gp ARG1 ARG2 ARG3 ...
 
+ * New command `set minussign` causes routine gprintf() to use a typographic
+ character "minus sign" rather than a hyphen for negative numbers.  This affects
+ only axis tic labels and strings explicitly created with gprintf(). This 
+ command first appeared in version 5.0 patchlevel 5 and is considered EXPERIMENTAL
+ (implementation details may change).
+
 3 New commands
 #start
 # import f(x) from "plugin.so"             # load function from shared library
@@ -267,6 +273,7 @@ C
 # set style textbox                        # text elements can be enclosed in a box
 # set view map {scale}                     # allows resizing a 3D projection plot
 # set multiplot {next|previous}            # navigate within the auto-layout grid
+# set minussign                            # use typographic "minus sign", not hyphen
 #end
 
 2 Changes in version 5
@@ -340,6 +347,19 @@ C
        plot 'file' using 1:(f(column(2)))
        call 'script' 1.23 "ABC"
           (in script:  print ARG1, ARG2, "number of args = ", ARGC
+2 Demos and Online Examples
+?demos
+?online examples
+?examples
+ The `gnuplot` distribution contains a collection of examples in the `demo`
+ directory. You can browse on-line versions of these examples produced by the
+ png, svg, and canvas terminals at
+^ <a href="http://gnuplot.info/demos/">
+   http://gnuplot.info/demos
+^ </a>
+ The commands that produced each demo plot are shown next to the plot, and
+ the corresponding gnuplot script can be downloaded to serve as a model for
+ generating similar plots.
 
 2 Batch/Interactive Operation
 ?batch/interactive
@@ -602,7 +622,8 @@ C
 
    plot for [i=2:6] 'datafile' using i title "Results for ".columnhead(i)
 
- See `labels`, `using xticlabels`, `plot title`, `using`.
+ This use of column headings is automated by `set key autotitle columnhead`.
+ See `labels`, `using xticlabels`, `plot title`, `using`, `key autotitle`.
 2 Enhanced text mode
 ?enhanced text
 ?enhanced
@@ -1508,17 +1529,17 @@ C marker below is used to signal this to doc2html:
 ?column
 #column(x) & int or string & column $x$ during datafile manipulation. \\
 %column(x)@int or string at column $x$ during datafile manipulation.
- `column(x)` may be used only in expressions as part of `using` manipulations
- to fits or datafile plots.  It evaluates to the numerical value of the contents
- of column x. See `plot datafile using`.
+ `column(x)` may be used only as part of a plot, splot, or stats command.
+ It evaluates to the numerical value of the content of column x.
+ See `plot datafile using`.
 4 columnhead
 ?expressions functions columnhead
 ?columnhead
 #columnhead(x) & int & string containing first entry of column $x$ in datafile. \\
 %columnhead(x)@int at string containing first entry of column $x$ in datafile.
- `columnhead(x)` may only be used in expressions as part of `using` manipulations
- to fits or datafile plots.  It evaluates to a string containing the contents of
- column x in the first line of data. See `plot datafile using`.
+ `columnhead(x)` may only be used as part of a plot, splot, or stats command.
+ It evaluates to a string containing the content of column x in the first line
+ of a data file. See `plot datafile using`.
 4 exists
 ?expressions functions exists
 ?exists
@@ -2458,6 +2479,11 @@ Ffigure_newsyntax
  associated with each line, analogous to `linecolor` or `linewidth`.  It is not
  necessary to place the current terminal in a special mode just to draw dashed
  lines.  I.e. the command `set term <termname> {solid|dashed}` is now ignored.
+ If backwards compatibility with old scripts written for version 4 is required,
+ the following lines can be used instead:
+
+      if (GPVAL_VERSION >= 5.0) set for [i=1:9] linetype i dashtype i
+      if (GPVAL_VERSION < 5.0) set termoption dashed
 
  All lines have the property `dashtype solid` unless you specify otherwise.
  You can change the default for a particular linetype using the command
@@ -2684,11 +2710,23 @@ Ffigure_newsyntax
 2 Plotting
 ?plotting
  There are four `gnuplot` commands which actually create a plot: `plot`,
- `splot`, `replot`, and `refresh`.  `plot` generates 2D plots, `splot` generates
- 3D plots (actually 2D projections, of course), and `replot` appends its
- arguments to the previous `plot` or `splot` and executes the modified
- command.  `refresh` reexecutes the previous `plot` or `splot` command using
- previously stored data rather than rereading data from a file.
+ `splot`, `replot`, and `refresh`.  Other commands control the layout, style,
+ and content of the plot that will eventually be created.
+ `plot` generates 2D plots. `splot` generates 3D plots (actually 2D projections,
+ of course). `replot` reexecutes the previous `plot` or `splot` command.
+ `refresh` is similar to `replot` but it reuses any previously stored data
+ rather than rereading data from a file or input stream.
+
+=multiplot
+=inset
+=subfigures
+ Each time you issue one of these four commands it will redraw the screen or
+ generate a new page of output containing all of the currently defined axes,
+ labels, titles, and all of the various functions or data sources listed in the
+ original plot command. If instead you need to place several complete plots next
+ to each other on the same page, e.g. to make a panel of sub-figures or to inset
+ a small plot inside a larger plot, use the command `set multiplot` to suppress
+ generation of a new page for each plot command.
 
  Much of the general information about plotting can be found in the discussion
  of `plot`; information specific to 3D can be found in the `splot` section.
@@ -3819,7 +3857,8 @@ Ffigure_labels1
  The `labels` style reads coordinates and text from a data file and places
  the text string at the corresponding 2D or 3D position.  3 or 4 input columns
  of basic data are required.  Additional input columns may be used to provide
- information such as variable font size or text color (see `rgbcolor variable`).
+ properties that vary point by point such as text rotation angle (keywords
+ `rotate variable`) or color (see `textcolor variable`).
 
       3 columns:  x  y  string    # 2D version
       4 columns:  x  y  z  string # 3D version
@@ -3856,7 +3895,11 @@ Ffigure_labels2
    symbol(z) = "∙□+⊙♠♣♡♢"[int(z):int(z)]
    splot 'file' using 1:2:(symbol($3)) with labels
 
- See also `datastrings`, `set style data`.
+ This example shows use of labels with variable rotation angle in column 4 and
+ textcolor ("tc") in column 5.  Note that variable color is always taken from
+ the last column in the `using` specifier.
+
+   plot $Data using 1:2:3:4:5 with labels tc variable rotate variable
 2 lines
 ?plotting styles lines
 ?style lines
@@ -4289,8 +4332,8 @@ Ffigure_mapcontours
 ?commands clear
 ?clear
  The `clear` command erases the current screen or output device as specified
- by `set output`.  This usually generates a formfeed on hardcopy devices.  Use
- `set terminal` to set the device type.
+ by `set terminal` and `set output`.  This usually generates a formfeed on
+ hardcopy devices.
 
  For some terminals `clear` erases only the portion of the plotting surface
  defined by `set size`, so for these it can be used in conjunction with `set
@@ -5861,6 +5904,7 @@ Ffigure_mapcontours
 ?data-file smooth
 ?datafile smooth
 ?smooth
+?splines
  `gnuplot` includes a few general-purpose routines for interpolation and
  approximation of data; these are grouped under the `smooth` option.  More
  sophisticated data processing may be performed by preprocessing the data
@@ -6088,6 +6132,7 @@ Ffigure_mapcontours
 ?plot special-filenames
 ?datafile special-filenames
 ?special-filenames
+?++
  There are a few filenames that have a special meaning:  '', '-', '+' and '++'.
 
  The empty filename '' tells gnuplot to re-use the previous input file in the
@@ -6253,7 +6298,7 @@ Ffigure_mapcontours
  $1, $2, ... are shorthand for column(1), column(2) ...  The function `valid(N)`
  tests whether the value in the Nth column is a valid number.
 =column
-=columnhead
+=columnheader
  If each column of data in the input file contains a label in the first row
  rather than a data value, this label can be used to identify the column on
  input and/or in the plot legend. The column() function can be used to select
@@ -6269,8 +6314,7 @@ Ffigure_mapcontours
        plot 'datafile' using "Age":"Height", '' using "Age":"Weight"
 
  The full string must match. Comparison is case-sensitive.
- To use the column labels in the plot legend, use 
- `set key autotitle columnhead`.
+ To use column labels in the plot legend, use `set key autotitle columnhead`.
 
  In addition to the actual columns 1...N in the input data file, gnuplot
  presents data from several "pseudo-columns" that hold bookkeeping information.
@@ -6299,7 +6343,6 @@ Ffigure_mapcontours
  Note that the use of "\t", "\n", or "\f" requires use of double-quotes
  rather than single-quotes.
 5 using_examples
-?examples
 ?commands plot datafile using examples
 ?plot datafile using examples
 ?datafile using examples
@@ -6884,7 +6927,7 @@ Ffigure_mapcontours
  the index of the desired style.
 
  If gnuplot was built with `pm3d` support, the special keyword `palette` is
- allowed for smooth color change of lines, points and dots in `splots`. The
+ allowed for smooth color change of lines, points and dots in `splot`. The
  color is chosen from a smooth palette which was set previously with the
  command `set palette`. The color value corresponds to the z-value of the
  point coordinates or to the color coordinate if specified by the 4th parameter
@@ -7953,7 +7996,7 @@ Ffigure_mapcontours
 
        set colorbox
        set colorbox {
-                  { vertical | horizontal }
+                  { vertical | horizontal } {{no}invert}
                   { default | user }
                   { origin x, y }
                   { size x, y }
@@ -9373,21 +9416,6 @@ Ffigure_missing
  subtracted from the height of the key box.  This is useful mainly when you are
  putting a box around the key and want larger borders around the key entries.
 
- All plotted curves of `plot`s and `splot`s are titled according to the
- default option `autotitles`. The automatic generation of titles can be
- suppressed by `noautotitles`; then only those titles explicitly defined
- by `(s)plot ... title ...` will be drawn.
-
-=columnheader
- The command `set key autotitle columnheader` causes the first entry in each
- column of input data to be interpreted as a text string and used as a title for
- the corresponding plot. If the quantity being plotted is a function of data
- from several columns, gnuplot may be confused as to which column to draw the
- title from. In this case it is necessary to specify the column explicitly in
- the plot command, e.g.
-
-       plot "datafile" using (($2+$3)/$4) title columnhead(3) with lines
-
  An overall title can be put on the key (`title "<text>"`)---see also `syntax`
  for the distinction between text in single- or double-quotes. 
 
@@ -9435,6 +9463,31 @@ Ffigure_missing
  This places the key in the bottom left corner, left-justifies the text,
  gives it a title, and draws a box around it in linetype 3:
        set key left bottom Left title 'Legend' box 3
+4 key autotitle
+?commands set key autotitle
+?set key autotitle
+?key autotitle
+?autotitle
+ `set key autotitle` causes each plot to be identified in the key by the name
+ of the data file or function used in the plot command. This is the default.
+ `set key noautotitle` disables the automatic generation of plot titles.
+=columnnheader
+ The command `set key autotitle columnheader` causes the first entry in each
+ column of input data to be interpreted as a text string and used as a title for
+ the corresponding plot. If the quantity being plotted is a function of data
+ from several columns, gnuplot may be confused as to which column to draw the
+ title from. In this case it is necessary to specify the column explicitly in
+ the plot command, e.g.
+
+       plot "datafile" using (($2+$3)/$4) title columnhead(3) with lines
+
+ Note: The effect of `set key autotitle columnheader`, treatment of the first
+ line in a data file as column headers rather than data applies even if the
+ key is disabled by `unset key`.  It also applies to `stats` and `fit` commands
+ even though they generate no key.
+
+ In all cases an explicit `title` or `notitle` keyword in the plot command
+ itself will override the default from `set key autotitle`.
 4 key placement
 ?commands set key placement
 ?set key placement
@@ -9626,7 +9679,10 @@ Ffigure_missing
  See `set xdata` and `set timefmt`.
 
  The options available for `set label` are also available for the `labels` plot
- style. See `labels`.
+ style. See `labels`.  In this case the properties `textcolor`, `rotate`, and
+ `pointsize` may be followed by keyword `variable` rather than by a fixed value.
+ In this case the corresponding property of individual labels is determined by
+ additional columns in the `using` specifier. 
 
 4 examples
 ?label examples
@@ -9955,6 +10011,50 @@ Ffigure_missing
  labels will be included in either the margin calculation or the calculation
  of the positions of other text to be written in the margin.  This can lead
  to tic labels overwriting other text if the axis is very close to the border.
+3 minussign
+?commands set minussign
+?commands show minussign
+?commands unset minussign
+?set minussign
+?show minussign
+?unset minussign
+?minussign
+ Gnuplot uses the C language library routine sprintf() for most formatted input.
+ However it also has its own formatting routine `gprintf()` that is used to
+ generate axis tic labels. The C library routine always use a hyphen character
+ (ascii \055) to indicate a negative number, as in -7.  Many people prefer a
+ different typographic minus sign character (unicode U+2212) for this purpose,
+ as in −7.  The command
+
+      set minussign
+
+ causes gprintf() to use this minus sign character rather than a hyphen in
+ numeric output. In a utf-8 locale this is the multibyte sequence corresponding
+ to unicode U+2212.  In a Window codepage 1252 locale this is the 8-bit 
+ character ALT+150 ("en dash").  The `set minussign` command will affect axis
+ tic labels and any labels that are created by explicitly invoking gprintf.
+ It has no effect on other strings that contain a hyphen.  See `gprintf`.
+
+ Note that this command is ignored when you are using any of the LaTeX
+ terminals, as LaTeX has its own mechanism for handling minus signs.
+ It also is not necessary when using the postscript terminal because the 
+ postscript prologue output by gnuplot remaps the ascii hyphen code \055 to a
+ different glyph named `minus`.  If you want to use the postscript terminal
+ while `set minussign` is active,  you will probably need to select the option
+ `set term post adobeglyphnames`.
+
+ This command is EXPERIMENTAL. It has known limitations and implementation
+ details may change.
+
+ Example (assumes utf8 locale):
+
+      set minus
+      A = -5
+      print "A = ",A                 # printed string will contain a hyphen
+      print gprintf("A = %g",A)      # printed string will contain character U+2212
+      set label "V = -5"             # label will contain a hyphen
+      set label sprintf("V = %g",-5) # label will contain a hyphen
+      set label gprintf("V = %g",-5) # label will contain character U+2212
 3 monochrome
 ?commands set monochrome
 ?set monochrome
@@ -10134,7 +10234,7 @@ Ffigure_missing
 ?nomultiplot
 ?layout
  The command `set multiplot` places `gnuplot` in the multiplot mode, in which
- several plots are placed on the same page, window, or screen.
+ several plots are placed next to each other on the same page or screen window.
 
  Syntax:
        set multiplot
@@ -10153,8 +10253,10 @@ Ffigure_missing
  to its normal single-plot mode.  For other terminals, each separate `plot`
  command produces an updated display.
 
+=inset
  The `clear` command is used to erase the rectangular area of the page that will
- be used for the next plot.  This is typically needed for "inset" plots.
+ be used for the next plot.  This is typically needed to inset a small plot
+ inside a larger plot.
 
  Any labels or arrows that have been defined will be drawn for each plot
  according to the current size and origin (unless their coordinates are
@@ -11969,6 +12071,7 @@ Ffigure_missing
                               {{pointtype | pt} <point_type>}
                               {{pointsize | ps} <point_size>}
                               {{pointinterval | pi} <interval>}
+                              {{dashtype | dt} <dashtype>}
                               {palette}
        unset style line
        show style line
@@ -12279,7 +12382,6 @@ Ffigure_missing
       set termoption {no}enhanced
       set termoption font "<fontname>{,<fontsize>}"
       set termoption fontscale <scale>
-      set termoption {solid|dashed}
       set termoption {linewidth <lw>}{lw <lw>}
 
 3 tics
@@ -14123,13 +14225,17 @@ Ffigure_missing
  When `matrix` is specified, all matrix entries are included in the analysis.
  The matrix dimensions are saved in the variables STATS_size_x and STATS_size_y.
 
- It may be convenient to track the statistics from more than one file at the
- same time. The `name` option causes the default prefix "STATS" to be replaced
- by a user-specified string.  For example, the mean value of column 2 data from
- two different files could be compared by
+=columnheader
+ It may be convenient to track the statistics from more than one file or data
+ column in parallel. The `name` option causes the default prefix "STATS" to be
+ replaced by a user-specified string.  For example, the mean value of column 2
+ data from two different files could be compared by
       stats "file1.dat" using 2 name "A"
       stats "file2.dat" using 2 name "B"
       if (A_mean < B_mean) {...}
+ The keyword `columnheader` or function `columnheader(N)` can be used to
+ generate the prefix from the contents of the first row of a data file:
+      do for [COL=5:8] { stats 'datafile' using COL name columnheader }
 
  The index reported in STATS_index_xxx corresponds to the value of pseudo-column
  0 ($0) in plot commands.  I.e. the first point has index 0, the last point
diff --git a/docs/titlepag.tex b/docs/titlepag.tex
index fea7d2b..d765685 100644
--- a/docs/titlepag.tex
+++ b/docs/titlepag.tex
@@ -1,5 +1,5 @@
 %
-% $Id: titlepag.tex,v 1.39.2.8 2016/07/13 18:32:28 sfeam Exp $
+% $Id: titlepag.tex,v 1.39.2.9 2016/10/09 17:23:56 sfeam Exp $
 %
 
 \ifx\LaTeXe\undefined
@@ -175,7 +175,7 @@
   \vspace{2ex}
 
 %  25 Dec 2014  Version 5.0
-   Version 5.0.4 (July 2016)
+   Version 5.0.5 (October 2016)
 
    \end{center}
 \newpage
diff --git a/src/color.c b/src/color.c
index 6ab985d..3005a49 100644
--- a/src/color.c
+++ b/src/color.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: color.c,v 1.114.2.1 2015/04/16 05:11:21 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: color.c,v 1.114.2.2 2016/08/27 20:50:12 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - color.c */
@@ -545,8 +545,6 @@ cbtick_callback(
 void
 draw_color_smooth_box(int plot_mode)
 {
-    double tmp;
-
     if (color_box.where == SMCOLOR_BOX_NO)
 	return;
     if (!term->filled_polygon)
@@ -629,8 +627,13 @@ draw_color_smooth_box(int plot_mode)
 	}
     }
 
-    if (color_box.bounds.ybot > color_box.bounds.ytop) { /* switch them */
-	tmp = color_box.bounds.ytop;
+    if (color_box.bounds.ybot > color_box.bounds.ytop) {
+	double tmp = color_box.bounds.ytop;
+	color_box.bounds.ytop = color_box.bounds.ybot;
+	color_box.bounds.ybot = tmp;
+    }
+    if (color_box.invert && color_box.rotation == 'v') {
+	double tmp = color_box.bounds.ytop;
 	color_box.bounds.ytop = color_box.bounds.ybot;
 	color_box.bounds.ybot = tmp;
     }
diff --git a/src/command.c b/src/command.c
index 882f671..a91c9ac 100644
--- a/src/command.c
+++ b/src/command.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: command.c,v 1.292.2.10 2015/08/01 05:19:16 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: command.c,v 1.292.2.13 2016/08/19 16:14:08 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - command.c */
@@ -931,6 +931,7 @@ history_command()
 
     } else {
 	int n = 0;		   /* print only <last> entries */
+	char *tmp;
 	TBOOLEAN append = FALSE;   /* rewrite output file or append it */
 	static char *name = NULL;  /* name of the output file; NULL for stdout */
 
@@ -944,8 +945,9 @@ history_command()
 	if (!END_OF_COMMAND && isanumber(c_token)) {
 	    n = int_expression();
 	}
-	free(name);
-	if ((name = try_to_get_string())) {
+	if ((tmp = try_to_get_string())) {
+	    free(name);
+	    name = tmp;
 	    if (!END_OF_COMMAND && almost_equals(c_token, "ap$pend")) {
 		append = TRUE;
 		c_token++;
@@ -2698,7 +2700,7 @@ help_command()
     if (len > 0)
 	helpbuf[len++] = ' ';	/* add a space */
     capture(helpbuf + len, start, c_token - 1, MAX_LINE_LEN - len);
-    squash_spaces(helpbuf + base);	/* only bother with new stuff */
+    squash_spaces(helpbuf + base, 1);	/* only bother with new stuff */
     len = strlen(helpbuf);
 
     /* now, a lone ? will print subtopics only */
diff --git a/src/datafile.c b/src/datafile.c
index 9f137a8..3ebd2d5 100644
--- a/src/datafile.c
+++ b/src/datafile.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: datafile.c,v 1.290.2.23 2016/06/15 18:00:43 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: datafile.c,v 1.290.2.27 2016/09/03 23:18:57 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - datafile.c */
@@ -272,6 +272,7 @@ static TBOOLEAN index_found = FALSE;
 static int df_longest_columnhead = 0;
 
 /* stuff for every point:line */
+static TBOOLEAN set_every = FALSE;
 static int everypoint = 1;
 static int firstpoint = 0;
 static int lastpoint = MAXINT;
@@ -333,7 +334,7 @@ static struct curve_points *df_current_plot;	/* used to process histogram labels
 #define NO_COLUMN_HEADER (-99)  /* some value that can never be a real column */
 static int column_for_key_title = NO_COLUMN_HEADER;
 static TBOOLEAN df_already_got_headers = FALSE;
-static char *df_key_title = NULL;     /* filled in from column header if requested */
+char *df_key_title = NULL;     /* filled in from column header if requested */
 
 
 /* Binary *read* variables used by df_readbinary().
@@ -1042,7 +1043,7 @@ df_open(const char *cmd_filename, int max_using, struct curve_points *plot)
 {
     int name_token = c_token - 1;
     TBOOLEAN duplication = FALSE;
-    TBOOLEAN set_index = FALSE, set_every = FALSE, set_skip = FALSE;
+    TBOOLEAN set_index = FALSE, set_skip = FALSE;
     TBOOLEAN set_using = FALSE;
     TBOOLEAN set_matrix = FALSE;
 
@@ -1054,7 +1055,6 @@ df_open(const char *cmd_filename, int max_using, struct curve_points *plot)
 	data_fp = NULL;
     }
 
-    /*{{{  initialise static variables */
     free(df_format);
     df_format = NULL;         /* no format string */
 
@@ -1078,6 +1078,7 @@ df_open(const char *cmd_filename, int max_using, struct curve_points *plot)
     blank_count = 2;
     /* by initialising blank_count, leading blanks will be ignored */
 
+    set_every = FALSE;
     everypoint = everyline = 1; /* unless there is an every spec */
     firstpoint = firstline = 0;
     lastpoint = lastline = MAXINT;
@@ -1100,10 +1101,20 @@ df_open(const char *cmd_filename, int max_using, struct curve_points *plot)
     /* Save for use by df_readline(). */
     /* Perhaps it should be a parameter to df_readline? */
     df_current_plot = plot;
+
+    /* If 'set key autotitle columnhead' is in effect we always treat the
+     * first data row as non-data (df_readline() will return DF_COLUMNHEADERS
+     * rather than the column count).  This is true even if the key is off
+     * or the data is read from 'stats' or from 'fit' rather than plot.
+     * FIXME:  This should probably be controlled by an option to 
+     *         'set datafile' rather than 'set key'.  Or maybe both?
+     */
     column_for_key_title = NO_COLUMN_HEADER;
-    parse_1st_row_as_headers = FALSE;
     df_already_got_headers = FALSE;
-    /*}}} */
+    if ((&keyT)->auto_titles == COLUMNHEAD_KEYTITLES)
+	parse_1st_row_as_headers = TRUE;
+    else
+	parse_1st_row_as_headers = FALSE;
 
     if (!cmd_filename)
 	int_error(c_token, "missing filename");
@@ -2411,6 +2422,13 @@ df_determine_matrix_info(FILE *fin)
 		df_xpixels = nc;
 		df_ypixels = nr;
 
+		if (set_every) {
+		    df_xpixels = 1 + ((int)(GPMIN(lastpoint,df_xpixels-1)) - firstpoint) / everypoint;
+		    df_ypixels = 1 + ((int)(GPMIN(lastline,df_ypixels-1)) - firstline) / everyline;
+		    FPRINTF((stderr,"datafile.c:%d filtering (%d,%d) to (%d,%d)\n",
+				 __LINE__, nc, nr, df_xpixels, df_ypixels));
+		}
+
 		/* This matrix is the one (and only) requested by name.	*/
 		/* Dummy up index range and skip rest of file.		*/
 		if (indexname) {
@@ -2860,7 +2878,9 @@ df_set_key_title_columnhead(struct curve_points *plot)
     } else if (!END_OF_COMMAND && isanumber(c_token)) {
 	column_for_key_title = int_expression();
     } else {
-	if (df_no_use_specs == 1)
+	if (!plot) /* stats "name" option rather than plot title */
+	    column_for_key_title = use_spec[0].column;
+	else if (df_no_use_specs == 1)
 	    column_for_key_title = use_spec[0].column;
 	else if (plot->plot_type == DATA3D)
 	    column_for_key_title = use_spec[2].column;
@@ -5340,15 +5360,8 @@ df_generate_pseudodata()
 	AXIS_INDEX u_axis = FIRST_X_AXIS;
 	AXIS_INDEX v_axis = FIRST_Y_AXIS;
 
-	if ((df_pseudorecord >= nusteps) && (df_pseudorecord > 0)) {
-	    df_pseudorecord = 0;
-	    if (++df_pseudospan >= nvsteps)
-		return NULL;
-	    else
-		return ""; /* blank record for end of scan line */
-	}
-
-	if (df_pseudospan == 0) {
+	/* Fill in the static variables only once per plot */
+	if (df_pseudospan == 0 && df_pseudorecord == 0) {
 	    if (samples_1 < 2 || samples_2 < 2 || iso_samples_1 < 2 || iso_samples_2 < 2)
 		int_error(NO_CARET, "samples or iso_samples < 2. Must be at least 2.");
 	    if (parametric) {
@@ -5376,9 +5389,25 @@ df_generate_pseudodata()
 	    nvsteps = iso_samples_2;
 	}
 
+	/* wrap at end of each line */
+	if (df_pseudorecord >= nusteps) {
+	    df_pseudorecord = 0;
+	    if (++df_pseudospan >= nvsteps)
+		return NULL;
+	    else
+		return ""; /* blank record for end of scan line */
+	}
+
 	/* Duplicate algorithm from calculate_set_of_isolines() */
 	u = u_min + df_pseudorecord * u_step;
 	v = v_max - df_pseudospan * v_isostep;
+
+	/* Round-off error is most visible at the border */
+	if (df_pseudorecord == nusteps-1)
+	    u = u_max;
+	if (df_pseudospan == nvsteps-1)
+	    v = v_min;
+
 	if (parametric) {
 	    df_pseudovalue_0 = u;
 	    df_pseudovalue_1 = v;
diff --git a/src/datafile.h b/src/datafile.h
index ca64714..77779f7 100644
--- a/src/datafile.h
+++ b/src/datafile.h
@@ -1,5 +1,5 @@
 /*
- * $Id: datafile.h,v 1.49.2.1 2016/03/19 04:06:21 sfeam Exp $
+ * $Id: datafile.h,v 1.49.2.2 2016/08/25 04:28:36 sfeam Exp $
  */
 
 /* GNUPLOT - datafile.h */
@@ -131,6 +131,9 @@ extern TBOOLEAN df_nofpe_trap;
 extern TBOOLEAN evaluate_inside_using;
 extern TBOOLEAN df_warn_on_missing_columnheader;
 
+/* Used by plot title columnhead, stats name columnhead */
+extern char *df_key_title;
+
 /* Prototypes of functions exported by datafile.c */
 
 int df_open __PROTO((const char *, int, struct curve_points *));
diff --git a/src/eval.c b/src/eval.c
index 39d179f..3c2303d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: eval.c,v 1.119.2.2 2015/08/01 05:07:23 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: eval.c,v 1.119.2.4 2016/08/18 17:23:10 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - eval.c */
@@ -683,7 +683,7 @@ evaluate_at(struct at_type *at_ptr, struct value *val_ptr)
 }
 
 void
-free_at(struct at_type *at_ptr)
+real_free_at(struct at_type *at_ptr)
 {
     int i;
     /* All string constants belonging to this action table have to be
@@ -697,7 +697,7 @@ free_at(struct at_type *at_ptr)
 	    gpfree_string(&(a->arg.v_arg));
 	/* a summation contains its own action table wrapped in a private udf */
 	if (a->index == SUM) {
-	    free_at(a->arg.udf_arg->at);
+	    real_free_at(a->arg.udf_arg->at);
 	    free(a->arg.udf_arg);
 	}
 #ifdef HAVE_EXTERNAL_FUNCTIONS
@@ -955,6 +955,7 @@ update_gpval_variables(int context)
 	fill_gpval_string("GPVAL_TERMOPTIONS", term_options);
 	fill_gpval_string("GPVAL_OUTPUT", (outstr) ? outstr : "");
 	fill_gpval_string("GPVAL_ENCODING", encoding_names[encoding]);
+	fill_gpval_string("GPVAL_MINUS_SIGN", minus_sign ? minus_sign : "-");
     }
 
     /* If we are called from int_error() then set the error state */
diff --git a/src/eval.h b/src/eval.h
index 7311da7..ba9b5a5 100644
--- a/src/eval.h
+++ b/src/eval.h
@@ -1,5 +1,5 @@
 /*
- * $Id: eval.h,v 1.46 2014/03/10 01:28:37 sfeam Exp $
+ * $Id: eval.h,v 1.46.2.1 2016/08/18 17:23:10 sfeam Exp $
  */
 
 /* GNUPLOT - eval.h */
@@ -167,7 +167,7 @@ void f_jtern __PROTO((union argument *x));
 
 void execute_at __PROTO((struct at_type *at_ptr));
 void evaluate_at __PROTO((struct at_type *at_ptr, struct value *val_ptr));
-void free_at __PROTO((struct at_type *at_ptr));
+void real_free_at __PROTO((struct at_type *at_ptr));
 struct udvt_entry * add_udv_by_name __PROTO((char *key));
 struct udvt_entry * get_udv_by_name __PROTO((char *key));
 void del_udv_by_name __PROTO(( char *key, TBOOLEAN isWildcard ));
@@ -188,4 +188,8 @@ int gp_words __PROTO((char *string));
 /* Evaluate the function linking secondary axis to primary axis */
 double eval_link_function __PROTO((int, double));
 
+/* Wrap real_free_at in a macro */
+#define free_at(at_ptr) \
+ do { real_free_at(at_ptr); at_ptr = NULL; } while (0)
+
 #endif /* GNUPLOT_EVAL_H */
diff --git a/src/gadgets.c b/src/gadgets.c
index 5161e43..096bbf6 100644
--- a/src/gadgets.c
+++ b/src/gadgets.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.115.2.6 2016/07/08 20:48:34 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.115.2.7 2016/08/27 20:50:12 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - gadgets.c */
@@ -58,7 +58,7 @@ legend_key keyT = DEFAULT_KEY_PROPS;
 color_box_struct color_box; /* initialized in init_color() */
 color_box_struct default_color_box = {SMCOLOR_BOX_DEFAULT, 'v', 1, LT_BLACK, LAYER_FRONT, 0,
 					{screen, screen, screen, 0.90, 0.2, 0.0},
-					{screen, screen, screen, 0.05, 0.6, 0.0},
+					{screen, screen, screen, 0.05, 0.6, 0.0}, FALSE,
 					{0,0,0,0} };
 
 /* The graph box, in terminal coordinates, as calculated by boundary()
diff --git a/src/gadgets.h b/src/gadgets.h
index 39d39e9..7f69c57 100644
--- a/src/gadgets.h
+++ b/src/gadgets.h
@@ -96,6 +96,7 @@ typedef struct text_label {
  * indicated by tag = -2 */
 #define NONROTATABLE_LABEL_TAG -2
 #define ROTATE_IN_3D_LABEL_TAG -3
+#define VARIABLE_ROTATE_LABEL_TAG -4
 #define EMPTY_LABELSTRUCT \
     {NULL, NONROTATABLE_LABEL_TAG, \
      {character, character, character, 0.0, 0.0, 0.0}, CENTRE, 0, 0, \
@@ -394,6 +395,7 @@ typedef struct {
   int xoffset;	/* To adjust left or right, e.g. for y2tics */
   struct position origin;
   struct position size;
+  TBOOLEAN invert;	/* gradient low->high runs top->bot rather than bot->top */
   BoundingBox bounds;
 } color_box_struct;
 
diff --git a/src/graph3d.c b/src/graph3d.c
index 9e929b9..7ecfb8b 100644
--- a/src/graph3d.c
+++ b/src/graph3d.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.311.2.13 2016/06/13 05:22:53 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: graph3d.c,v 1.311.2.15 2016/09/14 03:54:17 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - graph3d.c */
@@ -2029,7 +2029,18 @@ setup_3d_box_corners()
 	front_x  = X_AXIS.max;
     }
 
-    if (surface_rot_x > 90) {
+    quadrant = surface_rot_x / 90;
+    if ((quadrant & 2) && !splot_map) {
+	double temp;
+	temp = front_y;
+	front_y = back_y;
+	back_y = temp;
+	temp = front_x;
+	front_x = back_x;
+	back_x = temp;
+    }
+
+    if ((quadrant + 1) & 2) {
 	/* labels on the back axes */
 	yaxis_x = back_x;
 	xaxis_y = back_y;
diff --git a/src/graphics.c b/src/graphics.c
index d49815d..b4f7c86 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: graphics.c,v 1.464.2.30 2016/07/05 20:47:36 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: graphics.c,v 1.464.2.31 2016/07/21 19:00:31 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - graphics.c */
diff --git a/src/misc.c b/src/misc.c
index 61b51c7..d93e86c 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: misc.c,v 1.188.2.9 2015/12/29 20:33:35 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: misc.c,v 1.188.2.10 2016/08/16 19:35:19 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - misc.c */
@@ -1078,10 +1078,12 @@ lp_parse(struct lp_style_type *lp, lp_class destination_class, TBOOLEAN allow_po
 	    continue;
 	}
 
-	/* This is so that "set obj ... lw N fc <colorspec>" doesn't eat */
-	/* up the colorspec as a line property.  We need to parse it later */
-	/* as a _fill_ property */
-	if ((destination_class == LP_NOFILL)
+	/* This is so that "set obj ... lw N fc <colorspec>" doesn't eat up the
+	 * fc colorspec as a line property.  We need to parse it later as a
+	 * _fill_ property. Also prevents "plot ... fc <col1> fs <foo> lw <baz>"
+	 * from generating an error claiming redundant line properties.
+	 */
+	if ((destination_class == LP_NOFILL || destination_class == LP_ADHOC)
 	&&  (equals(c_token,"fc") || almost_equals(c_token,"fillc$olor")))
 	    break;
 
diff --git a/src/plot2d.c b/src/plot2d.c
index b3b0cde..19dde27 100644
--- a/src/plot2d.c
+++ b/src/plot2d.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: plot2d.c,v 1.336.2.27 2016/06/18 05:59:25 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: plot2d.c,v 1.336.2.32 2016/09/28 03:50:45 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - plot2d.c */
@@ -341,6 +341,8 @@ refresh_bounds(struct curve_points *first_plot, int nplots)
 		continue;
 	    }
 	}
+	if (this_plot->plot_style == BOXES || this_plot->plot_style == IMPULSES)
+	    impulse_range_fiddling(this_plot);
     }
 
     this_plot = first_plot;
@@ -524,9 +526,9 @@ get_data(struct curve_points *current_plot)
 
     case LABELPOINTS:
 	/* 3 column data: X Y Label */
-	/* 4th column allows rgb variable or pointsize variable */
+	/* extra columns allow variable pointsize and/or rotation */
 	min_cols = 3;
-	max_cols = 4;
+	max_cols = 5;
 	expect_string( 3 );
 	break;
 
@@ -1122,7 +1124,10 @@ get_data(struct curve_points *current_plot)
 		    tl = store_label(current_plot->labels, &(current_plot->points[i]), 
 			    i, df_tokens[2], 
 			    current_plot->varcolor ? current_plot->varcolor[i] : 0.0);
-		    tl->lp_properties.p_size = v[3];
+		    if (current_plot->labels->tag == VARIABLE_ROTATE_LABEL_TAG)
+			tl->rotate = (int)(v[3]);
+		    else
+			tl->lp_properties.p_size = v[3];
 		}
 		i++;
 		break;
@@ -1603,11 +1608,14 @@ box_range_fiddling(struct curve_points *plot)
     double xlow, xhigh;
     int i = plot->p_count - 1;
 
-    if (i == 0)
+    if (i <= 0)
 	return;
     if (axis_array[plot->x_axis].autoscale & AUTOSCALE_MIN) {
 	if (plot->points[0].type != UNDEFINED && plot->points[1].type != UNDEFINED) {
-	    xlow = plot->points[0].x - (plot->points[1].x - plot->points[0].x) / 2.;
+	    if (boxwidth_is_absolute)
+		xlow = plot->points[0].x - boxwidth;
+	    else
+		xlow = plot->points[0].x - (plot->points[1].x - plot->points[0].x) / 2.;
 	    xlow = AXIS_DE_LOG_VALUE(plot->x_axis, xlow);
 	    if (axis_array[plot->x_axis].min > xlow)
 		axis_array[plot->x_axis].min = xlow;
@@ -1615,7 +1623,10 @@ box_range_fiddling(struct curve_points *plot)
     }
     if (axis_array[plot->x_axis].autoscale & AUTOSCALE_MAX) {
 	if (plot->points[i].type != UNDEFINED && plot->points[i-1].type != UNDEFINED) {
-	    xhigh = plot->points[i].x + (plot->points[i].x - plot->points[i-1].x) / 2.;
+	    if (boxwidth_is_absolute)
+		xhigh = plot->points[i].x + boxwidth;
+	    else
+		xhigh = plot->points[i].x + (plot->points[i].x - plot->points[i-1].x) / 2.;
 	    xhigh = AXIS_DE_LOG_VALUE(plot->x_axis, xhigh);
 	    if (axis_array[plot->x_axis].max < xhigh)
 		axis_array[plot->x_axis].max = xhigh;
@@ -2066,10 +2077,12 @@ eval_plots()
 	    TBOOLEAN set_smooth = FALSE, set_axes = FALSE, set_title = FALSE;
 	    TBOOLEAN set_with = FALSE, set_lpstyle = FALSE;
 	    TBOOLEAN set_fillstyle = FALSE;
+	    TBOOLEAN set_fillcolor = FALSE;
 	    TBOOLEAN set_labelstyle = FALSE;
 #ifdef EAM_OBJECTS
 	    TBOOLEAN set_ellipseaxes_units = FALSE;
 #endif
+	    t_colorspec fillcolor = DEFAULT_COLORSPEC;
 	    int sample_range_token;	/* Only used by function plots */
 
 	    plot_num++;
@@ -2462,6 +2475,7 @@ eval_plots()
 
 		    new_lt = lp_parse(&lp, LP_ADHOC,
 				     this_plot->plot_style & PLOT_STYLE_HAS_POINT);
+
 		    if (stored_token != c_token) {
 			if (set_lpstyle) {
 			    duplication=TRUE;
@@ -2522,7 +2536,8 @@ eval_plots()
 			set_fillstyle = TRUE;
 		    }
 		    if (equals(c_token,"fc") || almost_equals(c_token,"fillc$olor")) {
-			parse_colorspec(&this_plot->lp_properties.pm3d_color, TC_VARIABLE);
+			parse_colorspec(&fillcolor, TC_VARIABLE);
+			set_fillcolor = TRUE;
 		    }
 		    if (stored_token != c_token)
 			continue;
@@ -2564,7 +2579,7 @@ eval_plots()
 	    /* No line/point style given. As lp_parse also supplies
 	     * the defaults for linewidth and pointsize, call it now
 	     * to define them. */
-	    if (! set_lpstyle) {
+	    if (!set_lpstyle) {
 		this_plot->lp_properties.l_type = line_num;
 		this_plot->lp_properties.l_width = 1.0;
 		this_plot->lp_properties.p_type = line_num;
@@ -2582,7 +2597,13 @@ eval_plots()
 
 		lp_parse(&this_plot->lp_properties, LP_ADHOC,
 			 this_plot->plot_style & PLOT_STYLE_HAS_POINT);
+	    }
 
+	    /* If this plot style uses a fillstyle and we saw an explicit */
+	    /* fill color, apply it now.				  */
+	    if (this_plot->plot_style & PLOT_STYLE_HAS_FILL){
+		if (set_fillcolor)
+		    this_plot->lp_properties.pm3d_color = fillcolor;
 	    }
 
 	    /* Some low-level routines expect to find the pointflag attribute */
diff --git a/src/pm3d.c b/src/pm3d.c
index 036c373..f11cac6 100644
--- a/src/pm3d.c
+++ b/src/pm3d.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: pm3d.c,v 1.104 2014/05/13 18:26:40 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: pm3d.c,v 1.104.2.1 2016/09/26 05:38:00 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - pm3d.c */
@@ -1141,6 +1141,7 @@ set_plot_with_palette(int plot_num, int plot_mode)
     struct curve_points *this_2dplot = first_plot;
     int surface = 0;
     struct text_label *this_label = first_label;
+    struct object *this_object;
 
     plot_has_palette = TRUE;
     /* Is pm3d switched on globally? */
@@ -1189,8 +1190,9 @@ set_plot_with_palette(int plot_num, int plot_mode)
 	}
     }
 
-    /* Any label with 'textcolor palette'? */
 #define TC_USES_PALETTE(tctype) (tctype==TC_Z) || (tctype==TC_CB) || (tctype==TC_FRAC)
+
+    /* Any label with 'textcolor palette'? */
     for (; this_label != NULL; this_label = this_label->next) {
 	if (TC_USES_PALETTE(this_label->textcolor.type))
 	    return;
@@ -1204,6 +1206,12 @@ set_plot_with_palette(int plot_num, int plot_mode)
     if (plot_mode == MODE_SPLOT)
 	if (TC_USES_PALETTE(axis_array[FIRST_Z_AXIS].label.textcolor.type)) return;
     if (TC_USES_PALETTE(axis_array[COLOR_AXIS].label.textcolor.type)) return;
+
+    for (this_object = first_object; this_object != NULL; this_object = this_object->next) {
+	if (TC_USES_PALETTE(this_object->lp_properties.pm3d_color.type))
+	    return;
+    }
+    
 #undef TC_USES_PALETTE
 
     /* Palette with continuous colors is not used. */
diff --git a/src/qtterminal/QtGnuplotItems.cpp b/src/qtterminal/QtGnuplotItems.cpp
index c6c9485..0a61094 100644
--- a/src/qtterminal/QtGnuplotItems.cpp
+++ b/src/qtterminal/QtGnuplotItems.cpp
@@ -70,6 +70,7 @@ void QtGnuplotEnhanced::addText(const QString& fontName, double fontSize,
 	}
 	font.setStyle(fontStyle);
 	font.setWeight(fontWeight);
+	font.setStyleStrategy(QFont::ForceOutline);	// pcf fonts die if rotated
 	QtGnuplotEnhancedFragment* item = new QtGnuplotEnhancedFragment(font, text, this);
 	item->setPos(m_currentPos + QPointF(0., -base));
 	if (showFlag)
@@ -79,12 +80,12 @@ void QtGnuplotEnhanced::addText(const QString& fontName, double fontSize,
 
 	if (overprint == 2)                         // Overprint
 	{
-		item->setPos(QPointF((m_overprintPos + m_currentPos.x())/2. - (item->boundingRect().right() + item->boundingRect().left())/2., -base));
+		item->setPos(QPointF((m_overprintPos + m_currentPos.x())/2. - item->width()/2., -base));
 		m_overprintMark = false;
 	}
 
 	if (widthFlag && (overprint != 2))
-		m_currentPos += QPointF(item->boundingRect().right(), 0.);
+		m_currentPos += QPointF(item->width(), 0.);
 }
 
 void QtGnuplotEnhanced::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
@@ -107,6 +108,12 @@ QRectF QtGnuplotEnhancedFragment::boundingRect() const
 	return metrics.boundingRect(m_text);
 }
 
+qreal QtGnuplotEnhancedFragment::width() const
+{
+	QFontMetricsF metrics(m_font);
+	return metrics.width(m_text);
+}
+
 void QtGnuplotEnhancedFragment::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
 {
 	Q_UNUSED(option);
diff --git a/src/qtterminal/QtGnuplotItems.h b/src/qtterminal/QtGnuplotItems.h
index b86c1fd..f1f4195 100644
--- a/src/qtterminal/QtGnuplotItems.h
+++ b/src/qtterminal/QtGnuplotItems.h
@@ -97,6 +97,7 @@ public:
 public:
 	virtual QRectF boundingRect() const;
 	virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+    qreal width() const;
 
 private:
 	QFont m_font;
diff --git a/src/qtterminal/QtGnuplotScene.cpp b/src/qtterminal/QtGnuplotScene.cpp
index 6d0c93d..ce52f57 100644
--- a/src/qtterminal/QtGnuplotScene.cpp
+++ b/src/qtterminal/QtGnuplotScene.cpp
@@ -295,6 +295,7 @@ void QtGnuplotScene::processEvent(QtGnuplotEventType type, QDataStream& in)
 		int size        ; in >> size;
 		m_font.setFamily(fontName);
 		m_font.setPointSize(size);
+		m_font.setStyleStrategy(QFont::ForceOutline);	// pcf fonts die if rotated
 	}
 	else if (type == GEPoint)
 	{
diff --git a/src/qtterminal/qt_conversion.cpp b/src/qtterminal/qt_conversion.cpp
index 38fd177..cf8a209 100644
--- a/src/qtterminal/qt_conversion.cpp
+++ b/src/qtterminal/qt_conversion.cpp
@@ -126,7 +126,7 @@ QImage qt_imageToQImage(int M, int N, coordval* image, t_imagecolor color_mode)
 			QRgb* line = (QRgb*)(qimage.scanLine(n));
 			for (int m = 0; m < M; m++)
 			{
-				if (isnan(*image))
+				if (*image != *image)
 				{
 					image++;
 					*line++ = 0x00000000;
diff --git a/src/readline.c b/src/readline.c
index 2b78bf3..fd4cb11 100644
--- a/src/readline.c
+++ b/src/readline.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: readline.c,v 1.62 2014/05/09 22:14:12 broeker Exp $"); }
+static char *RCSid() { return RCSid("$Id: readline.c,v 1.62.2.4 2016/08/23 00:23:34 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - readline.c */
@@ -77,6 +77,7 @@ getc_wrapper(FILE* fp /* should be stdin, supplied by readline */)
     int c;
 
     while (1) {
+	errno = 0;
 #ifdef USE_MOUSE
 	if (term && term->waitforinput && interactive) {
 	    c = term->waitforinput(0);
@@ -248,11 +249,11 @@ static int ansi_getc __PROTO((void));
 #  define TEXTGNUPLOT 0xf0
 #  ifdef WGP_CONSOLE
 #   define special_getc() win_getch()
-static char win_getch __PROTO((void));
+static int win_getch(void);
 #  else
 #   define special_getc() msdos_getch()
 #  endif /* WGP_CONSOLE */
-static char msdos_getch __PROTO((void));	/* HBB 980308: PROTO'ed it */
+static int msdos_getch(void);
 #  define DEL_ERASES_CURRENT_CHAR
 # endif				/* _Windows */
 
@@ -265,7 +266,7 @@ static char msdos_getch __PROTO((void));	/* HBB 980308: PROTO'ed it */
 #   include <conio.h>
 #  endif			/* __EMX__ */
 #  define special_getc() msdos_getch()
-static char msdos_getch();
+static int msdos_getch();
 #  define DEL_ERASES_CURRENT_CHAR
 # endif				/* MSDOS */
 
@@ -276,8 +277,8 @@ static char msdos_getch();
 #  undef special_getc()
 # endif				/* special_getc */
 # define special_getc() os2_getch()
-static char msdos_getch __PROTO((void));	/* HBB 980308: PROTO'ed it */
-static char os2_getch __PROTO((void));
+static int msdos_getch(void);
+static int os2_getch(void);
 #  define DEL_ERASES_CURRENT_CHAR
 #endif /* OS2 */
 
@@ -552,15 +553,18 @@ fn_completion(size_t anchor_pos, int direction)
 	start = cur_line + anchor_pos;
 	if (anchor_pos > 0) {
 	    /* first, look for a quote to start the string */
-	    for ( ; start > cur_line; start--) {
+	    for ( ; start >= cur_line; start--) {
 	        if ((*start == '"') || (*start == '\'')) {
 		    start++;
+		    /* handle pipe commands */
+		    if ((*start == '<') || (*start == '|'))
+			start++;
 		    break;
 		}
 	    }
-	    /* if not found, search for a space instead */
-	    if (start == cur_line) {
-		for (start = cur_line + anchor_pos ; start > cur_line; start--) {
+	    /* if not found, search for a space or a system command '!' instead */
+	    if (start <= cur_line) {
+		for (start = cur_line + anchor_pos; start >= cur_line; start--) {
 		    if ((*start == ' ') || (*start == '!')) {
 			start++;
 			break;
@@ -1130,7 +1134,7 @@ ansi_getc()
 #if defined(MSDOS) || defined(_Windows) || defined(OS2)
 
 #ifdef WGP_CONSOLE
-static char
+static int
 win_getch()
 {
     if (term && term->waitforinput)
@@ -1141,7 +1145,7 @@ win_getch()
 #endif
 
 /* Convert Arrow keystrokes to Control characters: */
-static char
+static int
 msdos_getch()
 {
 	char c;
@@ -1213,7 +1217,7 @@ msdos_getch()
 #ifdef OS2
 /* We need to call different procedures, dependent on the
    session type: VIO/window or an (XFree86) xterm */
-static char
+static int
 os2_getch() {
   static int IsXterm = 0;
   static int init = 0;
diff --git a/src/save.c b/src/save.c
index 23ffb10..cd6c252 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: save.c,v 1.256.2.18 2016/05/04 21:56:07 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: save.c,v 1.256.2.20 2016/08/27 20:50:12 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - save.c */
@@ -611,6 +611,11 @@ set encoding %s\n\
     if (!numeric_locale && !decimalsign)
 	fprintf(fp, "unset decimalsign\n");
 
+    if (use_minus_sign)
+	fprintf(fp, "set minussign\n");
+    else
+	fprintf(fp, "unset minussign\n");
+
     fputs("set view ", fp);
     if (splot_map == TRUE)
 	fprintf(fp, "map scale %g", mapview_scale);
@@ -958,6 +963,7 @@ set origin %g,%g\n",
     fputs(" size ", fp);
     save_position(fp, &color_box.size, FALSE);
     fprintf(fp, " %s ", color_box.layer ==  LAYER_FRONT ? "front" : "back");
+    fprintf(fp, " %sinvert ", color_box.invert ? "" : "no");
     if (color_box.border == 0) fputs("noborder", fp);
 	else if (color_box.border_lt_tag < 0) fputs("bdefault", fp);
 		 else fprintf(fp, "border %d", color_box.border_lt_tag);
diff --git a/src/set.c b/src/set.c
index 5799686..deb8063 100644
--- a/src/set.c
+++ b/src/set.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: set.c,v 1.459.2.27 2016/06/01 04:03:34 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: set.c,v 1.459.2.32 2016/09/15 19:21:15 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - set.c */
@@ -106,6 +106,7 @@ static void set_locale __PROTO((void));
 static void set_logscale __PROTO((void));
 static void set_mapping __PROTO((void));
 static void set_margin __PROTO((t_position *));
+static void set_minus_sign __PROTO((void));
 static void set_missing __PROTO((void));
 static void set_separator __PROTO((void));
 static void set_datafile_commentschars __PROTO((void));
@@ -172,6 +173,8 @@ static void parse_histogramstyle __PROTO((histogram_style *hs,
 		t_histogram_type def_type, int def_gap));
 static void set_style_parallel __PROTO((void));
 
+static const char *encoding_minus __PROTO((void));
+
 static const struct position default_position
 	= {first_axes, first_axes, first_axes, 0., 0., 0.};
 static const struct position default_offset
@@ -351,6 +354,9 @@ set_command()
 	case S_TMARGIN:
 	    set_margin(&tmargin);
 	    break;
+	case S_MINUS_SIGN:
+	    set_minus_sign();
+	    break;
 	case S_DATAFILE:
 	    if (almost_equals(++c_token,"miss$ing"))
 		set_missing();
@@ -1652,6 +1658,9 @@ set_encoding()
 
     /* Set degree sign to match encoding */
     set_degreesign(l);
+
+    /* Set minus sign to match encoding */
+    minus_sign = encoding_minus();
 }
 
 static void
@@ -1719,6 +1728,21 @@ set_degreesign(char *locale)
     }
 }
 
+/* Encoding-specific character enabled by "set minussign" */
+static const char *
+encoding_minus()
+{
+    static const char minus_utf8[4] = {0xE2, 0x88, 0x92, 0x0};
+    static const char minus_1252[2] = {0x96, 0x0};
+    /* NB: This SJIS character is correct, but produces bad spacing if used	*/
+    /*     static const char minus_sjis[4] = {0x81, 0x7c, 0x0, 0x0};		*/
+    switch (encoding) {
+	case S_ENC_UTF8:	return minus_utf8;
+	case S_ENC_CP1252:	return minus_1252;
+	case S_ENC_SJIS:
+	default:		return NULL;
+    }
+}
 
 /* process 'set fit' command */
 static void
@@ -2753,6 +2777,14 @@ set_margin(t_position *margin)
 
 }
 
+/* process 'set minus_sign' command */
+static void
+set_minus_sign()
+{
+    c_token++;
+    use_minus_sign = TRUE;
+}
+
 static void
 set_separator()
 {
@@ -3729,6 +3761,14 @@ set_colorbox()
 		}
 		c_token--;
 		continue;
+	    case S_COLORBOX_INVERT: /* Flip direction of color gradient + cbaxis */
+		c_token++;
+		color_box.invert = TRUE;
+		continue;
+	    case S_COLORBOX_NOINVERT: /* Flip direction of color gradient + cbaxis */
+		c_token++;
+		color_box.invert = FALSE;
+		continue;
 	    } /* switch over colorbox lookup table */
 	    int_error(c_token,"invalid colorbox option");
 	} /* end of while !end of command over colorbox options */
@@ -4767,11 +4807,8 @@ set_termoptions()
 	    real_expression();   /* Silently ignore the request */
 	}
     } else if (almost_equals(c_token,"dash$ed") || equals(c_token,"solid")) {
-	num_tokens = GPMIN(num_tokens,c_token+1);
-	if (term->flags & TERM_CAN_DASH)
-	    ok_to_call_terminal = TRUE;
-	else
-	    c_token++;
+	/* Silently ignore the request */
+	num_tokens = GPMIN(num_tokens,++c_token);
     } else if (almost_equals(c_token,"dashl$ength") || equals(c_token,"dl")) {
 	num_tokens = GPMIN(num_tokens,c_token+2);
 	if (term->flags & TERM_CAN_DASH)
@@ -6017,6 +6054,12 @@ parse_label_options( struct text_label *this_label, TBOOLEAN in_plot )
 		    int_error(c_token,"invalid option");
 		c_token++;
 		this_label->tag = ROTATE_IN_3D_LABEL_TAG;
+	    } else if (almost_equals(c_token,"var$iable")) {
+		if (in_plot)	/* only in 2D plot with labels */
+		    this_label->tag = VARIABLE_ROTATE_LABEL_TAG;
+		else
+		    set_rot = FALSE;
+		c_token++;
 	    } else
 		rotate = TEXT_VERTICAL;
 	    continue;
diff --git a/src/show.c b/src/show.c
index 49b34b3..a9e91a2 100644
--- a/src/show.c
+++ b/src/show.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: show.c,v 1.326.2.14 2016/01/01 00:51:13 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: show.c,v 1.326.2.17 2016/09/03 23:18:58 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - show.c */
@@ -159,6 +159,7 @@ static void show_loadpath __PROTO((void));
 static void show_fontpath __PROTO((void));
 static void show_zero __PROTO((void));
 static void show_datafile __PROTO((void));
+static void show_minus_sign __PROTO((void));
 #ifdef USE_MOUSE
 static void show_mouse __PROTO((void));
 #endif
@@ -330,6 +331,9 @@ show_command()
     case S_LOGSCALE:
 	show_logscale();
 	break;
+    case S_MINUS_SIGN:
+	show_minus_sign();
+	break;
     case S_OFFSETS:
 	show_offsets();
 	break;
@@ -749,6 +753,7 @@ show_all()
     show_logscale();
     show_offsets();
     show_margin();
+    show_minus_sign();
     show_output();
     show_print();
     show_parametric();
@@ -1858,8 +1863,9 @@ show_key()
     SHOW_ALL_NL;
 
     if (!(key->visible)) {
-	fputs("\
-\tkey is OFF\n", stderr);
+	fputs("\tkey is OFF\n", stderr);
+	if (key->auto_titles == COLUMNHEAD_KEYTITLES)
+	    fputs("\ttreatment of first record as column headers remains in effect\n", stderr);
 	return;
     }
 
@@ -2451,8 +2457,11 @@ show_colorbox()
 	default: /* should *never* happen */
 	    int_error(NO_CARET, "Argh!");
     }
-    fprintf(stderr,"\tcolor gradient is %s in the color box\n",
-	color_box.rotation == 'v' ? "VERTICAL" : "HORIZONTAL");
+    if (color_box.rotation == 'v')
+	fprintf(stderr,"\tcolor gradient is vertical %s\n",
+	color_box.invert ? " (inverted)" : "");
+    else
+	fprintf(stderr,"\tcolor gradient is horizontal\n");
 }
 
 
@@ -2563,6 +2572,18 @@ show_decimalsign()
     fprintf(stderr, "\tdegree sign for output is %s \n", degree_sign);
 }
 
+/* process 'show minus_sign' command */
+static void
+show_minus_sign()
+{
+    SHOW_ALL_NL;
+
+    if (use_minus_sign && minus_sign)
+        fprintf(stderr, "\tminus sign for output is %s \n", minus_sign);
+    else
+        fprintf(stderr, "\tno special minus sign\n");
+}
+
 
 /* process 'show fit' command */
 static void
diff --git a/src/stats.c b/src/stats.c
index bb329a4..3da301c 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: stats.c,v 1.14.2.8 2016/06/09 17:07:34 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: stats.c,v 1.14.2.12 2016/09/28 05:38:15 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - stats.c */
@@ -49,7 +49,7 @@ static char *RCSid() { return RCSid("$Id: stats.c,v 1.14.2.8 2016/06/09 17:07:34
 #define INITIAL_DATA_SIZE (4096)   /* initial size of data arrays */
 
 static int comparator __PROTO(( const void *a, const void *b ));
-static struct file_stats analyze_file __PROTO(( long n, int outofrange, int invalid, int blank, int dblblank ));
+static struct file_stats analyze_file __PROTO(( long n, int outofrange, int invalid, int blank, int dblblank, int headers ));
 static struct sgl_column_stats analyze_sgl_column __PROTO(( double *data, long n, long nr ));
 static struct two_column_stats analyze_two_columns __PROTO(( double *x, double *y,
 							     struct sgl_column_stats res_x,
@@ -90,6 +90,7 @@ struct file_stats {
     long invalid;
     long outofrange;
     long blocks;  /* blocks are separated by double blank lines */
+    long columnheaders;
 };
 
 struct sgl_column_stats {
@@ -160,7 +161,7 @@ comparator( const void *a, const void *b )
 }
 
 static struct file_stats
-analyze_file( long n, int outofrange, int invalid, int blank, int dblblank )
+analyze_file( long n, int outofrange, int invalid, int blank, int dblblank, int headers )
 {
     struct file_stats res;
 
@@ -169,6 +170,7 @@ analyze_file( long n, int outofrange, int invalid, int blank, int dblblank )
     res.blanks  = blank;
     res.blocks  = dblblank + 1;  /* blocks are separated by dbl blank lines */
     res.outofrange = outofrange;
+    res.columnheaders = headers;
 
     return res;
 }
@@ -386,6 +388,7 @@ file_output( struct file_stats s )
 	fprintf( print_out, "%s\t%ld\n", "invalid", s.invalid );
 	fprintf( print_out, "%s\t%ld\n", "blanks", s.blanks );
 	fprintf( print_out, "%s\t%ld\n", "blocks", s.blocks );
+	fprintf( print_out, "%s\t%ld\n", "columnheaders", s.columnheaders );
 	fprintf( print_out, "%s\t%ld\n", "outofrange", s.outofrange );
 	return;
     }
@@ -396,6 +399,7 @@ file_output( struct file_stats s )
     fprintf( print_out, "  Records:           %*ld\n", width, s.records );
     fprintf( print_out, "  Out of range:      %*ld\n", width, s.outofrange );
     fprintf( print_out, "  Invalid:           %*ld\n", width, s.invalid );
+    fprintf( print_out, "  Column headers:    %*ld\n", width, s.columnheaders );
     fprintf( print_out, "  Blank:             %*ld\n", width, s.blanks );
     fprintf( print_out, "  Data Blocks:       %*ld\n", width, s.blocks );
 }
@@ -621,6 +625,7 @@ file_variables( struct file_stats s, char *prefix )
     /* Suffix does not make sense here! */
     create_and_set_var( s.records, prefix, "records", "" );
     create_and_set_var( s.invalid, prefix, "invalid", "" );
+    create_and_set_var( s.columnheaders, prefix, "headers", "" );
     create_and_set_var( s.blanks,  prefix, "blank",   "" );
     create_and_set_var( s.blocks,  prefix, "blocks",  "" );
     create_and_set_var( s.outofrange, prefix, "outofrange", "" );
@@ -729,6 +734,7 @@ statsrequest(void)
     long invalid;          /* number of missing/invalid records */
     long blanks;           /* number of blank lines */
     long doubleblanks;     /* number of repeated blank lines */
+    long columnheaders;    /* number of records treated as headers rather than data */
     long out_of_range;     /* number pts rejected, because out of range */
 
     struct file_stats res_file;
@@ -737,6 +743,7 @@ statsrequest(void)
 
     /* Vars for variable handling */
     static char *prefix = NULL;       /* prefix for user-defined vars names */
+    TBOOLEAN prefix_from_columnhead = FALSE;
 
     /* Vars that control output */
     TBOOLEAN do_output = TRUE;     /* Generate formatted output */
@@ -752,6 +759,7 @@ statsrequest(void)
     /* Initialize */
     invalid = 0;          /* number of missing/invalid records */
     blanks = 0;           /* number of blank lines */
+    columnheaders = 0;    /* number of records treated as headers rather than data */
     doubleblanks = 0;     /* number of repeated blank lines */
     out_of_range = 0;     /* number pts rejected, because out of range */
     n = 0;                /* number of records retained */
@@ -765,7 +773,7 @@ statsrequest(void)
     if ( !data_x || !data_y )
       int_error( NO_CARET, "Internal error: out of memory in stats" );
 
-    n = invalid = blanks = doubleblanks = out_of_range = 0;
+    n = invalid = blanks = columnheaders = doubleblanks = out_of_range = 0;
 
     /* Get filename */
     i = c_token;
@@ -807,6 +815,34 @@ statsrequest(void)
 	if ( parametric )
 	    int_error( NO_CARET, "Stats command not available in parametric mode" );
 
+	/* Parse the remainder of the command line */
+	while( !(END_OF_COMMAND) ) {
+	    if ( almost_equals( c_token, "out$put" ) ) {
+		    do_output = TRUE;
+		    c_token++;
+
+	    } else if ( almost_equals( c_token, "noout$put" ) ) {
+		    do_output = FALSE;
+		    c_token++;
+
+	    } else if ( almost_equals(c_token, "pre$fix")
+		   ||   equals(c_token, "name")) {
+		c_token++;
+		free ( prefix );
+		if (almost_equals(c_token,"col$umnheader")) {
+		    df_set_key_title_columnhead(NULL);
+		    prefix_from_columnhead = TRUE;
+		    continue;
+		}
+		prefix = try_to_get_string();
+		if (!legal_identifier(prefix) || !strcmp ("GPVAL_", prefix))
+		    int_error( --c_token, "illegal prefix" );
+
+	    }  else {
+		int_error( c_token, "Unrecognized fit option");
+	    }
+	}
+
 	/* If the user has set an explicit locale for numeric input, apply it */
 	/* here so that it affects data fields read from the input file. */
 	set_numeric_locale();
@@ -848,6 +884,10 @@ statsrequest(void)
 	      doubleblanks += 1;
 	      continue;
 
+	    case DF_COLUMN_HEADERS:
+	      columnheaders += 1;
+	      continue;
+
 	    case 0:
 	      int_warn( NO_CARET, "bad data on line %d of file %s",
 	  		df_line_number, df_filename ? df_filename : "" );
@@ -874,6 +914,11 @@ statsrequest(void)
 	      }
 	      columns = 2;
 	      break;
+
+	    default: /* Who are these? */
+	      FPRINTF((stderr,"unhandled return code %d from df_readline\n", i));
+	      break;
+
 	    }
 	} /* end-while : done reading file */
 	df_close();
@@ -892,36 +937,19 @@ statsrequest(void)
 	    int_warn( NO_CARET, "All points out of range" );
 	else
 	    int_warn( NO_CARET, "No valid data points found in file" );
-	/* Skip rest of command line and return error */
-	while (!END_OF_COMMAND) c_token++;
-	goto stats_cleanup;
     }
 
-    /* Parse the remainder of the command line: 0 to 2 tokens possible */
-    while( !(END_OF_COMMAND) ) {
-	if ( almost_equals( c_token, "out$put" ) ) {
-		do_output = TRUE;
-		c_token++;
-
-	} else if ( almost_equals( c_token, "noout$put" ) ) {
-		do_output = FALSE;
-		c_token++;
-
-	} else if ( almost_equals(c_token, "pre$fix")
-	       ||   equals(c_token, "name")) {
-	    c_token++;
-	    free ( prefix );
-	    prefix = try_to_get_string();
-	    if (!legal_identifier(prefix) || !strcmp ("GPVAL_", prefix))
-		int_error( --c_token, "illegal prefix" );
-
-	}  else {
-	    int_error( c_token, "Expecting [no]output or prefix");
+    /* The analysis variables are named STATS_* unless the user either */
+    /* gave a specific name or told us to use a columnheader.          */
+    if (!prefix && prefix_from_columnhead && df_key_title && *df_key_title) {
+	prefix = gp_strdup(df_key_title);
+	squash_spaces(prefix, 0);
+	if (!legal_identifier(prefix)) {
+	    int_warn(NO_CARET, "columnhead %s is not a valid prefix", prefix ? prefix : "");
+	    free(prefix);
+	    prefix = NULL;
 	}
-
     }
-
-    /* Set defaults if not explicitly set by user */
     if (!prefix)
 	prefix = gp_strdup("STATS_");
     i = strlen(prefix);
@@ -931,7 +959,7 @@ statsrequest(void)
     }
 
     /* Do the actual analysis */
-    res_file = analyze_file( n, out_of_range, invalid, blanks, doubleblanks );
+    res_file = analyze_file( n, out_of_range, invalid, blanks, doubleblanks, columnheaders );
 
     /* Jan 2015: Revised detection and handling of matrix data */
     if (df_matrix) {
diff --git a/src/tables.c b/src/tables.c
index 5efced9..340c69d 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: tables.c,v 1.133.2.4 2015/10/05 16:04:46 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: tables.c,v 1.133.2.6 2016/08/27 20:50:14 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - tables.c */
@@ -210,6 +210,7 @@ const struct gen_table set_tbl[] =
     { "tmar$gin", S_TMARGIN },
     { "bmar$gin", S_BMARGIN },
 
+    { "minus$sign", S_MINUS_SIGN },
 #ifdef USE_MOUSE
     { "mo$use", S_MOUSE },
 #endif
@@ -436,6 +437,8 @@ const struct gen_table set_colorbox_tbl[] =
     { "nobo$rder",	S_COLORBOX_NOBORDER },
     { "o$rigin",	S_COLORBOX_ORIGIN },
     { "s$ize",		S_COLORBOX_SIZE },
+    { "inv$ert",	S_COLORBOX_INVERT },
+    { "noinv$ert",	S_COLORBOX_NOINVERT },
     { "fr$ont",		S_COLORBOX_FRONT },
     { "ba$ck",		S_COLORBOX_BACK },
     { NULL, S_COLORBOX_INVALID }
diff --git a/src/tables.h b/src/tables.h
index c1996c7..1a725f9 100644
--- a/src/tables.h
+++ b/src/tables.h
@@ -1,5 +1,5 @@
 /*
- * $Id: tables.h,v 1.91.2.1 2015/03/29 18:08:06 sfeam Exp $
+ * $Id: tables.h,v 1.91.2.3 2016/08/27 20:50:14 sfeam Exp $
  */
 
 /* GNUPLOT - tables.h */
@@ -83,6 +83,7 @@ enum set_id {
     S_LABEL, S_LINK,
     S_LINESTYLE, S_LINETYPE, S_LOADPATH, S_LOCALE, S_LOGSCALE, S_MACROS,
     S_MAPPING, S_MARGIN, S_LMARGIN, S_RMARGIN, S_TMARGIN, S_BMARGIN, S_MISSING,
+    S_MINUS_SIGN,
 #ifdef USE_MOUSE
     S_MOUSE,
 #endif
@@ -150,6 +151,7 @@ enum set_colorbox_id {
     S_COLORBOX_DEFAULT, S_COLORBOX_USER,
     S_COLORBOX_BORDER, S_COLORBOX_BDEFAULT, S_COLORBOX_NOBORDER,
     S_COLORBOX_ORIGIN, S_COLORBOX_SIZE,
+    S_COLORBOX_INVERT, S_COLORBOX_NOINVERT,
     S_COLORBOX_FRONT, S_COLORBOX_BACK
 };
 
diff --git a/src/tabulate.c b/src/tabulate.c
index 0369c3e..f102f8c 100644
--- a/src/tabulate.c
+++ b/src/tabulate.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: tabulate.c,v 1.22.2.1 2015/01/16 18:47:57 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: tabulate.c,v 1.22.2.2 2016/09/06 17:07:27 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - tabulate.c */
@@ -64,6 +64,7 @@ udvt_entry *table_var = NULL;
 TBOOLEAN table_mode = FALSE;
 
 static char *expand_newline __PROTO((const char *in));
+static TBOOLEAN imploded __PROTO((curve_points *this_plot));
 
 static FILE *outfile;
 
@@ -225,6 +226,9 @@ print_table(struct curve_points *current_plot, int plot_num)
 
 	} else {
 	    int plotstyle = current_plot->plot_style;
+	    int type;
+	    TBOOLEAN replace_undefined_with_blank = imploded(current_plot);
+
 	    if (plotstyle == HISTOGRAMS && current_plot->histogram->type == HT_ERRORBARS)
 		plotstyle = YERRORBARS;
 
@@ -317,12 +321,19 @@ print_table(struct curve_points *current_plot, int plot_num)
 		    }
 		}
 
+		type = current_plot->points[i].type;
+
 		snprintf(buffer, BUFFERSIZE, " %c",
-		    current_plot->points[i].type == INRANGE
-		    ? 'i' : current_plot->points[i].type == OUTRANGE
-		    ? 'o' : 'u');
+			type == INRANGE ? 'i' : type == OUTRANGE ? 'o' : 'u');
 		strappend(&line, &size, len, buffer);
-		print_line(line);
+
+		/* cp_implode() inserts dummy undefined point between curves */
+		/* but datafiles use a blank line for this purpose */
+		if (type == UNDEFINED && replace_undefined_with_blank)
+		    print_line("");
+		else 
+		    print_line(line);
+
 	    } /* for(point i) */
 	}
 
@@ -506,3 +517,27 @@ expand_newline(const char *in)
     } while (*s++);
     return tmpstr;
 }
+
+static TBOOLEAN
+imploded(curve_points *this_plot)
+{
+    switch (this_plot->plot_smooth) {
+	/* These smooth styles called cp_implode() */
+	case SMOOTH_UNIQUE:
+	case SMOOTH_FREQUENCY:
+	case SMOOTH_CUMULATIVE:
+	case SMOOTH_CUMULATIVE_NORMALISED:
+	case SMOOTH_CSPLINES:
+	case SMOOTH_ACSPLINES:
+	case SMOOTH_SBEZIER:
+	case SMOOTH_MONOTONE_CSPLINE:
+	    return TRUE;
+	/* These ones did not */
+	case SMOOTH_NONE:
+	case SMOOTH_BEZIER:
+	case SMOOTH_KDENSITY:
+	default:
+	    break;
+    }
+    return FALSE;
+}
diff --git a/src/term_api.h b/src/term_api.h
index 78651a2..4aff3f3 100644
--- a/src/term_api.h
+++ b/src/term_api.h
@@ -1,5 +1,5 @@
 /*
- * $Id: term_api.h,v 1.134.2.9 2016/01/18 23:51:59 sfeam Exp $
+ * $Id: term_api.h,v 1.134.2.10 2016/07/21 19:00:31 sfeam Exp $
  */
 
 /* GNUPLOT - term_api.h */
diff --git a/src/unset.c b/src/unset.c
index b514f58..ba9f42c 100644
--- a/src/unset.c
+++ b/src/unset.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: unset.c,v 1.206.2.9 2016/01/11 23:32:51 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: unset.c,v 1.206.2.11 2016/08/07 18:41:09 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - unset.c */
@@ -103,6 +103,7 @@ static void unset_logscale __PROTO((void));
 static void unset_mapping __PROTO((void));
 static void unset_margin __PROTO((t_position *));
 static void unset_missing __PROTO((void));
+static void unset_minus_sign __PROTO((void));
 #ifdef USE_MOUSE
 static void unset_mouse __PROTO((void));
 #endif
@@ -327,6 +328,9 @@ unset_command()
 	df_commentschars = gp_strdup(DEFAULT_COMMENTS_CHARS);
 	df_unset_datafile_binary();
 	break;
+    case S_MINUS_SIGN:
+	unset_minus_sign();
+	break;
     case S_MONOCHROME:
 	unset_monochrome();
 	break;
@@ -473,7 +477,7 @@ unset_command()
 	break;
     case S_Y2DTICS:
     case S_Y2MTICS:
-	unset_month_day_tics(FIRST_X_AXIS);
+	unset_month_day_tics(SECOND_Y_AXIS);
 	break;
     case S_MZTICS:
 	unset_minitics(FIRST_Z_AXIS);
@@ -1178,6 +1182,13 @@ unset_margin(t_position *margin)
     margin->x = -1;
 }
 
+/* process 'unset minus_sign' command */
+static void
+unset_minus_sign()
+{
+    use_minus_sign = FALSE;
+}
+
 /* process 'unset datafile' command */
 static void
 unset_missing()
diff --git a/src/util.c b/src/util.c
index 4cc2a65..45c9be6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: util.c,v 1.128.2.3 2015/08/03 18:33:02 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: util.c,v 1.128.2.5 2016/08/19 16:14:08 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - util.c */
@@ -65,6 +65,10 @@ char *decimalsign = NULL;
 /* degree sign.  Defaults to UTF-8 but will be changed to match encoding */
 char degree_sign[8] = "°";
 
+/* minus sign (encoding-specific string) */
+const char *minus_sign = NULL;
+TBOOLEAN use_minus_sign = FALSE;
+
 /* Holds the name of the current LC_NUMERIC as set by "set decimal locale" */
 char *numeric_locale = NULL;
 
@@ -960,6 +964,47 @@ gprintf(
 	    }
 	}
 
+    /* EXPERIMENTAL
+     * Some people prefer a "real" minus sign to the hyphen that standard
+     * formatted input and output both use.  Unlike decimal signs, there is
+     * no internationalization mechanism to specify this preference.
+     * This code replaces all hyphens with the character string specified by
+     * 'set minus_sign "..."'   typically unicode character U+2212 "−".
+     * Use at your own risk.  Should be OK for graphical output, but text output
+     * will not be readable by standard formatted input routines.
+     */
+	if (use_minus_sign		/* set minussign */
+	    && minus_sign		/* current encoding provides one */
+	    && !table_mode		/* not used inside "set table" */
+	    && !(term->flags & TERM_IS_LATEX)	/* but LaTeX doesn't want it */
+	   ) {
+
+	    char *dotpos1 = dest;
+	    char *dotpos2;
+	    size_t newlength = strlen(minus_sign);
+
+	    /* dot is the default hyphen we will be replacing */
+	    int dot = '-';
+
+	    /* replace every dot by the contents of minus_sign */
+	    while ((dotpos2 = strchr(dotpos1,dot)) != NULL) {
+		if (newlength == 1) {	/* The normal case */
+		    *dotpos2 = *minus_sign;
+		    dotpos1++;
+		} else {		/* Some multi-byte minus marker */
+		    size_t taillength = strlen(dotpos2);
+		    dotpos1 = dotpos2 + newlength;
+		    if (dotpos1 + taillength > limit)
+			int_error(NO_CARET,
+				  "format too long due to minus_sign string");
+		    /* move tail end of string out of the way */
+		    memmove(dotpos1, dotpos2 + 1, taillength);
+		    /* insert minus_sign */
+		    memcpy(dotpos2, minus_sign, newlength);
+		}
+	    }
+	}
+
 	/* this was at the end of every single case, before: */
 	dest += strlen(dest);
 	++format;
@@ -1237,11 +1282,12 @@ graph_error(const char *fmt, va_dcl)
 /*}}} */
 
 
-/* Squash spaces in the given string (DFK) */
-/* That is, reduce all multiple white-space chars to single spaces */
-/* Done in place. Currently used only by help_command() */
+/*
+ * Reduce all multiple white-space chars to single spaces (if remain == 1)
+ * or remove altogether (if remain == 0).  Modifies the original string.
+ */
 void
-squash_spaces(char *s)
+squash_spaces(char *s, int remain)
 {
     char *r = s;	/* reading point */
     char *w = s;	/* writing point */
@@ -1250,7 +1296,7 @@ squash_spaces(char *s)
     for (w = r = s; *r != NUL; r++) {
 	if (isspace((unsigned char) *r)) {
 	    /* white space; only copy if we haven't just copied a space */
-	    if (!space) {
+	    if (!space && remain > 0) {
 		space = TRUE;
 		*w++ = ' ';
 	    }			/* else ignore multiple spaces */
diff --git a/src/util.h b/src/util.h
index 151ac80..cdf2ac9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,5 +1,5 @@
 /*
- * $Id: util.h,v 1.44 2014/04/05 06:17:09 markisch Exp $
+ * $Id: util.h,v 1.44.2.2 2016/08/19 16:14:08 sfeam Exp $
  */
 
 /* GNUPLOT - util.h */
@@ -62,6 +62,10 @@ extern char *current_locale;	/* LC_TIME */
 /* degree sign */
 extern char degree_sign[8];
 
+/* minus sign */
+extern const char *minus_sign;
+extern TBOOLEAN use_minus_sign;
+
 extern const char *current_prompt; /* needed by is_error() and friends */
 
 /* Functions exported by util.c: */
@@ -114,11 +118,7 @@ void int_warn __PROTO(());
 void graph_error __PROTO(());
 #endif
 
-/* FIXME HBB 20010726: should be moved to where help_comamnd() is, and
- * made static. Currently, that's command.c, but it should probably
- * move to help.c, instead.
- */
-void squash_spaces __PROTO((char *));
+void squash_spaces __PROTO((char *s, int remain));
 
 TBOOLEAN existdir __PROTO((const char *));
 TBOOLEAN existfile(const char *);
diff --git a/src/version.c b/src/version.c
index b803cf8..dc76902 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1,5 +1,5 @@
 #ifndef lint
-static char *RCSid() { return RCSid("$Id: version.c,v 1.111.2.13 2016/07/15 06:08:34 sfeam Exp $"); }
+static char *RCSid() { return RCSid("$Id: version.c,v 1.111.2.16 2016/10/09 17:23:56 sfeam Exp $"); }
 #endif
 
 /* GNUPLOT - version.c */
@@ -40,11 +40,11 @@ static char *RCSid() { return RCSid("$Id: version.c,v 1.111.2.13 2016/07/15 06:0
 
 
 const char gnuplot_version[] = "5.0";
-const char gnuplot_patchlevel[] = "4";
+const char gnuplot_patchlevel[] = "5";
 #ifdef DEVELOPMENT_VERSION
 #include "timestamp.h"
 #else
-const char gnuplot_date[] = "2016-07-21 ";
+const char gnuplot_date[] = "2016-10-02";
 #endif
 const char gnuplot_copyright[] = "Copyright (C) 1986-1993, 1998, 2004, 2007-2016";
 
diff --git a/src/wxterminal/wxt_gui.cpp b/src/wxterminal/wxt_gui.cpp
index a7f06f2..26a239e 100644
--- a/src/wxterminal/wxt_gui.cpp
+++ b/src/wxterminal/wxt_gui.cpp
@@ -1,5 +1,5 @@
 /*
- * $Id: wxt_gui.cpp,v 1.128.2.24 2016/02/13 16:30:57 markisch Exp $
+ * $Id: wxt_gui.cpp,v 1.128.2.27 2016/08/26 04:16:01 sfeam Exp $
  */
 
 /* GNUPLOT - wxt_gui.cpp */
@@ -519,6 +519,7 @@ void wxtFrame::OnExport( wxCommandEvent& WXUNUSED( event ) )
 		saveDir, wxT(""),
 		wxT("PNG files (*.png)|*.png|PDF files (*.pdf)|*.pdf|SVG files (*.svg)|*.svg"),
 		wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
 	exportFileDialog.SetFilterIndex(userFilterIndex);
 
 	if (exportFileDialog.ShowModal() == wxID_CANCEL)
@@ -538,7 +539,7 @@ void wxtFrame::OnExport( wxCommandEvent& WXUNUSED( event ) )
 	switch (exportFileDialog.GetFilterIndex()) {
 	case 0 :
 		/* Save as PNG file. */
-		surface = cairo_get_target(wxt_current_plot->cr);
+		surface = cairo_get_target(panel->plot.cr);
 		ierr = cairo_surface_write_to_png(surface, fullpathFilename.mb_str(wxConvUTF8));
 		if (ierr != CAIRO_STATUS_SUCCESS)
 			fprintf(stderr,"error writing PNG file: %s\n", cairo_status_to_string(ierr));
@@ -546,45 +547,55 @@ void wxtFrame::OnExport( wxCommandEvent& WXUNUSED( event ) )
 
 	case 1 :
 		/* Save as PDF file. */
-		save_cr = wxt_current_plot->cr;
+		save_cr = panel->plot.cr;
 		cairo_save(save_cr);
 		surface = cairo_pdf_surface_create(
 			fullpathFilename.mb_str(wxConvUTF8),
-			wxt_current_plot->device_xmax, wxt_current_plot->device_ymax);
-		wxt_current_plot->cr = cairo_create(surface);
+			panel->plot.device_xmax, panel->plot.device_ymax);
+		if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
+			fprintf(stderr, "Cairo error: could not create surface for file %s.\n", (const char *)fullpathFilename.mb_str());
+			cairo_surface_destroy(surface);
+			break;
+		}
+		panel->plot.cr = cairo_create(surface);
 		cairo_surface_destroy(surface);
 
-		cairo_scale(wxt_current_plot->cr,
-			1./(double)wxt_current_plot->oversampling_scale,
-			1./(double)wxt_current_plot->oversampling_scale);
-		wxt_current_panel->wxt_cairo_refresh();
+		cairo_scale(panel->plot.cr,
+			1./(double)panel->plot.oversampling_scale,
+			1./(double)panel->plot.oversampling_scale);
+		panel->wxt_cairo_refresh();
 
-		cairo_show_page(wxt_current_plot->cr);
+		cairo_show_page(panel->plot.cr);
 		cairo_surface_finish(surface);
-		wxt_current_plot->cr = save_cr;
-		cairo_restore(wxt_current_plot->cr);
+		panel->plot.cr = save_cr;
+		cairo_restore(panel->plot.cr);
 		break;
 
 	case 2 :
 #ifdef CAIRO_HAS_SVG_SURFACE
 		/* Save as SVG file. */
-		save_cr = wxt_current_plot->cr;
+		save_cr = panel->plot.cr;
 		cairo_save(save_cr);
 		surface = cairo_svg_surface_create(
 			fullpathFilename.mb_str(wxConvUTF8),
-			wxt_current_plot->device_xmax, wxt_current_plot->device_ymax);
-		wxt_current_plot->cr = cairo_create(surface);
+			panel->plot.device_xmax, panel->plot.device_ymax);
+		if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
+			fprintf(stderr, "Cairo error: could not create surface for file %s.\n", (const char *)fullpathFilename.mb_str());
+			cairo_surface_destroy(surface);
+			break;
+		}
+		panel->plot.cr = cairo_create(surface);
 		cairo_surface_destroy(surface);
 
-		cairo_scale(wxt_current_plot->cr,
-			1./(double)wxt_current_plot->oversampling_scale,
-			1./(double)wxt_current_plot->oversampling_scale);
-		wxt_current_panel->wxt_cairo_refresh();
+		cairo_scale(panel->plot.cr,
+			1./(double)panel->plot.oversampling_scale,
+			1./(double)panel->plot.oversampling_scale);
+		panel->wxt_cairo_refresh();
 
-		cairo_show_page(wxt_current_plot->cr);
+		cairo_show_page(panel->plot.cr);
 		cairo_surface_finish(surface);
-		wxt_current_plot->cr = save_cr;
-		cairo_restore(wxt_current_plot->cr);
+		panel->plot.cr = save_cr;
+		cairo_restore(panel->plot.cr);
 		break;
 #endif
 
@@ -1878,7 +1889,6 @@ void wxt_init()
 	/* initialize helper pointers */
 	wxt_current_panel = wxt_current_window->frame->panel;
 	wxt_current_plot = &(wxt_current_panel->plot);
-	wxt_current_command_list = &(wxt_current_panel->command_list);
 
 	wxt_sigint_check();
 
@@ -1999,8 +2009,6 @@ void wxt_graphics()
 	/* apply the queued rendering settings */
 	wxt_current_panel->wxt_settings_apply();
 
-	FPRINTF((stderr,"Graphics1\n"));
-
 	wxt_MutexGuiEnter();
 	/* set the transformation matrix of the context, and other details */
 	/* depends on plot->xscale and plot->yscale */
@@ -2810,7 +2818,7 @@ void wxt_command_push(gp_command command)
 {
 	wxt_sigint_init();
 	wxt_current_panel->command_list_mutex.Lock();
-	wxt_current_command_list->push_back(command);
+	wxt_current_panel->command_list.push_back(command);
 	wxt_current_panel->command_list_mutex.Unlock();
 	wxt_sigint_check();
 	wxt_sigint_restore();
diff --git a/src/wxterminal/wxt_gui.h b/src/wxterminal/wxt_gui.h
index 91f9bea..afee8fa 100644
--- a/src/wxterminal/wxt_gui.h
+++ b/src/wxterminal/wxt_gui.h
@@ -1,5 +1,5 @@
 /*
- * $Id: wxt_gui.h,v 1.48.2.6 2016/03/22 17:08:36 markisch Exp $
+ * $Id: wxt_gui.h,v 1.48.2.8 2016/08/26 04:16:01 sfeam Exp $
  */
 
 /* GNUPLOT - wxt_gui.h */
@@ -172,9 +172,9 @@ extern "C" {
  * console window */
 # ifdef _Windows
 #  ifndef _WIN32_WINNT 
-#   define _WIN32_WINNT 0x0500
+#   define _WIN32_WINNT 0x0501
 #  endif
-#  include "Windows.h"
+#  include <windows.h>
 #  include "win/wtext.h"
 #  include "win/winmain.h"
 # endif
@@ -596,7 +596,6 @@ static wxt_window_t* wxt_findwindowbyid(wxWindowID);
 
 /* pointers to currently active instances */
 static wxt_window_t *wxt_current_window;
-static command_list_t *wxt_current_command_list;
 static wxtPanel *wxt_current_panel;
 static plot_struct *wxt_current_plot;
 
diff --git a/term/js/canvasmath.js b/term/js/canvasmath.js
index b16befd..f2d9cad 100644
--- a/term/js/canvasmath.js
+++ b/term/js/canvasmath.js
@@ -1,5 +1,5 @@
 /*
- * $Id: canvasmath.js,v 1.10 2012/11/16 03:47:31 sfeam Exp $
+ * $Id: canvasmath.js,v 1.10.2.1 2016/08/07 00:06:18 sfeam Exp $
  */
 // The canvastext.js code was released to the public domain by Jim Studt, 2007.
 // He may keep some sort of up to date copy at http://www.federated.com/~jim/canvastext/
@@ -275,6 +275,7 @@ CanvasTextFunctions.letters = {
 8463: { width: 21, points: [[9,22],[3,1],[-1,-1],[5,7],[7,11],[9,13],[11,14],[13,14],[15,14],[16,12],[16,10],[14,5],[14,2],[15,1],[19,3],[-1,-1],[7,21],[9,22],[-1,-1],[4,15],[14,20]] },
 8491: { width: 0, points: [[-99,197]] },
 8495: { width: 18, points: [[4,6],[8,7],[11,8],[14,10],[15,12],[14,14],[12,15],[9,15],[6,14],[4,11],[3,8],[3,5],[4,3],[5,2],[7,1],[9,1],[12,2],[14,4],[-1,-1],[9,15],[7,14],[5,11],[4,8],[4,4],[5,2]] },
+8722: { width: 20, points: [[2,9],[18,9]] },
 
 // Used to indicate missing glyph
 129: { width: 18, points: [[2,-2],[2,21],[16,21],[16,-2],[2,-2]] }
diff --git a/term/post.trm b/term/post.trm
index 82221b3..5fa952a 100644
--- a/term/post.trm
+++ b/term/post.trm
@@ -1,5 +1,5 @@
 /* Hello, Emacs: this is -*-C-*- !
- * $Id: post.trm,v 1.288.2.2 2016/01/01 00:12:14 sfeam Exp $
+ * $Id: post.trm,v 1.288.2.3 2016/08/17 17:09:49 sfeam Exp $
  */
 
 /* GNUPLOT - post.trm */
@@ -1769,9 +1769,25 @@ end\n\
 	    fprintf(gppsfile,"%s",OldEPSL_linetypes[i]);
     }
 
-    if (ps_params->duplex_option)
-	fprintf(gppsfile, "statusdict begin %s setduplexmode end\n",
+    /* The use of statusdict and setduplexmode is not 'Standard'  */
+    /* PostScript.  This method is used in Level 1 as a means of  */
+    /* controlling device properties, and is device specific.     */
+    /* Level 2/3 PostScript performs these functions via          */
+    /* setpagedevice.  See PostScript Language Reference 3rd Ed.  */
+    /* pages 426-32 and 679-80 for details.  The code below just  */
+    /* makes the passing of _simplex_ work across levels 1-3 and  */
+    /* the matter of Duplex and Tumble is left to others.         */
+    /* Be aware that BRscript3 is not happy if presented with a   */
+    /* single page and Duplex is forced on, whereas the Xerox     */
+    /* Phaser 8560 sees there is only one page and uses simplex.  */
+
+    if (ps_params->duplex_option) {
+	if (ps_params->level1 )
+	    fprintf(gppsfile, "statusdict begin %s setduplexmode end\n",
 		ps_params->duplex_state ? "true" : "false");
+	else if (!ps_params->duplex_state) fprintf(gppsfile,
+	    "%%%%BeginFeature: *Duplex Simplex\n << /Duplex false >> setpagedevice\n%%%%EndFeature\n");
+    }
 
     if (dict)
 	while (*dict)
diff --git a/term/pslatex.trm b/term/pslatex.trm
index f8a46f9..e5c3904 100644
--- a/term/pslatex.trm
+++ b/term/pslatex.trm
@@ -1,5 +1,5 @@
 /* Hello, Emacs, this is -*-C-*-
- * $Id: pslatex.trm,v 1.90.2.4 2016/07/08 20:48:34 sfeam Exp $
+ * $Id: pslatex.trm,v 1.90.2.5 2016/09/01 19:01:25 sfeam Exp $
  */
 
 /* GNUPLOT - pslatex.trm */
@@ -939,10 +939,22 @@ EPSLATEX_linetype(int linetype)
 TERM_PUBLIC void
 EPSLATEX_layer(t_termlayer syncpoint)
 {
+    static int plotno = 0;
+
     switch (syncpoint) {
 
+    case TERM_LAYER_BEFORE_PLOT:
+	fprintf(gppsfile, "%% Begin plot #%d\n", ++plotno);
+	break;
+    
+    case TERM_LAYER_AFTER_PLOT:
+	PS_linetype(LT_UNDEFINED);	/* Forces a stroke and resets linetype */
+	fprintf(gppsfile, "%% End plot #%d\n", plotno);
+	break;
+
     case TERM_LAYER_RESET:        /* Start of plot; reset flag */
 	epslatex_text_layer = 0;
+	plotno = 0;
 	break;
 
     case TERM_LAYER_BACKTEXT: /* Start of "back" text layer */
diff --git a/term/qt.trm b/term/qt.trm
index 7a156b0..1f27b07 100644
--- a/term/qt.trm
+++ b/term/qt.trm
@@ -1,5 +1,5 @@
 /* GNUPLOT - qt.trm 
- * $Id: qt.trm,v 1.14 2014/04/20 20:23:35 lodewyck Exp $
+ * $Id: qt.trm,v 1.14.2.1 2016/07/21 19:29:01 sfeam Exp $
  */
 
 /*[
@@ -53,7 +53,7 @@ TERM_TABLE_START (qt_driver)
     qt_text_angle, qt_justify_text,
     qt_point, do_arrow, qt_set_font,
     qt_pointsize,
-    TERM_CAN_MULTIPLOT|TERM_NO_OUTPUTFILE|TERM_ALPHA_CHANNEL|TERM_CAN_DASH|TERM_ENHANCED_TEXT,
+    TERM_CAN_MULTIPLOT|TERM_NO_OUTPUTFILE|TERM_ALPHA_CHANNEL|TERM_CAN_DASH|TERM_ENHANCED_TEXT|TERM_POLYGON_PIXELS,
     0 /* suspend */, 0 /* resume */, qt_fillbox, qt_linewidth
 #ifdef USE_MOUSE
     , qt_waitforinput, qt_put_tmptext, qt_set_ruler, qt_set_cursor, qt_set_clipboard
diff --git a/term/svg.trm b/term/svg.trm
index e883035..9086ca4 100644
--- a/term/svg.trm
+++ b/term/svg.trm
@@ -1,5 +1,5 @@
 /* Hello, Emacs, this is -*-C-*-
- * $Id: svg.trm,v 1.170.2.1 2016/05/02 03:59:18 sfeam Exp $
+ * $Id: svg.trm,v 1.170.2.2 2016/08/04 23:01:12 sfeam Exp $
  */
 
 /*------------------------------------------------------------------------------------------------------------------------------------
@@ -178,10 +178,10 @@ static int SVG_plotno = 0;
 static TBOOLEAN SVG_gridline = FALSE;
 static TBOOLEAN SVG_hasgrid = FALSE;
 
-static int SVG_fontAscent = 0;	/* estimated current font ascent*/
-static int SVG_fontDescent = 0;	/* estimated current font descent*/
-static int SVG_fontLeading = 0;	/* estimated current font leading*/
-static int SVG_fontAvWidth = 0;	/* estimated current font char average width*/
+static double SVG_fontAscent  = 0;	/* estimated current font ascent*/
+static double SVG_fontDescent = 0;	/* estimated current font descent*/
+static double SVG_fontLeading = 0;	/* estimated current font leading*/
+static double SVG_fontAvWidth = 0;	/* estimated current font char average width*/
 
 static short SVG_Pen_RealID __PROTO ((int));
 static void SVG_PathOpen __PROTO ((void));
@@ -370,10 +370,10 @@ SVG_SetFont (const char *name, double size)
  * 'font-size' (!), we have to to define font properties in a less
  * than optimal way */
 
-    SVG_fontAscent = (int) (SVG_fontSizeCur * 1.00 * SVG_SCALE);
-    SVG_fontDescent = (int) (SVG_fontSizeCur * 0.25 * SVG_SCALE);
-    SVG_fontLeading = (int) (SVG_fontSizeCur * 0.25 * SVG_SCALE);
-    SVG_fontAvWidth = (int) (SVG_fontSizeCur * 0.70 * SVG_SCALE);
+    SVG_fontAscent  = (SVG_fontSizeCur * 0.90 * SVG_SCALE);
+    SVG_fontDescent = (SVG_fontSizeCur * 0.25 * SVG_SCALE);
+    SVG_fontLeading = (SVG_fontSizeCur * 0.35 * SVG_SCALE);
+    SVG_fontAvWidth = (SVG_fontSizeCur * 0.70 * SVG_SCALE);
 
     term->h_char = SVG_fontAvWidth;
     term->v_char = (SVG_fontAscent + SVG_fontDescent + SVG_fontLeading);
@@ -1449,6 +1449,7 @@ TERM_PUBLIC void
 SVG_put_text (unsigned int x, unsigned int y, const char *str)
 {
     char *alignment;
+    double vertical_offset;
     int h = x, v = y;
 
     SVG_PathClose ();
@@ -1469,14 +1470,9 @@ SVG_put_text (unsigned int x, unsigned int y, const char *str)
     }
 
 /* vertical justification*/
-
-    if (SVG_TextAngle % 180) {
-	/* vertical text */
-	h += (SVG_fontAscent - SVG_fontDescent) / 2;
-    } else {
-	/* horizontal text */
-	v -= (SVG_fontAscent - SVG_fontDescent) / 2;
-    }
+    vertical_offset = (SVG_fontAscent - SVG_fontDescent) / 2.;
+    h += vertical_offset * sin(SVG_TextAngle * DEG2RAD);
+    v -= vertical_offset * cos(SVG_TextAngle * DEG2RAD);
 
 /* define text position and attributes */
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/gnuplot.git



More information about the debian-science-commits mailing list