Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 ivtools (1.2.11a1-8) unstable; urgency=medium
 .
   * address GCC-6 errors, abs(unsigned) and zero comparison (closes: #835747)
     - commit 9741bca, GCC-6 zero comparison
     - commit 5dd153e, GCC-6 abs(unsigned)
Author: Barak A. Pearlmutter <bap@debian.org>
Bug-Debian: https://bugs.debian.org/835747

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- ivtools-1.2.11a1.orig/CHANGES-0.8
+++ ivtools-1.2.11a1/CHANGES-0.8
@@ -777,7 +777,7 @@ Interpreter Changes
  
 	* add LISP-like symbol assignment semantics to comterp.  Now
 	expressions that return a symbol can appear on the right hand
-	or left hand side of an assigment operator.  See new command
+	or left hand side of an assignment operator.  See new command
 	"symvar", and "symbol" has been renamed "symval".
 
 	* add support for command aliases to comterp, to allow
--- ivtools-1.2.11a1.orig/CHANGES-0.9
+++ ivtools-1.2.11a1/CHANGES-0.9
@@ -204,9 +204,9 @@ Jul 25th 2001 ivtools-0.9.5
 
 - fixes a problem with importing files introduced when migrating away
 from the use of istream::gets (required for gcc-3.0 and libstdc++ v3).
-istream::gets would automatically skip the newline delimeter.  When
+istream::gets would automatically skip the newline delimiter.  When
 using istream::get in libstdc++ v3 I needed to manually skip the
-newline delimeter.
+newline delimiter`.
 
 - globally change optimization from -O6 to -O2, which makes gcc-3.0
 compile time much more reasonable.
--- ivtools-1.2.11a1.orig/COPYRIGHT
+++ ivtools-1.2.11a1/COPYRIGHT
@@ -1,5 +1,7 @@
 /*
- * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Scott E. Johnston
+ * Copyright (c) 2014-2015 Scott E. Johnston
+ * Copyright (c) 2009-2014 Wave Semiconductor Inc.
+ * Copyright (c) 2001-2009 Scott E. Johnston
  * Copyright (c) 2000  Vectaport Inc., IET Inc
  * Copyright (c) 1999  Vectaport Inc., IET Inc, R.B. Kissh and Associates
  * Copyright (c) 1998  Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler
--- ivtools-1.2.11a1.orig/MANIFEST
+++ ivtools-1.2.11a1/MANIFEST
@@ -1,4 +1,4 @@
-sivtools-1.2/CHANGES
+ivtools-1.2/CHANGES
 ivtools-1.2/CHANGES-0.4
 ivtools-1.2/CHANGES-0.5
 ivtools-1.2/CHANGES-0.6
@@ -187,6 +187,8 @@ ivtools-1.2/src/ComTerp/mathfunc.c
 ivtools-1.2/src/ComTerp/mathfunc.h
 ivtools-1.2/src/ComTerp/numfunc.c
 ivtools-1.2/src/ComTerp/numfunc.h
+ivtools-1.2/src/ComTerp/parsefunc.c
+ivtools-1.2/src/ComTerp/parsefunc.h
 ivtools-1.2/src/ComTerp/parser.c
 ivtools-1.2/src/ComTerp/parser.h
 ivtools-1.2/src/ComTerp/postfunc.c
@@ -1193,6 +1195,9 @@ ivtools-1.2/src/idraw/Imakefile
 ivtools-1.2/src/idraw/Makefile
 ivtools-1.2/src/idraw/README
 ivtools-1.2/src/idraw/main.c
+ivtools-1.2/src/imake/config.h
+ivtools-1.2/src/imake/imake.c
+ivtools-1.2/src/imake/imakemdep.h
 ivtools-1.2/src/include/Dispatch/Imakefile
 ivtools-1.2/src/include/Dispatch/Makefile
 ivtools-1.2/src/include/Dispatch/_defines.h
@@ -1584,7 +1589,9 @@ ivtools-1.2/src/include/Unidraw/upage.h
 ivtools-1.2/src/include/Unidraw/viewer.h
 ivtools-1.2/src/include/ivstd/Imakefile
 ivtools-1.2/src/include/ivstd/Makefile
+ivtools-1.2/src/include/ivstd/fstream
 ivtools-1.2/src/include/ivstd/fstream.h
+ivtools-1.2/src/include/ivstd/ignores.h
 ivtools-1.2/src/include/ivstd/iosfwd
 ivtools-1.2/src/include/ivstd/iostream.h
 ivtools-1.2/src/include/ivstd/leakchecker.h
@@ -1597,7 +1604,6 @@ ivtools-1.2/src/include/ivstd/stdio.h
 ivtools-1.2/src/include/ivstd/stdlib.h
 ivtools-1.2/src/include/ivstd/stream.h
 ivtools-1.2/src/include/ivstd/string.h
-ivtools-1.2/src/include/ivstd/version.h
 ivtools-1.2/src/iueserv_/Imakefile
 ivtools-1.2/src/iueserv_/Makefile
 ivtools-1.2/src/iueserv_/README
@@ -1817,7 +1823,6 @@ ivtools-1.2/src/utils/ftp.h
 ivtools-1.2/src/utils/http.cc
 ivtools-1.2/src/utils/http.h
 ivtools-1.2/src/utils/ivdl.cc
-ivtools-1.2/src/utils/ivtmpnam.c
 ivtools-1.2/src/utils/parse.h
 ivtools-1.2/src/utils/readwrite.h
 ivtools-1.2/src/utils/sockets.cc
--- ivtools-1.2.11a1.orig/MANIFEST.comterp
+++ ivtools-1.2.11a1/MANIFEST.comterp
@@ -139,6 +139,8 @@ src/ComTerp/mathfunc.c
 src/ComTerp/mathfunc.h
 src/ComTerp/numfunc.c
 src/ComTerp/numfunc.h
+src/ComTerp/parsefunc.c
+src/ComTerp/parsefunc.h
 src/ComTerp/parser.c
 src/ComTerp/parser.h
 src/ComTerp/postfunc.c
@@ -220,6 +222,9 @@ src/comterp_/README
 src/comterp_/main.c
 src/comtest/Imakefile
 src/comtest/main.c
+src/imake/config.h
+src/imake/imake.c
+src/imake/imakemdep.h
 src/include/IV-2_6/Imakefile
 src/include/IV-2_6/InterViews/Imakefile
 src/include/IV-2_6/InterViews/alignment.h
@@ -283,14 +288,15 @@ src/include/Unidraw/ulist.h
 src/include/Unidraw/umap.h
 src/include/Unidraw/unidraw.h
 src/include/ivstd/Imakefile
+src/include/ivstd/fstream
 src/include/ivstd/fstream.h
+src/include/ivstd/ignores.h
 src/include/ivstd/iosfwd
 src/include/ivstd/math.h
 src/include/ivstd/osfcn.h
 src/include/ivstd/signal.h
 src/include/ivstd/stdio.h
 src/include/ivstd/string.h
-src/include/ivstd/version.h
 src/scripts/Imakefile
 src/scripts/bsdinst.sh
 src/scripts/chgsuffix.sh
--- ivtools-1.2.11a1.orig/Makefile.am
+++ ivtools-1.2.11a1/Makefile.am
@@ -129,8 +129,8 @@ libUniIdraw_la_LIBADD		= libUnidraw.la l
 libUnidraw_common_la_LIBADD	= libIV.la
 libUnidraw_la_LIBADD		= libIV.la $(X11_LD)
 
-IVSTD_INCLUDES = -Isrc -Isrc/include -Isrc/include/ivstd
-IV2_6_INCLUDES = -Div2_6_compatible -Isrc -Isrc/include/IV-2_6 -Isrc/include -Isrc/include/ivstd
+IVSTD_INCLUDES = -I$(srcdir)/src -I$(srcdir)/src/include -I$(srcdir)/src/include/ivstd
+IV2_6_INCLUDES = -Div2_6_compatible -I$(srcdir)/src -I$(srcdir)/src/include/IV-2_6 -I$(srcdir)/src/include -I$(srcdir)/src/include/ivstd
 
 ### libComTerp
 
@@ -151,7 +151,8 @@ src/ComTerp/bquotefunc.cc src/ComTerp/ch
 src/ComTerp/comfunc.cc src/ComTerp/comvalue.cc src/ComTerp/condfunc.cc	\
 src/ComTerp/debugfunc.cc src/ComTerp/dotfunc.cc				\
 src/ComTerp/helpfunc.cc src/ComTerp/iofunc.cc src/ComTerp/listfunc.cc	\
-src/ComTerp/mathfunc.cc src/ComTerp/numfunc.cc src/ComTerp/parser.cc	\
+src/ComTerp/mathfunc.cc src/ComTerp/numfunc.cc				\
+src/ComTerp/parsefunc.cc src/ComTerp/parser.cc				\
 src/ComTerp/postfunc.cc src/ComTerp/randfunc.cc src/ComTerp/scanner.cc	\
 src/ComTerp/statfunc.cc src/ComTerp/strmfunc.cc				\
 src/ComTerp/symbolfunc.cc src/ComTerp/typefunc.cc			\
@@ -163,7 +164,7 @@ libComTerpPART1_la_CPPFLAGS = \
 libComTerpPART2_la_SOURCES = src/ComTerp/comterp.cc
 
 libComTerpPART2_la_CPPFLAGS = \
- -Div2_6_incompatible -Isrc/include \
+ -Div2_6_incompatible -I$(srcdir)/src/include \
  $(ACE_CPPFLAGS) -Dcplusplus_2_1 $(IVSTD_INCLUDES)
 
 ### libIV_common
@@ -234,7 +235,7 @@ src/DrawServ/drawkit.cc src/DrawServ/rcd
 
 libDrawServPART2_la_CPPFLAGS = \
  -Dcplusplus_2_1 -Div2_6_incompatible	\
- -Isrc/include $(ACE_CPPFLAGS) $(IV2_6_INCLUDES)
+ -I$(srcdir)/src/include $(ACE_CPPFLAGS) $(IV2_6_INCLUDES)
 
 ### libUnidraw
 
@@ -268,7 +269,7 @@ libComUnidrawPART1_la_SOURCES = src/ComU
 
 libComUnidrawPART1_la_CPPFLAGS = \
  -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) \
- -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES)
+ -Div2_6_incompatible -I$(srcdir)/src/include $(IV2_6_INCLUDES)
 
 ### libComGlyph
 
@@ -277,7 +278,7 @@ src/ComGlyph/comtextedit.cc src/ComGlyph
 src/ComGlyph/terpdialog.cc
 
 libComGlyph_la_CPPFLAGS = \
- -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include $(IVSTD_INCLUDES)
+ -Dcplusplus_2_1 -Div2_6_incompatible -I$(srcdir)/src/include $(IVSTD_INCLUDES)
 
 ### libIV
 
@@ -292,20 +293,20 @@ libIV_la_CPPFLAGS = \
  -DABSLIBALLDIR='"$(pkgdatadir)"' \
  -DRELLIBALLDIR='"lib/$(PACKAGE)"' \
  -DX_LIBDIR='"$(libdir)"' \
- -Isrc/IV $(IVSTD_INCLUDES)
+ -I$(srcdir)/src/IV $(IVSTD_INCLUDES)
 
 libIVPART1_la_SOURCES = src/InterViews/psfont.cc
 
 libIVPART1_la_CPPFLAGS = \
  -Dcplusplus_2_1 \
  -Dps_metrics_dir='"$(PSFontDir)"' \
- -Isrc/IV $(IVSTD_INCLUDES)
+ -I$(srcdir)/src/IV $(IVSTD_INCLUDES)
 
 libIVPART2_la_SOURCES = src/InterViews/dialogs.cc src/InterViews/kit.cc
 
 libIVPART2_la_CPPFLAGS = \
  -Dcplusplus_2_1 -Dsgi_motif_kit -Dmotif_kit -Ddefault_kit=SMFKit \
- -Isrc/IV $(IVSTD_INCLUDES)
+ -I$(srcdir)/src/IV $(IVSTD_INCLUDES)
 
 libIVPART3_la_SOURCES = src/Dispatch/dispatcher.cc			\
 src/Dispatch/iohandler.cc src/IV-2_6/adjuster2_6.cc			\
@@ -365,12 +366,12 @@ src/OS/host.cc src/OS/listimpl.cc src/OS
 src/OS/string.cc src/OS/ustring.cc
 
 libIVPART3_la_CPPFLAGS = \
- -Dcplusplus_2_1 -Isrc/IV $(IVSTD_INCLUDES)
+ -Dcplusplus_2_1 -I$(srcdir)/src/IV $(IVSTD_INCLUDES)
 
 libIVPART4_la_SOURCES = src/InterViews/tiff.cc
 
 libIVPART4_la_CPPFLAGS = \
- -Dcplusplus_2_1 $(TIFF_LOC_CPPFLAG) -Isrc/IV $(IVSTD_INCLUDES)
+ -Dcplusplus_2_1 $(TIFF_LOC_CPPFLAG) -I$(srcdir)/src/IV $(IVSTD_INCLUDES)
 
 ### libUnidraw
 
@@ -493,7 +494,7 @@ src/GraphUnidraw/graphkit.cc
 
 libGraphUnidrawPART1_la_CPPFLAGS = \
  -Dcplusplus_2_1 \
- -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES)
+ -Div2_6_incompatible -I$(srcdir)/src/include $(IV2_6_INCLUDES)
 
 # libFrameUnidraw
 
@@ -515,7 +516,7 @@ libFrameUnidrawPART1_la_SOURCES = src/Fr
 src/FrameUnidraw/framekit.cc src/FrameUnidraw/framestates.cc
 
 libFrameUnidrawPART1_la_CPPFLAGS = \
- -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include $(IV2_6_INCLUDES)
+ -Dcplusplus_2_1 -Div2_6_incompatible -I$(srcdir)/src/include $(IV2_6_INCLUDES)
 
 ### libOverlayUnidraw
 
@@ -567,12 +568,12 @@ src/OverlayUnidraw/slctbyattr.cc
 
 libOverlayUnidrawPART1_la_CPPFLAGS = \
  -Dcplusplus_2_1 -Div2_6_incompatible $(ACE_CPPFLAGS) \
- -Isrc/OverlayUnidraw -Isrc/include $(IV2_6_INCLUDES)
+ -I$(srcdir)/src/OverlayUnidraw -I$(srcdir)/src/include $(IV2_6_INCLUDES)
 
 libOverlayUnidrawPART2_la_SOURCES = src/OverlayUnidraw/aceimport.cc
 
 libOverlayUnidrawPART2_la_CPPFLAGS = \
- -Dcplusplus_2_1 -Div2_6_incompatible -Isrc/include \
+ -Dcplusplus_2_1 -Div2_6_incompatible -I$(srcdir)/src/include \
  $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES)
 
 if HAVE_LIBCLIPPOLY
@@ -626,7 +627,7 @@ src/TIFF/tif_version.c src/TIFF/tif_warn
 #  src/TIFF/mkg3states.c src/TIFF/mkspans.c
 #  src/TIFF/tif_machdep.c
 
-libTIFF_la_CPPFLAGS = -Isrc/TIFF -Isrc/include/TIFF -Isrc/include
+libTIFF_la_CPPFLAGS = -I$(srcdir)/src/TIFF -I$(srcdir)/src/include/TIFF -I$(srcdir)/src/include
 
 tif_fax3.$(OBJEXT) : g3states.h
 .libs/libTIFF_la-tif_fax3.lo: g3states.h
@@ -659,22 +660,14 @@ InterViews: src/IV/InterViews.defaults
 
 ### binaries
 
-bin_SCRIPTS = ivgetjpg ivtiftopnm pnmtopgm
-
-ivgetjpg: src/scripts/ivgetjpg.bash
-	cp $< $@
-	chmod a+x $@
-
-ivtiftopnm: src/scripts/ivtiftopnm.bash
-	cp $< $@
-	chmod a+x $@
+bin_SCRIPTS = pnmtopgm
 
 pnmtopgm: src/scripts/pnmtopgm.sh
 	cp $< $@
 	chmod a+x $@
 
 bin_PROGRAMS = comdraw comterp comtest dclock drawserv drawtool		\
-flipbook gclock glyphterp graphdraw iclass idemo idraw ivtext ivtmpnam	\
+flipbook gclock glyphterp graphdraw iclass idemo idraw ivtext		\
 stdcmapppm
 
 comdraw_SOURCES = src/comdraw/main.cc
@@ -700,11 +693,10 @@ src/iclass/iclass.h src/iclass/main.cc
 idemo_SOURCES = src/idemo/main.cc
 idraw_SOURCES = src/idraw/main.cc
 ivtext_SOURCES = src/ivtext/main.cc
-ivtmpnam_SOURCES = src/utils/ivtmpnam.c # C
 stdcmapppm_SOURCES = src/utils/stdcmapppm.c # C
 
 
-AM_CPPFLAGS = -Isrc/include
+AM_CPPFLAGS = -I$(srcdir)/src/include
 AM_CXXFLAGS = -Wno-write-strings -Wno-deprecated
 
 
@@ -718,14 +710,13 @@ dclock_CPPFLAGS		= -Dcplusplus_2_1 $(IV2
 drawserv_CPPFLAGS	= -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES)
 drawtool_CPPFLAGS	= -Dcplusplus_2_1 $(ACE_INLINE_CPPFLAGS) $(IV2_6_INCLUDES)
 flipbook_CPPFLAGS	= -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES)
-gclock_CPPFLAGS		= -Dcplusplus_2_1 -Isrc/glyphs $(IVSTD_INCLUDES)
+gclock_CPPFLAGS		= -Dcplusplus_2_1 -I$(srcdir)/src/glyphs $(IVSTD_INCLUDES)
 glyphterp_CPPFLAGS	= -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IVSTD_INCLUDES)
 graphdraw_CPPFLAGS	= -Dcplusplus_2_1 $(ACE_CPPFLAGS) $(IV2_6_INCLUDES)
 iclass_CPPFLAGS		= -Dcplusplus_2_1 $(IV2_6_INCLUDES)
 idemo_CPPFLAGS		= -Dcplusplus_2_1 $(IVSTD_INCLUDES)
 idraw_CPPFLAGS		= -Dcplusplus_2_1 $(IV2_6_INCLUDES)
 ivtext_CPPFLAGS		= -Dcplusplus_2_1 $(IVSTD_INCLUDES)
-ivtmpnam_CPPFLAGS	=
 stdcmapppm_CPPFLAGS	=
 
 # AM_LDFLAGS =
@@ -744,7 +735,6 @@ iclass_LDADD	= libIV.la
 idemo_LDADD	= libIV.la
 idraw_LDADD	= libUniIdraw.la libUnidraw.la
 ivtext_LDADD	= libIVGlyph.la libIV.la
-ivtmpnam_LDADD	=
 stdcmapppm_LDADD=
 
 ### directories to recurse into, for installation of include files
--- ivtools-1.2.11a1.orig/README.cygwin
+++ ivtools-1.2.11a1/README.cygwin
@@ -53,7 +53,6 @@ They need to be built and installed by h
 setup.
 
 	cd src/utils		# workaround for a Makefile incompatibility
-        make ivtmpnam;cd CYGWIN; install -c -m 755 ivtmpnam.exe /usr/local/bin
         make stdcmapppm;cd CYGWIN; install -c -m 755 stdcmapppm.exe /usr/local/bin
 
 6. acquire an X server for Windows NT, and try things out.
--- ivtools-1.2.11a1.orig/autogen.sh
+++ ivtools-1.2.11a1/autogen.sh
@@ -2,14 +2,16 @@
 
 set -e
 
-## option --foreign engaged so these files are no longer mandatory
+# echo "Usage: ./autoget.sh [options]"
+# echo "Options:"
+# echo "  --warn=all    warn about various autoconf constructs"
+
+## automake --foreign option engaged so these files are no longer mandatory:
 # for f in NEWS AUTHORS ChangeLog; do
 #     test -e "$f" || cp --verbose /dev/null "$f"
 # done
 
-mkdir --parent --verbose m4
-
-autoreconf --install --symlink
+## Unnecessary: m4/acltx_prog_ps2pdf.m4 and hence m4/ now in the repo.
+# mkdir --parent --verbose m4
 
-## Use --force to recreate things that don't seem to require recreation:
-# autoreconf --install --symlink --make --force
+autoreconf --force --install --symlink $*
--- ivtools-1.2.11a1.orig/configure.ac
+++ ivtools-1.2.11a1/configure.ac
@@ -4,38 +4,93 @@
 # Header
 AC_PREREQ([2.67])
 
-AC_INIT([InterViews Application Framework and Drawing Tools],[1.2.8],[johnston@vectaport.com],[ivtools],[http://www.ivtools.org])
+AC_INIT([InterViews Application Framework and Drawing Tools],[1.2.11],[johnston@vectaport.com],[ivtools],[http://www.ivtools.org])
 
 dnl The foreign option allows the follow files to not exist: NEWS AUTHORS ChangeLog
-AM_INIT_AUTOMAKE([subdir-objects foreign])
-
+AM_INIT_AUTOMAKE([subdir-objects foreign -Wall])
 AC_CONFIG_SRCDIR([src/Unidraw/path.cc])
-
 AC_CONFIG_HEADERS([config.h])
-
 AC_CONFIG_MACRO_DIR([m4])
 
-AC_LANG([C++])
+# Process options
+AC_MSG_CHECKING([with_ace])
+AC_ARG_WITH([ace],
+       [AS_HELP_STRING([--with-ace],[use the ACE library (default: check)])],,
+       [with_ace=check])
+AC_MSG_RESULT([${with_ace}])
+
+AC_MSG_CHECKING([with_tiff])
+AC_ARG_WITH([tiff],
+       [AS_HELP_STRING([--with-tiff],[use the TIFF library (default: check)])],,
+       [with_tiff=check])
+AC_MSG_RESULT([${with_tiff}])
+
+AC_MSG_CHECKING([with_clippoly])
+AC_ARG_WITH([clippoly],
+       [AS_HELP_STRING([--with-clippoly],[use the CLIPPOLY library (default: check)])],,
+       [with_clippoly=check])
+AC_MSG_RESULT([${with_clippoly}])
+
+AC_MSG_CHECKING([PSFontDir])
+AC_ARG_WITH([PSFontDir],
+       [AS_HELP_STRING([--with-PSFontDir=DIR],[for font metrics (default: searches)])],,
+       [with_PSFontDir=check])
+AC_MSG_RESULT([${with_PSFontDir}])
 
 # Checks for programs.
+AC_LANG([C++])
 AC_PROG_CXX
 AC_PROG_CC
 AM_PROG_CC_C_O
+AM_PROG_AR
 AC_PROG_INSTALL
-ACLTX_PROG_PS2PDF(AC_MSG_WARN([Cannot find ps2pdf]))
+ACLTX_PROG_PS2PDF([AC_MSG_WARN([Cannot find ps2pdf])])
 AM_CONDITIONAL([PS2PDF], [test x$ps2pdf != xno])
+LT_INIT
 
 # Checks for libraries.
-AC_CHECK_LIB([m], [pow], [MATH_LD=-lm], AC_MSG_WARN([Cannot find math library]))
-AC_CHECK_LIB([X11], [XOpenDisplay], [X11_LD=-lX11], AC_MSG_ERROR([Cannot find X11 library]))
-AC_CHECK_LIB([Xext], [XextFindDisplay], [XEXT_LD=-lXext], AC_MSG_ERROR([Cannot find Xext library]))
-AC_CHECK_LIB([ACE], [ace_cleanup_destroyer], [ACE_LD=-lACE], AC_MSG_WARN([Cannot find ACE library]))
-AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LD=-ltiff],
- AC_CHECK_LIB([TIFF], [TIFFOpen], [TIFF_LD=-lTIFF], AC_MSG_WARN([Cannot find tiff or TIFF library])))
-AC_CHECK_LIB([clippoly], [clippoly_version], [CLIPPOLY_LD=-lclippoly], AC_MSG_WARN([Cannot find clippoly library]))
-AM_CONDITIONAL([HAVE_LIBACE], [test x${ACE_LD} != x])
-AM_CONDITIONAL([HAVE_LIBTIFF], [test x${TIFF_LD} != x])
-AM_CONDITIONAL([HAVE_LIBCLIPPOLY], [test x${CLIPPOLY_LD} != x])
+AC_PATH_XTRA
+CFLAGS="${X_CFLAGS} ${CFLAGS}"
+CXXFLAGS="${X_CFLAGS} ${CXXFLAGS}"
+LDFLAGS="${X_LIBS} ${LDFLAGS}"
+
+AC_CHECK_LIB([m], [pow], [MATH_LD=-lm], [AC_MSG_WARN([Cannot find math library])])
+AC_CHECK_LIB([X11], [XOpenDisplay], [X11_LD=-lX11], [AC_MSG_ERROR([Cannot find X11 library])])
+AC_CHECK_LIB([Xext], [XextFindDisplay], [XEXT_LD=-lXext], [AC_MSG_ERROR([Cannot find Xext library])])
+
+AS_IF([test ${with_ace} != no],
+ [AC_CHECK_LIB([ACE], [ace_cleanup_destroyer],
+  [with_ace=yes
+   ACE_LD=-lACE],
+  [AS_IF([test ${with_ace} = check],
+    [with_ace=no
+     AC_MSG_WARN([Cannot find ACE library])],
+    [AC_MSG_ERROR([Cannot find ACE library])])])])
+
+AS_IF([test ${with_tiff} != no],
+ [AC_CHECK_LIB([tiff], [TIFFOpen],
+   [with_tiff=yes
+    TIFF_LD=-ltiff],
+   [AC_CHECK_LIB([TIFF], [TIFFOpen],
+     [with_tiff=yes
+      TIFF_LD=-lTIFF],
+     [AS_IF([test ${with_tiff} = check],
+       [with_tiff=no
+        AC_MSG_WARN([Cannot find tiff or TIFF library])],
+       [AC_MSG_ERROR([Cannot find tiff or TIFF library])])])])])
+
+AS_IF([test ${with_clippoly} != no],
+ [AC_CHECK_LIB([clippoly], [clippoly_version],
+   [with_clippoly=yes
+    CLIPPOLY_LD=-lclippoly],
+   [AS_IF([test ${with_ace} = check],
+     [with_clippoly=no
+      AC_MSG_WARN([Cannot find clippoly library])],
+     [AC_MSG_ERROR([Cannot find clippoly library])])])])
+
+AM_CONDITIONAL([HAVE_LIBACE], [test ${with_ace} = yes])
+AM_CONDITIONAL([HAVE_LIBTIFF], [test ${with_tiff} = yes])
+AM_CONDITIONAL([HAVE_LIBCLIPPOLY], [test ${with_clippoly} = yes])
 
 AC_SUBST(X11_LD)
 AC_SUBST(XEXT_LD)
@@ -43,8 +98,6 @@ AC_SUBST(ACE_LD)
 AC_SUBST(TIFF_LD)
 AC_SUBST(CLIPPOLY_LD)
 
-LT_INIT
-
 # Generated dynamic library version
 dnl This is not the approved way of versioning dynamic libraries
 dnl but we just want to generate version 1.2.8
@@ -57,13 +110,11 @@ LIB_IV_VER=3:8:2
 AC_SUBST(LIB_IV_VER)
 
 # Checks for header files.
-AC_PATH_X
-AC_PATH_XTRA
-
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h malloc.h \
 memory.h netdb.h netinet/in.h stddef.h stdlib.h string.h strings.h \
-sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \
-ace/Acceptor.h ace/ACE.h])
+sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
+AS_IF([test ${with_ace} = yes],
+ [AC_CHECK_HEADERS([ace/Acceptor.h ace/ACE.h])])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
@@ -92,19 +143,31 @@ regcomp select socket sqrt strcasecmp st
 strncasecmp strrchr strstr strtol uname hypot hypotf])
 
 # Checks for locations
-AC_CHECK_FILE([/usr/share/fonts/type1/gsfonts/a010015l.afm],
- [PSFontDir=/usr/share/fonts/type1/gsfonts],
- AC_CHECK_FILE([/usr/share/ghostscript/fonts/bchr.afm],
-  [PSFontDir=/usr/share/ghostscript/fonts],
-  AC_CHECK_FILE([/usr/lib/ghostscript/fonts/bchr.afm],
-   [PSFontDir=/usr/lib/ghostscript/fonts],
-   AC_CHECK_FILE([/usr/lib/ps/bchr.afm],
-    [PSFontDir=/usr/lib/ps],
-    AC_CHECK_FILE([/usr/lib/X11/fonts/Type1Adobe/afm/bchr.afm],
-     [PSFontDir=/usr/lib/X11/fonts/Type1Adobe/afm],
-     AC_MSG_ERROR([cannot find PS Font Directory]))))))
+AS_IF([test x"${with_PSFontDir}" = xcheck],
+ [AC_MSG_NOTICE([scanning ad-hoc list of locations for PSFontDir])
+  AC_CHECK_FILE([/usr/share/fonts/type1/gsfonts/a010015l.afm],
+   [PSFontDir=/usr/share/fonts/type1/gsfonts],
+   [AC_CHECK_FILE([/usr/share/ghostscript/fonts/bchr.afm],
+     [PSFontDir=/usr/share/ghostscript/fonts],
+     [AC_CHECK_FILE([/usr/lib/ghostscript/fonts/bchr.afm],
+       [PSFontDir=/usr/lib/ghostscript/fonts],
+       [AC_CHECK_FILE([/usr/lib/ps/bchr.afm],
+	 [PSFontDir=/usr/lib/ps],
+	 [AC_CHECK_FILE([/usr/lib/X11/fonts/Type1Adobe/afm/bchr.afm],
+	   [PSFontDir=/usr/lib/X11/fonts/Type1Adobe/afm],
+	   [AC_CHECK_FILE([/Library/Fonts/],
+	     [PSFontDir=/Library/Fonts],
+	     [AC_CHECK_FILE([/System/Library/Fonts/],
+	       [PSFontDir=/System/Library/Fonts],
+	       [AC_MSG_ERROR([cannot find PS Font Directory])])])])])])])])
+  AC_MSG_NOTICE([Using PSFontDir ${PSFontDir}])],
+ [PSFontDir="${with_PSFontDir}"])
 AC_SUBST(PSFontDir)
 
+# Random noise-control options.
+AX_CXXFLAGS_WARN_ALL
+CXXFLAGS="${CXXFLAGS} -Wno-narrowing"
+
 # Trailer
 AC_CONFIG_FILES([Makefile src/Makefile src/include/Makefile])
 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-131007-scott-001.txt
@@ -0,0 +1,415 @@
+Patch:    ivtools-131007-scott-001
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  Miscellaneous fixes and extensions to ivtools
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComTerp/debugfunc.h
+===================================================================
+--- src/ComTerp/debugfunc.h	(revision 7865)
++++ src/ComTerp/debugfunc.h	(revision 8205)
+@@ -52,7 +52,7 @@
+     virtual void execute();
+     virtual void execute_body(ComValue&);
+     virtual const char* docstring() { 
+-	return "%s -- pause script execution until C/R"; }
++	return "%s([msgstr]) -- pause script execution until C/R"; }
+     virtual boolean stepfunc() { return false; }
+ 
+ };
+Index: src/ComTerp/listfunc.c
+===================================================================
+--- src/ComTerp/listfunc.c	(revision 7865)
++++ src/ComTerp/listfunc.c	(revision 8205)
+@@ -268,6 +268,9 @@
+   static int all_symid = symbol_add("all");
+   ComValue allv(stack_key(all_symid));
+   boolean allflag = allv.is_true();
++  static int substr_symid = symbol_add("substr");
++  ComValue substrv(stack_key(substr_symid));
++  boolean substrflag = substrv.is_true();
+   reset_stack();
+ 
+   AttributeValueList *nvl = allflag ? new AttributeValueList : nil;
+@@ -280,12 +283,18 @@
+ 	avl->First(it);
+       int index= lastflag ? avl->Number()-1 : 0;
+       while(!avl->Done(it)) {
++        int match;
+ 	AttributeValue* testv = avl->GetAttrVal(it);
+-	comterp()->push_stack(*testv);
+-	comterp()->push_stack(valv);
+-	EqualFunc eqfunc(comterp());
+-	eqfunc.exec(2,0);
+-	if(comterp()->pop_stack().is_true()) {
++        if(!substrflag) {
++	  comterp()->push_stack(*testv);
++	  comterp()->push_stack(valv);
++	  EqualFunc eqfunc(comterp());
++	  eqfunc.exec(2,0);
++	  match =  comterp()->pop_stack().is_true();
++	} else {
++	  match = strstr(testv->string_ptr(), valv.string_ptr()) != NULL;
++	}
++	if(match) {
+ 	  if (allflag)
+ 	    nvl->Append(new AttributeValue(index, AttributeValue::IntType));
+ 	  else {
+@@ -294,13 +303,14 @@
+ 	    return;
+ 	  }
+ 	}
++	
+ 	if (lastflag)
+ 	  avl->Prev(it);
+ 	else
+ 	  avl->Next(it);
+ 	index += lastflag ? -1 : 1;
+       };
+-
++      
+   } else if (listorstrv.is_string()) {
+ 
+       if (valv.is_char()) {
+Index: src/ComTerp/listfunc.h
+===================================================================
+--- src/ComTerp/listfunc.h	(revision 7865)
++++ src/ComTerp/listfunc.h	(revision 8205)
+@@ -85,14 +85,14 @@
+ 
+ 
+ //: list index command for ComTerp.
+-// val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
++// val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
+ class ListIndexFunc : public ComFunc {
+ public:
+     ListIndexFunc(ComTerp*);
+ 
+     virtual void execute();
+     virtual const char* docstring() { 
+-      return "num=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found"; }
++      return "num=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found"; }
+ };
+ 
+ #endif /* !defined(_listfunc_h) */
+Index: src/ComTerp/symbolfunc.c
+===================================================================
+--- src/ComTerp/symbolfunc.c	(revision 7865)
++++ src/ComTerp/symbolfunc.c	(revision 8205)
+@@ -481,8 +481,12 @@
+   }
+   else {
+     const char* foundstr = strstr(string, nv.symbol_ptr());
+-    n = afterflag ?  strlen(string)-(foundstr-string) : foundstr-string;
+-    offset = afterflag ? foundstr-string : 0;
++    if(foundstr==NULL) {
++      push_stack(ComValue::nullval());
++      return;
++    }
++    n = afterflag ?  strlen(string)-(foundstr-string)-strlen(nv.symbol_ptr()) : foundstr-string;
++    offset = afterflag ? foundstr-string+strlen(nv.symbol_ptr()) : 0;
+   };
+   if(n>0) { 
+     char buffer[n+1];
+Index: src/ComTerp/iofunc.c
+===================================================================
+--- src/ComTerp/iofunc.c	(revision 7865)
++++ src/ComTerp/iofunc.c	(revision 8205)
+@@ -116,24 +116,9 @@
+   const char* fstr = formatstr.is_string() ? formatstr.string_ptr() : "nil";
+   ComValue::comterp(comterp());
+ 
+-#if __GNUC__<3
+   streambuf* strmbuf = nil;
+   if (stringflag.is_false() && strflag.is_false() &&
+       symbolflag.is_false() && symflag.is_false()) {
+-    filebuf * fbuf = new filebuf();
+-    strmbuf = fbuf;
+-    if (comterp()->handler()) {
+-      int fd = Math::max(1, comterp()->handler()->get_handle());
+-      fbuf->attach(fd);
+-    } else
+-      fbuf->attach(fileno(errflag.is_false() ? stdout : stderr));
+-  } else {
+-    strmbuf = new std::strstreambuf();
+-  }
+-#else
+-  streambuf* strmbuf = nil;
+-  if (stringflag.is_false() && strflag.is_false() &&
+-      symbolflag.is_false() && symflag.is_false()) {
+     fileptr_filebuf * fbuf = nil;
+     if (comterp()->handler() && fileobjv.is_unknown() && errflag.is_false() && outflag.is_false()) {
+       fbuf = new fileptr_filebuf(comterp()->handler() && comterp()->handler()->wrfptr() 
+@@ -151,7 +136,6 @@
+     strmbuf = fbuf;
+   } else
+     strmbuf = new std::strstreambuf();
+-#endif
+   ostream out(strmbuf);
+ 
+   int narg = nargsfixed();
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 7865)
++++ src/man/man1/comterp.1	(revision 8205)
+@@ -8,20 +8,23 @@
+ remote
+ .br
+ .B comterp 
+-server 'portnum'
++server "portnum"
+ .br
+ .B comterp 
+-logger 'portnum'
++logger "portnum"
+ .br
+ .B comterp 
+-client 'host' 'portnum' ['file']
++client "host" "portnum" ["file"]
+ .br
+ .B comterp 
+-telcat 'host' 'portnum' ['file']
++telcat "host" "portnum" ["file"]
+ .br
+ .B comterp 
+-run 'file'  
++run "file"  
+ .br
++.B comterp 
++"expr"
++.br
+ .SH DESCRIPTION
+ comterp demonstrates the command interpreter incorporated into
+ ivtools. A user (or client program) can interact with comterp via
+@@ -53,33 +56,36 @@
+ Invoke a single command interpreter, like the default, and include a
+ remote command for accessing other comterp's in server mode.
+ 
+-comterp server 'portnum'
++comterp server "portnum"
+ 
+ Listens for and accept connections on portnum, then setup a command
+ interpreter to wait for and process commands from that connection.
+ 
+-comterp logger 'portnum'
++comterp logger "portnum"
+ 
+ Listens for and accept connections on portnum, then simply forward
+ the incoming messages to stdout, while ack'ing back with newlines. For
+ debugging purposes, not really a use of the interpreter.
+ 
+-comterp client 'host' 'portnum' ['file']
++comterp client "host" "portnum" ["file"]
+ 
+ Connect to a portnum on a host and send/receive new-line terminated
+ text buffers.  For debugging purposes, not really a use of the
+ interpreter.
+ 
+-comterp telcat 'host' 'portnum' ['file']
++comterp telcat "host" "portnum" ["file"]
+ 
+ Connect to a portnum on a host, cat the file, then close the
+ connection.  Not really a use of the interpreter either.
+ 
+-comterp run 'file'
++comterp run "file"
+ 
+ Run contents of file then exit.
+ 
++comterp "expr"
+ 
++Evaluate single expression then exit.
++
+ .SH OPERATOR TABLE
+ .nf
+     Operators  Command Name   Priority    Order       Type
+@@ -202,7 +208,7 @@
+ 
+  num=size(list|attrlist|str) -- return size of a list (or string)
+ 
+- val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
++ val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
+ 
+ .SH STREAM COMMANDS:
+  
+@@ -230,7 +236,7 @@
+ 
+  val=trace([flag] :get) -- toggle or set trace mode
+ 
+- pause()  -- pause script execution until C/R
++ pause([msgstr])  -- pause script execution until C/R
+ 
+  step() -- toggle stepwise script execution
+ 
+Index: src/GraphUnidraw/nodecomp.c
+===================================================================
+--- src/GraphUnidraw/nodecomp.c	(revision 7865)
++++ src/GraphUnidraw/nodecomp.c	(revision 8205)
+@@ -178,23 +178,25 @@
+     _node = new TopoNode(this);
+     _reqlabel = true;
+ 
+-    Picture* pic = new Picture();
+-    SF_Ellipse* ellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic);
+-    ellipse->SetPattern(unidraw->GetCatalog()->FindGrayLevel(1));
+-    TextGraphic* txt = new TextGraphic(graph->GetFile(), stdgraphic);
+-    ellipse->Align(4, txt, 4); // same as Center in IV-2_6/InterViews/alignment.h
+-    pic->Append(ellipse, txt);
+-    SetGraphic(pic);
+-
+-    GraphGraphic();
+-
+-    // kludge to fix ps: fonts are collected from comp\'s graphic, so we
+-    // need to add the font to the picture\'s gs
+-    pic->FillBg(ellipse->BgFilled() && !ellipse->GetBgColor()->None());
+-    pic->SetColors(ellipse->GetFgColor(), ellipse->GetBgColor());
+-    pic->SetPattern(ellipse->GetPattern());
+-    pic->SetBrush(ellipse->GetBrush());
+-    pic->SetFont(txt->GetFont());
++    if (unidraw) {
++      Picture* pic = new Picture();
++      SF_Ellipse* ellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic);
++      ellipse->SetPattern(unidraw->GetCatalog()->FindGrayLevel(1));
++      TextGraphic* txt = new TextGraphic(graph->GetFile(), stdgraphic);
++      ellipse->Align(4, txt, 4); // same as Center in IV-2_6/InterViews/alignment.h
++      pic->Append(ellipse, txt);
++      SetGraphic(pic);
++      
++      GraphGraphic();
++      
++      // kludge to fix ps: fonts are collected from comp\'s graphic, so we
++      // need to add the font to the picture\'s gs
++      pic->FillBg(ellipse->BgFilled() && !ellipse->GetBgColor()->None());
++      pic->SetColors(ellipse->GetFgColor(), ellipse->GetBgColor());
++      pic->SetPattern(ellipse->GetPattern());
++      pic->SetBrush(ellipse->GetBrush());
++      pic->SetFont(txt->GetFont());
++    }
+ }
+ 
+ NodeComp::NodeComp(OverlayComp* parent) : OverlayComp(nil, parent) {
+Index: src/comterp_/main.c
+===================================================================
+--- src/comterp_/main.c	(revision 7865)
++++ src/comterp_/main.c	(revision 8205)
+@@ -41,6 +41,7 @@
+ #include <version.h>
+ 
+ #include <ComTerp/comterpserv.h>
++#include <ComTerp/comvalue.h>
+ 
+ 
+ #if BUFSIZ>1024
+@@ -71,6 +72,8 @@
+     boolean client_flag = argc>1 && strcmp(argv[1], "client") == 0;
+     boolean telcat_flag = argc>1 && strcmp(argv[1], "telcat") == 0;
+     boolean run_flag = argc>1 && strcmp(argv[1], "run") == 0;
++    boolean expr_flag = argc>1 && !server_flag && !logger_flag && 
++                        !remote_flag && !client_flag && !telcat_flag && !run_flag;
+ 
+ #ifdef HAVE_ACE
+     if (server_flag || logger_flag) {
+@@ -253,6 +256,12 @@
+ 	terp->set_args(argc-3, argv+2);
+ 	terp->runfile(rfile);
+ 	return 0;
++      } if (expr_flag) {
++	terp->brief(1);
++	ComValue::comterp(terp);
++        ComValue comval(terp->run(argv[1]));
++        cout << comval << '\n';
++        return 0;
+       } else {
+ 	
+ 	struct stat buf;
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 7865)
++++ src/comterp_/README	(revision 8205)
+@@ -4,11 +4,12 @@
+ SYNOPSIS
+      comterp
+      comterp remote
+-     comterp server 'portnum'
+-     comterp logger 'portnum'
+-     comterp client 'host' 'portnum' ['file']
+-     comterp telcat 'host' 'portnum' ['file']
+-     comterp run 'file'	
++     comterp server "portnum"
++     comterp logger "portnum"
++     comterp client "host" "portnum" ["file"]
++     comterp telcat "host" "portnum" ["file"]
++     comterp run "file"	
++     comterp "expr"
+ 
+ DESCRIPTION
+ 
+@@ -43,33 +44,37 @@
+ remote command for accessing other comterp's in server mode.
+ 
+ 
+-comterp server 'portnum'
++comterp server "portnum"
+ 
+ Listens for and accept connections on portnum, then setup a command
+ interpreter to wait for and process commands from that connection.
+ 
+-comterp logger 'portnum'
++comterp logger "portnum"
+ 
+ Listens for and accept connections on portnum, then simply forward
+ the incoming messages to stdout, while ack'ing back with newlines. For
+ debugging purposes, not really a use of the interpreter.
+ 
+-comterp client 'host' 'portnum' ['file']
++comterp client "host" "portnum" ["file"]
+ 
+ Connect to a portnum on a host and send/receive new-line terminated
+ text buffers.  For debugging purposes, not really a use of the
+ interpreter.
+ 
+-comterp telcat 'host' 'portnum' ['file']
++comterp telcat "host" "portnum" ["file"]
+ 
+ Connect to a portnum on a host, cat the file, then close the
+ connection.  Not really a use of the interpreter either.
+ 
+-comterp run 'file'
++comterp run "file"
+ 
+ Run contents of file then exit.
+ 
++comterp "expr"
+ 
++Evaluate single expression then exit.
++
++
+ OPERATOR TABLE
+ 
+     Operators     Command Name         Priority    Order       Type
+@@ -190,7 +195,7 @@
+ 
+ num=size(list|attrlist|str) -- return size of a list (or string)
+ 
+-val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
++val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
+ 
+ STREAM COMMANDS:
+ 
+@@ -226,7 +231,7 @@
+ 
+ val=trace([flag] :get) -- toggle or set trace mode
+ 
+-pause()  -- pause script execution until C/R
++pause([msgstr])  -- pause script execution until C/R
+ 
+ step() -- toggle stepwise script execution
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-131029-scott-002.txt
@@ -0,0 +1,294 @@
+Patch:    ivtools-131029-scott-002
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  depth-first traversal extension to stream operator
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComUnidraw/grstrmfunc.h
+===================================================================
+--- src/ComUnidraw/grstrmfunc.h	(revision 8208)
++++ src/ComUnidraw/grstrmfunc.h	(revision 8254)
+@@ -44,4 +44,30 @@
+ };
+ 
+ 
++
++//: stream depth-first command
++class GrDepthFunc : public StreamFunc {
++public:
++    GrDepthFunc(ComTerp*);
++
++    virtual void execute();
++    virtual const char* docstring() { 
++      return "strm=depth(compview) -- depth-first walk of comp tree using stream"; }
++
++    CLASS_SYMID("GrDepthFunc");
++
++};
++
++//: hidden func used by next command for stream depth command
++class GrDepthNextFunc : public StrmFunc {
++public:
++    GrDepthNextFunc(ComTerp*);
++
++    virtual void execute();
++    virtual const char* docstring() { 
++      return "hidden func used by next command for depth command"; }
++
++    CLASS_SYMID("GrDepthNextFunc");
++
++};
+ #endif /* !defined(_grstrmfunc_h) */
+Index: src/ComUnidraw/comeditor.c
+===================================================================
+--- src/ComUnidraw/comeditor.c	(revision 8208)
++++ src/ComUnidraw/comeditor.c	(revision 8254)
+@@ -133,6 +133,7 @@
+ void ComEditor::AddCommands(ComTerp* comterp) {
+     ((ComTerpServ*)comterp)->add_defaults();
+ 
++    comterp->add_command("depth", new GrDepthFunc(comterp));
+     comterp->add_command("parent", new GrParentFunc(comterp));
+     comterp->add_command("rect", new CreateRectFunc(comterp, this));
+     comterp->add_command("rectangle", new CreateRectFunc(comterp, this));
+Index: src/ComUnidraw/grstrmfunc.c
+===================================================================
+--- src/ComUnidraw/grstrmfunc.c	(revision 8208)
++++ src/ComUnidraw/grstrmfunc.c	(revision 8254)
+@@ -121,3 +121,98 @@
+ 
+ #endif
+ 
++/*****************************************************************************/
++
++int GrDepthFunc::_symid;
++
++GrDepthFunc::GrDepthFunc(ComTerp* comterp) : StreamFunc(comterp) {
++}
++
++void GrDepthFunc::execute() {
++  ComValue compsv(stack_arg_post_eval(0));
++  reset_stack();
++  
++  if (compsv.object_compview()) {
++    
++    static GrDepthNextFunc* snfunc = nil;
++    if (!snfunc) {
++      snfunc = new GrDepthNextFunc(comterp());
++      snfunc->funcid(symbol_add("depthnext"));
++    }
++
++    AttributeValueList* avl = new AttributeValueList();
++    Component* comp = ((ComponentView*)compsv.obj_val())->GetSubject();
++    if (!comp->IsA(OVERLAYS_COMP)) {
++      push_stack(ComValue::nullval());
++      return;
++    }
++    OverlaysComp* ovcomps = (OverlaysComp*)comp;
++
++    ComValue* av = 
++      new ComValue(new OverlayViewRef(ovcomps), ovcomps->classid());
++    avl->Append(av);
++    avl->Append(new ComValue());
++    ComValue* av2 = 
++      new ComValue(new OverlayViewRef((OverlaysComp*)ovcomps->GetParent()), ovcomps->classid());
++    avl->Append(av2);
++    
++    ComValue stream(snfunc, avl);
++    stream.stream_mode(-1); // for internal use (use by this func)
++    stream.type(ComValue::StreamType);
++    push_stack(stream);
++    
++  }
++}
++
++/*****************************************************************************/
++
++int GrDepthNextFunc::_symid;
++
++GrDepthNextFunc::GrDepthNextFunc(ComTerp* comterp) : StrmFunc(comterp) {
++}
++
++void GrDepthNextFunc::execute() {
++  ComValue operand1(stack_arg(0));
++
++  /* invoked by next func */
++  reset_stack();
++  AttributeValueList* avl = operand1.stream_list();
++  if (avl) {
++    Iterator i;
++    avl->First(i);
++    ComValue* currval = (ComValue*)avl->GetAttrVal(i);
++    avl->Next(i);
++    ComValue* prevval = (ComValue*)avl->GetAttrVal(i);
++    avl->Next(i);
++    ComValue* stopval = (ComValue*)avl->GetAttrVal(i);
++    
++    /* filter stream */
++    if (currval->is_known()) {
++      OverlayComp* currcomp = (OverlayComp*)currval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
++      OverlayComp* prevcomp = (OverlayComp*)prevval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
++      OverlayComp* stopcomp = (OverlayComp*)stopval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
++      OverlayComp* nextcomp = currcomp->DepthNext(prevcomp);
++      while(nextcomp && nextcomp==(OverlayComp*)currcomp->GetParent()) {
++	prevcomp=currcomp;
++	currcomp=nextcomp;
++        nextcomp = currcomp->DepthNext(prevcomp);
++      }
++      if(nextcomp && nextcomp!=stopcomp) {
++        ((OverlayViewRef*)currval->obj_val())->SetSubject(nextcomp);
++        if (!prevcomp) {
++          ComValue new_prevval(new OverlayViewRef(currcomp), currcomp->classid());;
++          *prevval = new_prevval;
++	} else
++	  ((OverlayViewRef*)prevval->obj_val())->SetSubject(currcomp);
++        ComValue av(new OverlayViewRef(nextcomp), nextcomp->classid());
++        push_stack(av);
++        return;
++      }
++    }
++    
++  }
++  push_stack(ComValue::nullval());
++
++  return;
++}
++
+Index: src/ComTerp/strmfunc.c
+===================================================================
+--- src/ComTerp/strmfunc.c	(revision 8208)
++++ src/ComTerp/strmfunc.c	(revision 8254)
+@@ -489,10 +489,10 @@
+ 
+ void FilterFunc::execute() {
+   ComValue streamv(stack_arg_post_eval(0));
+-  ComValue filterv(stack_arg(1));
++  ComValue filterv(stack_arg_post_eval(1));
+   reset_stack();
+ 
+-  /* setup for filterenation */
++  /* setup for filtering */
+   static FilterNextFunc* flfunc = nil;
+   
+   if (!flfunc) {
+Index: src/ComTerp/strmfunc.h
+===================================================================
+--- src/ComTerp/strmfunc.h	(revision 8208)
++++ src/ComTerp/strmfunc.h	(revision 8254)
+@@ -76,7 +76,7 @@
+     virtual void execute();
+     virtual boolean post_eval() { return true; }
+     virtual const char* docstring() { 
+-      return ",, is the concat operator"; }
++      return ",, is the stream concat operator"; }
+ 
+     CLASS_SYMID("ConcatFunc");
+ 
+@@ -89,7 +89,7 @@
+ 
+     virtual void execute();
+     virtual const char* docstring() { 
+-      return "hidden func used by next command for ,, (concat) operator."; }
++      return "hidden func used by next command for ,, (stream concat) operator."; }
+ 
+     CLASS_SYMID("ConcatNextFunc");
+ 
+@@ -172,5 +172,4 @@
+     CLASS_SYMID("FilterNextFunc");
+ 
+ };
+-
+ #endif /* !defined(_strmfunc_h) */
+Index: src/ComTerp/comvalue.h
+===================================================================
+--- src/ComTerp/comvalue.h	(revision 8208)
++++ src/ComTerp/comvalue.h	(revision 8254)
+@@ -101,7 +101,7 @@
+     // assignment operator.
+ 
+     virtual void* geta(int type, int compid=-1); 
+-    // return a pointer if ObjectType matches
++    // return a pointer if ObjectType matches or compid is superclass
+ 
+     int narg() const;
+     // number of arguments associated with this command or keyword.
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 8208)
++++ src/man/man1/comterp.1	(revision 8254)
+@@ -121,7 +121,7 @@
+     &&         and            41          L-to-R      binary
+     ||         or             40          L-to-R      binary
+     ,          tuple          35          L-to-R      binary
+-    ,,         concat         33          L-to-R      binary
++    ,,         stream concat  33          L-to-R      binary
+     %=         mod_assign     30          R-to-L      binary
+     *=         mpy_assign     30          R-to-L      binary
+     +=         add_assign     30          R-to-L      binary
+@@ -218,6 +218,8 @@
+ 
+  cnt=each(strm) -- traverse stream returning its length
+ 
++ comp=filter(comps classid) -- filter stream of comps for matching classid
++
+ .SH CONTROL COMMANDS (using post evaluation):
+ 
+  val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true, evaluate and return trueexpr, otherwise evaluate and return falseexpr
+Index: src/man/man1/comdraw.1
+===================================================================
+--- src/man/man1/comdraw.1	(revision 8208)
++++ src/man/man1/comdraw.1	(revision 8254)
+@@ -93,7 +93,9 @@
+  val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list.
+  num=size(list|attrlist|compview) -- return size of a list.
+  compview=parent(compview) -- get parent of graphic
++ comp=depth(comps) -- depth-first walk of comp tree
+ 
++
+ .SH VIEWER COMMANDS
+ 
+  update() -- update viewer
+Index: src/comdraw/README
+===================================================================
+--- src/comdraw/README	(revision 8208)
++++ src/comdraw/README	(revision 8254)
+@@ -85,7 +85,9 @@
+ val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list.
+ num=size(list|attrlist|str|compview) -- return size of a list (or string)
+ compview=parent(compview) -- get parent of graphic
++strm=depth(comps) -- depth-first walk of comp tree using stream
+ 
++
+ VIEWER COMMANDS
+ 
+ update() -- update viewer
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 8208)
++++ src/comterp_/README	(revision 8254)
+@@ -110,7 +110,7 @@
+     &&            and                  41          L-to-R      binary
+     ||            or                   40          L-to-R      binary
+     ,             tuple                35          L-to-R      binary
+-    ,,            concat               33          L-to-R      binary
++    ,,            stream concat        33          L-to-R      binary
+     %=            mod_assign           30          R-to-L      binary
+     *=            mpy_assign           30          R-to-L      binary
+     +=            add_assign           30          R-to-L      binary
+@@ -205,6 +205,8 @@
+ 
+ cnt=each(strm) -- traverse stream returning its length
+ 
++comp=filter(comps classid) -- filter stream of comps for matching classid
++
+ CONTROL COMMANDS (using post evaluation):
+ 
+ val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true,
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-131104-scott-003.txt
@@ -0,0 +1,62 @@
+Patch:    ivtools-131104-scott-003
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  depth-first streaming primitive
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComUnidraw/grstrmfunc.c
+===================================================================
+--- src/ComUnidraw/grstrmfunc.c	(revision 8255)
++++ src/ComUnidraw/grstrmfunc.c	(revision 8259)
+@@ -186,13 +186,13 @@
+     avl->Next(i);
+     ComValue* stopval = (ComValue*)avl->GetAttrVal(i);
+     
+-    /* filter stream */
++    /* depth-first seach */
+     if (currval->is_known()) {
+       OverlayComp* currcomp = (OverlayComp*)currval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+       OverlayComp* prevcomp = (OverlayComp*)prevval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+       OverlayComp* stopcomp = (OverlayComp*)stopval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+       OverlayComp* nextcomp = currcomp->DepthNext(prevcomp);
+-      while(nextcomp && nextcomp==(OverlayComp*)currcomp->GetParent()) {
++      while(nextcomp && nextcomp==(OverlayComp*)currcomp->GetUp()) {
+ 	prevcomp=currcomp;
+ 	currcomp=nextcomp;
+         nextcomp = currcomp->DepthNext(prevcomp);
+Index: src/ComTerp/comvalue.c
+===================================================================
+--- src/ComTerp/comvalue.c	(revision 8255)
++++ src/ComTerp/comvalue.c	(revision 8259)
+@@ -405,7 +405,8 @@
+       return obj_val();
+   } else {
+     if (compid>=0 && object_compview()) {
+-      if (((ComponentView*)obj_val())->GetSubject()->IsA(compid))
++      if (((ComponentView*)obj_val())->GetSubject() && 
++	  ((ComponentView*)obj_val())->GetSubject()->IsA(compid))
+         return ((ComponentView*)obj_val())->GetSubject();
+     }
+     return nil;
+Index: src/OverlayUnidraw/ovcomps.h
+===================================================================
+--- src/OverlayUnidraw/ovcomps.h	(revision 8255)
++++ src/OverlayUnidraw/ovcomps.h	(revision 8259)
+@@ -186,6 +186,9 @@
+     virtual void ClearVisit() { visited(false); }
+     // clear visit mark 
+ 
++    virtual OverlayComp* GetUp() { return (OverlayComp*)GetParent(); }
++    // usually same as parent
++
+ protected:
+     ParamList* GetParamList();
+     // return ParamList of required/optional/keyword arguments to be read
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-131114-scott-004.txt
@@ -0,0 +1,64 @@
+Patch:    ivtools-131114-scott-004
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  fix problem with command arguments that are expressions that start with left paren
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComTerp/ctrlfunc.c
+===================================================================
+--- src/ComTerp/ctrlfunc.c	(revision 8263)
++++ src/ComTerp/ctrlfunc.c	(revision 8287)
+@@ -418,7 +418,7 @@
+         FuncObj* tokbuf = (FuncObj*)argv.obj_val();
+         val = new ComValue(comterpserv()->run(tokbuf->toks(), tokbuf->ntoks()));
+       }
+-      if (val->is_nil() && symretv.is_true()) {
++      if (!val || val->is_nil() && symretv.is_true()) {
+ 	delete val;
+ 	val = new ComValue(argv.symbol_val(), AttributeValue::SymbolType);
+       }
+Index: src/ComUtil/_parser.c
+===================================================================
+--- src/ComUtil/_parser.c	(revision 8263)
++++ src/ComUtil/_parser.c	(revision 8287)
+@@ -1097,11 +1097,27 @@
+ 
+ 	 }
+ 
+-      /* If left paren was encountered without a proceeding identifier   */
+-      /* it is not to be associated with a command.  Push it on the      */
+-      /* paren stack with a -1 indicator for the command id to show such.*/
+-      /* Push the negated value of the token type onto the operator      */
+-      /* stack, in order to distinguish it from the other operators.     */
++      /* If left paren was encountered without a proceeding identifier */
++      /* it is not to be associated with a command.  First pop any     */
++      /* previous expression off the stack.  Then push it on the paren */
++      /* stack with a -1 indicator for the command id to show such.    */
++      /* Push the negated value of the token type onto the operator    */
++      /* stack, in order to distinguish it from the other operators.   */
++	 while ( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) &&
++                 (TopOfOperStack >= 0 ))
++         {
++             if (OperStack[TopOfOperStack].oper_type == OPERATOR)
++             {
++                 OPERSTK_POP( temp_id );
++                 PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),
++                      (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );
++             }
++             else
++             {
++                 OPERSTK_POP( temp_id );
++                 PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0);
++             }
++	 }
+ 	 PARENSTK_PUSH( toktype, -1, 1 );
+ 	 OPERSTK_PUSH( -toktype, LEFTPAREN );
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-131114-scott-005.txt
@@ -0,0 +1,65 @@
+Patch:    ivtools-131114-scott-005
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  fix to fix in patch 004
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComUtil/_parser.c
+===================================================================
+--- src/ComUtil/_parser.c	(revision 8289)
++++ src/ComUtil/_parser.c	(revision 8292)
+@@ -1097,27 +1097,26 @@
+ 
+ 	 }
+ 
+-      /* If left paren was encountered without a proceeding identifier */
+-      /* it is not to be associated with a command.  First pop any     */
+-      /* previous expression off the stack.  Then push it on the paren */
+-      /* stack with a -1 indicator for the command id to show such.    */
+-      /* Push the negated value of the token type onto the operator    */
+-      /* stack, in order to distinguish it from the other operators.   */
+-	 while ( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) &&
+-                 (TopOfOperStack >= 0 ))
+-         {
+-             if (OperStack[TopOfOperStack].oper_type == OPERATOR)
+-             {
+-                 OPERSTK_POP( temp_id );
+-                 PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),
+-                      (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );
+-             }
+-             else
+-             {
+-                 OPERSTK_POP( temp_id );
+-                 PFOUT( TOK_KEYWORD, temp_id, 1, 0, 0);
+-             }
++      /* If left paren was encountered without a proceeding identifier   */
++      /* and a binary operator expected, output any current expression.  */
++         if( expecting==OPTYPE_BINARY ) {
++	   while ( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) &&
++		   (TopOfOperStack >= 0 ))
++	     {
++	       if (OperStack[TopOfOperStack].oper_type == OPERATOR)
++		 {
++		   OPERSTK_POP( temp_id );
++		   PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),
++			  (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );
++		 }
++	     }
+ 	 }
++
++      /* If left paren was encountered without a proceeding identifier    */
++      /* it is not to be associated with a command.  Push it on the       */
++      /* paren stack with a -1 indicator for the command id to show that. */
++      /* Push the negated value of the token type onto the operator       */
++      /* stack, in order to distinguish it from the other operators.      */
+ 	 PARENSTK_PUSH( toktype, -1, 1 );
+ 	 OPERSTK_PUSH( -toktype, LEFTPAREN );
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140307-scott-006.txt
@@ -0,0 +1,479 @@
+Patch:    ivtools-140307-scott-006
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComTerp/mathfunc.c
+===================================================================
+--- src/ComTerp/mathfunc.c	(revision 8294)
++++ src/ComTerp/mathfunc.c	(working copy)
+@@ -73,6 +73,20 @@
+     push_stack(result);
+ }
+ 
++Log2Func::Log2Func(ComTerp* comterp) : ComFunc(comterp) {
++}
++
++void Log2Func::execute() {
++    ComValue operandx = stack_arg(0);
++    reset_stack();
++    if (operandx.is_nil()) {
++      push_stack(ComValue::nullval());
++      return;
++    }
++    ComValue result(log2(operandx.double_val()));
++    push_stack(result);
++}
++
+ PowFunc::PowFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+ 
+Index: src/ComTerp/mathfunc.h
+===================================================================
+--- src/ComTerp/mathfunc.h	(revision 8294)
++++ src/ComTerp/mathfunc.h	(working copy)
+@@ -67,6 +67,18 @@
+ 
+ };
+ 
++//: logarithmic (base 2) command for ComTerp.
++// dbl=log2(x) -- returns the base-2 logarithm of x.
++class Log2Func : public ComFunc {
++public:
++    Log2Func(ComTerp*);
++
++    virtual void execute();
++    virtual const char* docstring() { 
++      return "dbl=%s(x) -- returns the base-2 logarithm of x"; }
++
++};
++
+ //: power command for ComTerp.
+ // dbl=pow(x y) -- returns the value of x raised to the power of y.
+ class PowFunc : public ComFunc {
+Index: src/ComTerp/comfunc.h
+===================================================================
+--- src/ComTerp/comfunc.h	(revision 8294)
++++ src/ComTerp/comfunc.h	(working copy)
+@@ -54,7 +54,7 @@
+     // method that needs to be filled in, that will take ComValue arguments
+     // off the stack, then compute and push a ComValue result on the stack.
+ 
+-    void exec(int nargs, int nkeys, int pedepth=0, int command_symid=0);
++    virtual void exec(int nargs, int nkeys, int pedepth=0, int command_symid=0);
+     // invokes push_funcstate, then plain execute, then pop_funcstate.
+     // for use from the body of regular execute methods.
+ 
+Index: src/ComTerp/strmfunc.c
+===================================================================
+--- src/ComTerp/strmfunc.c	(revision 8294)
++++ src/ComTerp/strmfunc.c	(working copy)
+@@ -38,6 +38,33 @@
+ StrmFunc::StrmFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+ 
++void StrmFunc::print_stream(std::ostream& out, AttributeValue& streamv) {
++  static int indent=0;
++  if(!streamv.is_stream()) 
++    out << "NOT A STREAM\n";
++  else {
++    for (int i=0; i<indent; i++) out << ' ';
++    out << "func = " << (streamv.stream_func() ? symbol_pntr(((ComFunc*)streamv.stream_func())->funcid()) : "NOFUNC")
++              << ", avl = " << *streamv.stream_list() << "\n";
++    if (streamv.stream_func()==NULL) 
++      out << "Unexpected NOFUNC\n";
++    Iterator it;
++    streamv.stream_list()->First(it);
++    int j=0;
++    while(!streamv.stream_list()->Done(it)) {
++      if (streamv.stream_list()->GetAttrVal(it)->is_stream()) {
++        indent+=3;
++        out << "depth=" << indent/3 << ", argc="  << j << ":  ";
++        StrmFunc::print_stream(out, *streamv.stream_list()->GetAttrVal(it));
++        indent-=3;
++      }
++      j++;
++      streamv.stream_list()->Next(it);
++    }
++    out.flush();
++  }
++}
++
+ /*****************************************************************************/
+ 
+ int StreamFunc::_symid;
+@@ -352,6 +379,7 @@
+ }
+ 
+ void NextFunc::execute_impl(ComTerp* comterp, ComValue& streamv) {
++
+     _next_depth++;
+ 
+     if (!streamv.is_stream()) {
+@@ -361,6 +389,8 @@
+ 
+     int outside_stackh = comterp->stack_height();
+ 
++    // fprintf(stderr, "stream:  mode=%d, name=%s, depth=%d\n", streamv.stream_mode(), symbol_pntr(((ComFunc*)streamv.stream_func())->funcid()), _next_depth);
++
+     if (streamv.stream_mode()<0) {
+ 
+       /* internal execution -- handled by stream func */
+@@ -397,12 +427,22 @@
+ 	    if (val->stream_mode()<0 && val->stream_func()) {
+ 	      /* internal use */
+ 	      comterp->push_stack(*val);
++
++              // fprintf(stdout, "Stack before stream_func exec\n");
++              // comterp->print_stack();
++
+ 	      ((ComFunc*)val->stream_func())->exec(1,0);
+ 	    }else {
+ 
+ 	      /* external use */
+ 	      ComValue cval(*val);
++              // fprintf(stderr, "before: strm arg 0x%lx, stack_top %d\n", val, comterp->stack_height());
++
++              // fprintf(stdout, "Stack before NextFunc::execute_impl\n");
++              // comterp->print_stack();
++
+ 	      NextFunc::execute_impl(comterp, cval);
++              // fprintf(stderr, "after:  strm arg 0x%lx, stack_top %d\n", val, comterp->stack_height());
+ 
+ 	    }
+ 	    
+@@ -434,6 +474,9 @@
+ 	  avl->Next(i);
+ 	}
+ 
++        // fprintf(stdout, "Stack before streamed func %s\n", symbol_pntr(funcptr->funcid()));
++        // comterp->print_stack();
++
+ 	funcptr->exec(narg, nkey);
+       }
+ 
+Index: src/ComTerp/strmfunc.h
+===================================================================
+--- src/ComTerp/strmfunc.h	(revision 8294)
++++ src/ComTerp/strmfunc.h	(working copy)
+@@ -39,6 +39,7 @@
+ public:
+     StrmFunc(ComTerp*);
+ 
++    static void print_stream(std::ostream& out, AttributeValue& streamv);
+ };
+ 
+ //: stream command
+Index: src/ComTerp/comterp.c
+===================================================================
+--- src/ComTerp/comterp.c	(revision 8294)
++++ src/ComTerp/comterp.c	(working copy)
+@@ -297,7 +297,8 @@
+ 	avl->Prepend(new AttributeValue(topval));
+       }
+ 
+-      ComValue val(sv.obj_val(), avl);
++      ComValue val((ComFunc*)sv.obj_val(), avl);
++      // fprintf(stderr, "Just packed up stream for %s\n", symbol_pntr(((ComFunc*)sv.obj_val())->funcid()));
+       val.stream_mode(1); // for external use
+       push_stack(val);
+       return;
+@@ -681,6 +682,7 @@
+ boolean ComTerp::skip_arg(ComValue* topval, int& offset, int offlimit, int& tokcnt) {
+   tokcnt = 0;
+   ComValue& curr = *(topval+offset);
++  // fprintf(stderr, "offset is %d, topval is at 0x%lx\n", offset, topval);
+   if (curr.is_type(ComValue::KeywordType)) {
+     cerr << "unexpected keyword found by ComTerp::skip_arg\n";
+     return false;
+@@ -750,9 +752,15 @@
+ 
+ 
+ int ComTerp::print_stack() const {
++    print_stack(cout);
++    return true;
++}
++
++int ComTerp::print_stack(std::ostream& out) const {
+     for (int i = _stack_top; i >= 0; i--) {
+-	cout << _stack[i] << "\n";
++	out << _stack[i] << "\n";
+     }
++    out.flush();
+     return true;
+ }
+ 
+@@ -1236,6 +1244,7 @@
+     add_command("exp", new ExpFunc(this));
+     add_command("log", new LogFunc(this));
+     add_command("log10", new Log10Func(this));
++    add_command("log2", new Log2Func(this));
+     add_command("pow", new PowFunc(this));
+ 
+     add_command("acos", new ACosFunc(this));
+Index: src/ComTerp/comterp.h
+===================================================================
+--- src/ComTerp/comterp.h	(revision 8294)
++++ src/ComTerp/comterp.h	(working copy)
+@@ -113,6 +113,8 @@
+     // print the top of the stack to an ostream.
+     int print_stack() const;
+     // print the entire stack to stdout.
++    int print_stack(std::ostream& out) const;
++    // print the entire stack to stdout.
+     int stack_height() { return _stack_top+1; }
+     // return current height of the stack.
+     boolean brief() const;
+Index: src/ComTerp/symbolfunc.c
+===================================================================
+--- src/ComTerp/symbolfunc.c	(revision 8294)
++++ src/ComTerp/symbolfunc.c	(working copy)
+@@ -465,6 +465,9 @@
+   static int after_symid = symbol_add("after");
+   ComValue afterflagv(stack_key(after_symid));
+   boolean afterflag = afterflagv.is_true();
++  static int nonil_symid = symbol_add("nonil");
++  ComValue nonilflagv(stack_key(nonil_symid));
++  boolean nonilflag = nonilflagv.is_true();
+   reset_stack();
+ 
+   if (strv.is_unknown()) {
+@@ -482,7 +485,10 @@
+   else {
+     const char* foundstr = strstr(string, nv.symbol_ptr());
+     if(foundstr==NULL) {
+-      push_stack(ComValue::nullval());
++      if(nonilflag)
++	push_stack(strv);
++      else
++	push_stack(ComValue::nullval());
+       return;
+     }
+     n = afterflag ?  strlen(string)-(foundstr-string)-strlen(nv.symbol_ptr()) : foundstr-string;
+@@ -495,7 +501,10 @@
+     ComValue retval(buffer);
+     push_stack(retval);
+   } else
+-    push_stack(ComValue::nullval());
++    if(nonilflag)
++      push_stack(strv);
++    else
++      push_stack(ComValue::nullval());
+ }
+ 
+ 
+Index: src/ComTerp/symbolfunc.h
+===================================================================
+--- src/ComTerp/symbolfunc.h	(revision 8294)
++++ src/ComTerp/symbolfunc.h	(working copy)
+@@ -149,14 +149,14 @@
+ 
+ 
+ //: command to extract a sub string
+-// str=substr(str n :after) -- extract characters from a string
++// str=substr(str n :after :before) -- extract characters from a string
+ class SubStrFunc : public ComFunc {
+ public:
+     SubStrFunc(ComTerp*);
+     virtual void execute();
+ 
+     virtual const char* docstring() { 
+-      return "str=%s(str n|str :after) -- extract characters from a string"; }
++      return "str=%s(str n|str :after :nonil) -- extract characters from a string (:nonil return string if no match)"; }
+ };
+ 
+ 
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 8294)
++++ src/man/man1/comterp.1	(working copy)
+@@ -145,6 +145,8 @@
+ 
+  dbl=log10(x) -- returns the base-10 logarithm of x
+ 
++ dbl=log2(x) -- returns the base-2 logarithm of x
++
+  dbl=pow(x y) -- returns the value of x raised to the power of y
+ 
+  dbl=acos(x) -- returns the arc cosine of x in radians
+@@ -270,7 +272,7 @@
+ 
+  str=join(clist :sym) -- join list of characters into string
+ 
+- str=substr(str n|str :after) -- extract characters from a string
++ str=substr(str n|str :after :nonil) -- extract characters from a string (:nonil returns string if no match)
+ 
+  bool=eq(str1 str2 :n len) -- partial string comparison
+ 
+Index: src/ComUtil/popen2.c
+===================================================================
+--- src/ComUtil/popen2.c	(revision 8294)
++++ src/ComUtil/popen2.c	(working copy)
+@@ -52,11 +52,26 @@
+     exit(1);
+   }
+    
++#if 0
+   if(pipe2(fds_processOutput, O_NONBLOCK) != 0) //create  process  output  pipe
+   {
+     fprintf(stderr, "pipe (process output) failed\n");
+     exit(1);
+   }
++#else
++  if(pipe(fds_processOutput) != 0) //create  process  output  pipe
++  {
++    fprintf(stderr, "pipe (process output) failed\n");
++    exit(1);
++  }
++  int flags;
++  for(int i=0; i<2; i++) {
++      flags = fcntl(fds_processOutput[i], F_GETFL, 0);
++      flags |= O_NONBLOCK;
++      fcntl(fds_processOutput[i], F_SETFL, flags);
++  }
++#endif
++
+    
+   //FORKING  A  CHILD  PROCESS:
+   pid_t pid;
+Index: src/Attribute/attrlist.c
+===================================================================
+--- src/Attribute/attrlist.c	(revision 8294)
++++ src/Attribute/attrlist.c	(working copy)
+@@ -204,6 +204,14 @@
+ 
+ boolean AttributeList::IsEmpty () { return _alist->IsEmpty(); }
+ 
++void AttributeList::print_attrlist(AttributeList* al) {
++    print_attrlist(std::cout, al);
++}
++
++void AttributeList::print_attrlist(std::ostream& out, AttributeList* al) {
++    out << *al;
++}
++
+ ostream& operator<< (ostream& out, const AttributeList& al) {
+ 
+     AttributeList* attrlist = (AttributeList*)&al;
+@@ -462,6 +470,12 @@
+ 	        out << *attrval->array_ref();
+   	        out << "}";
+ 	        break;
++	    case AttributeValue::StreamType:
++	        out << "stream";
++	        break;
++	    case AttributeValue::ObjectType:
++	        out << "object(class=" << attrval->obj_type_val() << ", ptr= " << attrval->obj_val() << ")";
++	        break;
+             default:
+ 		out << "nil";
+ 	        break;
+Index: src/Attribute/attrvalue.c
+===================================================================
+--- src/Attribute/attrvalue.c	(revision 8294)
++++ src/Attribute/attrvalue.c	(working copy)
+@@ -742,6 +742,10 @@
+     return _v.objval.type;
+ }
+ 
++const char* AttributeValue::class_name() {
++    return symbol_pntr(_v.objval.type);
++}
++
+ AttributeValueList* AttributeValue::array_val() { 
+ 	return array_ref();
+ }
+@@ -792,6 +796,10 @@
+ void AttributeValue::command_symid(int id, boolean alias) { 
+   _command_symid = (alias ? -1 : 1) * id; }
+ 
++const char* AttributeValue::command_name() {
++    return symbol_pntr(_command_symid);
++}
++
+ ostream& operator<< (ostream& out, const AttributeValue& sv) {
+     AttributeValue* svp = (AttributeValue*)&sv;
+     const char* title;
+Index: src/Attribute/attrlist.h
+===================================================================
+--- src/Attribute/attrlist.h	(revision 8294)
++++ src/Attribute/attrlist.h	(working copy)
+@@ -115,6 +115,12 @@
+     // merge the contents of another AttributeList into this one,
+     // replicating the AttributeValue as needed.
+ 
++    static void print_attrlist(AttributeList* al);
++    // print AttributeList to stdout
++
++    static void print_attrlist(std::ostream& out, AttributeList* al);
++    // print AttributeList to out
++
+ protected:
+     void Append(Attribute*);
+     // append Attribute to end of list.  Could cause duplicates.
+Index: src/Attribute/attrvalue.h
+===================================================================
+--- src/Attribute/attrvalue.h	(revision 8294)
++++ src/Attribute/attrvalue.h	(working copy)
+@@ -225,7 +225,6 @@
+     unsigned int symbol_val();	      // symbol id by value.                        
+     void* obj_val();		      // void* pointer to object by value.          
+     unsigned int obj_type_val();      // classid of object by value.                
+-    unsigned int& class_symid();       // classid of object by value.                
+     AttributeValueList* array_val();  // values in list by value.                   
+     unsigned int array_type_val();    // type of values in list by value            
+     AttributeValueList* list_val();   // values in list by value.                   
+@@ -233,6 +232,10 @@
+     unsigned int keyid_val();	      // symbol id of keyword by value.             
+     unsigned int keynarg_val();	      // number of arguments after keyword by value.
+ 
++    unsigned int& class_symid();      // classid of object.
++    const char* class_name();         // class name of object.
++
++
+     const char* string_ptr();
+     // lookup and return pointer to string associated with string.
+     const char* symbol_ptr();
+@@ -249,8 +252,10 @@
+     // symbol id of associated command name, for use with ComTerp.
+     void command_symid(int, boolean alias=false);
+     // set symbol id of associated command name, for use with ComTerp.
+-    boolean command_alias();
++    // boolean command_alias();
+     // returns true if command is an alias, not the first name.
++    const char* command_name();
++    // returns name of command.
+ 
+     const boolean object_compview() { return is_object() && _object_compview; }
+     // true if object is wrapped with a ComponentView
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 8294)
++++ src/comterp_/README	(working copy)
+@@ -133,6 +133,8 @@
+ 
+ dbl=log10(x) -- returns the base-10 logarithm of x
+ 
++dbl=log2(x) -- returns the base-2 logarithm of x
++
+ dbl=pow(x y) -- returns the value of x raised to the power of y
+ 
+ dbl=acos(x) -- returns the arc cosine of x in radians
+@@ -265,7 +267,7 @@
+ 
+ str=join(clist :sym) -- join list of characters into string
+ 
+-str=substr(str n|str :after) -- extract characters from a string
++str=substr(str n|str :after :nonil) -- extract characters from a string (:nonil returns string if no match)
+ 
+ bool=eq(str1 str2 :n len) -- partial string comparison
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140320-scott-007.txt
@@ -0,0 +1,133 @@
+Patch:    ivtools-140320-scott-007
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComUnidraw/grstrmfunc.h
+===================================================================
+--- src/ComUnidraw/grstrmfunc.h	(revision 8399)
++++ src/ComUnidraw/grstrmfunc.h	(revision 8411)
+@@ -37,7 +37,7 @@
+ 
+     virtual void execute();
+     virtual const char* docstring() { 
+-      return "strm=%s(ostrm|list|attrlist|compview) -- copy stream or convert list"; }
++      return "strm=%s(ostrm|list|attrlist|compview) -- copy stream or convert list (unary $)"; }
+ 
+     CLASS_SYMID("GrStreamFunc");
+ 
+Index: src/ComTerp/listfunc.h
+===================================================================
+--- src/ComTerp/listfunc.h	(revision 8399)
++++ src/ComTerp/listfunc.h	(revision 8411)
+@@ -45,7 +45,7 @@
+     virtual void execute();
+     virtual boolean post_eval() { return true; }
+     virtual const char* docstring() { 
+-      return "lst=%s([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream"; }
++      return "lst=%s([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream (unary $$)"; }
+ };
+ 
+ //: list member command for ComTerp.
+Index: src/ComTerp/strmfunc.h
+===================================================================
+--- src/ComTerp/strmfunc.h	(revision 8399)
++++ src/ComTerp/strmfunc.h	(revision 8411)
+@@ -50,7 +50,7 @@
+     virtual void execute();
+     virtual boolean post_eval() { return true; }
+     virtual const char* docstring() { 
+-      return "strm=%s(ostrm|list|attrlist) -- copy stream or convert list"; }
++      return "strm=%s(ostrm|list|attrlist) -- copy stream or convert list (unary $)"; }
+ 
+     CLASS_SYMID("StreamFunc");
+ 
+Index: src/ComTerp/comterp.c
+===================================================================
+--- src/ComTerp/comterp.c	(revision 8399)
++++ src/ComTerp/comterp.c	(revision 8411)
+@@ -686,9 +686,11 @@
+   if (curr.is_type(ComValue::KeywordType)) {
+     cerr << "unexpected keyword found by ComTerp::skip_arg\n";
+     return false;
++#if 0
+   } else if (curr.is_type(ComValue::UnknownType)) {
+-    cerr << "unexpected unknown found by ComTerp::skip_arg\n";
++    cerr << "unexpected nil found by ComTerp::skip_arg\n";
+     return false;
++#endif
+   } else if (curr.is_type(ComValue::BlankType)) {
+     if (offlimit == offset) {
+       cerr << "offlimit hit by ComTerp::skip_arg\n";
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 8399)
++++ src/man/man1/comterp.1	(revision 8411)
+@@ -92,7 +92,6 @@
+     ---------  ------------   --------    -----       ----
+     .          dot            130         R-to-L      binary
+     `          bquote         125         R-to-L      unary-prefix
+-    $          stream         125         R-to-L      unary-prefix
+     !          negate         110         R-to-L      unary-prefix
+     ~          bit_not        110         R-to-L      unary-prefix
+     ++         incr           110         R-to-L      unary-prefix
+@@ -122,6 +121,8 @@
+     ||         or             40          L-to-R      binary
+     ,          tuple          35          L-to-R      binary
+     ,,         stream concat  33          L-to-R      binary
++    $          stream         32          R-to-L      unary-prefix
++    $$         list           32          R-to-L      unary-prefix
+     %=         mod_assign     30          R-to-L      binary
+     *=         mpy_assign     30          R-to-L      binary
+     +=         add_assign     30          R-to-L      binary
+Index: src/ComUtil/optable.c
+===================================================================
+--- src/ComUtil/optable.c	(revision 8399)
++++ src/ComUtil/optable.c	(revision 8411)
+@@ -101,7 +101,6 @@
+   {" ",          "space",              140,        FALSE,      OPTYPE_BINARY },
+   {".",          "dot",                130,        FALSE,      OPTYPE_BINARY },
+   {"`",          "bquote",             125,        TRUE,       OPTYPE_UNARY_PREFIX },
+-  {"$",          "stream",             125,        TRUE,       OPTYPE_UNARY_PREFIX },
+   {"!",          "negate",             110,        TRUE,       OPTYPE_UNARY_PREFIX },
+   {"~",          "bit_not",            110,        TRUE,       OPTYPE_UNARY_PREFIX },
+   {"++",         "incr",               110,        TRUE,       OPTYPE_UNARY_PREFIX },
+@@ -131,6 +130,8 @@
+   {"||",         "or",                 40,         FALSE,      OPTYPE_BINARY },
+   {",",          "tuple",              35,         FALSE,      OPTYPE_BINARY },
+   {",,",         "concat",             33,         FALSE,      OPTYPE_BINARY },
++  {"$",          "stream",             32,         TRUE,       OPTYPE_UNARY_PREFIX },
++  {"$$",         "list",               32,         TRUE,       OPTYPE_UNARY_PREFIX },
+   {"%=",         "mod_assign",         30,         TRUE,       OPTYPE_BINARY },
+   {"*=",         "mpy_assign",         30,         TRUE,       OPTYPE_BINARY },
+   {"+=",         "add_assign",         30,         TRUE,       OPTYPE_BINARY },
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 8399)
++++ src/comterp_/README	(revision 8411)
+@@ -81,7 +81,6 @@
+     ---------     ------------         --------    -----       ----
+     .             dot                  130         L-to-R      binary
+     `             bquote               125         R-to-L      unary-prefix
+-    $             stream               125         R-to-L      unary-prefix
+     !             negate               110         R-to-L      unary-prefix
+     ~             bit_not              110         R-to-L      unary-prefix
+     ++            incr                 110         R-to-L      unary-prefix
+@@ -111,6 +110,8 @@
+     ||            or                   40          L-to-R      binary
+     ,             tuple                35          L-to-R      binary
+     ,,            stream concat        33          L-to-R      binary
++    $             stream               32          R-to-L      unary-prefix
++    $$            list                 32          R-to-L      unary-prefix
+     %=            mod_assign           30          R-to-L      binary
+     *=            mpy_assign           30          R-to-L      binary
+     +=            add_assign           30          R-to-L      binary
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140324-scott-008.txt
@@ -0,0 +1,83 @@
+Patch:    ivtools-140324-scott-008
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComUnidraw/grstrmfunc.h
+===================================================================
+--- src/ComUnidraw/grstrmfunc.h	(revision 8415)
++++ src/ComUnidraw/grstrmfunc.h	(revision 8421)
+@@ -37,7 +37,7 @@
+ 
+     virtual void execute();
+     virtual const char* docstring() { 
+-      return "strm=%s(ostrm|list|attrlist|compview) -- copy stream or convert list (unary $)"; }
++      return "strm=%s(ostrm|list|attrlist|val|compview) -- copy stream or convert list (unary $)"; }
+ 
+     CLASS_SYMID("GrStreamFunc");
+ 
+Index: src/ComTerp/strmfunc.c
+===================================================================
+--- src/ComTerp/strmfunc.c	(revision 8415)
++++ src/ComTerp/strmfunc.c	(revision 8421)
+@@ -114,6 +114,12 @@
+       ComValue stream(snfunc, avl);
+       stream.stream_mode(-1); // for internal use (use by this func)
+       push_stack(stream);
++    } else {
++      AttributeValueList* avl = new AttributeValueList();
++      avl->Append(new AttributeValue(operand1));
++      ComValue stream(snfunc, avl);
++      stream.stream_mode(-1); // for internal use (use by this func)
++      push_stack(stream);
+     }
+     
+   }
+Index: src/ComTerp/strmfunc.h
+===================================================================
+--- src/ComTerp/strmfunc.h	(revision 8415)
++++ src/ComTerp/strmfunc.h	(revision 8421)
+@@ -50,7 +50,7 @@
+     virtual void execute();
+     virtual boolean post_eval() { return true; }
+     virtual const char* docstring() { 
+-      return "strm=%s(ostrm|list|attrlist) -- copy stream or convert list (unary $)"; }
++      return "strm=%s(ostrm|list|attrlist|val) -- copy stream or convert list (unary $)"; }
+ 
+     CLASS_SYMID("StreamFunc");
+ 
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 8415)
++++ src/man/man1/comterp.1	(revision 8421)
+@@ -217,7 +217,7 @@
+  
+  val=next(stream) -- return next value from stream
+ 
+- strm=stream(ostrm|list|attrlist) -- copy stream or convert list
++ strm=stream(ostrm|list|attrlist|val) -- copy stream or convert list
+ 
+  cnt=each(strm) -- traverse stream returning its length
+ 
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 8415)
++++ src/comterp_/README	(revision 8421)
+@@ -204,7 +204,7 @@
+ 
+ val=next(strm) -- return next value from stream
+ 
+-strm=stream(ostrm|list|attrlist) -- copy stream or convert list
++strm=stream(ostrm|list|attrlist|val) -- copy stream or convert list
+ 
+ cnt=each(strm) -- traverse stream returning its length
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140402-scott-009.txt
@@ -0,0 +1,61 @@
+Patch:    ivtools-140402-scott-009
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComTerp/symbolfunc.c
+===================================================================
+--- src/ComTerp/symbolfunc.c	(revision 8425)
++++ src/ComTerp/symbolfunc.c	(working copy)
+@@ -255,16 +255,22 @@
+ }
+ 
+ void SplitStrFunc::execute() {
++  ComValue zerov(0, ComValue::IntType);
+   ComValue commav(',');
+   ComValue symvalv(stack_arg(0));
+   static int tokstr_symid = symbol_add("tokstr");
+-  ComValue tokstrv(stack_key(tokstr_symid, false, commav));
++  ComValue tokstrv(stack_key(tokstr_symid, false, zerov));
+   boolean tokstrflag = tokstrv.is_known();
+   static int tokval_symid = symbol_add("tokval");
+-  ComValue tokvalv(stack_key(tokval_symid, false, commav));
++  ComValue tokvalv(stack_key(tokval_symid, false, zerov));
+   boolean tokvalflag = tokvalv.is_known();
+   reset_stack();
+ 
++  boolean tokstr_charflag = tokstrv.is_type(ComValue::CharType);
++  if(tokstrv.is_type(ComValue::IntType)) tokstrv = commav;
++  if(tokvalv.is_type(ComValue::IntType)) tokvalv = commav;
++  
++
+   if (symvalv.is_string()) {
+     AttributeValueList* avl = new AttributeValueList();
+     ComValue retval(avl);
+@@ -279,7 +285,7 @@
+       char delim = tokstrv.char_val();
+       while (*str) {
+         int delim1=0;
+-        while(*str && (isspace(*str) || *str==delim)) {
++        while(*str && isspace(*str) || *str==delim) {
+           if (*str==delim) {
+             if ((delim1 || avl->Number()==0) && !isspace(delim) ) {
+               ComValue* comval = new ComValue(ComValue::nullval());
+@@ -296,7 +302,7 @@
+           }
+           break;
+         }
+-        while (*str && !isspace(*str) && *str!=delim && bufoff<BUFSIZ-1) {
++        while (*str && (tokstr_charflag?*str!='\n':!isspace(*str)) && *str!=delim && bufoff<BUFSIZ-1) {
+           if(*str=='"') {
+             while(*str && (*str!='"' || *(str-1)!='\\') && bufoff<BUFSIZ-1) 
+               buffer[bufoff++] = *str++;
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140415-scott-010.txt
@@ -0,0 +1,72 @@
+Patch:    ivtools-140416-scott-010
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/ComTerp/postfunc.c
+===================================================================
+--- src/ComTerp/postfunc.c	(revision 8435)
++++ src/ComTerp/postfunc.c	(working copy)
+@@ -256,11 +256,11 @@
+ }
+ 
+ void BreakFunc::execute() {
++  ComValue retval(stack_arg(0,true,ComValue::trueval()));
+   reset_stack();
+ 
+   SeqFunc::breakflag(1);
+ 
+-  ComValue retval(ComValue::trueval());
+   push_stack(retval);
+   return;
+ }
+Index: src/ComTerp/postfunc.h
+===================================================================
+--- src/ComTerp/postfunc.h	(revision 8435)
++++ src/ComTerp/postfunc.h	(working copy)
+@@ -131,7 +131,7 @@
+ 
+     virtual void execute();
+     virtual const char* docstring() { 
+-      return "%s -- break out of for or while loop"; }
++      return "break([retval]) -- break out of for or while loop"; }
+ 
+ };
+ 
+Index: src/man/man1/comterp.1
+===================================================================
+--- src/man/man1/comterp.1	(revision 8435)
++++ src/man/man1/comterp.1	(working copy)
+@@ -235,6 +235,10 @@
+ 
+  val=switch(val key-body-pairs) -- switch statement (:casen for pos., :case_n for neg., otherwise :symbol)
+ 
++ continue -- skip to next iteration of for or while loop
++
++ break([retval]) -- break out of for or while loop
++
+ .SH OTHER COMMANDS
+ 
+  help(cmdname [cmdname ...] :all :posteval) -- help for commands
+Index: src/comterp_/README
+===================================================================
+--- src/comterp_/README	(revision 8435)
++++ src/comterp_/README	(working copy)
+@@ -226,7 +226,7 @@
+ 
+ continue -- skip to next iteration of for or while loop
+ 
+-break -- break out of for or while loop
++break([retval]) -- break out of for or while loop
+ 
+ OTHER COMMANDS
+ 
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140418-scott-011.txt
@@ -0,0 +1,53 @@
+Patch:    ivtools-140418-scott-011
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/GraphUnidraw/nodecomp.c
+===================================================================
+--- src/GraphUnidraw/nodecomp.c	(revision 8464)
++++ src/GraphUnidraw/nodecomp.c	(working copy)
+@@ -182,7 +182,7 @@
+       Picture* pic = new Picture();
+       SF_Ellipse* ellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic);
+       ellipse->SetPattern(unidraw->GetCatalog()->FindGrayLevel(1));
+-      TextGraphic* txt = new TextGraphic(graph->GetFile(), stdgraphic);
++      TextGraphic* txt = new TextGraphic(graph->GetFile()?graph->GetFile():"", stdgraphic);
+       ellipse->Align(4, txt, 4); // same as Center in IV-2_6/InterViews/alignment.h
+       pic->Append(ellipse, txt);
+       SetGraphic(pic);
+Index: src/Unidraw/ulabel.c
+===================================================================
+--- src/Unidraw/ulabel.c	(revision 8464)
++++ src/Unidraw/ulabel.c	(working copy)
+@@ -42,7 +42,7 @@
+     if (gr != nil) {
+ 	ULabel::SetFont(gr->GetFont());
+     }
+-    _string = strdup(s);
++    _string = s ? strdup(s) : s;
+ }
+ 
+ ULabel::~ULabel () {
+Index: src/OverlayUnidraw/ovcomps.c
+===================================================================
+--- src/OverlayUnidraw/ovcomps.c	(revision 8464)
++++ src/OverlayUnidraw/ovcomps.c	(working copy)
+@@ -1008,7 +1008,7 @@
+     Graphic* g = comp->GetGraphic();
+ 
+     _comps->Append(new UList(comp));
+-    if (g != nil) GetGraphic()->Append(g);
++    if (g != nil && GetGraphic()) GetGraphic()->Append(g);
+ 
+     SetParent(comp, this);
+ }
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140418-scott-012.txt
@@ -0,0 +1,27 @@
+Patch:    ivtools-140418-scott-012
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/Unidraw/ulabel.c
+===================================================================
+--- src/Unidraw/ulabel.c	(revision 8474)
++++ src/Unidraw/ulabel.c	(working copy)
+@@ -42,7 +42,7 @@
+     if (gr != nil) {
+ 	ULabel::SetFont(gr->GetFont());
+     }
+-    _string = s ? strdup(s) : s;
++    _string = strdup(s);
+ }
+ 
+ ULabel::~ULabel () {
--- /dev/null
+++ ivtools-1.2.11a1/patches/ivtools-140424-scott-013.txt
@@ -0,0 +1,27 @@
+Patch:    ivtools-140424-scott-013
+For:      ivtools-1.2.11
+Author:   scott@wavesemi.com
+Subject:  support for ipl development
+
+This is an intermediate patch to ivtools-1.2.11.  To apply, cd to the
+top-level directory of the ivtools source tree (the directory with src
+and config subdirs), and apply like this:
+
+	patch -p0 <ThisFile
+
+Then rebuild with "make;make install"
+
+
+Index: src/Attribute/attrvalue.h
+===================================================================
+--- src/Attribute/attrvalue.h	(revision 8479)
++++ src/Attribute/attrvalue.h	(working copy)
+@@ -184,6 +184,8 @@
+     // return sizeof of value of given type.
+     int type_symid() const;
+     // return symbol id corresponding to type
++    const char* type_name() { return symbol_pntr(type_symid()); }
++    // type name of object.
+ 
+     void assignval (const AttributeValue&);
+     // copy contents of AttributeValue
--- /dev/null
+++ ivtools-1.2.11a1/patches/jorge-ivtools-patch1.diff
@@ -0,0 +1,120 @@
+From f45d99dd43c19be62d06e34e9c5d4ff50c34d9c7 Mon Sep 17 00:00:00 2001
+From: Anon Contrib <cuchifrito@users.noreply.github.com>
+Date: Wed, 18 Feb 2015 17:18:38 -0500
+Subject: [PATCH] Changes to build on Yosemite
+
+---
+ config/site.def.DARWIN        | 2 +-
+ src/OverlayUnidraw/clippoly.c | 2 +-
+ src/glyphs/strchooser/main.c  | 2 +-
+ src/tests/y2k/y2ktest.cc      | 2 +-
+ src/utils/ftp.cc              | 4 ++--
+ src/utils/ivdl.cc             | 4 ++--
+ src/utils/sockets.h           | 2 +-
+ 7 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/config/site.def.DARWIN b/config/site.def.DARWIN
+index 580a7ca..d6036fb 100644
+--- a/config/site.def.DARWIN
++++ b/config/site.def.DARWIN
+@@ -63,7 +63,7 @@
+ #if 0
+ #define SharedLibraryCmd(ldobjs,extra_flags) $(LD) -r extra_flags -o $@~ ldobjs
+ #else
+-#define SharedLibraryCmdDarwin(ldobjs,depobjs,rev,libname) CCDriver -dynamiclib -install_name Prefix/lib/$(AOUT) -current_version rev -compatibility_version rev -o $@~ ldobjs depobjs -flat_namespace -undefined suppress
++#define SharedLibraryCmdDarwin(ldobjs,depobjs,rev,libname) CCDriver -dynamiclib -install_name Prefix/lib/$(CPU)/$(AOUT) -current_version rev -compatibility_version rev -o $@~ ldobjs depobjs -flat_namespace -undefined suppress
+ #endif
+ 
+ #define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
+diff --git a/src/OverlayUnidraw/clippoly.c b/src/OverlayUnidraw/clippoly.c
+index c239894..4ee6d63 100644
+--- a/src/OverlayUnidraw/clippoly.c
++++ b/src/OverlayUnidraw/clippoly.c
+@@ -216,7 +216,7 @@ void clippoly(ClipOperation op,
+ 	}
+ 	break;
+     default:
+-	cerr << "Error: unknown clippoly operation" << endl;
++	std::cerr << "Error: unknown clippoly operation" << std::endl;
+ 	break;
+     }
+ 
+diff --git a/src/glyphs/strchooser/main.c b/src/glyphs/strchooser/main.c
+index ed71a65..c8d7b58 100644
+--- a/src/glyphs/strchooser/main.c
++++ b/src/glyphs/strchooser/main.c
+@@ -125,7 +125,7 @@ declareActionCallback(Session)
+ declareActionCallback(App)
+ implementActionCallback(App)
+ 
+-main(int argc, char *argv[]) {
++int main(int argc, char *argv[]) {
+   Session * session =  new Session("strchooser", argc, argv, options, properties);
+   LayoutKit &    lk = *LayoutKit::instance();
+   WidgetKit *    wk =  MFKit::instance();
+diff --git a/src/tests/y2k/y2ktest.cc b/src/tests/y2k/y2ktest.cc
+index 05bbe84..4e7c384 100644
+--- a/src/tests/y2k/y2ktest.cc
++++ b/src/tests/y2k/y2ktest.cc
+@@ -25,7 +25,7 @@
+ using std::cin;
+ using std::cout;
+ 
+-main() {
++int main() {
+   Date date(1, "Jan", 1999);
+ 
+   cout << "Current date initialized to ";
+diff --git a/src/utils/ftp.cc b/src/utils/ftp.cc
+index 3b29b25..4f0d06f 100644
+--- a/src/utils/ftp.cc
++++ b/src/utils/ftp.cc
+@@ -44,7 +44,7 @@ void CFtp::DoRetrieve() {
+   // Connect to host "hostname" at port "port".
+   int control_fd = AConnect(); 
+ 
+-  fstream control_stream(control_fd);
++  std::fstream control_stream(control_fd);
+   
+   // Check for steam's existence
+   if (!control_stream.is_open()) {
+@@ -210,7 +210,7 @@ void CFtp::DoRetrieve() {
+   data_fd = Listen();
+   
+   // Pass Data Connection Stream to ReadWrite().
+-  fstream data_stream(data_fd);
++  std::fstream data_stream(data_fd);
+   if(!(ReadWrite(data_stream, NULL, localfile))) {
+     control_stream.close();
+     Shutdown(control_fd);
+diff --git a/src/utils/ivdl.cc b/src/utils/ivdl.cc
+index c99b351..32e5b2e 100644
+--- a/src/utils/ivdl.cc
++++ b/src/utils/ivdl.cc
+@@ -32,8 +32,8 @@ int main(int argc, char** argv)
+ {
+   
+   if(argc != 3){
+-    cerr << "Wrong number of args.\n";
+-    cerr << "Use:  a.out URL FilenameToSave\n";
++    std::cerr << "Wrong number of args.\n";
++    std::cerr << "Use:  a.out URL FilenameToSave\n";
+     exit(0);
+   }
+ 
+diff --git a/src/utils/sockets.h b/src/utils/sockets.h
+index 77d6185..1213621 100644
+--- a/src/utils/sockets.h
++++ b/src/utils/sockets.h
+@@ -72,7 +72,7 @@ class CSocket {
+   void PConnect();  // Sets up a passive socket connection.
+   int Listen(); // Blocks until incoming connection is made.
+ 
+-  int ReadWrite(fstream&, String, char*); // Socket reading and file writing. 
++  int ReadWrite(std::fstream&, String, char*); // Socket reading and file writing. 
+   
+   // Closes a socket connection, given a file descriptor.
+   void Shutdown(int);             
+-- 
+2.2.1
+
--- /dev/null
+++ ivtools-1.2.11a1/patches/maverick-fixes
@@ -0,0 +1,3998 @@
+*** ./ivtools-1.2/config/site.def.DARWIN.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/config/site.def.DARWIN	2015-01-24 11:26:33.000000000 -0800
+***************
+*** 28,40 ****
+   * build RPC classes -- requires iostreams & TCP sockets
+   */
+  #undef BuildRPCClasses
+! #define BuildRPCClasses (YES&&!LibStdCPlusPlusV3)
+  #define SOMAXCONN 5
+  
+  /* override -ansi -pedantic from xfree86.cf */
+  /* use ucontext routines */
+  #undef DefaultCCOptions
+! #define DefaultCCOptions -fno-common -D_XOPEN_SOURCE
+  
+  /* machine-specific gcc include directory -- does not change with each new version of gcc */
+  #if 0
+--- 28,41 ----
+   * build RPC classes -- requires iostreams & TCP sockets
+   */
+  #undef BuildRPCClasses
+! /* #define BuildRPCClasses (YES&&!LibStdCPlusPlusV3) */
+! #define BuildRPCClasses NO
+  #define SOMAXCONN 5
+  
+  /* override -ansi -pedantic from xfree86.cf */
+  /* use ucontext routines */
+  #undef DefaultCCOptions
+! #define DefaultCCOptions -fno-common -D_XOPEN_SOURCE -x c++
+  
+  /* machine-specific gcc include directory -- does not change with each new version of gcc */
+  #if 0
+***************
+*** 59,65 ****
+  #if 0
+  #define SharedLibraryCmd(ldobjs,extra_flags) $(LD) -r extra_flags -o $@~ ldobjs
+  #else
+! #define SharedLibraryCmdDarwin(ldobjs,depobjs,rev,libname) CCDriver -dynamiclib -install_name @PREFIX@/lib/$(AOUT) -current_version rev -compatibility_version rev -o $@~ ldobjs depobjs -flat_namespace -undefined suppress
+  #endif
+  
+  #define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
+--- 60,66 ----
+  #if 0
+  #define SharedLibraryCmd(ldobjs,extra_flags) $(LD) -r extra_flags -o $@~ ldobjs
+  #else
+! #define SharedLibraryCmdDarwin(ldobjs,depobjs,rev,libname) CCDriver -dynamiclib -install_name Prefix/lib/$(AOUT) -current_version rev -compatibility_version rev -o $@~ ldobjs depobjs -flat_namespace -undefined suppress
+  #endif
+  
+  #define NormalDynamicSharedLibraryTarget(libname,rev,depobjs,ldobjs)	@@\
+*** ./ivtools-1.2/configure.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/configure	2015-01-18 22:22:41.000000000 -0800
+***************
+*** 3586,3591 ****
+--- 3586,3593 ----
+  # Standard set of common directories for X headers.
+  # Check X11 before X11Rn because it is often a symlink to the current release.
+  ac_x_header_dirs='
++ /opt/X11/include
++ 
+  /usr/X11/include
+  /usr/X11R6/include
+  /usr/X11R5/include
+***************
+*** 3719,3725 ****
+  for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+  do
+    # Don't even attempt the hair of trying to link an X program!
+!   for ac_extension in a so sl; do
+      if test -r $ac_dir/libXt.$ac_extension; then
+        ac_x_libraries=$ac_dir
+        break 2
+--- 3721,3727 ----
+  for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+  do
+    # Don't even attempt the hair of trying to link an X program!
+!   for ac_extension in a so sl dylib; do
+      if test -r $ac_dir/libXt.$ac_extension; then
+        ac_x_libraries=$ac_dir
+        break 2
+*** ./ivtools-1.2/MANIFEST.comterp.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/MANIFEST.comterp	2015-01-25 17:31:18.000000000 -0800
+***************
+*** 283,288 ****
+--- 283,289 ----
+  src/include/Unidraw/umap.h
+  src/include/Unidraw/unidraw.h
+  src/include/ivstd/Imakefile
++ src/include/ivstd/fstream
+  src/include/ivstd/fstream.h
+  src/include/ivstd/iosfwd
+  src/include/ivstd/math.h
+*** ./ivtools-1.2/MANIFEST.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/MANIFEST	2015-01-25 17:30:51.000000000 -0800
+***************
+*** 1584,1589 ****
+--- 1584,1590 ----
+  ivtools-1.2/src/include/Unidraw/viewer.h
+  ivtools-1.2/src/include/ivstd/Imakefile
+  ivtools-1.2/src/include/ivstd/Makefile
++ ivtools-1.2/src/include/ivstd/fstream
+  ivtools-1.2/src/include/ivstd/fstream.h
+  ivtools-1.2/src/include/ivstd/iosfwd
+  ivtools-1.2/src/include/ivstd/iostream.h
+*** ./ivtools-1.2/src/comdraw/main.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/comdraw/main.c	2015-01-25 18:28:22.000000000 -0800
+***************
+*** 298,306 ****
+--- 298,308 ----
+      // Register COMTERP_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // COMTERP_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
++ #if 0
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, COMTERP_QUIT_HANDLER::instance ()) == -1)
+          cerr << "comdraw:  unable to register quit handler with ACE reactor\n";
++ #endif
+  
+  #endif
+      int exit_status = 0;
+*** ./ivtools-1.2/src/ComTerp/comhandler.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/comhandler.c	2015-01-25 17:08:57.000000000 -0800
+***************
+*** 26,36 ****
+  #ifdef HAVE_ACE
+  #include <iostream.h>
+  #include <fstream.h>
+- #if __GNUC__==2 && __GNUC_MINOR__<=7
+- #else
+  using namespace std;
+  #include <vector>
+- #endif
+  
+  #include <ComTerp/comhandler.h>
+  #include <ComTerp/comterpserv.h>
+--- 26,33 ----
+***************
+*** 140,150 ****
+  	    return -1;
+  	} else {
+  	    if (!comterp_->stack_empty()) {
+! #if __GNUC__<3
+! 	      filebuf obuf(1);
+! #else
+! 	      fileptr_filebuf obuf(stdout, ios_base::out);
+! #endif
+  	      ostream ostr(&obuf);
+  	      ostr << "timeexpr result:  ";
+  	      comterp_->print_stack_top(ostr);
+--- 137,143 ----
+  	    return -1;
+  	} else {
+  	    if (!comterp_->stack_empty()) {
+! 	      FILEBUF(obuf, stdout, ios_base::out);
+  	      ostream ostr(&obuf);
+  	      ostr << "timeexpr result:  ";
+  	      comterp_->print_stack_top(ostr);
+***************
+*** 206,212 ****
+      } else {
+        if (inbuf[0]!='\004')
+  	cout << "from pipe(" << fd << "):  " << inbuf << "\n";
+!       fileptr_filebuf obuf(fd ? wrfptr() : stdout, ios_base::out);
+        ostream ostr(&obuf);
+        ostr << "\n";
+        ostr.flush();
+--- 199,205 ----
+      } else {
+        if (inbuf[0]!='\004')
+  	cout << "from pipe(" << fd << "):  " << inbuf << "\n";
+!       FILEBUF(obuf, fd ? wrfptr() : stdout, ios_base::out);
+        ostream ostr(&obuf);
+        ostr << "\n";
+        ostr.flush();
+*** ./ivtools-1.2/src/ComTerp/comterp.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/comterp.c	2015-01-25 17:29:43.000000000 -0800
+***************
+*** 29,37 ****
+  #include <strstream>
+  #include <unistd.h>
+  
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  #include <ComTerp/comhandler.h>
+  
+--- 29,35 ----
+***************
+*** 72,80 ****
+  #include <string.h>
+  #include <strstream>
+  #include <unistd.h>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  #ifdef LEAKCHECK
+  #include <leakchecker.h>
+--- 70,76 ----
+***************
+*** 346,354 ****
+      }
+  
+      if (stepflag()) {
+!       fileptr_filebuf fbufout(handler() && handler()->wrfptr() 
+! 		      ? handler()->wrfptr() : stdout, 
+! 		      ios_base::out);
+        ostream out(&fbufout);
+        out << ">>> " << *func << "(" << *func->funcstate() << ")\n";
+        static int pause_symid = symbol_add("pause");
+--- 342,348 ----
+      }
+  
+      if (stepflag()) {
+!       FILEBUF(fbufout, handler() && handler()->wrfptr() ? handler()->wrfptr() : stdout, ios_base::out);
+        ostream out(&fbufout);
+        out << ">>> " << *func << "(" << *func->funcstate() << ")\n";
+        static int pause_symid = symbol_add("pause");
+***************
+*** 1071,1092 ****
+    char errbuf_save[BUFSIZ];
+    errbuf_save[0] = '\0';
+  
+! #if __GNUC__<3
+!   filebuf fbuf;
+!   if (handler()) {
+!     int fd = Math::max(1, handler()->get_handle());
+!     fbuf.attach(fd);
+!   } else
+!     fbuf.attach(fileno(stdout));
+! #elif (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 || defined(__CYGWIN__)
+!   fileptr_filebuf fbuf(handler() && handler()->wrfptr() 
+! 		       ? handler()->wrfptr() : (_fd>0 ? fdopen(_fd, "w") : stdout), 
+! 	       ios_base::out);
+! #else
+!   fileptr_filebuf fbuf(handler()&&handler()->get_handle()>0 
+! 		       ? handler()->get_handle() : 1, 
+! 		       ios_base::out, false, static_cast<size_t>(BUFSIZ));
+! #endif
+    ostream out(&fbuf);
+    boolean eolflag = false;
+    boolean errorflag = false;
+--- 1065,1071 ----
+    char errbuf_save[BUFSIZ];
+    errbuf_save[0] = '\0';
+  
+!   FILEBUF(fbuf, handler() && handler()->wrfptr() ? handler()->wrfptr() : (_fd>0 ? fdopen(_fd, "w") : stdout), ios_base::out);
+    ostream out(&fbuf);
+    boolean eolflag = false;
+    boolean errorflag = false;
+***************
+*** 1358,1364 ****
+  	if (read_expr()) {
+  	    if (eval_expr(true)) {
+  	        err_print( stderr, "comterp" );
+! 	        fileptr_filebuf obuf(stdout, ios_base::out);
+  		ostream ostr(&obuf);
+  		ostr << "err\n";
+  		ostr.flush();
+--- 1337,1343 ----
+  	if (read_expr()) {
+  	    if (eval_expr(true)) {
+  	        err_print( stderr, "comterp" );
+! 		FILEBUF(obuf, stdout, ios_base::out);
+  		ostream ostr(&obuf);
+  		ostr << "err\n";
+  		ostr.flush();
+***************
+*** 1672,1679 ****
+  
+  void ComTerp::postfix_echo(postfix_token* pfbuf, int pfnum) {
+    // print everything in the pfbuf for this function
+!   fileptr_filebuf fbuf(handler() && handler()->wrfptr()
+! 	       ? handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbuf);
+   
+    boolean oldbrief = brief();
+--- 1651,1657 ----
+  
+  void ComTerp::postfix_echo(postfix_token* pfbuf, int pfnum) {
+    // print everything in the pfbuf for this function
+!   FILEBUF(fbuf,handler() && handler()->wrfptr() ? handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbuf);
+   
+    boolean oldbrief = brief();
+*** ./ivtools-1.2/src/ComTerp/comterpserv.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/comterpserv.c	2015-01-25 16:49:11.000000000 -0800
+***************
+*** 32,40 ****
+  #include <OS/math.h>
+  #include <iostream.h>
+  #include <string.h>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  #if BUFSIZ>1024
+  #undef BUFSIZ
+--- 32,38 ----
+***************
+*** 194,200 ****
+      int fd = Math::max(server->_fd, 1);
+      char instr[BUFSIZ];
+      FILE* ifptr = fd==0 ? stdin : server->handler()->rdfptr();
+!     fileptr_filebuf fbuf(ifptr, ios_base::in);
+      istream in (&fbuf);
+      in.get(instr, BUFSIZ, '\n');  // needs to be generalized with <vector.h>
+      server->_instat = in.good(); 
+--- 192,198 ----
+      int fd = Math::max(server->_fd, 1);
+      char instr[BUFSIZ];
+      FILE* ifptr = fd==0 ? stdin : server->handler()->rdfptr();
+!     FILEBUF(fbuf, ifptr, ios_base::in);
+      istream in (&fbuf);
+      in.get(instr, BUFSIZ, '\n');  // needs to be generalized with <vector.h>
+      server->_instat = in.good(); 
+***************
+*** 229,235 ****
+  
+      int fd = (int)server->_fd;
+      FILE* ofptr = fd==1 ? stdout : server->handler()->wrfptr();
+!     fileptr_filebuf fbuf(ofptr, ios_base::out);
+      ostream out(&fbuf);
+      for (; outpos < bufsize-1 && s[outpos]; outpos++)
+  	out.put(s[outpos]);
+--- 227,233 ----
+  
+      int fd = (int)server->_fd;
+      FILE* ofptr = fd==1 ? stdout : server->handler()->wrfptr();
+!     FILEBUF(fbuf, ofptr, ios_base::out);
+      ostream out(&fbuf);
+      for (; outpos < bufsize-1 && s[outpos]; outpos++)
+  	out.put(s[outpos]);
+***************
+*** 284,290 ****
+        pop_servstate();
+        return -1;
+      }
+!     fileptr_filebuf ibuf(ifptr, ios_base::in);
+      istream istr(&ibuf);
+      ComValue* retval = nil;
+      int status = 0;
+--- 282,288 ----
+        pop_servstate();
+        return -1;
+      }
+!     FILEBUF(ibuf, ifptr, ios_base::in);
+      istream istr(&ibuf);
+      ComValue* retval = nil;
+      int status = 0;
+***************
+*** 334,340 ****
+  	        snprintf(buf, BUFSIZ, "comterp(%s)", filename);
+  	        err_print( stderr, buf );
+                  FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
+! 	        fileptr_filebuf obuf(ofptr, ios_base::out);
+  		ostream ostr(&obuf);
+  		ostr.flush();
+  		status = -1;
+--- 332,338 ----
+  	        snprintf(buf, BUFSIZ, "comterp(%s)", filename);
+  	        err_print( stderr, buf );
+                  FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
+! 	        FILEBUF(obuf, ofptr, ios_base::out);
+  		ostream ostr(&obuf);
+  		ostr.flush();
+  		status = -1;
+***************
+*** 371,377 ****
+            snprintf(buf, BUFSIZ, "comterp(%s)", filename);
+  	  err_print( stderr, buf );
+            FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
+! 	  fileptr_filebuf obuf(ofptr, ios_base::out);
+  	  ostream ostr(&obuf);
+  	  ostr.flush();
+  	  status = -1;
+--- 369,375 ----
+            snprintf(buf, BUFSIZ, "comterp(%s)", filename);
+  	  err_print( stderr, buf );
+            FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
+! 	  FILEBUF(obuf, ofptr, ios_base::out);
+  	  ostream ostr(&obuf);
+  	  ostr.flush();
+  	  status = -1;
+*** ./ivtools-1.2/src/ComTerp/ctrlfunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/ctrlfunc.c	2015-01-24 08:44:00.000000000 -0800
+***************
+*** 22,27 ****
+--- 22,28 ----
+   * 
+   */
+  
++ #include <unistd.h>
+  #include <fstream.h>
+  #include <iostream>
+  #include <ComTerp/comhandler.h>
+***************
+*** 41,52 ****
+  
+  #define TITLE "CtrlFunc"
+  
+- #if __GNUC__>=3
+  static char newline;
+! #if __GNUC__>3||__GNUC_MINOR_>1
+  #include <ext/stdio_filebuf.h>
+  #endif
+- #endif
+  
+  using std::cerr;
+  
+--- 42,51 ----
+  
+  #define TITLE "CtrlFunc"
+  
+  static char newline;
+! #ifndef __APPLE__
+  #include <ext/stdio_filebuf.h>
+  #endif
+  
+  using std::cerr;
+  
+***************
+*** 191,202 ****
+  
+  #ifdef HAVE_ACE
+  
+- #if __GNUC__==3&&__GNUC_MINOR__<1
+-   fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
+-   push_stack(ComValue::nullval());
+-   return;
+- #endif
+- 
+    ACE_SOCK_STREAM *socket = nil;
+    ACE_SOCK_Connector *conn = nil;
+    SocketObj* socketobj = nil;
+--- 190,195 ----
+***************
+*** 226,256 ****
+    } else
+      return;
+    
+- #if 0
+- #if __GNUC__<3
+-   filebuf ofbuf;
+-   ofbuf.attach(socket->get_handle());
+- #elif __GNUC__<4 && !defined(__CYGWIN__)
+-   fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out,
+- 			false, static_cast<size_t>(BUFSIZ));
+- #else
+-   fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out,
+- 			static_cast<size_t>(BUFSIZ));
+- #endif
+-   ostream out(&ofbuf);
+-   out << cmdstr;
+-   if (cmdstr[strlen(cmdstr)-1] != '\n') out << "\n";
+-   out.flush();
+- #else
+- #if 0
+-   int i=0;
+-   do {
+-     if(write(socket->get_handle(), cmdstr+i++, 1)!=1)
+-       fprintf(stderr, "Unexpected error writing byte to socket\n");
+-   } while ( cmdstr[i]!='\0');
+-   if (cmdstr[i-1] != '\n')  
+-     write(socket->get_handle(), "\n", 1);
+- #else
+    int cmdlen = strlen(cmdstr);
+    int newline_flag = cmdstr[cmdlen-1]=='\n';
+    if (!newline_flag) cmdstr[cmdlen]='\n';
+--- 219,224 ----
+***************
+*** 258,273 ****
+    if (nbytes != cmdlen+(newline_flag?0:1))
+        fprintf(stderr, "write to socket failed\n");
+    if (!newline_flag) cmdstr[cmdlen]='\0';
+- #endif
+- #endif
+    if (nowaitv.is_false()) {
+- #if __GNUC__<3
+-     filebuf ifbuf;
+-     ifbuf.attach(socket->get_handle());
+-     istream in(&ifbuf);
+-     char* buf;
+-     in.gets(&buf);
+- #else
+      char buf[BUFSIZ];
+      int i=0;
+      do {
+--- 226,232 ----
+***************
+*** 275,281 ****
+      } while (i<BUFSIZ-1 && buf[i-1]!='\n');
+      if (buf[i-1]=='\n') buf[i]=0;
+      // fprintf(stderr, "buf read back from remote %s", buf);
+- #endif
+      ComValue retval(comterpserv()->run(buf, true));
+      push_stack(retval);
+    }
+--- 234,239 ----
+***************
+*** 346,357 ****
+  
+  #ifdef HAVE_ACE
+  
+- #if __GNUC__==3&&__GNUC_MINOR__<1
+-   fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
+-   push_stack(ComValue::nullval());
+-   return;
+- #endif
+- 
+    if (hostv.is_string() && portv.is_known()) {
+  
+      const char* hoststr = hostv.string_ptr();
+--- 304,309 ----
+*** ./ivtools-1.2/src/ComTerp/debugfunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/debugfunc.c	2015-01-25 17:09:51.000000000 -0800
+***************
+*** 22,34 ****
+   * 
+   */
+  
+- #if __GNUC__==2 && __GNUC_MINOR__<=7
+- #else
+  #include <vector>
+- #endif
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  #include <ComTerp/comhandler.h>
+  
+--- 22,29 ----
+***************
+*** 82,91 ****
+    comterp()->npause()++;
+  
+    comterp()->push_servstate();
+!   fileptr_filebuf fbufin(comterp() && comterp()->handler() && comterp()->handler()->rdfptr() 
+  		 ? comterp()->handler()->rdfptr() : stdin, ios_base::in);
+    istream in(&fbufin);
+!   fileptr_filebuf fbufout(comterp()->handler() && comterp()->handler()->wrfptr()
+  		  ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbufout);
+  
+--- 77,86 ----
+    comterp()->npause()++;
+  
+    comterp()->push_servstate();
+!   FILEBUF(fbufin, comterp() && comterp()->handler() && comterp()->handler()->rdfptr() 
+  		 ? comterp()->handler()->rdfptr() : stdin, ios_base::in);
+    istream in(&fbufin);
+!   FILEBUF(fbufout, comterp()->handler() && comterp()->handler()->wrfptr()
+  		  ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbufout);
+  
+*** ./ivtools-1.2/src/ComTerp/helpfunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/helpfunc.c	2015-01-25 17:10:28.000000000 -0800
+***************
+*** 36,44 ****
+  
+  #include <iostream.h>
+  #include <strstream>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  #include <streambuf>
+  using std::streambuf;
+  
+--- 36,42 ----
+***************
+*** 96,102 ****
+  	    comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val();
+  	} else
+  	  comfuncs[i] = nil;
+- 	command_ids[i] = val.string_val();
+  	str_flags[i] = true;
+        } else {
+  	comfuncs[i] = nil;
+--- 94,99 ----
+***************
+*** 163,186 ****
+    reset_stack();
+  
+    std::strstreambuf sbuf;
+! #if __GNUC__<3
+!   filebuf fbuf;
+!   if (comterp()->handler() && HELPOUT) {
+!     int fd = Math::max(1, comterp()->handler()->get_handle());
+!     fbuf.attach(fd);
+!   } 
+!   ostream outs( (comterp()->handler() && HELPOUT) ? ((streambuf*)&fbuf) : (streambuf*)&sbuf );
+!   ostream *out = &outs;
+! #else
+!   fileptr_filebuf fbuf((comterp()->handler() && HELPOUT) && comterp()->handler()->wrfptr()
+  	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+- #if 1
+    ostream outs((comterp()->handler() && HELPOUT) ? (streambuf*)&fbuf : (streambuf*)&sbuf);
+- #else
+-   ostream outs((streambuf*)&fbuf);
+- #endif
+    ostream *out = &outs;
+! #endif
+  
+    if (noargs) {
+  
+--- 160,170 ----
+    reset_stack();
+  
+    std::strstreambuf sbuf;
+!   FILEBUF(fbuf, comterp()->handler() && HELPOUT && comterp()->handler()->wrfptr()
+  	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+    ostream outs((comterp()->handler() && HELPOUT) ? (streambuf*)&fbuf : (streambuf*)&sbuf);
+    ostream *out = &outs;
+! 
+  
+    if (noargs) {
+  
+***************
+*** 199,219 ****
+  	  if (first) 
+  	    first = false;
+  	  else
+- #if 0
+- 	    out->put('\n');
+- #else
+  	    *out << '\n';
+- #endif
+- #if __GNUC__<3
+- 	  out->form(comfuncs[i]->docstring2(), symbol_pntr(command_ids[i]));
+- #else
+  	  {
+  	    char buffer[BUFSIZ];
+  	    snprintf(buffer, BUFSIZ, 
+  		     comfuncs[i]->docstring2(), symbol_pntr(command_ids[i]));
+  	    *out << buffer;
+  	  }
+- #endif
+  	  printed = true;
+  	}
+        }
+--- 183,195 ----
+***************
+*** 234,249 ****
+  		  first = false;
+  		else
+  		  out->put('\n');
+- #if __GNUC__<3
+- 		out->form(comfunc->docstring2(), symbol_pntr(value->command_symid()));
+- #else
+  		{
+  		  char buffer[BUFSIZ];
+  		  snprintf(buffer, BUFSIZ, 
+  			   comfunc->docstring2(), symbol_pntr(value->command_symid()));
+  		  *out << buffer;
+  		}
+- #endif
+  	      } else 
+  		out_form((*out), "unknown operator: %s\n", symbol_pntr(command_ids[i]));
+  
+--- 210,221 ----
+***************
+*** 266,273 ****
+  
+    if (!comterp()->handler() || !HELPOUT) {
+      *out << '\0';
+!     int help_str_symid = symbol_add(sbuf.str());
+!     ComValue retval(sbuf.str()); 
+      push_stack(retval);
+    } else
+      out->flush();
+--- 238,245 ----
+  
+    if (!comterp()->handler() || !HELPOUT) {
+      *out << '\0';
+!     // int help_str_symid = symbol_add(sbuf.str());
+!     ComValue retval(sbuf.str());
+      push_stack(retval);
+    } else
+      out->flush();
+*** ./ivtools-1.2/src/ComTerp/iofunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/iofunc.c	2015-01-25 17:13:10.000000000 -0800
+***************
+*** 36,41 ****
+--- 36,42 ----
+  #include <fstream.h>
+  #endif
+  #include <streambuf>
++ #include <unistd.h>
+  
+  #define TITLE "IoFunc"
+  
+***************
+*** 116,157 ****
+    const char* fstr = formatstr.is_string() ? formatstr.string_ptr() : "nil";
+    ComValue::comterp(comterp());
+  
+- #if __GNUC__<3
+-   streambuf* strmbuf = nil;
+-   if (stringflag.is_false() && strflag.is_false() &&
+-       symbolflag.is_false() && symflag.is_false()) {
+-     filebuf * fbuf = new filebuf();
+-     strmbuf = fbuf;
+-     if (comterp()->handler()) {
+-       int fd = Math::max(1, comterp()->handler()->get_handle());
+-       fbuf->attach(fd);
+-     } else
+-       fbuf->attach(fileno(errflag.is_false() ? stdout : stderr));
+-   } else {
+-     strmbuf = new std::strstreambuf();
+-   }
+- #else
+    streambuf* strmbuf = nil;
+    if (stringflag.is_false() && strflag.is_false() &&
+        symbolflag.is_false() && symflag.is_false()) {
+      fileptr_filebuf * fbuf = nil;
+      if (comterp()->handler() && fileobjv.is_unknown() && errflag.is_false() && outflag.is_false()) {
+!       fbuf = new fileptr_filebuf(comterp()->handler() && comterp()->handler()->wrfptr() 
+! 			 ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+      } else if (fileobjv.is_known()) {
+        FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid());
+!       if (fileobj) 
+!         fbuf = new fileptr_filebuf(fileobj->fptr(), ios_base::out);
+!       else {
+          PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid());
+!         fbuf = new fileptr_filebuf(pipeobj ? pipeobj->wrfptr() : stdout, ios_base::out);
+        }
+!     } else 
+!       fbuf = new fileptr_filebuf(errflag.is_false() ? stdout : stderr, ios_base::out);
+      strmbuf = fbuf;
+    } else
+      strmbuf = new std::strstreambuf();
+- #endif
+    ostream out(strmbuf);
+  
+    int narg = nargsfixed();
+--- 117,143 ----
+    const char* fstr = formatstr.is_string() ? formatstr.string_ptr() : "nil";
+    ComValue::comterp(comterp());
+  
+    streambuf* strmbuf = nil;
+    if (stringflag.is_false() && strflag.is_false() &&
+        symbolflag.is_false() && symflag.is_false()) {
+      fileptr_filebuf * fbuf = nil;
+      if (comterp()->handler() && fileobjv.is_unknown() && errflag.is_false() && outflag.is_false()) {
+!       FILEBUFP(fbuf, comterp()->handler() && comterp()->handler()->wrfptr() 
+! 	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+      } else if (fileobjv.is_known()) {
+        FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid());
+!       if (fileobj) {
+!         FILEBUFP(fbuf, fileobj->fptr(), ios_base::out);
+!       } else {
+          PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid());
+!         FILEBUFP(fbuf, pipeobj ? pipeobj->wrfptr() : stdout, ios_base::out);
+        }
+!     } else {
+!       FILEBUFP(fbuf, errflag.is_false() ? stdout : stderr, ios_base::out);
+!     }
+      strmbuf = fbuf;
+    } else
+      strmbuf = new std::strstreambuf();
+    ostream out(strmbuf);
+  
+    int narg = nargsfixed();
+***************
+*** 373,378 ****
+--- 359,365 ----
+      PipeObj* pipeobj = new PipeObj(filenamev.string_ptr());
+      ComValue retval(PipeObj::class_symid(), (void*)pipeobj);
+      push_stack(retval);
++ #ifdef HAVE_ACE
+      if (Component::use_unidraw()) {
+        ComterpHandler* pipe_handler = new ComterpHandler(comterpserv());
+        if (ComterpHandler::reactor_singleton()->register_handler(pipeobj->rdfd(), pipe_handler, 
+***************
+*** 382,387 ****
+--- 369,375 ----
+        }
+        pipe_handler->log_only(1);
+      }
++ #endif
+    } else {
+      FileObj* fileobj = new FileObj(filenamev.string_ptr(), modev.is_string() ? modev.string_ptr() : "r", pipeflagv.is_true());
+      if (fileobj->fptr())  {
+*** ./ivtools-1.2/src/ComTerp/parser.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/parser.c	2015-01-24 08:46:20.000000000 -0800
+***************
+*** 30,38 ****
+  
+  #define TITLE "Parser"
+  
+- #if __GNUC__>=3
+  static char newline;
+- #endif
+  
+  /*****************************************************************************/
+  
+--- 30,36 ----
+***************
+*** 152,165 ****
+  
+  char* Parser::istream_fgets(char* s, int n, void* instreamp) {
+    istream& in  = *(istream*)instreamp;
+- #if __GNUC__<3
+-   char *instr;
+-   in.gets(&instr);
+- #else
+    char instr[BUFSIZ];
+    in.get(instr, BUFSIZ);  // needs to be generalized with <vector.h>
+    in.get(newline);
+- #endif
+    if (in.good()) {
+      int i = 0;
+      for (; i<n-2; i++) {
+--- 150,158 ----
+*** ./ivtools-1.2/src/ComTerp/postfunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComTerp/postfunc.c	2015-01-25 17:12:30.000000000 -0800
+***************
+*** 52,59 ****
+  
+  void PostFixFunc::execute() {
+    // print everything on the stack for this function
+!   fileptr_filebuf fbuf(comterp()->handler() && comterp()->handler()->wrfptr()
+! 	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbuf);
+   
+    boolean oldbrief = comterp()->brief();
+--- 52,59 ----
+  
+  void PostFixFunc::execute() {
+    // print everything on the stack for this function
+!   FILEBUF(fbuf, comterp()->handler() && comterp()->handler()->wrfptr()
+! 	  ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+    ostream out(&fbuf);
+   
+    boolean oldbrief = comterp()->brief();
+*** ./ivtools-1.2/src/comterp_/main.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/comterp_/main.c	2015-01-25 17:17:36.000000000 -0800
+***************
+*** 109,117 ****
+  	}
+  
+          // Perform logging service until COMTERP_QUIT_HANDLER receives SIGINT.
+!         while (COMTERP_QUIT_HANDLER::instance ()->is_set () == 0)
+              ComterpHandler::reactor_singleton()->handle_events ();
+!     
+          return 0;
+      }
+      if (client_flag || telcat_flag) {
+--- 109,117 ----
+  	}
+  
+          // Perform logging service until COMTERP_QUIT_HANDLER receives SIGINT.
+!         while (COMTERP_QUIT_HANDLER::instance ()->is_set () == 0) {
+              ComterpHandler::reactor_singleton()->handle_events ();
+! 	}
+          return 0;
+      }
+      if (client_flag || telcat_flag) {
+***************
+*** 134,155 ****
+  
+      if (!telcat_flag) {
+        
+- #if __GNUC__<3
+-       filebuf obuf;
+-       obuf.attach(server.get_handle());
+- #else
+        FILE* ofptr = nil;
+!       fileptr_filebuf obuf(ofptr = fdopen(server.get_handle(), "w"), ios_base::out);
+! #endif
+        ostream out(&obuf);
+        
+- #if __GNUC__<3
+-       filebuf ibuf;
+-       ibuf.attach(server.get_handle());
+- #else
+        FILE* ifptr = nil;
+!       fileptr_filebuf ibuf(ifptr = fdopen(server.get_handle(), "r"), ios_base::in);
+! #endif
+        
+        istream in(&ibuf);
+        
+--- 134,145 ----
+  
+      if (!telcat_flag) {
+        
+        FILE* ofptr = nil;
+!       FILEBUF(obuf, ofptr = fdopen(server.get_handle(), "w"), ios_base::out);
+        ostream out(&obuf);
+        
+        FILE* ifptr = nil;
+!       FILEBUF(ibuf, ifptr = fdopen(server.get_handle(), "r"), ios_base::in);
+        
+        istream in(&ibuf);
+        
+***************
+*** 158,176 ****
+  	if (feof(inptr)) break;
+  	out << buffer;
+  	out.flush();
+- #if __GNUC__<3
+- 	char* inbuf;
+- 	char ch;
+- 	ch = in.get();
+- 	if (ch == '>')
+- 	  ch = in.get(); // ' '
+- 	else {
+- 	  in.unget();
+- 	  in.gets(&inbuf);
+- 	  if (client_flag) 
+- 	    cout << inbuf << "\n";
+- 	}
+- #else
+  	char inbuf[BUFSIZ];
+  	char ch;
+  	ch = in.get();
+--- 148,153 ----
+***************
+*** 183,192 ****
+  	  if (client_flag) 
+  	    cout << inbuf << "\n";
+  	}
+- #endif
+        }
+  
+! #if __GNUC__>=3
+        if (ofptr) fclose(ofptr);
+        if (ifptr) fclose(ifptr);
+  #endif
+--- 160,168 ----
+  	  if (client_flag) 
+  	    cout << inbuf << "\n";
+  	}
+        }
+  
+! #ifndef __APPLE__
+        if (ofptr) fclose(ofptr);
+        if (ifptr) fclose(ifptr);
+  #endif
+***************
+*** 194,215 ****
+      } else if (inptr) {
+  
+  
+! #if __GNUC__<3
+!       filebuf inbuf;
+!       inbuf.attach(fileno(inptr));
+! #else
+!       fileptr_filebuf inbuf(inptr, ios_base::in);
+! #endif
+        istream in(&inbuf);
+        
+  
+! #if __GNUC__<3
+!       filebuf obuf;
+!       obuf.attach(server.get_handle());
+! #else
+!       FILE* ofptr = nil;
+!       fileptr_filebuf obuf(fdopen(server.get_handle(), "w"), ios_base::out);
+! #endif
+        ostream out(&obuf);
+  
+        char buffer[BUFSIZ*BUFSIZ];
+--- 170,180 ----
+      } else if (inptr) {
+  
+  
+!       FILEBUF(inbuf, inptr, ios_base::in);
+        istream in(&inbuf);
+        
+  
+!       FILEBUF(obuf, fdopen(server.get_handle(), "w"), ios_base::out);
+        ostream out(&obuf);
+  
+        char buffer[BUFSIZ*BUFSIZ];
+***************
+*** 219,225 ****
+  	  out.write(buffer, in.gcount());
+        }
+        out.flush();
+! #if __GNUC__>=3
+        if (ofptr) fclose(ofptr);
+  #endif
+      } else 
+--- 184,190 ----
+  	  out.write(buffer, in.gcount());
+        }
+        out.flush();
+! #ifndef __APPLE__
+        if (ofptr) fclose(ofptr);
+  #endif
+      } else 
+*** ./ivtools-1.2/src/ComUnidraw/unifunc.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComUnidraw/unifunc.c	2015-01-25 17:44:03.000000000 -0800
+***************
+*** 54,68 ****
+  #include <Unidraw/Graphic/graphic.h>
+  #include <InterViews/transformer.h>
+  #include <InterViews/window.h>
+  #include <ComTerp/comterpserv.h>
+  #include <ComTerp/comvalue.h>
+  #include <Attribute/attrlist.h>
+  #include <stdio.h>
+  #include <strstream>
+  #include <unistd.h>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  #include <string.h>
+  #include <iostream>
+  
+--- 54,67 ----
+  #include <Unidraw/Graphic/graphic.h>
+  #include <InterViews/transformer.h>
+  #include <InterViews/window.h>
++ #include <ComTerp/comhandler.h>
+  #include <ComTerp/comterpserv.h>
+  #include <ComTerp/comvalue.h>
+  #include <Attribute/attrlist.h>
+  #include <stdio.h>
+  #include <strstream>
+  #include <unistd.h>
+  #include <fstream.h>
+  #include <string.h>
+  #include <iostream>
+  
+***************
+*** 409,456 ****
+  #endif
+  
+  
+- #if __GNUC__<3
+-     filebuf fbuf;
+-     if (file.is_type(ComValue::StringType))
+-         fbuf.open(file.string_ptr(), "w");
+- 
+-     else if (sock.is_true()) {
+- #ifdef HAVE_ACE
+- 	ComTerpServ* terp = (ComTerpServ*)comterp();
+- 	ComterpHandler* handler = (ComterpHandler*)terp->handler();
+- 	if (handler) {
+- 	  ACE_SOCK_Stream peer = handler->peer();
+- 	  fbuf.attach(peer.get_handle());
+- 	}
+- 	else
+- #endif
+- 	  fbuf.attach(fileno(stdout));
+-     }
+- 
+-     else {
+- #ifdef HAVE_ACE
+-         const char* hoststr = nil;
+-         const char* portstr = nil;
+-         hoststr = host.type()==ComValue::StringType ? host.string_ptr() : nil;
+-         portstr = port.type()==ComValue::StringType ? port.string_ptr() : nil;
+-         u_short portnum = portstr ? atoi(portstr) : port.ushort_val();
+-     
+-         if (portnum) {
+-             socket = new ACE_SOCK_Stream;
+-             ACE_SOCK_Connector conn;
+-             ACE_INET_Addr addr (portnum, hoststr);
+-     
+-             if (conn.connect (*socket, addr) == -1)
+-                 ACE_ERROR ((LM_ERROR, "%p\n", "open"));
+-             fbuf.attach(socket->get_handle());
+-         } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) {
+-             fbuf.attach(comterp()->handler()->get_handle());
+-         } else
+- #endif
+-             fbuf.attach(fileno(stdout));
+-     }
+- 
+- #else
+  
+      filebuf* pfbuf;
+      FILE* ofptr = nil;
+--- 408,413 ----
+***************
+*** 467,477 ****
+  	if (handler) {
+  	  ACE_SOCK_Stream peer = handler->peer();
+  	  ofptr = fdopen(peer.get_handle(), "r");
+! 	  pfbuf = new fileptr_filebuf(ofptr, output);
+  	}
+  	else 
+  #endif
+! 	  pfbuf = new fileptr_filebuf(stdout, output);
+      }
+  
+      else {
+--- 424,434 ----
+  	if (handler) {
+  	  ACE_SOCK_Stream peer = handler->peer();
+  	  ofptr = fdopen(peer.get_handle(), "r");
+! 	  FILEBUFP(pfbuf, ofptr, output);
+  	}
+  	else 
+  #endif
+! 	  FILEBUFP(pfbuf, stdout, output);
+      }
+  
+      else {
+***************
+*** 489,512 ****
+      
+              if (conn.connect (*socket, addr) == -1)
+                  ACE_ERROR ((LM_ERROR, "%p\n", "open"));
+!             pfbuf = new fileptr_filebuf(ofptr = fdopen(socket->get_handle(), "r"), output);
+          } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) {
+!             pfbuf = new fileptr_filebuf(comterp()->handler()->rdfptr(), output);
+          } else
+  #endif
+!             pfbuf = new fileptr_filebuf(stdout, output);
+      }
+  
+- #endif
+      ostream* out;
+      if (string.is_true()||str.is_true())
+        out = new std::strstream();
+      else
+- #if __GNUC__<3      
+-       out = new ostream(&fbuf);
+- #else
+        out = new ostream(pfbuf);
+- #endif
+  
+      if (!compviewv.is_array()) {
+  
+--- 446,464 ----
+      
+              if (conn.connect (*socket, addr) == -1)
+                  ACE_ERROR ((LM_ERROR, "%p\n", "open"));
+!             FILEBUFP(pfbuf, ofptr = fdopen(socket->get_handle(), "r"), output);
+          } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) {
+! 	  FILEBUFP(pfbuf, comterp()->handler()->rdfptr(), output);
+          } else
+  #endif
+! 	  FILEBUFP(pfbuf, stdout, output);
+      }
+  
+      ostream* out;
+      if (string.is_true()||str.is_true())
+        out = new std::strstream();
+      else
+        out = new ostream(pfbuf);
+  
+      if (!compviewv.is_array()) {
+  
+***************
+*** 568,576 ****
+      }
+      delete out;
+  
+- #if __GNUC__>=3
+      delete pfbuf;
+- #endif    
+      
+  #ifdef HAVE_ACE
+      if (sock.is_false() && socket) {
+--- 520,526 ----
+*** ./ivtools-1.2/src/ComUtil/errsys.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComUtil/errsys.c	2015-01-22 12:06:29.000000000 -0800
+***************
+*** 212,225 ****
+      }
+  
+      if (!fptr) {
+! 	strcpy( fullpath, RELLIBALLDIR );
+  	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
+  	strcat( fullpath, errfile );
+  	fptr = fopen(fullpath, "r");
+      }
+      
+      if (!fptr) {
+! 	strcpy( fullpath, ABSLIBALLDIR );
+  	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
+  	strcat( fullpath, errfile );
+  	fptr = fopen(fullpath, "r");
+--- 212,225 ----
+      }
+  
+      if (!fptr) {
+! 	strcpy( fullpath, "RELLIBALLDIR" );
+  	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
+  	strcat( fullpath, errfile );
+  	fptr = fopen(fullpath, "r");
+      }
+      
+      if (!fptr) {
+! 	strcpy( fullpath, "ABSLIBALLDIR" );
+  	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
+  	strcat( fullpath, errfile );
+  	fptr = fopen(fullpath, "r");
+*** ./ivtools-1.2/src/ComUtil/Imakefile.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/ComUtil/Imakefile	2015-01-22 12:04:27.000000000 -0800
+***************
+*** 16,22 ****
+  Obj(comerr)
+  Obj(dmm)
+  Obj(errfile)
+! MakeObjectFromSrcFlags(errsys,-DABSLIBALLDIR=\"$(ABSLIBALLDIR)/\" -DRELLIBALLDIR=\"$(RELLIBALLDIR)/\")
+  Obj(funcptrs)
+  Obj(_lexscan)
+  Obj(mblock)
+--- 16,22 ----
+  Obj(comerr)
+  Obj(dmm)
+  Obj(errfile)
+! MakeObjectFromSrcFlags(errsys,-DABSLIBALLDIR=$(ABSLIBALLDIR)/ -DRELLIBALLDIR=$(RELLIBALLDIR)/)
+  Obj(funcptrs)
+  Obj(_lexscan)
+  Obj(mblock)
+*** ./ivtools-1.2/src/DrawServ/drawcatalog.c.dist	2015-01-27 13:46:29.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/drawcatalog.c	2015-01-27 11:45:50.000000000 -0800
+***************
+*** 37,45 ****
+  #include <iostream.h>
+  #include <stdio.h>
+  #include <string.h>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  /*****************************************************************************/
+  
+--- 37,43 ----
+***************
+*** 60,87 ****
+          _valid = true;
+  
+      } else {
+- #if __GNUC__<3
+-         filebuf fbuf;
+- #else
+          filebuf* pfbuf = nil;
+- #endif
+  	if (strcmp(name, "-") == 0) {
+! #if __GNUC__<3
+! 	    _valid = fbuf.attach(fileno(stdin)) != 0;
+! #else
+! 	    pfbuf = new fileptr_filebuf(stdin, input);
+  	    _valid = 1;
+- #endif
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+! #if __GNUC__<3
+! 	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
+! #else
+! 	    pfbuf = new fileptr_filebuf(fptr, input);
+  	    _valid = fptr ? 1 : 0;
+- #endif
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+--- 58,73 ----
+          _valid = true;
+  
+      } else {
+          filebuf* pfbuf = nil;
+  	if (strcmp(name, "-") == 0) {
+! 	    FILEBUFP(pfbuf, stdin, input);
+  	    _valid = 1;
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+! 	    FILEBUFP(pfbuf, fptr, input);
+  	    _valid = fptr ? 1 : 0;
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+***************
+*** 90,100 ****
+  	}
+  	
+          if (_valid) {
+- #if __GNUC__<3
+- 	    istream in(&fbuf);
+- #else
+  	    istream in(pfbuf);
+- #endif
+  	    const char* command = "drawserv";
+  	    int len = strlen(command)+1;
+  	    char buf[len];
+--- 76,82 ----
+***************
+*** 116,124 ****
+  		comp = nil;
+  	    }
+          }
+- #if __GNUC__>=3
+  	delete pfbuf;
+- #endif
+      }
+      
+      if (fptr) {
+--- 98,104 ----
+*** ./ivtools-1.2/src/DrawServ/drawfunc.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/drawfunc.c	2015-01-27 11:52:08.000000000 -0800
+***************
+*** 82,93 ****
+    ComValue userv(stack_key(user_sym));
+    reset_stack();
+  
+- #if __GNUC__==3&&__GNUC_MINOR__<1
+-   fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
+-   push_stack(ComValue::nullval());
+-   return;
+- #endif
+- 
+    DrawLink* link = nil;
+  
+    /* creating a new link to remote drawserv */
+--- 82,87 ----
+***************
+*** 97,115 ****
+      if (statev.int_val()==DrawLink::one_way && 
+  	((DrawServ*)unidraw)->cycletest
+  	(sidv.uint_val(), hostv.string_ptr(), userv.string_ptr(), pidv.int_val())) {
+! #if 1
+! #if __GNUC__<4 && !defined(__CYGWIN__)
+!       fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, false, static_cast<size_t>(BUFSIZ));
+! #else
+!       fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, static_cast<size_t>(BUFSIZ));
+! #endif
+        ostream out(&obuf);
+        out << "ackback(cycle)\n";
+        out.flush();
+        comterp()->quit();
+- #else
+-       comterp()->handler()->destroy();
+- #endif
+        return;
+      }
+      
+--- 91,101 ----
+      if (statev.int_val()==DrawLink::one_way && 
+  	((DrawServ*)unidraw)->cycletest
+  	(sidv.uint_val(), hostv.string_ptr(), userv.string_ptr(), pidv.int_val())) {
+!       FILEBUF(obuf, comterp()->handler()->wrfptr(), ios_base::out);
+        ostream out(&obuf);
+        out << "ackback(cycle)\n";
+        out.flush();
+        comterp()->quit();
+        return;
+      }
+      
+***************
+*** 203,213 ****
+  
+    reset_stack();
+  
+- #if __GNUC__==3&&__GNUC_MINOR__<1
+-   fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
+-   push_stack(ComValue::nullval());
+-   return;
+- #endif
+    DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil;
+    DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil;
+    
+--- 189,194 ----
+***************
+*** 233,238 ****
+--- 214,220 ----
+  
+  /*****************************************************************************/
+  
++ #ifdef HAVE_ACE
+  GraphicIdFunc::GraphicIdFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
+  }
+  
+***************
+*** 292,297 ****
+--- 274,280 ----
+    }
+  }
+  
++ #endif /* defined(HAVE_ACE) */
+  
+  /*****************************************************************************/
+  
+*** ./ivtools-1.2/src/DrawServ/drawfunc.h.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/drawfunc.h	2015-01-24 10:59:14.000000000 -0800
+***************
+*** 47,52 ****
+--- 47,53 ----
+  	return "%s([sid osid :pid pid :user namestr :host hoststr :hostid hostid :remap] | :all) -- command to manage session id's"; }
+  };
+  
++ #ifdef HAVE_ACE
+  //: command to send message between remote selections
+  // grid(id selector :state selected :request newselector :grant oldselector) -- command to send message between remote selections
+  class GraphicIdFunc : public UnidrawFunc {
+***************
+*** 66,71 ****
+--- 67,73 ----
+      virtual const char* docstring() { 
+  	return "%s(id) -- command to change session (or graphic id) to use local session id"; }
+  };
++ #endif /* defined(HAVE_ACE) */
+  
+  //: command to return point list associated with a graphic
+  // ptlist=points(compview) -- return point list from compview graphic
+*** ./ivtools-1.2/src/DrawServ/drawlink.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/drawlink.c	2015-01-27 11:53:36.000000000 -0800
+***************
+*** 99,109 ****
+      if (ComterpHandler::reactor_singleton()->register_handler(ackhandler(), ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1)
+        fprintf(stderr, "drawserv: error registering ackback handler (handle==%d)\n", _socket->get_handle());
+  
+! #if __GNUC__<4 && !defined(__CYGWIN__)
+!     fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, false, static_cast<size_t>(BUFSIZ));
+! #else
+!     fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, static_cast<size_t>(BUFSIZ));
+! #endif
+      ostream out(&obuf);
+      out << "drawlink(\"";
+      char buffer[HOST_NAME_MAX];
+--- 99,105 ----
+      if (ComterpHandler::reactor_singleton()->register_handler(ackhandler(), ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1)
+        fprintf(stderr, "drawserv: error registering ackback handler (handle==%d)\n", _socket->get_handle());
+  
+!     FILEBUF(obuf, fdopen(_socket->get_handle(), "w"), ios_base::out);
+      ostream out(&obuf);
+      out << "drawlink(\"";
+      char buffer[HOST_NAME_MAX];
+*** ./ivtools-1.2/src/DrawServ/drawserv.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/drawserv.c	2015-01-27 11:55:32.000000000 -0800
+***************
+*** 368,378 ****
+      if (link && link != orglink && link->state()==DrawLink::two_way) {
+        int fd = link->handle();
+        if (fd>=0) {
+! #if __GNUC__<4 && !defined(__CYGWIN__)
+! 	fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast<size_t>(BUFSIZ));
+! #else
+! 	fileptr_filebuf fbuf(fd, ios_base::out, static_cast<size_t>(BUFSIZ));
+! #endif
+  	ostream out(&fbuf);
+  	out << cmdstring;
+  	out << "\n";
+--- 368,374 ----
+      if (link && link != orglink && link->state()==DrawLink::two_way) {
+        int fd = link->handle();
+        if (fd>=0) {
+! 	FILEBUF(fbuf, fdopen(fd, "w"), ios_base::out);
+  	ostream out(&fbuf);
+  	out << cmdstring;
+  	out << "\n";
+***************
+*** 390,400 ****
+    if (link) {
+      int fd = link->handle();
+      if (fd>=0) {
+! #if __GNUC__<4 && !defined(__CYGWIN__)
+!       fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast<size_t>(BUFSIZ));
+! #else
+!       fileptr_filebuf fbuf(fd, ios_base::out, static_cast<size_t>(BUFSIZ));
+! #endif
+        ostream out(&fbuf);
+        out << cmdstring;
+        out << "\n";
+--- 386,392 ----
+    if (link) {
+      int fd = link->handle();
+      if (fd>=0) {
+!       FILEBUF(fbuf, fdopen(fd, "w"), ios_base::out);
+        ostream out(&fbuf);
+        out << cmdstring;
+        out << "\n";
+*** ./ivtools-1.2/src/DrawServ/Imakefile.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/DrawServ/Imakefile	2015-01-24 11:01:02.000000000 -0800
+***************
+*** 32,37 ****
+--- 32,39 ----
+  Obj26A(drawlink)
+  Obj26(drawlinkcomp)
+  Obj26(drawlinklist)
++ #else
++ Obj26(drawfunc)
+  #endif
+  Obj26(drawserv)
+  Obj26A(drawserv-handler)
+*** ./ivtools-1.2/src/drawserv_/main.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/drawserv_/main.c	2015-01-27 11:56:03.000000000 -0800
+***************
+*** 283,291 ****
+--- 283,293 ----
+      // Register COMTERP_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // COMTERP_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
++ #if 0
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, COMTERP_QUIT_HANDLER::instance ()) == -1)
+          cerr << "drawserv:  unable to register quit handler with ACE reactor\n";
++ #endif
+  
+  #endif
+  
+*** ./ivtools-1.2/src/drawtool/main.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/drawtool/main.c	2015-01-27 13:45:37.000000000 -0800
+***************
+*** 263,272 ****
+      // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
+          cerr << "drawtool:  unable to register quit handler with ACE reactor\n";
+! 
+  #endif
+  
+      if (argc > 2) {
+--- 263,273 ----
+      // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
++ #if 0
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
+          cerr << "drawtool:  unable to register quit handler with ACE reactor\n";
+! #endif
+  #endif
+  
+      if (argc > 2) {
+*** ./ivtools-1.2/src/flipbook/main.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/flipbook/main.c	2015-01-25 18:30:19.000000000 -0800
+***************
+*** 284,292 ****
+--- 284,294 ----
+      // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
++ #if 0
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
+          cerr << "flipbook:  unable to register quit handler with ACE reactor\n";
++ #endif
+  
+  #endif
+      if (argc > 2) {
+*** ./ivtools-1.2/src/FrameUnidraw/framecatalog.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/FrameUnidraw/framecatalog.c	2015-01-27 11:37:50.000000000 -0800
+***************
+*** 56,83 ****
+          _valid = true;
+  
+      } else {
+- #if __GNUC__<3
+-         filebuf fbuf;
+- #else
+          filebuf* pfbuf = nil;
+- #endif
+  	if (strcmp(name, "-") == 0) {
+! #if __GNUC__<3
+! 	    _valid = fbuf.attach(fileno(stdin)) != 0;
+! #else
+! 	    pfbuf = new fileptr_filebuf(stdin, input);
+  	    _valid = 1;
+- #endif
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+! #if __GNUC__<3
+! 	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
+! #else
+! 	    pfbuf = fptr ? new fileptr_filebuf(fptr, input) : nil;
+  	    _valid = fptr ? 1 : 0;
+- #endif
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+--- 56,73 ----
+          _valid = true;
+  
+      } else {
+          filebuf* pfbuf = nil;
+  	if (strcmp(name, "-") == 0) {
+! 	    FILEBUFP(pfbuf, stdin, input);
+  	    _valid = 1;
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+!             if (fptr) {
+!  	        FILEBUFP(pfbuf, fptr, input);
+! 	    }
+  	    _valid = fptr ? 1 : 0;
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+***************
+*** 86,96 ****
+  	}
+  
+          if (_valid) {
+- #if __GNUC__<3
+- 	    istream in(&fbuf);
+- #else
+  	    istream in(pfbuf);
+- #endif
+  
+  	    char ch;
+  	    while (isspace(ch = in.get())); in.putback(ch);
+--- 76,82 ----
+***************
+*** 115,123 ****
+  	    }
+          }
+  
+- #if __GNUC__>=3
+  	delete pfbuf;
+- #endif
+      }
+  
+      if (fptr) {
+--- 101,107 ----
+*** ./ivtools-1.2/src/graphdraw/main.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/graphdraw/main.c	2015-01-27 11:44:11.000000000 -0800
+***************
+*** 270,279 ****
+      // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
+          cerr << "graphdraw:  unable to register quit handler with ACE reactor\n";
+! 
+  #endif
+  
+      const char* initial_file = (argc == 2) ? argv[1] : nil;
+--- 270,280 ----
+      // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
+      // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
+      // exit.
++ #if 0
+      if (ComterpHandler::reactor_singleton()->register_handler 
+  	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
+          cerr << "graphdraw:  unable to register quit handler with ACE reactor\n";
+! #endif
+  #endif
+  
+      const char* initial_file = (argc == 2) ? argv[1] : nil;
+*** ./ivtools-1.2/src/GraphUnidraw/graphcatalog.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/GraphUnidraw/graphcatalog.c	2015-01-25 18:16:17.000000000 -0800
+***************
+*** 52,60 ****
+  #include <stdio.h>
+  #include <stream.h>
+  #include <string.h>
+- #if __GNUC__>=3
+  #include <fstream.h>
+- #endif
+  
+  /*****************************************************************************/
+  
+--- 52,58 ----
+***************
+*** 75,102 ****
+          _valid = true;
+  
+      } else {
+- #if __GNUC__<3
+-         filebuf fbuf;
+- #else
+  	filebuf* pfbuf = nil;
+- #endif
+  	if (strcmp(name, "-") == 0) {
+! #if __GNUC__<3
+! 	    _valid = fbuf.attach(fileno(stdin)) != 0;
+! #else
+! 	    pfbuf = new fileptr_filebuf(stdin, input);
+  	    _valid = 1;
+- #endif
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+! #if __GNUC__<3
+! 	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
+! #else
+! 	    pfbuf = new fileptr_filebuf(fptr, input);
+  	    _valid = fptr ? 1 : 0;
+- #endif
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+--- 73,88 ----
+          _valid = true;
+  
+      } else {
+  	filebuf* pfbuf = nil;
+  	if (strcmp(name, "-") == 0) {
+! 	    FILEBUFP(pfbuf, stdin, input);
+  	    _valid = 1;
+  	    name = nil;
+  	} else {
+  	    fptr = fopen(name, "r");
+  	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+! 	    FILEBUFP(pfbuf, fptr, input);
+  	    _valid = fptr ? 1 : 0;
+  	    if (compressed) {
+  		int namelen = strlen(name);
+  		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+***************
+*** 105,115 ****
+  	}
+  
+          if (_valid) {
+- #if __GNUC__<3
+- 	    istream in(&fbuf);
+- #else
+  	    istream in(pfbuf);
+- #endif
+  
+  	    char ch;
+  	    while (isspace(ch = in.get())); in.putback(ch);
+--- 91,97 ----
+***************
+*** 131,139 ****
+  		comp = nil;
+  	    }
+          }
+- #if __GNUC__>=3
+  	delete pfbuf;
+- #endif
+      }
+  
+      if (fptr) {
+--- 113,119 ----
+*** ./ivtools-1.2/src/include/ivstd/fstream.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/include/ivstd/fstream	2015-01-25 16:33:09.000000000 -0800
+***************
+*** 0 ****
+--- 1,1571 ----
++ #ifndef __APPLE__
++ #include_next <fstream>
++ #else
++ // -*- C++ -*-
++ //===------------------------- fstream ------------------------------------===//
++ //
++ //                     The LLVM Compiler Infrastructure
++ //
++ // This file is dual licensed under the MIT and the University of Illinois Open
++ // Source Licenses. See LICENSE.TXT for details.
++ //
++ //===----------------------------------------------------------------------===//
++ 
++ #ifndef _LIBCPP_FSTREAM
++ #define _LIBCPP_FSTREAM
++ 
++ /*
++     fstream synopsis
++ 
++ template <class charT, class traits = char_traits<charT> >
++ class basic_filebuf
++     : public basic_streambuf<charT, traits>
++ {
++ public:
++     typedef charT                          char_type;
++     typedef traits                         traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     // 27.9.1.2 Constructors/destructor:
++     basic_filebuf();
++     basic_filebuf(basic_filebuf&& rhs);
++     virtual ~basic_filebuf();
++ 
++     // 27.9.1.3 Assign/swap:
++     basic_filebuf& operator=(basic_filebuf&& rhs);
++     void swap(basic_filebuf& rhs);
++ 
++     // 27.9.1.4 Members:
++     bool is_open() const;
++     basic_filebuf* open(const char* s, ios_base::openmode mode);
++     basic_filebuf* open(const string& s, ios_base::openmode mode);
++     basic_filebuf* open(FILE* fp, ios_base::openmode mode);
++     basic_filebuf* close();
++ 
++ protected:
++     // 27.9.1.5 Overridden virtual functions:
++     virtual streamsize showmanyc();
++     virtual int_type underflow();
++     virtual int_type uflow();
++     virtual int_type pbackfail(int_type c = traits_type::eof());
++     virtual int_type overflow (int_type c = traits_type::eof());
++     virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* s, streamsize n);
++     virtual pos_type seekoff(off_type off, ios_base::seekdir way,
++                              ios_base::openmode which = ios_base::in | ios_base::out);
++     virtual pos_type seekpos(pos_type sp,
++                              ios_base::openmode which = ios_base::in | ios_base::out);
++     virtual int sync();
++     virtual void imbue(const locale& loc);
++ };
++ 
++ template <class charT, class traits>
++   void
++   swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
++ 
++ typedef basic_filebuf<char>    filebuf;
++ typedef basic_filebuf<wchar_t> wfilebuf;
++ 
++ template <class charT, class traits = char_traits<charT> >
++ class basic_ifstream
++     : public basic_istream<charT,traits>
++ {
++ public:
++     typedef charT                          char_type;
++     typedef traits                         traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_ifstream();
++     explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
++     explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
++     basic_ifstream(basic_ifstream&& rhs);
++ 
++     basic_ifstream& operator=(basic_ifstream&& rhs);
++     void swap(basic_ifstream& rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* s, ios_base::openmode mode = ios_base::in);
++     void open(const string& s, ios_base::openmode mode = ios_base::in);
++     void open(FILE* fp, ios_base::openmode mode = ios_base::in);
++     void close();
++ };
++ 
++ template <class charT, class traits>
++   void
++   swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
++ 
++ typedef basic_ifstream<char>    ifstream;
++ typedef basic_ifstream<wchar_t> wifstream;
++ 
++ template <class charT, class traits = char_traits<charT> >
++ class basic_ofstream
++     : public basic_ostream<charT,traits>
++ {
++ public:
++     typedef charT                          char_type;
++     typedef traits                         traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_ofstream();
++     explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
++     explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
++     basic_ofstream(basic_ofstream&& rhs);
++ 
++     basic_ofstream& operator=(basic_ofstream&& rhs);
++     void swap(basic_ofstream& rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* s, ios_base::openmode mode = ios_base::out);
++     void open(const string& s, ios_base::openmode mode = ios_base::out);
++     void open(FILE* fp, ios_base::openmode mode = ios_base::out);
++     void close();
++ };
++ 
++ template <class charT, class traits>
++   void
++   swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
++ 
++ typedef basic_ofstream<char>    ofstream;
++ typedef basic_ofstream<wchar_t> wofstream;
++ 
++ template <class charT, class traits=char_traits<charT> >
++ class basic_fstream
++     : public basic_iostream<charT,traits>
++ {
++ public:
++     typedef charT                          char_type;
++     typedef traits                         traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_fstream();
++     explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
++     explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
++     explicit basic_fstream(FILE* fp, ios_base::openmode mode = ios_base::in|ios_base::out);
++     basic_fstream(basic_fstream&& rhs);
++ 
++     basic_fstream& operator=(basic_fstream&& rhs);
++     void swap(basic_fstream& rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
++     void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
++     void open(FILE* fp, ios_base::openmode mode = ios_base::in|ios_base::out);
++     void close();
++ };
++ 
++ template <class charT, class traits>
++   void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
++ 
++ typedef basic_fstream<char>    fstream;
++ typedef basic_fstream<wchar_t> wfstream;
++ 
++ }  // std
++ 
++ */
++ 
++ #include <__config>
++ #include <ostream>
++ #include <istream>
++ #include <__locale>
++ #include <cstdio>
++ 
++ #include <__undef_min_max>
++ 
++ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
++ #pragma GCC system_header
++ #endif
++ 
++ _LIBCPP_BEGIN_NAMESPACE_STD
++ 
++ template <class _CharT, class _Traits>
++ class _LIBCPP_TYPE_VIS_ONLY basic_filebuf
++     : public basic_streambuf<_CharT, _Traits>
++ {
++ public:
++     typedef _CharT                           char_type;
++     typedef _Traits                          traits_type;
++     typedef typename traits_type::int_type   int_type;
++     typedef typename traits_type::pos_type   pos_type;
++     typedef typename traits_type::off_type   off_type;
++     typedef typename traits_type::state_type state_type;
++ 
++     // 27.9.1.2 Constructors/destructor:
++     basic_filebuf();
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_filebuf(basic_filebuf&& __rhs);
++ #endif
++     virtual ~basic_filebuf();
++ 
++     // 27.9.1.3 Assign/swap:
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_filebuf& operator=(basic_filebuf&& __rhs);
++ #endif
++     void swap(basic_filebuf& __rhs);
++ 
++     // 27.9.1.4 Members:
++     bool is_open() const;
++     basic_filebuf* open(const char* __s, ios_base::openmode __mode);
++     basic_filebuf* open(const string& __s, ios_base::openmode __mode);
++     basic_filebuf* open(FILE* fd, ios_base::openmode __mode);
++     basic_filebuf* close();
++ 
++ protected:
++     // 27.9.1.5 Overridden virtual functions:
++     virtual int_type underflow();
++     virtual int_type pbackfail(int_type __c = traits_type::eof());
++     virtual int_type overflow (int_type __c = traits_type::eof());
++     virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
++     virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
++                              ios_base::openmode __wch = ios_base::in | ios_base::out);
++     virtual pos_type seekpos(pos_type __sp,
++                              ios_base::openmode __wch = ios_base::in | ios_base::out);
++     virtual int sync();
++     virtual void imbue(const locale& __loc);
++ 
++ private:
++     int __fpflag;
++     char*       __extbuf_;
++     const char* __extbufnext_;
++     const char* __extbufend_;
++     char __extbuf_min_[8];
++     size_t __ebs_;
++     char_type* __intbuf_;
++     size_t __ibs_;
++     FILE* __file_;
++     const codecvt<char_type, char, state_type>* __cv_;
++     state_type __st_;
++     state_type __st_last_;
++     ios_base::openmode __om_;
++     ios_base::openmode __cm_;
++     bool __owns_eb_;
++     bool __owns_ib_;
++     bool __always_noconv_;
++ 
++     bool __read_mode();
++     void __write_mode();
++ };
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>::basic_filebuf()
++     : __fpflag(0),
++       __extbuf_(0),
++       __extbufnext_(0),
++       __extbufend_(0),
++       __ebs_(0),
++       __intbuf_(0),
++       __ibs_(0),
++       __file_(0),
++       __cv_(nullptr),
++       __st_(),
++       __st_last_(),
++       __om_(0),
++       __cm_(0),
++       __owns_eb_(false),
++       __owns_ib_(false),
++       __always_noconv_(false)
++ {
++     if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
++     {
++         __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
++         __always_noconv_ = __cv_->always_noconv();
++     }
++     setbuf(0, 4096);
++ }
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
++     : basic_streambuf<_CharT, _Traits>(__rhs)
++ {
++     if (__rhs.__extbuf_ == __rhs.__extbuf_min_)
++     {
++         __extbuf_ = __extbuf_min_;
++         __extbufnext_ = __extbuf_ + (__rhs.__extbufnext_ - __rhs.__extbuf_);
++         __extbufend_ = __extbuf_ + (__rhs.__extbufend_ - __rhs.__extbuf_);
++     }
++     else
++     {
++         __extbuf_ = __rhs.__extbuf_;
++         __extbufnext_ = __rhs.__extbufnext_;
++         __extbufend_ = __rhs.__extbufend_;
++     }
++     __ebs_ = __rhs.__ebs_;
++     __intbuf_ = __rhs.__intbuf_;
++     __ibs_ = __rhs.__ibs_;
++     __file_ = __rhs.__file_;
++     __cv_ = __rhs.__cv_;
++     __st_ = __rhs.__st_;
++     __st_last_ = __rhs.__st_last_;
++     __om_ = __rhs.__om_;
++     __cm_ = __rhs.__cm_;
++     __owns_eb_ = __rhs.__owns_eb_;
++     __owns_ib_ = __rhs.__owns_ib_;
++     __always_noconv_ = __rhs.__always_noconv_;
++     if (__rhs.pbase())
++     {
++         if (__rhs.pbase() == __rhs.__intbuf_)
++             this->setp(__intbuf_, __intbuf_ + (__rhs. epptr() - __rhs.pbase()));
++         else
++             this->setp((char_type*)__extbuf_,
++                        (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
++         this->pbump(__rhs. pptr() - __rhs.pbase());
++     }
++     else if (__rhs.eback())
++     {
++         if (__rhs.eback() == __rhs.__intbuf_)
++             this->setg(__intbuf_, __intbuf_ + (__rhs.gptr() - __rhs.eback()),
++                                   __intbuf_ + (__rhs.egptr() - __rhs.eback()));
++         else
++             this->setg((char_type*)__extbuf_,
++                        (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
++                        (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
++     }
++     __rhs.__extbuf_ = 0;
++     __rhs.__extbufnext_ = 0;
++     __rhs.__extbufend_ = 0;
++     __rhs.__ebs_ = 0;
++     __rhs.__intbuf_ = 0;
++     __rhs.__ibs_ = 0;
++     __rhs.__file_ = 0;
++     __rhs.__st_ = state_type();
++     __rhs.__st_last_ = state_type();
++     __rhs.__om_ = 0;
++     __rhs.__cm_ = 0;
++     __rhs.__owns_eb_ = false;
++     __rhs.__owns_ib_ = false;
++     __rhs.setg(0, 0, 0);
++     __rhs.setp(0, 0);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_filebuf<_CharT, _Traits>&
++ basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
++ {
++     close();
++     swap(__rhs);
++     return *this;
++ }
++ 
++ #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>::~basic_filebuf()
++ {
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++     try
++     {
++ #endif  // _LIBCPP_NO_EXCEPTIONS
++         close();
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++     }
++     catch (...)
++     {
++     }
++ #endif  // _LIBCPP_NO_EXCEPTIONS
++     if (__owns_eb_)
++         delete [] __extbuf_;
++     if (__owns_ib_)
++         delete [] __intbuf_;
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
++ {
++     basic_streambuf<char_type, traits_type>::swap(__rhs);
++     if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
++     {
++         _VSTD::swap(__extbuf_, __rhs.__extbuf_);
++         _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
++         _VSTD::swap(__extbufend_, __rhs.__extbufend_);
++     }
++     else
++     {
++         ptrdiff_t __ln = __extbufnext_ - __extbuf_;
++         ptrdiff_t __le = __extbufend_ - __extbuf_;
++         ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
++         ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
++         if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
++         {
++             __extbuf_ = __rhs.__extbuf_;
++             __rhs.__extbuf_ = __rhs.__extbuf_min_;
++         }
++         else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
++         {
++             __rhs.__extbuf_ = __extbuf_;
++             __extbuf_ = __extbuf_min_;
++         }
++         __extbufnext_ = __extbuf_ + __rn;
++         __extbufend_ = __extbuf_ + __re;
++         __rhs.__extbufnext_ = __rhs.__extbuf_ + __ln;
++         __rhs.__extbufend_ = __rhs.__extbuf_ + __le;
++     }
++     _VSTD::swap(__ebs_, __rhs.__ebs_);
++     _VSTD::swap(__intbuf_, __rhs.__intbuf_);
++     _VSTD::swap(__ibs_, __rhs.__ibs_);
++     _VSTD::swap(__file_, __rhs.__file_);
++     _VSTD::swap(__cv_, __rhs.__cv_);
++     _VSTD::swap(__st_, __rhs.__st_);
++     _VSTD::swap(__st_last_, __rhs.__st_last_);
++     _VSTD::swap(__om_, __rhs.__om_);
++     _VSTD::swap(__cm_, __rhs.__cm_);
++     _VSTD::swap(__owns_eb_, __rhs.__owns_eb_);
++     _VSTD::swap(__owns_ib_, __rhs.__owns_ib_);
++     _VSTD::swap(__always_noconv_, __rhs.__always_noconv_);
++     if (this->eback() == (char_type*)__rhs.__extbuf_min_)
++     {
++         ptrdiff_t __n = this->gptr() - this->eback();
++         ptrdiff_t __e = this->egptr() - this->eback();
++         this->setg((char_type*)__extbuf_min_,
++                    (char_type*)__extbuf_min_ + __n,
++                    (char_type*)__extbuf_min_ + __e);
++     }
++     else if (this->pbase() == (char_type*)__rhs.__extbuf_min_)
++     {
++         ptrdiff_t __n = this->pptr() - this->pbase();
++         ptrdiff_t __e = this->epptr() - this->pbase();
++         this->setp((char_type*)__extbuf_min_,
++                    (char_type*)__extbuf_min_ + __e);
++         this->pbump(__n);
++     }
++     if (__rhs.eback() == (char_type*)__extbuf_min_)
++     {
++         ptrdiff_t __n = __rhs.gptr() - __rhs.eback();
++         ptrdiff_t __e = __rhs.egptr() - __rhs.eback();
++         __rhs.setg((char_type*)__rhs.__extbuf_min_,
++                    (char_type*)__rhs.__extbuf_min_ + __n,
++                    (char_type*)__rhs.__extbuf_min_ + __e);
++     }
++     else if (__rhs.pbase() == (char_type*)__extbuf_min_)
++     {
++         ptrdiff_t __n = __rhs.pptr() - __rhs.pbase();
++         ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
++         __rhs.setp((char_type*)__rhs.__extbuf_min_,
++                    (char_type*)__rhs.__extbuf_min_ + __e);
++         __rhs.pbump(__n);
++     }
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
++ {
++     __x.swap(__y);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ bool
++ basic_filebuf<_CharT, _Traits>::is_open() const
++ {
++     return __file_ != 0;
++ }
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>*
++ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
++ {
++     basic_filebuf<_CharT, _Traits>* __rt = 0;
++     if (__file_ == 0)
++     {
++         __rt = this;
++         const char* __mdstr;
++         switch (__mode & ~ios_base::ate)
++         {
++         case ios_base::out:
++         case ios_base::out | ios_base::trunc:
++             __mdstr = "w";
++             break;
++         case ios_base::out | ios_base::app:
++         case ios_base::app:
++             __mdstr = "a";
++             break;
++         case ios_base::in:
++             __mdstr = "r";
++             break;
++         case ios_base::in | ios_base::out:
++             __mdstr = "r+";
++             break;
++         case ios_base::in | ios_base::out | ios_base::trunc:
++             __mdstr = "w+";
++             break;
++         case ios_base::in | ios_base::out | ios_base::app:
++         case ios_base::in | ios_base::app:
++             __mdstr = "a+";
++             break;
++         case ios_base::out | ios_base::binary:
++         case ios_base::out | ios_base::trunc | ios_base::binary:
++             __mdstr = "wb";
++             break;
++         case ios_base::out | ios_base::app | ios_base::binary:
++         case ios_base::app | ios_base::binary:
++             __mdstr = "ab";
++             break;
++         case ios_base::in | ios_base::binary:
++             __mdstr = "rb";
++             break;
++         case ios_base::in | ios_base::out | ios_base::binary:
++             __mdstr = "r+b";
++             break;
++         case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
++             __mdstr = "w+b";
++             break;
++         case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
++         case ios_base::in | ios_base::app | ios_base::binary:
++             __mdstr = "a+b";
++             break;
++         default:
++             __rt = 0;
++             break;
++         }
++         if (__rt)
++         {
++             __file_ = fopen(__s, __mdstr);
++             if (__file_)
++             {
++                 __om_ = __mode;
++                 if (__mode & ios_base::ate)
++                 {
++                     if (fseek(__file_, 0, SEEK_END))
++                     {
++                         fclose(__file_);
++                         __file_ = 0;
++                         __rt = 0;
++                     }
++                 }
++             }
++             else
++                 __rt = 0;
++         }
++     }
++     return __rt;
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_filebuf<_CharT, _Traits>*
++ basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
++ {
++     return open(__s.c_str(), __mode);
++ }
++ 
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>*
++ basic_filebuf<_CharT, _Traits>::open(FILE* fp, ios_base::openmode __mode)
++ {
++     basic_filebuf<_CharT, _Traits>* __rt = 0;
++     if (__file_ == 0)
++     {
++         __rt = this;
++         const char* __mdstr;
++         switch (__mode & ~ios_base::ate)
++         {
++         case ios_base::out:
++         case ios_base::out | ios_base::trunc:
++             __mdstr = "w";
++             break;
++         case ios_base::out | ios_base::app:
++         case ios_base::app:
++             __mdstr = "a";
++             break;
++         case ios_base::in:
++             __mdstr = "r";
++             break;
++         case ios_base::in | ios_base::out:
++             __mdstr = "r+";
++             break;
++         case ios_base::in | ios_base::out | ios_base::trunc:
++             __mdstr = "w+";
++             break;
++         case ios_base::in | ios_base::out | ios_base::app:
++         case ios_base::in | ios_base::app:
++             __mdstr = "a+";
++             break;
++         case ios_base::out | ios_base::binary:
++         case ios_base::out | ios_base::trunc | ios_base::binary:
++             __mdstr = "wb";
++             break;
++         case ios_base::out | ios_base::app | ios_base::binary:
++         case ios_base::app | ios_base::binary:
++             __mdstr = "ab";
++             break;
++         case ios_base::in | ios_base::binary:
++             __mdstr = "rb";
++             break;
++         case ios_base::in | ios_base::out | ios_base::binary:
++             __mdstr = "r+b";
++             break;
++         case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
++             __mdstr = "w+b";
++             break;
++         case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
++         case ios_base::in | ios_base::app | ios_base::binary:
++             __mdstr = "a+b";
++             break;
++         default:
++             __rt = 0;
++             break;
++         }
++         if (__rt)
++         {
++             __file_ = fp;
++             __fpflag = 1;
++             if (__file_)
++             {
++                 __om_ = __mode;
++                 if (__mode & ios_base::ate)
++                 {
++                     if (fseek(__file_, 0, SEEK_END))
++                     {
++                         fclose(__file_);
++                         __file_ = 0;
++                         __rt = 0;
++                     }
++                 }
++             }
++             else
++                 __rt = 0;
++         }
++     }
++     return __rt;
++ }
++ 
++ template <class _CharT, class _Traits>
++ basic_filebuf<_CharT, _Traits>*
++ basic_filebuf<_CharT, _Traits>::close()
++ {
++     basic_filebuf<_CharT, _Traits>* __rt = 0;
++     if (__file_ && !__fpflag)
++     {
++         __rt = this;
++         unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
++         if (sync())
++             __rt = 0;
++         if (fclose(__h.release()) == 0)
++             __file_ = 0;
++         else
++             __rt = 0;
++ 
++     } else {
++       __file_ = 0;
++       __rt = 0;
++     }
++     return __rt;
++ }
++ template <class _CharT, class _Traits>
++ typename basic_filebuf<_CharT, _Traits>::int_type
++ basic_filebuf<_CharT, _Traits>::underflow()
++ {
++     if (__file_ == 0)
++         return traits_type::eof();
++     bool __initial = __read_mode();
++     char_type __1buf;
++     if (this->gptr() == 0)
++         this->setg(&__1buf, &__1buf+1, &__1buf+1);
++     const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
++     int_type __c = traits_type::eof();
++     if (this->gptr() == this->egptr())
++     {
++         memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
++         if (__always_noconv_)
++         {
++             size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
++             __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
++             if (__nmemb != 0)
++             {
++                 this->setg(this->eback(),
++                            this->eback() + __unget_sz,
++                            this->eback() + __unget_sz + __nmemb);
++                 __c = traits_type::to_int_type(*this->gptr());
++             }
++         }
++         else
++         {
++             memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
++             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
++             __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
++             size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
++                                  static_cast<size_t>(__extbufend_ - __extbufnext_));
++             codecvt_base::result __r;
++             __st_last_ = __st_;
++             size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
++             if (__nr != 0)
++             {
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++                 if (!__cv_)
++                     throw bad_cast();
++ #endif
++                 __extbufend_ = __extbufnext_ + __nr;
++                 char_type*  __inext;
++                 __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
++                                        this->eback() + __unget_sz,
++                                        this->eback() + __ibs_, __inext);
++                 if (__r == codecvt_base::noconv)
++                 {
++                     this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
++                     __c = traits_type::to_int_type(*this->gptr());
++                 }
++                 else if (__inext != this->eback() + __unget_sz)
++                 {
++                     this->setg(this->eback(), this->eback() + __unget_sz, __inext);
++                     __c = traits_type::to_int_type(*this->gptr());
++                 }
++             }
++         }
++     }
++     else
++         __c = traits_type::to_int_type(*this->gptr());
++     if (this->eback() == &__1buf)
++         this->setg(0, 0, 0);
++     return __c;
++ }
++ 
++ template <class _CharT, class _Traits>
++ typename basic_filebuf<_CharT, _Traits>::int_type
++ basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c)
++ {
++     if (__file_ && this->eback() < this->gptr())
++     {
++         if (traits_type::eq_int_type(__c, traits_type::eof()))
++         {
++             this->gbump(-1);
++             return traits_type::not_eof(__c);
++         }
++         if ((__om_ & ios_base::out) ||
++             traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
++         {
++             this->gbump(-1);
++             *this->gptr() = traits_type::to_char_type(__c);
++             return __c;
++         }
++     }
++     return traits_type::eof();
++ }
++ 
++ template <class _CharT, class _Traits>
++ typename basic_filebuf<_CharT, _Traits>::int_type
++ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
++ {
++     if (__file_ == 0)
++         return traits_type::eof();
++     __write_mode();
++     char_type __1buf;
++     char_type* __pb_save = this->pbase();
++     char_type* __epb_save = this->epptr();
++     if (!traits_type::eq_int_type(__c, traits_type::eof()))
++     {
++         if (this->pptr() == 0)
++             this->setp(&__1buf, &__1buf+1);
++         *this->pptr() = traits_type::to_char_type(__c);
++         this->pbump(1);
++     }
++     if (this->pptr() != this->pbase())
++     {
++         if (__always_noconv_)
++         {
++             size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
++             if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
++                 return traits_type::eof();
++         }
++         else
++         {
++             char* __extbe = __extbuf_;
++             codecvt_base::result __r;
++             do
++             {
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++                 if (!__cv_)
++                     throw bad_cast();
++ #endif
++                 const char_type* __e;
++                 __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
++                                         __extbuf_, __extbuf_ + __ebs_, __extbe);
++                 if (__e == this->pbase())
++                     return traits_type::eof();
++                 if (__r == codecvt_base::noconv)
++                 {
++                     size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
++                     if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
++                         return traits_type::eof();
++                 }
++                 else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
++                 {
++                     size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
++                     if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
++                         return traits_type::eof();
++                     if (__r == codecvt_base::partial)
++                     {
++                         this->setp((char_type*)__e, this->pptr());
++                         this->pbump(this->epptr() - this->pbase());
++                     }
++                 }
++                 else
++                     return traits_type::eof();
++             } while (__r == codecvt_base::partial);
++         }
++         this->setp(__pb_save, __epb_save);
++     }
++     return traits_type::not_eof(__c);
++ }
++ 
++ template <class _CharT, class _Traits>
++ basic_streambuf<_CharT, _Traits>*
++ basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
++ {
++     this->setg(0, 0, 0);
++     this->setp(0, 0);
++     if (__owns_eb_)
++         delete [] __extbuf_;
++     if (__owns_ib_)
++         delete [] __intbuf_;
++     __ebs_ = __n;
++     if (__ebs_ > sizeof(__extbuf_min_))
++     {
++         if (__always_noconv_ && __s)
++         {
++             __extbuf_ = (char*)__s;
++             __owns_eb_ = false;
++         }
++         else
++         {
++             __extbuf_ = new char[__ebs_];
++             __owns_eb_ = true;
++         }
++     }
++     else
++     {
++         __extbuf_ = __extbuf_min_;
++         __ebs_ = sizeof(__extbuf_min_);
++         __owns_eb_ = false;
++     }
++     if (!__always_noconv_)
++     {
++         __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
++         if (__s && __ibs_ >= sizeof(__extbuf_min_))
++         {
++             __intbuf_ = __s;
++             __owns_ib_ = false;
++         }
++         else
++         {
++             __intbuf_ = new char_type[__ibs_];
++             __owns_ib_ = true;
++         }
++     }
++     else
++     {
++         __ibs_ = 0;
++         __intbuf_ = 0;
++         __owns_ib_ = false;
++     }
++     return this;
++ }
++ 
++ template <class _CharT, class _Traits>
++ typename basic_filebuf<_CharT, _Traits>::pos_type
++ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
++                                         ios_base::openmode)
++ {
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++     if (!__cv_)
++         throw bad_cast();
++ #endif
++     int __width = __cv_->encoding();
++     if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
++         return pos_type(off_type(-1));
++     // __width > 0 || __off == 0
++     int __whence;
++     switch (__way)
++     {
++     case ios_base::beg:
++         __whence = SEEK_SET;
++         break;
++     case ios_base::cur:
++         __whence = SEEK_CUR;
++         break;
++     case ios_base::end:
++         __whence = SEEK_END;
++         break;
++     default:
++         return pos_type(off_type(-1));
++     }
++ #if _WIN32
++     if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
++         return pos_type(off_type(-1));
++     pos_type __r = ftell(__file_);
++ #else
++     if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
++         return pos_type(off_type(-1));
++     pos_type __r = ftello(__file_);
++ #endif
++     __r.state(__st_);
++     return __r;
++ }
++ 
++ template <class _CharT, class _Traits>
++ typename basic_filebuf<_CharT, _Traits>::pos_type
++ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
++ {
++     if (__file_ == 0 || sync())
++         return pos_type(off_type(-1));
++ #if _WIN32
++     if (fseek(__file_, __sp, SEEK_SET))
++         return pos_type(off_type(-1));
++ #else
++     if (fseeko(__file_, __sp, SEEK_SET))
++         return pos_type(off_type(-1));
++ #endif
++     __st_ = __sp.state();
++     return __sp;
++ }
++ 
++ template <class _CharT, class _Traits>
++ int
++ basic_filebuf<_CharT, _Traits>::sync()
++ {
++     if (__file_ == 0)
++         return 0;
++ #ifndef _LIBCPP_NO_EXCEPTIONS
++     if (!__cv_)
++         throw bad_cast();
++ #endif
++     if (__cm_ & ios_base::out)
++     {
++         if (this->pptr() != this->pbase())
++             if (overflow() == traits_type::eof())
++                 return -1;
++         codecvt_base::result __r;
++         do
++         {
++             char* __extbe;
++             __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
++             size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
++             if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
++                 return -1;
++         } while (__r == codecvt_base::partial);
++         if (__r == codecvt_base::error)
++             return -1;
++         if (fflush(__file_))
++             return -1;
++     }
++     else if (__cm_ & ios_base::in)
++     {
++         off_type __c;
++         state_type __state = __st_last_;
++         bool __update_st = false;
++         if (__always_noconv_)
++             __c = this->egptr() - this->gptr();
++         else
++         {
++             int __width = __cv_->encoding();
++             __c = __extbufend_ - __extbufnext_;
++             if (__width > 0)
++                 __c += __width * (this->egptr() - this->gptr());
++             else
++             {
++                 if (this->gptr() != this->egptr())
++                 {
++                     const int __off =  __cv_->length(__state, __extbuf_,
++                                                      __extbufnext_,
++                                                      this->gptr() - this->eback());
++                     __c += __extbufnext_ - __extbuf_ - __off;
++                     __update_st = true;
++                 }
++             }
++         }
++ #if _WIN32
++         if (fseek(__file_, -__c, SEEK_CUR))
++             return -1;
++ #else
++         if (fseeko(__file_, -__c, SEEK_CUR))
++             return -1;
++ #endif
++         if (__update_st)
++             __st_ = __state;
++         __extbufnext_ = __extbufend_ = __extbuf_;
++         this->setg(0, 0, 0);
++         __cm_ = 0;
++     }
++     return 0;
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
++ {
++     sync();
++     __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
++     bool __old_anc = __always_noconv_;
++     __always_noconv_ = __cv_->always_noconv();
++     if (__old_anc != __always_noconv_)
++     {
++         this->setg(0, 0, 0);
++         this->setp(0, 0);
++         // invariant, char_type is char, else we couldn't get here
++         if (__always_noconv_)  // need to dump __intbuf_
++         {
++             if (__owns_eb_)
++                 delete [] __extbuf_;
++             __owns_eb_ = __owns_ib_;
++             __ebs_ = __ibs_;
++             __extbuf_ = (char*)__intbuf_;
++             __ibs_ = 0;
++             __intbuf_ = 0;
++             __owns_ib_ = false;
++         }
++         else  // need to obtain an __intbuf_.
++         {     // If __extbuf_ is user-supplied, use it, else new __intbuf_
++             if (!__owns_eb_ && __extbuf_ != __extbuf_min_)
++             {
++                 __ibs_ = __ebs_;
++                 __intbuf_ = (char_type*)__extbuf_;
++                 __owns_ib_ = false;
++                 __extbuf_ = new char[__ebs_];
++                 __owns_eb_ = true;
++             }
++             else
++             {
++                 __ibs_ = __ebs_;
++                 __intbuf_ = new char_type[__ibs_];
++                 __owns_ib_ = true;
++             }
++         }
++     }
++ }
++ 
++ template <class _CharT, class _Traits>
++ bool
++ basic_filebuf<_CharT, _Traits>::__read_mode()
++ {
++     if (!(__cm_ & ios_base::in))
++     {
++         this->setp(0, 0);
++         if (__always_noconv_)
++             this->setg((char_type*)__extbuf_,
++                        (char_type*)__extbuf_ + __ebs_,
++                        (char_type*)__extbuf_ + __ebs_);
++         else
++             this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
++         __cm_ = ios_base::in;
++         return true;
++     }
++     return false;
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_filebuf<_CharT, _Traits>::__write_mode()
++ {
++     if (!(__cm_ & ios_base::out))
++     {
++         this->setg(0, 0, 0);
++         if (__ebs_ > sizeof(__extbuf_min_))
++         {
++             if (__always_noconv_)
++                 this->setp((char_type*)__extbuf_,
++                            (char_type*)__extbuf_ + (__ebs_ - 1));
++             else
++                 this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
++         }
++         else
++             this->setp(0, 0);
++         __cm_ = ios_base::out;
++     }
++ }
++ 
++ // basic_ifstream
++ 
++ template <class _CharT, class _Traits>
++ class _LIBCPP_TYPE_VIS_ONLY basic_ifstream
++     : public basic_istream<_CharT, _Traits>
++ {
++ public:
++     typedef _CharT                         char_type;
++     typedef _Traits                        traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_ifstream();
++     explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
++     explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_ifstream(basic_ifstream&& __rhs);
++ #endif
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_ifstream& operator=(basic_ifstream&& __rhs);
++ #endif
++     void swap(basic_ifstream& __rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* __s, ios_base::openmode __mode = ios_base::in);
++     void open(const string& __s, ios_base::openmode __mode = ios_base::in);
++     void open(int fd, ios_base::openmode __mode = ios_base::in);
++     void close();
++ 
++ private:
++     basic_filebuf<char_type, traits_type> __sb_;
++ };
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ifstream<_CharT, _Traits>::basic_ifstream()
++     : basic_istream<char_type, traits_type>(&__sb_)
++ {
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
++     : basic_istream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode | ios_base::in) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
++     : basic_istream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode | ios_base::in) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
++     : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
++       __sb_(_VSTD::move(__rhs.__sb_))
++ {
++     this->set_rdbuf(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ifstream<_CharT, _Traits>&
++ basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
++ {
++     basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
++     __sb_ = _VSTD::move(__rhs.__sb_);
++     return *this;
++ }
++ 
++ #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
++ {
++     basic_istream<char_type, traits_type>::swap(__rhs);
++     __sb_.swap(__rhs.__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
++ {
++     __x.swap(__y);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_filebuf<_CharT, _Traits>*
++ basic_ifstream<_CharT, _Traits>::rdbuf() const
++ {
++     return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ bool
++ basic_ifstream<_CharT, _Traits>::is_open() const
++ {
++     return __sb_.is_open();
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode | ios_base::in))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode | ios_base::in))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ifstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
++ {
++     if (__sb_.open(fd, __mode | ios_base::in))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_ifstream<_CharT, _Traits>::close()
++ {
++     if (__sb_.close() == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ // basic_ofstream
++ 
++ template <class _CharT, class _Traits>
++ class _LIBCPP_TYPE_VIS_ONLY basic_ofstream
++     : public basic_ostream<_CharT, _Traits>
++ {
++ public:
++     typedef _CharT                         char_type;
++     typedef _Traits                        traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_ofstream();
++     explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
++     explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_ofstream(basic_ofstream&& __rhs);
++ #endif
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_ofstream& operator=(basic_ofstream&& __rhs);
++ #endif
++     void swap(basic_ofstream& __rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* __s, ios_base::openmode __mode = ios_base::out);
++     void open(const string& __s, ios_base::openmode __mode = ios_base::out);
++     void open(int fd, ios_base::openmode __mode = ios_base::out);
++     void close();
++ 
++ private:
++     basic_filebuf<char_type, traits_type> __sb_;
++ };
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ofstream<_CharT, _Traits>::basic_ofstream()
++     : basic_ostream<char_type, traits_type>(&__sb_)
++ {
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
++     : basic_ostream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode | ios_base::out) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
++     : basic_ostream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode | ios_base::out) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
++     : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
++       __sb_(_VSTD::move(__rhs.__sb_))
++ {
++     this->set_rdbuf(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_ofstream<_CharT, _Traits>&
++ basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
++ {
++     basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
++     __sb_ = _VSTD::move(__rhs.__sb_);
++     return *this;
++ }
++ 
++ #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
++ {
++     basic_ostream<char_type, traits_type>::swap(__rhs);
++     __sb_.swap(__rhs.__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
++ {
++     __x.swap(__y);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_filebuf<_CharT, _Traits>*
++ basic_ofstream<_CharT, _Traits>::rdbuf() const
++ {
++     return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ bool
++ basic_ofstream<_CharT, _Traits>::is_open() const
++ {
++     return __sb_.is_open();
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode | ios_base::out))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode | ios_base::out))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_ofstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
++ {
++     if (__sb_.open(fd, __mode | ios_base::out))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_ofstream<_CharT, _Traits>::close()
++ {
++     if (__sb_.close() == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ // basic_fstream
++ 
++ template <class _CharT, class _Traits>
++ class _LIBCPP_TYPE_VIS_ONLY basic_fstream
++     : public basic_iostream<_CharT, _Traits>
++ {
++ public:
++     typedef _CharT                         char_type;
++     typedef _Traits                        traits_type;
++     typedef typename traits_type::int_type int_type;
++     typedef typename traits_type::pos_type pos_type;
++     typedef typename traits_type::off_type off_type;
++ 
++     basic_fstream();
++     explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
++     explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
++     explicit basic_fstream(int fd, ios_base::openmode __mode = ios_base::in | ios_base::out);
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_fstream(basic_fstream&& __rhs);
++ #endif
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++     basic_fstream& operator=(basic_fstream&& __rhs);
++ #endif
++     void swap(basic_fstream& __rhs);
++ 
++     basic_filebuf<char_type, traits_type>* rdbuf() const;
++     bool is_open() const;
++     void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
++     void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
++     void open(int fd, ios_base::openmode __mode = ios_base::in | ios_base::out);
++     void close();
++ 
++ private:
++     basic_filebuf<char_type, traits_type> __sb_;
++ };
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>::basic_fstream()
++     : basic_iostream<char_type, traits_type>(&__sb_)
++ {
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
++     : basic_iostream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
++     : basic_iostream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(__s, __mode) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>::basic_fstream(int fd, ios_base::openmode __mode)
++     : basic_iostream<char_type, traits_type>(&__sb_)
++ {
++     if (__sb_.open(fd, __mode) == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
++     : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
++       __sb_(_VSTD::move(__rhs.__sb_))
++ {
++     this->set_rdbuf(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_fstream<_CharT, _Traits>&
++ basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
++ {
++     basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
++     __sb_ = _VSTD::move(__rhs.__sb_);
++     return *this;
++ }
++ 
++ #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
++ {
++     basic_iostream<char_type, traits_type>::swap(__rhs);
++     __sb_.swap(__rhs.__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
++ {
++     __x.swap(__y);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ basic_filebuf<_CharT, _Traits>*
++ basic_fstream<_CharT, _Traits>::rdbuf() const
++ {
++     return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ bool
++ basic_fstream<_CharT, _Traits>::is_open() const
++ {
++     return __sb_.is_open();
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
++ {
++     if (__sb_.open(__s, __mode))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ void
++ basic_fstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
++ {
++     if (__sb_.open(fd, __mode))
++         this->clear();
++     else
++         this->setstate(ios_base::failbit);
++ }
++ 
++ template <class _CharT, class _Traits>
++ inline _LIBCPP_INLINE_VISIBILITY
++ void
++ basic_fstream<_CharT, _Traits>::close()
++ {
++     if (__sb_.close() == 0)
++         this->setstate(ios_base::failbit);
++ }
++ 
++ _LIBCPP_END_NAMESPACE_STD
++ 
++ #endif  // _LIBCPP_FSTREAM
++ #endif  // defined(__APPLE__)
+*** ./ivtools-1.2/src/include/ivstd/fstream.h.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/include/ivstd/fstream.h	2015-01-25 16:56:24.000000000 -0800
+***************
+*** 1,10 ****
+  #ifndef _iv_fstream_
+  #define _iv_fstream_
+! #include_next <fstream>
+  #if __GNUC__>=3
+  #define input ios_base::in
+  #define output ios_base::out
+! #if __GNUC__>3 || __GNUC__==3 && __GNUC_MINOR__>0 /* && !defined(__APPLE__) */
+  #include <ext/stdio_filebuf.h>
+  #define fileptr_filebuf __gnu_cxx::stdio_filebuf<char>
+  #else
+--- 1,10 ----
+  #ifndef _iv_fstream_
+  #define _iv_fstream_
+! #include <fstream>
+  #if __GNUC__>=3
+  #define input ios_base::in
+  #define output ios_base::out
+! #if (__GNUC__>3 || __GNUC__==3 && __GNUC_MINOR__>0) && !defined(__APPLE__)
+  #include <ext/stdio_filebuf.h>
+  #define fileptr_filebuf __gnu_cxx::stdio_filebuf<char>
+  #else
+***************
+*** 14,17 ****
+--- 14,30 ----
+  #define input "r"
+  #define output "w"
+  #endif
++ #ifndef __APPLE__
++ #define FILEBUF(bufname, fptr, mode)		\
++      fileptr_filebuf bufname(fptr, mode)
++ #define FILEBUFP(bufname, fptr, mode)	\
++      fileptr_filebuf* bufname = new fileptr_filebuf(fptr, mode)
++ #else
++ #define FILEBUF(bufname, fptr, mode)		\
++      fileptr_filebuf bufname; \
++      bufname.open(fptr, mode); 
++ #define FILEBUFP(bufname, fptr, mode) \
++      fileptr_filebuf* bufname = new fileptr_filebuf; \
++      bufname -> open(fptr,mode);
++ #endif
+  #endif
+*** ./ivtools-1.2/src/include/ivstd/Imakefile.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/include/ivstd/Imakefile	2015-01-22 12:46:54.000000000 -0800
+***************
+*** 8,11 ****
+--- 8,12 ----
+  
+  InstallIncludes(ivstd)
+  InstallInclude(ivstd,iosfwd)
++ InstallInclude(ivstd,fstream)
+  
+*** ./ivtools-1.2/src/OverlayUnidraw/aceimport.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/OverlayUnidraw/aceimport.c	2015-01-25 17:39:56.000000000 -0800
+***************
+*** 80,107 ****
+  int
+  UnidrawImportHandler::handle_input (ACE_HANDLE fd)
+  {
+- #if 0
+-     if (!_inptr) {
+-         _filebuf = new filebuf();
+- 	boolean valid = _filebuf->attach(fd) != 0;
+- 	_inptr = new istream(_filebuf);
+-         _import_cmd->instream(_inptr);
+-     }
+-     int ch;
+-     ch = _inptr->get();
+-     if (ch != EOF && _inptr->good()) {
+-       _inptr->putback(ch);
+-       _import_cmd->Execute();
+-     }
+-     return _inptr->good() ? 0 : -1;
+- #else
+- #if __GNUC__<3
+-     filebuf fbuf;
+-     if(fbuf.attach(fd)==0) return -1;
+- #else
+      if (!_infptr) _infptr = fdopen(fd, "r");
+!     fileptr_filebuf fbuf(_infptr, ios_base::in);
+! #endif
+      istream in(&fbuf);
+      int ch = in.get();
+      if (ch != EOF && in.good()) {
+--- 80,87 ----
+  int
+  UnidrawImportHandler::handle_input (ACE_HANDLE fd)
+  {
+      if (!_infptr) _infptr = fdopen(fd, "r");
+!     FILEBUF(fbuf, _infptr, ios_base::in);
+      istream in(&fbuf);
+      int ch = in.get();
+      if (ch != EOF && in.good()) {
+***************
+*** 110,116 ****
+        _import_cmd->Execute();
+      }
+      return -1;  /* only return -1, which indicates input handling is fini */
+- #endif
+  }
+  
+  int
+--- 90,95 ----
+*** ./ivtools-1.2/src/OverlayUnidraw/ovcatalog.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/OverlayUnidraw/ovcatalog.c	2015-01-25 17:33:33.000000000 -0800
+***************
+*** 188,209 ****
+          _valid = true;
+  
+      } else {
+- #if __GNUC__<3	  
+-         filebuf fbuf;
+- 	if (strcmp(name, "-") == 0) {
+- 	    _valid = fbuf.attach(fileno(stdin)) != 0;
+- 	    name = nil;
+- 	} else {
+- 	    fptr = fopen(name, "r");
+- 	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
+- 	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
+- 	    if (compressed) {
+- 		int namelen = strlen(name);
+- 		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
+- 		else if (strcmp(name+namelen-2,".Z")==0) name[namelen-2] = '\0';
+- 	    }
+- 	}
+- #else
+  	boolean stdin_flag = strcmp(name, "-")==0;
+  	if (!stdin_flag) {
+  	  fptr = fopen(name, "r");
+--- 188,193 ----
+***************
+*** 219,226 ****
+  	  name = nil;
+  	}
+  	if (!_valid && !ParamList::urltest(name)) return false;
+!         fileptr_filebuf fbuf(stdin_flag ? stdin : fptr, ios_base::in);
+! #endif
+  	
+          if (_valid || ParamList::urltest(name)) {
+  	    istream in(&fbuf);
+--- 203,209 ----
+  	  name = nil;
+  	}
+  	if (!_valid && !ParamList::urltest(name)) return false;
+!         FILEBUF(fbuf, stdin_flag ? stdin : fptr, ios_base::in);
+  	
+          if (_valid || ParamList::urltest(name)) {
+  	    istream in(&fbuf);
+*** ./ivtools-1.2/src/OverlayUnidraw/ovfile.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/OverlayUnidraw/ovfile.c	2015-01-25 17:34:11.000000000 -0800
+***************
+*** 223,235 ****
+        OvImportCmd impcmd((Editor*)nil);
+        FILE* fptr = popen(pathname, "r");
+        if (fptr) {
+! #if __GNUC__<3
+! 	ifstream ifs;
+! 	ifs.rdbuf()->attach(fileno(fptr));
+! #else
+! 	fileptr_filebuf fbuf(fptr, ios_base::in);
+  	istream ifs(&fbuf);
+- #endif
+  	OverlayComp* child = (OverlayComp*) impcmd.Import(ifs);
+  	if (child) {
+  	  filecomp->Append(child);
+--- 223,230 ----
+        OvImportCmd impcmd((Editor*)nil);
+        FILE* fptr = popen(pathname, "r");
+        if (fptr) {
+! 	FILEBUF(fbuf, fptr, ios_base::in);
+  	istream ifs(&fbuf);
+  	OverlayComp* child = (OverlayComp*) impcmd.Import(ifs);
+  	if (child) {
+  	  filecomp->Append(child);
+*** ./ivtools-1.2/src/OverlayUnidraw/ovimport.c.dist	2015-01-27 13:46:30.000000000 -0800
+--- ./ivtools-1.2/src/OverlayUnidraw/ovimport.c	2015-01-25 17:38:34.000000000 -0800
+***************
+*** 121,129 ****
+  implementPtrList(StreamList,istream)
+  implementPtrList(HandlerList,ReadImageHandler)
+  
+- #if __GNUC__>=3
+  static char newline;
+- #endif
+  
+  
+  /*****************************************************************************/
+--- 121,127 ----
+***************
+*** 467,480 ****
+  
+      if (pos >= 0) { 
+  
+- #if __GNUC__<3
+-       char* buffer;
+-       in.gets(&buffer);
+- #else
+        char buffer[BUFSIZ];
+        in.get(buffer, BUFSIZ);
+        in.get(newline);
+- #endif
+  
+        if (strncmp(buffer, "P6", 2)) {
+          cerr << "only binary ppms (magic P6) supported at this time" << endl;
+--- 465,473 ----
+***************
+*** 483,503 ****
+  
+        u_long width, height;
+        do { 
+- #if __GNUC__<3	
+-         in.gets(&buffer);
+- #else
+  	in.get(buffer,BUFSIZ);
+  	in.get(newline);
+- #endif
+        } while (buffer[0] == '#');
+        sscanf(buffer, "%d %d", &width, &height);
+  
+- #if __GNUC__<3	
+-       in.gets(&buffer);
+- #else
+        in.get(buffer,BUFSIZ);
+        in.get(newline);
+- #endif
+        int maxval;
+        sscanf(buffer, "%d", &maxval);
+        if (maxval != 255) {
+--- 476,488 ----
+***************
+*** 604,621 ****
+  
+      clr_fl(_fd, O_NONBLOCK);
+  
+- #if __GNUC__<3
+-     ifstream* ifs = new ifstream;
+-     ifs->rdbuf()->attach(_fd);
+- #else
+      FILE* ifptr = fdopen(_fd, "r");
+!     fileptr_filebuf* fbuf = new fileptr_filebuf(ifptr, ios_base::in);
+      istream* ifs = new istream(fbuf);
+- #endif
+      _helper.add_stream(ifs);
+- #if __GNUC__>=3
+      _helper.add_file(ifptr);
+- #endif
+      boolean empty;
+  
+      int newfd;
+--- 589,599 ----
+  
+      clr_fl(_fd, O_NONBLOCK);
+  
+      FILE* ifptr = fdopen(_fd, "r");
+!     FILEBUFP(fbuf,ifptr, ios_base::in);
+      istream* ifs = new istream(fbuf);
+      _helper.add_stream(ifs);
+      _helper.add_file(ifptr);
+      boolean empty;
+  
+      int newfd;
+***************
+*** 1098,1110 ****
+        } else if (!is_url()) {
+  	fptr = popen(path_, "r");
+  	if (fptr) {
+! #if __GNUC__<3
+! 	  ifstream* ifs = new ifstream;
+!           ifs->rdbuf()->attach(fileno(fptr));
+! #else
+! 	  fileptr_filebuf* fbuf = new fileptr_filebuf(fptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+- #endif
+  	  inptr_ = ifs;
+  	}
+        }	
+--- 1076,1083 ----
+        } else if (!is_url()) {
+  	fptr = popen(path_, "r");
+  	if (fptr) {
+! 	  FILEBUFP(fbuf, fptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+  	  inptr_ = ifs;
+  	}
+        }	
+***************
+*** 1407,1419 ****
+      
+  
+      if (fptr) {
+! #if __GNUC__<3
+!       ifstream* in = new ifstream;
+!       in->rdbuf()->attach(fileno(fptr));
+! #else
+!       fileptr_filebuf* fbuf = new fileptr_filebuf(fptr, ios_base::in);
+        istream* in = new istream(fbuf);
+- #endif
+        helper_->add_stream(in);
+  
+        if ((chooser_ && (chooser_->auto_convert() || chooser_->from_command())))
+--- 1380,1387 ----
+      
+  
+      if (fptr) {
+!       FILEBUFP(fbuf, fptr, ios_base::in);
+        istream* in = new istream(fbuf);
+        helper_->add_stream(in);
+  
+        if ((chooser_ && (chooser_->auto_convert() || chooser_->from_command())))
+***************
+*** 1496,1523 ****
+  	gunzip_fptr = popen(buffer, "r");
+          helper.add_pipe(gunzip_fptr);
+  	if (gunzip_fptr) {
+! #if __GNUC__<3
+! 	  ifstream* ifs = new ifstream;
+!           ifs->rdbuf()->attach(fileno(gunzip_fptr));
+! #else
+! 	  fileptr_filebuf* fbuf = new fileptr_filebuf(gunzip_fptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+- #endif
+            helper.add_stream(ifs);
+  	  in = gunzip_in = ifs;
+  	}
+        } else {
+  	int newfd = Pipe_Filter(instrm, "gunzip -c");
+  	if (newfd != -1) {
+- #if __GNUC__<3
+- 	  ifstream* ifs = new ifstream;
+-           ifs->rdbuf()->attach(newfd);
+- #else
+  	  FILE* ifptr = fdopen(newfd, "r");
+! 	  fileptr_filebuf* fbuf = new fileptr_filebuf(ifptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+  	  helper.add_file(ifptr);
+- #endif
+  	  helper.add_stream(ifs);
+  	  in = gunzip_in = ifs;
+  	}
+--- 1464,1481 ----
+  	gunzip_fptr = popen(buffer, "r");
+          helper.add_pipe(gunzip_fptr);
+  	if (gunzip_fptr) {
+! 	  FILEBUFP(fbuf, gunzip_fptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+            helper.add_stream(ifs);
+  	  in = gunzip_in = ifs;
+  	}
+        } else {
+  	int newfd = Pipe_Filter(instrm, "gunzip -c");
+  	if (newfd != -1) {
+  	  FILE* ifptr = fdopen(newfd, "r");
+! 	  FILEBUFP(fbuf, ifptr, ios_base::in);
+  	  istream* ifs = new istream(fbuf);
+  	  helper.add_file(ifptr);
+  	  helper.add_stream(ifs);
+  	  in = gunzip_in = ifs;
+  	}
+***************
+*** 1556,1570 ****
+  	      new_fd = fileno(pptr);
+  	  } else 
+  	    new_fd = Pipe_Filter(*in, "tf=`tempname`;pstoedit -f idraw - $tf.%d;cat $tf.*;rm $tf.*");
+- #if __GNUC__<3
+- 	  ifstream new_in;
+-           new_in.rdbuf()->attach(new_fd);
+- #else
+  	  FILE* ifptr = fdopen(new_fd, "r");
+  	  helper.add_file(ifptr);
+! 	  fileptr_filebuf fbuf(ifptr, ios_base::in);
+  	  istream new_in(&fbuf);
+- #endif
+  	  comp = catalog->ReadPostScript(new_in);
+  	  if (pptr) pclose(pptr);
+  	} else
+--- 1514,1523 ----
+  	      new_fd = fileno(pptr);
+  	  } else 
+  	    new_fd = Pipe_Filter(*in, "tf=`tempname`;pstoedit -f idraw - $tf.%d;cat $tf.*;rm $tf.*");
+  	  FILE* ifptr = fdopen(new_fd, "r");
+  	  helper.add_file(ifptr);
+! 	  FILEBUF(fbuf, ifptr, ios_base::in);
+  	  istream new_in(&fbuf);
+  	  comp = catalog->ReadPostScript(new_in);
+  	  if (pptr) pclose(pptr);
+  	} else
+***************
+*** 1594,1606 ****
+  	  FILE* pptr = popen(buffer, "r");
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! #if __GNUC__<3
+! 	    ifstream new_in;
+!             new_in.rdbuf()->attach(fileno(pptr));
+! #else
+! 	    fileptr_filebuf fbuf(pptr, ios_base::in);
+  	    istream new_in(&fbuf);
+- #endif
+  	    comp = PNM_Image(new_in);
+  	    pclose(pptr);
+  	  }
+--- 1547,1554 ----
+  	  FILE* pptr = popen(buffer, "r");
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! 	    FILEBUF(fbuf, pptr, ios_base::in);
+  	    istream new_in(&fbuf);
+  	    comp = PNM_Image(new_in);
+  	    pclose(pptr);
+  	  }
+***************
+*** 1659,1671 ****
+            helper.add_pipe(pptr);
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! #if __GNUC__<3
+! 	    ifstream* new_in = new ifstream;
+!             new_in->rdbuf()->attach(fileno(pptr));
+! #else
+! 	    fileptr_filebuf* fbuf = new fileptr_filebuf(pptr, ios_base::in);
+  	    istream* new_in = new istream(fbuf);
+- #endif
+              helper.add_stream(new_in);
+  	    comp = PNM_Image(*new_in);
+  	  }
+--- 1607,1614 ----
+            helper.add_pipe(pptr);
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! 	    FILEBUFP(fbuf, pptr, ios_base::in);
+  	    istream* new_in = new istream(fbuf);
+              helper.add_stream(new_in);
+  	    comp = PNM_Image(*new_in);
+  	  }
+***************
+*** 1689,1701 ****
+  	  FILE* pptr = popen(buffer, "r");
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! #if __GNUC__<3
+! 	    ifstream new_in;
+!             new_in.rdbuf()->attach(fileno(pptr));
+! #else
+! 	    fileptr_filebuf fbuf(pptr, ios_base::in);
+  	    istream new_in(&fbuf);
+- #endif
+  	    comp = PNM_Image(new_in);
+  	    pclose(pptr);
+  	  }
+--- 1632,1639 ----
+  	  FILE* pptr = popen(buffer, "r");
+  	  if (pptr) {
+  	    cerr << "input opened with " << buffer << "\n";
+! 	    FILEBUF(fbuf, pptr, ios_base::in);
+  	    istream new_in(&fbuf);
+  	    comp = PNM_Image(new_in);
+  	    pclose(pptr);
+  	  }
+***************
+*** 1952,1990 ****
+  
+  OverlayRaster* OvImportCmd::PGM_Raster (istream& in, boolean ascii) {
+   
+- #if __GNUC__<3 
+-     char* buffer;
+-     in.gets(&buffer);
+- #else
+      char buffer[BUFSIZ];
+      in.get(buffer, BUFSIZ);
+      in.get(newline);
+- #endif
+  
+      do {  // CREATOR and other comments
+- #if __GNUC__<3 
+-         in.gets(&buffer);
+- #else
+  	in.get(buffer, BUFSIZ);
+  	in.get(newline);
+- #endif
+      } while (buffer[0] == '#');
+  
+      int nrows, ncols;
+      if (sscanf(buffer, "%d %d", &ncols, &nrows)==1) {
+- #if __GNUC__<3 
+-           in.gets(&buffer);
+- #else
+  	  in.get(buffer, BUFSIZ);
+  	  in.get(newline);
+- #endif
+            sscanf(buffer, "%d", &nrows);
+      }
+- #if __GNUC__<3 
+-     in.gets(&buffer);
+- #else
+      in.get(buffer, BUFSIZ, '\n');
+- #endif
+      int maxval;
+      sscanf(buffer, "%d", &maxval);
+  
+--- 1890,1911 ----
+***************
+*** 2390,2420 ****
+  
+  
+  OverlayRaster* OvImportCmd::PPM_Raster (istream& in, boolean ascii) {
+- #if __GNUC__<3
+-     char* buffer;
+-     in.gets(&buffer); // read magic number
+- #else
+      char buffer[BUFSIZ];
+      in.get(buffer,BUFSIZ);
+      in.get(newline);
+- #endif
+  
+      do { // CREATOR and other comments
+- #if __GNUC__<3
+-         in.gets(&buffer);
+- #else
+  	in.get(buffer,BUFSIZ);
+  	in.get(newline);
+- #endif
+      } while (buffer[0] == '#');
+      int nrows, ncols;
+      sscanf(buffer, "%d %d", &ncols, &nrows);
+- #if __GNUC__<3
+-     in.gets(&buffer);
+- #else
+      in.get(buffer,BUFSIZ);
+      in.get(newline);
+- #endif
+      int maxval;
+      sscanf(buffer, "%d", &maxval);
+      if (maxval != 255) {
+--- 2311,2328 ----
+***************
+*** 2459,2480 ****
+      fd = outfd;
+    }
+    else {
+- #if __GNUC__<3    
+-     ifstream in2;
+-     in2.rdbuf()->attach(outfd);
+- #else
+      FILE* infptr = fdopen(outfd, "r");
+!     fileptr_filebuf fbuf(infptr, ios_base::in);
+      istream in2(&fbuf);
+- #endif
+  
+      comp = PNM_Image(in2);
+  
+      if(close(outfd)==-1)
+        cerr << "error in parent closing last end of the pipes\n";
+- #if __GNUC__>=3
+      if (infptr) fclose(infptr);
+- #endif
+    }
+  
+    return comp;
+--- 2367,2381 ----
+      fd = outfd;
+    }
+    else {
+      FILE* infptr = fdopen(outfd, "r");
+!     FILEBUF(fbuf, infptr, ios_base::in);
+      istream in2(&fbuf);
+  
+      comp = PNM_Image(in2);
+  
+      if(close(outfd)==-1)
+        cerr << "error in parent closing last end of the pipes\n";
+      if (infptr) fclose(infptr);
+    }
+  
+    return comp;
+***************
+*** 2536,2559 ****
+      } else
+        if(close(pipe1[0])==-1) 
+  	cerr << "error in child close of front end of pipe\n";
+- #if __GNUC__<3
+-     ofstream out;
+-     out.rdbuf()->attach(pipe1[1]);
+-     char buffer[BUFSIZ];
+-     while (!in.eof() && in.good()) {
+-       in.read(buffer, BUFSIZ);
+-       if (!in.eof() || in.gcount())
+- 	out.write(buffer, in.gcount());
+-     }
+-     out.flush();
+- #else
+      char buffer[BUFSIZ];
+      while (!in.eof() && in.good()) {
+        in.read(buffer, BUFSIZ);
+        if (!in.eof() || in.gcount())
+  	write(pipe1[1], buffer, in.gcount());
+      }
+- #endif
+      if(close(pipe1[1])==-1)
+        cerr << "error in child closing its output pipe\n";
+      int status;
+--- 2437,2448 ----
+***************
+*** 2717,2750 ****
+  Bitmap* OvImportCmd::PBM_Bitmap (istream& in) {
+      Bitmap* bitmap = nil;
+    
+- #if __GNUC__<3
+-     char* buffer;
+-     in.gets(&buffer);
+- #else
+      char buffer[BUFSIZ];
+      in.get(buffer,BUFSIZ);
+      in.get(newline);
+- #endif
+  
+      boolean asciiflag = strncmp("P1", buffer, 2) == 0;
+    
+      do { // CREATOR and other comments
+- #if __GNUC__<3
+-         in.gets(&buffer);
+- #else
+  	in.get(buffer,BUFSIZ);
+  	in.get(newline);
+- #endif
+      } while (buffer[0] == '#');
+  
+      int nrows, ncols;
+      if (sscanf(buffer, "%d %d", &ncols, &nrows)==1) {
+- #if __GNUC__<3
+-           in.gets(&buffer);
+- #else
+  	  in.get(buffer,BUFSIZ);
+  	  in.get(newline);
+- #endif
+            sscanf(buffer, "%d", &nrows);
+      }
+      void* nilpointer = nil;
+--- 2606,2626 ----
+*** ivtools-1.2/COPYRIGHT.dist	2015-01-29 08:19:09.000000000 -0800
+--- ivtools-1.2/COPYRIGHT	2015-01-29 08:18:12.000000000 -0800
+***************
+*** 1,5 ****
+  /*
+!  * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Scott E. Johnston
+   * Copyright (c) 2000  Vectaport Inc., IET Inc
+   * Copyright (c) 1999  Vectaport Inc., IET Inc, R.B. Kissh and Associates
+   * Copyright (c) 1998  Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler
+--- 1,7 ----
+  /*
+!  * Copyright (c) 2014-2015 Scott E. Johnston
+!  * Copyright (c) 2009-2014 Wave Semiconductor Inc.
+!  * Copyright (c) 2001-2009 Scott E. Johnston
+   * Copyright (c) 2000  Vectaport Inc., IET Inc
+   * Copyright (c) 1999  Vectaport Inc., IET Inc, R.B. Kissh and Associates
+   * Copyright (c) 1998  Vectaport Inc., R.B. Kissh and Associates, Eric F. Kahler
+*** ivtools-1.2/config/arch.def.dist	2015-01-29 08:57:29.000000000 -0800
+--- ivtools-1.2/config/arch.def	2015-01-29 08:57:50.000000000 -0800
+***************
+*** 8,20 ****
+  #define NO 0
+  #define NullParameter /**/
+  
+! #if __STDC__ && !defined(__CYGWIN__)
+  #define Concat(a,b)a##b
+  #else
+  #define Concat(a,b)a/**/b
+  #endif
+  
+! #if __STDC__ && !defined(__CYGWIN__)
+  #define Concat3(a,b,c)a##b##c
+  #else
+  #define Concat3(a,b,c)a/**/b/**/c
+--- 8,20 ----
+  #define NO 0
+  #define NullParameter /**/
+  
+! #if __STDC__ && !defined(__CYGWIN__) || defined(__APPLE__)
+  #define Concat(a,b)a##b
+  #else
+  #define Concat(a,b)a/**/b
+  #endif
+  
+! #if __STDC__ && !defined(__CYGWIN__) || defined(__APPLE__)
+  #define Concat3(a,b,c)a##b##c
+  #else
+  #define Concat3(a,b,c)a/**/b/**/c
--- ivtools-1.2.11a1.orig/src/AceDispatch/ace_dispatcher.cc
+++ ivtools-1.2.11a1/src/AceDispatch/ace_dispatcher.cc
@@ -22,6 +22,10 @@
  */
 
 #ifdef HAVE_ACE
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include <AceDispatch/ace_dispatcher.h>
 #include <AceDispatch/ace_iohandler.h>
 #include <ace/Event_Handler.h>
--- ivtools-1.2.11a1.orig/src/AceDispatch/ace_iohandler.cc
+++ ivtools-1.2.11a1/src/AceDispatch/ace_iohandler.cc
@@ -23,6 +23,10 @@
 
 #ifdef HAVE_ACE
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include <AceDispatch/ace_iohandler.h>
 
 ACE_IO_Handler::ACE_IO_Handler(IOHandler* handler) : ACE_Event_Handler() {
--- ivtools-1.2.11a1.orig/src/Attribute/attrlist.cc
+++ ivtools-1.2.11a1/src/Attribute/attrlist.cc
@@ -28,7 +28,6 @@
 
 
 #include <Attribute/alist.h>
-#include <Attribute/aliterator.h>
 #include <Attribute/attribute.h>
 #include <Attribute/attrlist.h>
 #include <Attribute/attrvalue.h>
@@ -204,6 +203,14 @@ boolean AttributeList::Includes (Attribu
 
 boolean AttributeList::IsEmpty () { return _alist->IsEmpty(); }
 
+void AttributeList::print_attrlist(AttributeList* al) {
+    print_attrlist(std::cout, al);
+}
+
+void AttributeList::print_attrlist(std::ostream& out, AttributeList* al) {
+    out << *al;
+}
+
 ostream& operator<< (ostream& out, const AttributeList& al) {
 
     AttributeList* attrlist = (AttributeList*)&al;
@@ -212,9 +219,11 @@ ostream& operator<< (ostream& out, const
         return out;
     }
     ALIterator i;
+    int init=0;
     for (attrlist->First(i); !attrlist->Done(i); attrlist->Next(i)) {
 	Attribute* attr = attrlist->GetAttr(i);
-	out << " :" << attr->Name() << " ";
+        if(init) out << " "; else init=1;
+	out << ":" << attr->Name() << " ";
 
 	AttributeValue* attrval = attr->Value();
 #if 1
@@ -326,6 +335,7 @@ AttributeValueList::AttributeValueList (
 	}
     }
     _nested_insert = false;
+    _prevget_i = -1;
 }
 
 AttributeValueList::~AttributeValueList () { 
@@ -350,21 +360,25 @@ AList* AttributeValueList::Elem (ALItera
 void AttributeValueList::Append (AttributeValue* v) {
     _alist->Append(new AList(v));
     ++_count;
+    _prevget_i = -1;
 }
 
 void AttributeValueList::Prepend (AttributeValue* v) {
     _alist->Prepend(new AList(v));
     ++_count;
+    _prevget_i = -1;
 }
 
 void AttributeValueList::InsertAfter (ALIterator i, AttributeValue* v) {
     Elem(i)->Prepend(new AList(v));
     ++_count;
+    _prevget_i = -1;
 }
 
 void AttributeValueList::InsertBefore (ALIterator i, AttributeValue* v) {
     Elem(i)->Append(new AList(v));
     ++_count;
+    _prevget_i = -1;
 }
 
 void AttributeValueList::Remove (ALIterator& i) {
@@ -374,6 +388,7 @@ void AttributeValueList::Remove (ALItera
     _alist->Remove(doomed);
     delete doomed;
     --_count;
+    _prevget_i = -1;
 }	
     
 void AttributeValueList::Remove (AttributeValue* p) {
@@ -384,6 +399,7 @@ void AttributeValueList::Remove (Attribu
         delete temp;
 	--_count;
     }
+    _prevget_i = -1;
 }
 
 AttributeValue* AttributeValueList::GetAttrVal (ALIterator i) { return AttrVal
@@ -462,6 +478,12 @@ ostream& operator<< (ostream& out, const
 	        out << *attrval->array_ref();
   	        out << "}";
 	        break;
+	    case AttributeValue::StreamType:
+	        out << "stream";
+	        break;
+	    case AttributeValue::ObjectType:
+  	        out << "object(class=" << symbol_pntr(attrval->obj_type_val()) << ", ptr= " << attrval->obj_val() << ")";
+	        break;
             default:
 		out << "nil";
 	        break;
@@ -483,19 +505,32 @@ void AttributeValueList::clear() {
     Remove(it);
     delete av;
   }
+  _prevget_i = -1;
 }
 
 AttributeValue* AttributeValueList::Get(unsigned int index) {
   if (Number()<=index) return nil;
   ALIterator it;
-  if(Number()<=index*2) {
-      Last(it);
-      for (int i=0; i<Number()-index-1; i++) Prev(it);
+  int delta = abs(((int)index)-_prevget_i);
+  if(_prevget_i!=-1 && (delta<<1)<Number()) {
+    it = _prevget_it;
+    if(_prevget_i>index) {
+        for (int i=0; i<delta; i++) Prev(it);
+    } else {
+        for (int i=0; i<delta; i++) Next(it);
+    }
   } else {
-      First(it);
-      for (int i=0; i<index; i++) Next(it);
+    if(Number()<=index*2) {
+        Last(it);
+        for (int i=0; i<Number()-index-1; i++) Prev(it);
+    } else {
+        First(it);
+        for (int i=0; i<index; i++) Next(it);
+    }
   }
-      return GetAttrVal(it);
+  _prevget_i = index;
+  _prevget_it = it;
+  return GetAttrVal(it);
 }
 
 AttributeValue* AttributeValueList::Set(unsigned int index, AttributeValue* av) {
@@ -527,6 +562,7 @@ void AttributeValueList::Insert(int inde
     while(i++<index) Next(it);
     InsertAfter(it, av);
   }
+  _prevget_i = -1;
 }
 
 AttributeValue* AttributeValueList::Replace (ALIterator& i, AttributeValue* av) {
@@ -536,6 +572,7 @@ AttributeValue* AttributeValueList::Repl
     _alist->Remove(doomed);
     delete doomed;
     Elem(i)->Append(new AList(av));
+    _prevget_i = -1;
     return removed;
 }	
    
--- ivtools-1.2.11a1.orig/src/Attribute/attrlist.h
+++ ivtools-1.2.11a1/src/Attribute/attrlist.h
@@ -34,6 +34,7 @@
 #include <OS/enter-scope.h>
 #include <InterViews/resource.h>
 #include <Attribute/classid.h>
+#include <Attribute/aliterator.h>
 
 #ifndef ALITERATOR
 #define ALIterator _lib_iv(Iterator)
@@ -42,6 +43,7 @@
 
 class ALIterator;
 class AList;
+
 #include <iosfwd>
 
 class Attribute;
@@ -115,6 +117,12 @@ public:
     // merge the contents of another AttributeList into this one,
     // replicating the AttributeValue as needed.
 
+    static void print_attrlist(AttributeList* al);
+    // print AttributeList to stdout
+
+    static void print_attrlist(std::ostream& out, AttributeList* al);
+    // print AttributeList to out
+
 protected:
     void Append(Attribute*);
     // append Attribute to end of list.  Could cause duplicates.
@@ -253,6 +261,8 @@ protected:
     unsigned int _count;
     boolean _nested_insert;
     int _max_out;
+    int _prevget_i;
+    ALIterator _prevget_it;
 
 #ifdef LEAKCHECK
  public:
--- ivtools-1.2.11a1.orig/src/Attribute/attrvalue.cc
+++ ivtools-1.2.11a1/src/Attribute/attrvalue.cc
@@ -23,6 +23,10 @@
  * 
  */
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
+
 #include <Attribute/aliterator.h>
 #include <Attribute/attribute.h>
 #include <Attribute/attrvalue.h>
@@ -742,6 +746,10 @@ unsigned int& AttributeValue::class_symi
     return _v.objval.type;
 }
 
+const char* AttributeValue::class_name() {
+    return symbol_pntr(_v.objval.type);
+}
+
 AttributeValueList* AttributeValue::array_val() { 
 	return array_ref();
 }
@@ -792,6 +800,10 @@ int AttributeValue::command_symid() { re
 void AttributeValue::command_symid(int id, boolean alias) { 
   _command_symid = (alias ? -1 : 1) * id; }
 
+const char* AttributeValue::command_name() {
+    return symbol_pntr(_command_symid);
+}
+
 ostream& operator<< (ostream& out, const AttributeValue& sv) {
     AttributeValue* svp = (AttributeValue*)&sv;
     const char* title;
@@ -1138,6 +1150,12 @@ void* AttributeValue::geta(int id) {
     return nil;
 }
 
+boolean AttributeValue::isa(int id) {
+  if (is_object(id))
+    return true;
+  return false;
+}
+
 int AttributeValue::type_symid() const {
   if (!_type_syms) {
     int i = 0;
@@ -1303,9 +1321,7 @@ void AttributeValue::state(int val) {
 }
 
 boolean AttributeValue::is_object(int class_symid) { 
-  if (!is_type(ObjectType)) return false;
-  if (this->class_symid() == class_symid) return true;
-  return false;
+  return is_type(ObjectType) && this->class_symid() == class_symid;
 }
 
 #if 0
--- ivtools-1.2.11a1.orig/src/Attribute/attrvalue.h
+++ ivtools-1.2.11a1/src/Attribute/attrvalue.h
@@ -184,6 +184,8 @@ public:
     // return sizeof of value of given type.
     int type_symid() const;
     // return symbol id corresponding to type
+    const char* type_name() { return symbol_pntr(type_symid()); }
+    // type name of object.
 
     void assignval (const AttributeValue&);
     // copy contents of AttributeValue
@@ -225,7 +227,6 @@ public:
     unsigned int symbol_val();	      // symbol id by value.                        
     void* obj_val();		      // void* pointer to object by value.          
     unsigned int obj_type_val();      // classid of object by value.                
-    unsigned int& class_symid();       // classid of object by value.                
     AttributeValueList* array_val();  // values in list by value.                   
     unsigned int array_type_val();    // type of values in list by value            
     AttributeValueList* list_val();   // values in list by value.                   
@@ -233,6 +234,10 @@ public:
     unsigned int keyid_val();	      // symbol id of keyword by value.             
     unsigned int keynarg_val();	      // number of arguments after keyword by value.
 
+    unsigned int& class_symid();      // classid of object.
+    const char* class_name();         // class name of object.
+
+
     const char* string_ptr();
     // lookup and return pointer to string associated with string.
     const char* symbol_ptr();
@@ -249,8 +254,10 @@ public:
     // symbol id of associated command name, for use with ComTerp.
     void command_symid(int, boolean alias=false);
     // set symbol id of associated command name, for use with ComTerp.
-    boolean command_alias();
+    // boolean command_alias();
     // returns true if command is an alias, not the first name.
+    const char* command_name();
+    // returns name of command.
 
     const boolean object_compview() { return is_object() && _object_compview; }
     // true if object is wrapped with a ComponentView
@@ -374,6 +381,8 @@ public:
 
     virtual void* geta(int type); 
     // return a pointer if ObjectType matches or is a parent class
+    virtual boolean isa(int type); 
+    // return true if ObjectType matches or is a parent class
 
     friend ostream& operator << (ostream& s, const AttributeValue&);
     // output AttributeValue to ostream.
--- ivtools-1.2.11a1.orig/src/Attribute/lexscan.h
+++ ivtools-1.2.11a1/src/Attribute/lexscan.h
@@ -42,7 +42,7 @@ public:
     ~LexScan();
 
     void init();
-    // intialize comment delimeters and internal token buffer.
+    // intialize comment delimiters and internal token buffer.
 
     attr_value get_next_token(unsigned int& toktype);         
     // return token in structure ready for constructing an AttributeValue.
--- ivtools-1.2.11a1.orig/src/Attribute/paramlist.cc
+++ ivtools-1.2.11a1/src/Attribute/paramlist.cc
@@ -25,6 +25,7 @@
  * Implementation of ParamList class.
  */
 
+#include <cstdio>
 #include <Attribute/alist.h>
 #include <Attribute/aliterator.h>
 #include <Attribute/paramlist.h>
--- ivtools-1.2.11a1.orig/src/ComTerp/assignfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/assignfunc.cc
@@ -31,6 +31,7 @@
 
 #include <fstream>
 #include <iostream>
+using std::cout;
 using std::cerr;
 
 #define TITLE "AssignFunc"
@@ -64,22 +65,27 @@ void AssignFunc::execute() {
 	    Unref(attrlist);
 	} else if (operand1.global_flag()) {
 	    void* oldval = nil;
-	    comterp()->globaltable()->find_and_remove(oldval, operand1.symbol_val());
-	    if (oldval) delete (ComValue*)oldval;
-	    comterp()->globaltable()->insert(operand1.symbol_val(), operand2);
+	    comterp()->globaltable()->find(oldval, operand1.symbol_val());
+	    if (oldval) 
+	      *(ComValue*)oldval = operand2;
+	    else
+  	      comterp()->globaltable()->insert(operand1.symbol_val(), operand2);
 	}
 	else {
 	    void* oldval = nil;
-	    comterp()->localtable()->find_and_remove(oldval, operand1.symbol_val());
-	    if (oldval) delete (ComValue*)oldval;
-	    comterp()->localtable()->insert(operand1.symbol_val(), operand2);
+	    comterp()->localtable()->find(oldval, operand1.symbol_val());
+	    if (oldval) 
+	      *(ComValue*)oldval = operand2;
+	    else
+	      comterp()->localtable()->insert(operand1.symbol_val(), operand2);
 	}
     } else if (operand1.is_object(Attribute::class_symid())) {
       Attribute* attr = (Attribute*)operand1.obj_val();
       attr->Value(operand2);
     } else {
-        cerr << "assignment to something other than a symbol or attribute (" <<
-          symbol_pntr(operand1.type_symid()) << ") ignored\n";
+        cout << "WARNING:  assignment to something other than a symbol or attribute (" <<
+          symbol_pntr(operand1.type_symid()) << ") ignored -- line " << funcstate()->linenum() << "\n";
+	cout << "comterp stack:  ";
         print_stack_arg_post_eval(0);
 	delete operand2;
     }
@@ -101,7 +107,7 @@ void ModAssignFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) {
 	    push_stack(ComValue::nullval());
 	    return;
@@ -111,9 +117,9 @@ void ModAssignFunc::execute() {
 	push_stack(operand2);
 	ModFunc modfunc(comterp());
 	modfunc.exec(2,0);
-	ComValue* result = new ComValue(pop_stack());
-        _comterp->localtable()->insert(operand1.symbol_val(), result);
-	push_stack(*result);
+	ComValue result(pop_stack());
+        *(ComValue*)op1val = result;
+	push_stack(result);
     }
 
 }
@@ -132,19 +138,18 @@ void MpyAssignFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) {
 	    push_stack(ComValue::nullval());
 	    return;
 	}
 	push_stack(*(ComValue*)op1val);
-	delete (ComValue*)op1val;
 	push_stack(operand2);
 	MpyFunc mpyfunc(comterp());
 	mpyfunc.exec(2,0);
-	ComValue* result = new ComValue(pop_stack());
-        _comterp->localtable()->insert(operand1.symbol_val(), result);
-	push_stack(*result);
+	ComValue result(pop_stack());
+        *(ComValue*)op1val = result;
+	push_stack(result);
     }
 
 }
@@ -152,7 +157,6 @@ void MpyAssignFunc::execute() {
 AddAssignFunc::AddAssignFunc(ComTerp* comterp) : AssignFunc(comterp) {
 }
 
-
 void AddAssignFunc::execute() {
     ComValue operand1(stack_arg(0, true));
     if (operand1.type() != ComValue::SymbolType) {
@@ -163,19 +167,18 @@ void AddAssignFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) {
 	    push_stack(ComValue::nullval());
 	    return;
 	}
 	push_stack(*(ComValue*)op1val);
-	delete (ComValue*)op1val;
 	push_stack(operand2);
 	AddFunc addfunc(comterp());
 	addfunc.exec(2,0);
-	ComValue* result = new ComValue(pop_stack());
-        _comterp->localtable()->insert(operand1.symbol_val(), result);
-	push_stack(*result);
+	ComValue result(pop_stack());
+        *(ComValue*)op1val = result;
+	push_stack(result);
     }
 
 }
@@ -194,19 +197,18 @@ void SubAssignFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) {
 	    push_stack(ComValue::nullval());
 	    return;
 	}
 	push_stack(*(ComValue*)op1val);
-	delete (ComValue*)op1val;
 	push_stack(operand2);
 	SubFunc subfunc(comterp());
 	subfunc.exec(2,0);
-	ComValue* result = new ComValue(pop_stack());
-        _comterp->localtable()->insert(operand1.symbol_val(), result);
-	push_stack(*result);
+	ComValue result(pop_stack());
+        *(ComValue*)op1val = result;
+	push_stack(result);
     }
 
 }
@@ -225,19 +227,18 @@ void DivAssignFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) {
 	    push_stack(ComValue::nullval());
 	    return;
 	}
 	push_stack(*(ComValue*)op1val);
-	delete (ComValue*)op1val;
 	push_stack(operand2);
 	DivFunc divfunc(comterp());
 	divfunc.exec(2,0);
-	ComValue* result = new ComValue(pop_stack());
-        _comterp->localtable()->insert(operand1.symbol_val(), result);
-	push_stack(*result);
+	ComValue result(pop_stack());
+        *(ComValue*)op1val = result;
+	push_stack(result);
     }
 
 }
@@ -253,21 +254,20 @@ void IncrFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val) 
 	    push_stack(ComValue::nullval());
 	else {
 	    push_stack(*(ComValue*)op1val);
-	    delete (ComValue*)op1val;
 	    ComValue one;
 	    one.type(ComValue::IntType);
 	    one.int_ref() = 1;
 	    push_stack(one);
 	    AddFunc addfunc(comterp());
 	    addfunc.exec(2,0);
-	    ComValue* result = new ComValue(pop_stack());
-            _comterp->localtable()->insert(operand1.symbol_val(), result);
-	    push_stack(*result);
+	    ComValue result(pop_stack());
+            *(ComValue*)op1val = result;
+	    push_stack(result);
 	}
     } else 
         push_stack(ComValue::nullval());
@@ -285,7 +285,7 @@ void IncrAfterFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val)
 	    push_stack(ComValue::nullval());
 	else {
@@ -296,10 +296,9 @@ void IncrAfterFunc::execute() {
 	    push_stack(one);
 	    AddFunc addfunc(comterp());
 	    addfunc.exec(2,0);
-	    ComValue* result = new ComValue(pop_stack());
-            _comterp->localtable()->insert(operand1.symbol_val(), result);
+	    ComValue result(pop_stack());
 	    push_stack(*(ComValue*)op1val);
-	    delete (ComValue*)op1val;
+            *(ComValue*)op1val = result;
 	}
     } else 
         push_stack(ComValue::nullval());
@@ -317,21 +316,20 @@ void DecrFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val)
 	    push_stack(ComValue::nullval());
 	else {
 	    push_stack(*(ComValue*)op1val);
-	    delete (ComValue*)op1val;
 	    ComValue one;
 	    one.type(ComValue::IntType);
 	    one.int_ref() = 1;
 	    push_stack(one);
 	    SubFunc subfunc(comterp());
 	    subfunc.exec(2,0);
-	    ComValue* result = new ComValue(pop_stack());
-            _comterp->localtable()->insert(operand1.symbol_val(), result);
-	    push_stack(*result);
+	    ComValue result(pop_stack());
+            *(ComValue*)op1val = result;
+	    push_stack(result);
 	}
     } else 
         push_stack(ComValue::nullval());
@@ -349,7 +347,7 @@ void DecrAfterFunc::execute() {
     reset_stack();
     if (operand1.type() == ComValue::SymbolType) {
         void* op1val = nil;
-        _comterp->localtable()->find_and_remove(op1val, operand1.symbol_val());
+        _comterp->localtable()->find(op1val, operand1.symbol_val());
 	if (!op1val)
 	    push_stack(ComValue::nullval());
 	else {
@@ -360,13 +358,11 @@ void DecrAfterFunc::execute() {
 	    push_stack(one);
 	    SubFunc subfunc(comterp());
 	    subfunc.exec(2,0);
-	    ComValue* result = new ComValue(pop_stack());
-            _comterp->localtable()->insert(operand1.symbol_val(), result);
+	    ComValue result(pop_stack());
 	    push_stack(*(ComValue*)op1val);
-	    delete (ComValue*)op1val;
+            *(ComValue*)op1val = result;
 	}
     } else 
         push_stack(ComValue::nullval());
 
 }
-
--- ivtools-1.2.11a1.orig/src/ComTerp/assignfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/assignfunc.h
@@ -37,7 +37,7 @@ public:
     virtual boolean post_eval() { return true; }
     virtual void execute();
     virtual const char* docstring() { 
-      return "= is the assigment operator"; }
+      return "= is the assignment operator"; }
 
     CLASS_SYMID("AssignFunc");
 };
--- ivtools-1.2.11a1.orig/src/ComTerp/bitfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/bitfunc.cc
@@ -30,6 +30,10 @@
 
 #define TITLE "BitFunc"
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
+
 /*****************************************************************************/
 
 BitAndFunc::BitAndFunc(ComTerp* comterp) : NumFunc(comterp) {
@@ -475,7 +479,7 @@ void BitNotFunc::execute() {
 	break;
     case ComValue::SymbolType:
     case ComValue::StringType:
-        result.boolean_ref() = operand1.symbol_val()<0;
+        result.boolean_ref() = operand1.symbol_val()!=0;
 	break;
     }
     reset_stack();
--- ivtools-1.2.11a1.orig/src/ComTerp/boolfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/boolfunc.cc
@@ -32,6 +32,10 @@
 
 #define TITLE "BoolFunc"
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
+
 static int sym_symid = symbol_add("sym");
 static int n_symid = symbol_add("n");
 
@@ -199,7 +203,7 @@ void NegFunc::execute() {
 	break;
     case ComValue::SymbolType:
     case ComValue::StringType:
-        result.boolean_ref() = operand1.symbol_val()<0;
+        result.boolean_ref() = operand1.symbol_val()==0;
 	break;
     case ComValue::StreamType:
         result.boolean_ref() = !operand1.stream_mode();
@@ -615,5 +619,21 @@ void LessThanOrEqualFunc::execute() {
     push_stack(result);
 }
 
+TrueFunc::TrueFunc(ComTerp* comterp) : NumFunc(comterp) {
+}
+
+void TrueFunc::execute() {
+    reset_stack();
+    push_stack(ComValue::trueval());
+}
+
+FalseFunc::FalseFunc(ComTerp* comterp) : NumFunc(comterp) {
+}
+
+void FalseFunc::execute() {
+    reset_stack();
+    push_stack(ComValue::falseval());
+}
+
 
 
--- ivtools-1.2.11a1.orig/src/ComTerp/boolfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/boolfunc.h
@@ -160,6 +160,30 @@ public:
 
 };
 
+//: returns true
+class TrueFunc : public NumFunc {
+// Accepts any arguments and returns true
+public:
+    TrueFunc(ComTerp*);
+
+    virtual void execute();
+    virtual const char* docstring() { 
+      return "true([...]) -- accepts any arguments and returns true"; }
+
+};
+
+//: returns false
+class FalseFunc : public NumFunc {
+// Accepts any arguments and returns false
+public:
+    FalseFunc(ComTerp*);
+
+    virtual void execute();
+    virtual const char* docstring() { 
+      return "false([...]) -- accepts any arguments and returns false"; }
+
+};
+
 
 #endif /* !defined(_boolfunc_h) */
 
--- ivtools-1.2.11a1.orig/src/ComTerp/comfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/comfunc.cc
@@ -266,7 +266,7 @@ ComValue& ComFunc::stack_arg_post(int n,
   }
 
   int loc = comterp()->_pfnum + offtop + argcnt-1;
-  if (loc<0) fprintf(stderr, "unexpected negative index for _pfcomvals\n");
+  if (loc<0) {fprintf(stderr, "unexpected negative index for _pfcomvals\n"); return ComValue::nullval();}
   else return comterp()->_pfcomvals[loc];
 }
 
@@ -400,9 +400,9 @@ ComFuncState* ComFunc::funcstate() {
 }
 
 void ComFunc::push_funcstate(int nargs, int nkeys, int pedepth,
-			     int command_symid) {
+			     int command_symid, unsigned linenum) {
   ComFuncState cfs(nargs, nkeys, pedepth, 
-		   command_symid==0 ? classid() : command_symid );
+		   command_symid==0 ? classid() : command_symid, linenum );
   _comterp->push_funcstate(cfs);
 }
 
@@ -412,7 +412,7 @@ void ComFunc::pop_funcstate() {
 
 void ComFunc::exec(int nargs, int nkeys, int pedepth,
 		   int command_symid) {
-  push_funcstate(nargs, nkeys, pedepth, command_symid);
+  push_funcstate(nargs, nkeys, pedepth, command_symid, 0);
   execute();
   pop_funcstate();
 }
@@ -526,7 +526,7 @@ ostream& operator<< (ostream& out, const
 /*****************************************************************************/
 
 ComFuncState::ComFuncState(int narg, int nkey, int pedepth, 
-			   int command_symid) {
+			   int command_symid, unsigned linenum) {
   _nargs = narg;
   _nkeys = nkey;
   _npops = 0;
@@ -534,6 +534,7 @@ ComFuncState::ComFuncState(int narg, int
   _nargspost = -1;
   _pedepth = pedepth;
   _command_symid = command_symid;
+  _linenum=linenum;
 }
 
 ComFuncState::ComFuncState(const ComFuncState& cfs) {
--- ivtools-1.2.11a1.orig/src/ComTerp/comfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/comfunc.h
@@ -54,7 +54,7 @@ public:
     // method that needs to be filled in, that will take ComValue arguments
     // off the stack, then compute and push a ComValue result on the stack.
 
-    void exec(int nargs, int nkeys, int pedepth=0, int command_symid=0);
+    virtual void exec(int nargs, int nkeys, int pedepth=0, int command_symid=0);
     // invokes push_funcstate, then plain execute, then pop_funcstate.
     // for use from the body of regular execute methods.
 
@@ -89,7 +89,7 @@ public:
     ComFuncState* funcstate();
     // current ComFuncState for use of current ComFunc.
     void push_funcstate(int nargs, int nkeys, int pedepth=0, 
-                        int command_symid=0);
+                        int command_symid=0, unsigned linenum=0);
     // push new ComFuncState on a stack of them.
     void pop_funcstate();
     // pop the top one off the ComFuncState stack.
@@ -238,7 +238,7 @@ protected:
 // which allows for nested and recursive use of a singular ComFunc.
 class ComFuncState {
 public:
-  ComFuncState(int nargs, int nkeys, int pedepth=0, int command_symid=0);
+  ComFuncState(int nargs, int nkeys, int pedepth=0, int command_symid=0, unsigned linenum=0);
   // initialize with number of arguments (including arguments following
   // keywords), number of keywords, an option post-eval depth (nesting
   // within blocks of post-evaluation commands), and an optional 
@@ -257,10 +257,11 @@ public:
   int& nargspost() { return _nargspost; }
   // number of unevaluated ComValue objects input to a post-evaluation ComFunc.
   int& pedepth() { return _pedepth; }
-  // post-evaluation depth: the nesting within blocks of post-evaluation commands,
-  // within blocks of conditionally executing control commands.
+  // post-evaluation depth: the nesting within blocks of post-evaluation commands  // within blocks of conditionally executing control commands.
   int& command_symid() { return _command_symid; }
   // symbol id associated with the ComFunc.
+  unsigned int& linenum() { return _linenum; }
+  // original line number of command
   
   friend ostream& operator << (ostream& s, const ComFuncState&);
   // print contents to ostream, brief or not depending on
@@ -275,5 +276,6 @@ protected:
   int _nargspost;
   int _pedepth;
   int _command_symid;
+  unsigned _linenum;
 };
 #endif /* !defined(_comfunc_h) */
--- ivtools-1.2.11a1.orig/src/ComTerp/comhandler.cc
+++ ivtools-1.2.11a1/src/ComTerp/comhandler.cc
@@ -26,11 +26,8 @@
 #ifdef HAVE_ACE
 #include <iostream.h>
 #include <fstream.h>
-#if __GNUC__==2 && __GNUC_MINOR__<=7
-#else
 using namespace std;
 #include <vector>
-#endif
 
 #include <ComTerp/comhandler.h>
 #include <ComTerp/comterpserv.h>
@@ -93,15 +90,18 @@ void ComterpHandler::timeoutscriptid(int
 void
 ComterpHandler::destroy (void)
 {
-    if (ComterpHandler::logger_mode()==0)
-        ACE_DEBUG ((LM_DEBUG, 
-		    "(%P|%t) disconnected from %s\n", this->peer_name_));
+  if (ComterpHandler::logger_mode()==0) {
+      const char* peer_name = this->peer_name_;
+      if (*peer_name == '\0') peer_name = "stdio";
+      ACE_DEBUG ((LM_DEBUG, 
+		  "(%P|%t) disconnected from %s\n", peer_name));
+  }
 #if 0
     ComterpHandler::reactor_singleton()->cancel_timer (this);
 #endif
     this->peer ().close ();
     if (_timeoutscriptid<0) {
-      if (comterp_->running()) 
+      if (comterp_ && comterp_->running()) 
 	comterp_->delete_later(1);
       else {
 	delete comterp_;
@@ -140,11 +140,7 @@ ComterpHandler::handle_timeout (const AC
 	    return -1;
 	} else {
 	    if (!comterp_->stack_empty()) {
-#if __GNUC__<3
-	      filebuf obuf(1);
-#else
-	      fileptr_filebuf obuf(stdout, ios_base::out);
-#endif
+	      FILEBUF(obuf, stdout, ios_base::out);
 	      ostream ostr(&obuf);
 	      ostr << "timeexpr result:  ";
 	      comterp_->print_stack_top(ostr);
@@ -206,7 +202,7 @@ ComterpHandler::handle_input (ACE_HANDLE
     } else {
       if (inbuf[0]!='\004')
 	cout << "from pipe(" << fd << "):  " << inbuf << "\n";
-      fileptr_filebuf obuf(fd ? wrfptr() : stdout, ios_base::out);
+      FILEBUF(obuf, fd ? wrfptr() : stdout, ios_base::out);
       ostream ostr(&obuf);
       ostr << "\n";
       ostr.flush();
--- ivtools-1.2.11a1.orig/src/ComTerp/comhandler.h
+++ ivtools-1.2.11a1/src/ComTerp/comhandler.h
@@ -30,6 +30,10 @@
 
 #ifdef HAVE_ACE
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include <stdio.h>
 #ifdef __alpha__
 #define __USE_GNU
@@ -42,6 +46,11 @@
 #include <ace/SOCK_Acceptor.h>
 #include <ace/Test_and_Set.h>
 
+// GNU HURD has no fixed limit
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 4096
+#endif
+
 class ComTerpServ;
 
 //: An ACE_Test_and_Set Singleton.
--- ivtools-1.2.11a1.orig/src/ComTerp/comterp.cc
+++ ivtools-1.2.11a1/src/ComTerp/comterp.cc
@@ -23,15 +23,14 @@
  * 
  */
 
+#include <cstdio>
 #include <ctype.h>
 #include <iostream.h>
 #include <string.h>
 #include <strstream>
 #include <unistd.h>
 
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 #include <ComTerp/comhandler.h>
 
@@ -55,6 +54,7 @@
 #include <ComTerp/listfunc.h>
 #include <ComTerp/mathfunc.h>
 #include <ComTerp/numfunc.h>
+#include <ComTerp/parsefunc.h>
 #include <ComTerp/postfunc.h>
 #include <ComTerp/randfunc.h>
 #include <ComTerp/statfunc.h>
@@ -72,9 +72,7 @@
 #include <string.h>
 #include <strstream>
 #include <unistd.h>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 #ifdef LEAKCHECK
 #include <leakchecker.h>
@@ -297,7 +295,8 @@ void ComTerp::eval_expr_internals(int pe
 	avl->Prepend(new AttributeValue(topval));
       }
 
-      ComValue val(sv.obj_val(), avl);
+      ComValue val((ComFunc*)sv.obj_val(), avl);
+      // fprintf(stderr, "Just packed up stream for %s\n", symbol_pntr(((ComFunc*)sv.obj_val())->funcid()));
       val.stream_mode(1); // for external use
       push_stack(val);
       return;
@@ -323,32 +322,34 @@ void ComTerp::eval_expr_internals(int pe
 	else
 	  func_for_next_expr_post_eval = 1;
       }
-      func->push_funcstate(nargs, nkeys, pedepth, func->funcid());
+      func->push_funcstate(nargs, nkeys, pedepth, func->funcid(), sv.linenum());
     }
 
     /* output execution trace */
     if (this->trace_mode()) {
-      for(int i=0; i<pedepth; i++) cerr << "    ";
-      cerr << symbol_pntr(sv.command_symid());
+      int ln = func->funcstate()->linenum();
+      if(ln<100) cout << " ";
+      if(ln<10) cout << " ";
+      cout << func->funcstate()->linenum() << ":  ";
+      for(int i=0; i<pedepth; i++) cout << "    ";
+      cout << symbol_pntr(sv.command_symid());
       if (func->post_eval()) 
-	cerr << ": nargs=" << nargs << " nkeys=" << nkeys << "\n";
+	cout << ": nargs=" << nargs << " nkeys=" << nkeys << "\n";
       else {
 	int ntotal = func->nargs() + func->nkeys();
 	for(int i=0; i<ntotal; i++) {
 	  if (i) 
-	    cerr << " ";
+	    cout << " ";
 	  else 
-	    cerr << "(";
-	  cerr << stack_top(i-ntotal+1);
+	    cout << "(";
+	  cout << stack_top(i-ntotal+1);
 	}
-	cerr << ")\n";
+	cout << ")\n";
       }
     }
 
     if (stepflag()) {
-      fileptr_filebuf fbufout(handler() && handler()->wrfptr() 
-		      ? handler()->wrfptr() : stdout, 
-		      ios_base::out);
+      FILEBUF(fbufout, handler() && handler()->wrfptr() ? handler()->wrfptr() : stdout, ios_base::out);
       ostream out(&fbufout);
       out << ">>> " << *func << "(" << *func->funcstate() << ")\n";
       static int pause_symid = symbol_add("pause");
@@ -370,6 +371,7 @@ void ComTerp::eval_expr_internals(int pe
     }
 
     func->execute();
+    int linenum = func->funcstate()->linenum();
     func->pop_funcstate();
 
     if (_just_reset && !_func_for_next_expr) {
@@ -378,7 +380,7 @@ void ComTerp::eval_expr_internals(int pe
     }
 
     if (stack_base+1 < _stack_top) {
-      fprintf(stderr, "func \"%s\" pushed more than a single value on stack\n", symbol_pntr(func->funcid()));
+      fprintf(stderr, "func \"%s\" pushed more than a single value on stack (line %d)\n", symbol_pntr(func->funcid()), linenum);
       fprintf(stderr, "stack_base %d, stack_top %d\n", stack_base, _stack_top);
       for(int i=stack_base+1; i<=_stack_top; i++)
           std::cerr << i << ":  " << _stack[i] << "\n";
@@ -404,6 +406,7 @@ void ComTerp::eval_expr_internals(int pe
     } else {
       
       if (_alist) {
+	// cerr << "looking up " << sv.symbol_ptr() << " (" << _alist << ")\n";
 	int id = sv.symbol_val();
 	AttributeValue* val = _alist->find(id);  
 	if (val) {
@@ -411,12 +414,38 @@ void ComTerp::eval_expr_internals(int pe
 	  push_stack(newval);
 	} else
 	  push_stack(ComValue::nullval());
-      } else 
-	push_stack(lookup_symval(sv));
+      } else {
+        ComValue val = lookup_symval(sv);
+        if(val.is_object(FuncObj::class_symid())) {
+          EvalFunc ef(this);
+          if(val.narg()!=val.nkey()) {
+            fprintf(stderr, "free format args not yet supported for custom funcs\n");
+            exit(1);
+	  }
+          if(val.narg()==0) {
+            fprintf(stderr, "keyword arguments needed for custom func invoking\n");
+            exit(1);
+	  }
+          AttributeList* al = new AttributeList();
+          for(int i=0; i<val.narg(); i++) {
+            ComValue keyv(pop_stack());
+            ComValue valv(pop_stack());
+            al->add_attr(keyv.keyid_val(), valv);
+          }
+	  push_stack(val);
+          ComValue alv(AttributeList::class_symid(), al);
+          push_stack(alv);
+	  static int alist_symid = symbol_add("alist");
+	  ComValue alkeyv(alist_symid, 1);
+	  push_stack(alkeyv);
+          ef.exec(2, 1);
+        } else {
+	  push_stack(val);
+	}
+      }
     }
     
   } else if (sv.is_object(Attribute::class_symid())) {
-    
 
     push_stack(*((Attribute*)sv.obj_val())->Value());
     
@@ -485,7 +514,7 @@ void ComTerp::load_sub_expr() {
       } 
     }
     _pfoff++;
-    if (stack_top().type() == ComValue::CommandType && 
+    if ((stack_top().type() == ComValue::CommandType || stack_top().is_funcobj()) && 
 	!_pfcomvals[_pfoff-1].pedepth()) break;
   }
   
@@ -575,7 +604,7 @@ int ComTerp::post_eval_expr(int tokcnt,
 	offset++;
 	if (_pfcomvals[offset-1].pedepth()!=pedepth)
 	  continue;
-	if (stack_top().is_type(ComValue::CommandType) 
+	if ((stack_top().is_type(ComValue::CommandType) || stack_top().is_funcobj()) 
 	    && stack_top().pedepth() == pedepth) break;
       }
 #ifdef POSTEVAL_EXPERIMENT 
@@ -681,12 +710,15 @@ boolean ComTerp::skip_key(ComValue* topv
 boolean ComTerp::skip_arg(ComValue* topval, int& offset, int offlimit, int& tokcnt) {
   tokcnt = 0;
   ComValue& curr = *(topval+offset);
+  // fprintf(stderr, "offset is %d, topval is at 0x%lx\n", offset, topval);
   if (curr.is_type(ComValue::KeywordType)) {
     cerr << "unexpected keyword found by ComTerp::skip_arg\n";
     return false;
+#if 0
   } else if (curr.is_type(ComValue::UnknownType)) {
-    cerr << "unexpected unknown found by ComTerp::skip_arg\n";
+    cerr << "unexpected nil found by ComTerp::skip_arg\n";
     return false;
+#endif
   } else if (curr.is_type(ComValue::BlankType)) {
     if (offlimit == offset) {
       cerr << "offlimit hit by ComTerp::skip_arg\n";
@@ -741,7 +773,7 @@ boolean ComTerp::skip_arg(ComValue* topv
 }
 
 ComValue& ComTerp::expr_top(int n) {
-  if (_pfnum+n < 0 || n>0) {
+  if (((int)_pfnum)+n < 0 || n>0) {
     return ComValue::unkval();    
   }
   else
@@ -750,9 +782,15 @@ ComValue& ComTerp::expr_top(int n) {
 
 
 int ComTerp::print_stack() const {
+    print_stack(cout);
+    return true;
+}
+
+int ComTerp::print_stack(std::ostream& out) const {
     for (int i = _stack_top; i >= 0; i--) {
-	cout << _stack[i] << "\n";
+	out << _stack[i] << "\n";
     }
+    out.flush();
     return true;
 }
 
@@ -931,16 +969,18 @@ ComValue& ComTerp::lookup_symval(ComValu
     if (comval.type() == ComValue::SymbolType) {
         void* vptr = nil;
 
-	if (!comval.global_flag() && localtable()->find(vptr, comval.symbol_val()) ) {
-	  comval.assignval(*(ComValue*)vptr);
-	  return comval;
-	} else  if (_alist) {
+	if (_alist) {
 	  int id = comval.symbol_val();
 	  AttributeValue* aval = _alist->find(id);  
 	  if (aval) {
 	    ComValue newval(*aval);
 	    *&comval = newval;
+	    return comval;
 	  }
+	}
+
+	if (!comval.global_flag() && localtable()->find(vptr, comval.symbol_val()) ) {
+	  comval.assignval(*(ComValue*)vptr);
 	  return comval;
 	} else if (globaltable()->find(vptr, comval.symbol_val())) {
 	  comval.assignval(*(ComValue*)vptr);
@@ -1071,22 +1111,7 @@ int ComTerp::run(boolean one_expr, boole
   char errbuf_save[BUFSIZ];
   errbuf_save[0] = '\0';
 
-#if __GNUC__<3
-  filebuf fbuf;
-  if (handler()) {
-    int fd = Math::max(1, handler()->get_handle());
-    fbuf.attach(fd);
-  } else
-    fbuf.attach(fileno(stdout));
-#elif (__GNUC__==3 && __GNUC_MINOR__<1) || __GNUC__>3 || defined(__CYGWIN__)
-  fileptr_filebuf fbuf(handler() && handler()->wrfptr() 
-		       ? handler()->wrfptr() : (_fd>0 ? fdopen(_fd, "w") : stdout), 
-	       ios_base::out);
-#else
-  fileptr_filebuf fbuf(handler()&&handler()->get_handle()>0 
-		       ? handler()->get_handle() : 1, 
-		       ios_base::out, false, static_cast<size_t>(BUFSIZ));
-#endif
+  FILEBUF(fbuf, handler() && handler()->wrfptr() ? handler()->wrfptr() : (_fd>0 ? fdopen(_fd, "w") : stdout), ios_base::out);
   ostream out(&fbuf);
   boolean eolflag = false;
   boolean errorflag = false;
@@ -1206,6 +1231,8 @@ void ComTerp::add_defaults() {
     add_command("gt_or_eq", new GreaterThanOrEqualFunc(this));
     add_command("lt", new LessThanFunc(this));
     add_command("lt_or_eq", new LessThanOrEqualFunc(this));
+    add_command("true", new TrueFunc(this));
+    add_command("false", new FalseFunc(this));
 
     add_command("stream", new StreamFunc(this));
     add_command("concat", new ConcatFunc(this));
@@ -1236,6 +1263,7 @@ void ComTerp::add_defaults() {
     add_command("exp", new ExpFunc(this));
     add_command("log", new LogFunc(this));
     add_command("log10", new Log10Func(this));
+    add_command("log2", new Log2Func(this));
     add_command("pow", new PowFunc(this));
 
     add_command("acos", new ACosFunc(this));
@@ -1268,6 +1296,7 @@ void ComTerp::add_defaults() {
     add_command("pause", new ComterpPauseFunc(this));
     add_command("step", new ComterpStepFunc(this));
     add_command("stackheight", new ComterpStackHeightFunc(this));
+    // add_command("mallinfo", new ComterpMallInfoFunc(this));
     add_command("symid", new SymIdFunc(this));
     add_command("symval", new SymValFunc(this));
     add_command("symbol", new SymbolFunc(this));
@@ -1287,6 +1316,7 @@ void ComTerp::add_defaults() {
 
     add_command("postfix", new PostFixFunc(this));
     add_command("posteval", new PostEvalFunc(this));
+    add_command("parse", new ParseFunc(this));
 
     add_command("if", new IfThenElseFunc(this));
     add_command("for", new ForFunc(this));
@@ -1358,7 +1388,7 @@ int ComTerp::runfile(const char* filenam
 	if (read_expr()) {
 	    if (eval_expr(true)) {
 	        err_print( stderr, "comterp" );
-	        fileptr_filebuf obuf(stdout, ios_base::out);
+		FILEBUF(obuf, stdout, ios_base::out);
 		ostream ostr(&obuf);
 		ostr << "err\n";
 		ostr.flush();
@@ -1649,7 +1679,7 @@ void ComTerp::push_servstate() {
   _linenum = 0;
   // _just_reset = false;
   _pfcomvals = nil;
-
+  
   if (_ctsstack_top+1 == _ctsstack_siz) {
     _ctsstack_siz *= 2;
     dmm_realloc_size(sizeof(ComTerpState));
@@ -1672,8 +1702,7 @@ void ComTerp::postfix_echo() {
 
 void ComTerp::postfix_echo(postfix_token* pfbuf, int pfnum) {
   // print everything in the pfbuf for this function
-  fileptr_filebuf fbuf(handler() && handler()->wrfptr()
-	       ? handler()->wrfptr() : stdout, ios_base::out);
+  FILEBUF(fbuf,handler() && handler()->wrfptr() ? handler()->wrfptr() : stdout, ios_base::out);
   ostream out(&fbuf);
  
   boolean oldbrief = brief();
--- ivtools-1.2.11a1.orig/src/ComTerp/comterp.h
+++ ivtools-1.2.11a1/src/ComTerp/comterp.h
@@ -113,6 +113,8 @@ public:
     // print the top of the stack to an ostream.
     int print_stack() const;
     // print the entire stack to stdout.
+    int print_stack(std::ostream& out) const;
+    // print the entire stack to stdout.
     int stack_height() { return _stack_top+1; }
     // return current height of the stack.
     boolean brief() const;
@@ -271,10 +273,10 @@ public:
     // echo the postfix tokens
 
     void delim_func(boolean flag) { _delim_func = flag; }
-    // set flag that indicates whether to run a delimeter selected func.
+    // set flag that indicates whether to run a delimiter-selected func.
  
     boolean delim_func() const { return _delim_func; }
-    // return flag that indicates whether to run a delimeter selected func.
+    // return flag that indicates whether to run a delimiter-selected func.
 
     void ignore_commands(boolean flag) { _ignore_commands = flag; }
     // set flag that indicates whether to ignore all built-in commands
@@ -283,16 +285,16 @@ public:
     // return flag that indicates whether to ignore all built-in commands
 
     void autostream(boolean flag) { _autostream = flag; }
-    // set flag that indicates whether to run a delimeter selected func.
+    // set flag that indicates whether to run a delimiter-selected func.
  
     boolean autostream() const { return _autostream; }
-    // return flag that indicates whether to run a delimeter selected func.
+    // return flag that indicates whether to run a delimiter-selected func.
 
     void running(boolean flag) { _running = flag; }
-    // set flag that indicates whether to run a delimeter selected func.
+    // set flag that indicates whether to run a delimiter-selected func.
  
     boolean running() const { return _running; }
-    // return flag that indicates whether to run a delimeter selected func.
+    // return flag that indicates whether to run a delimiter-selected func.
 
     void muted(boolean flag) { _muted = flag; }
     // set flag that indicates whether to mute output
@@ -399,7 +401,7 @@ protected:
     // echos postfix tokens if true
 
     boolean _delim_func;
-    // use delimeter selected func, passing symbol in ::command_symid()
+    // use delimiter-selected func, passing symbol in ::command_symid()
 
     boolean _ignore_commands;
     // ignore any built-in commands.
--- ivtools-1.2.11a1.orig/src/ComTerp/comterpserv.cc
+++ ivtools-1.2.11a1/src/ComTerp/comterpserv.cc
@@ -29,12 +29,11 @@
 #include <ComTerp/comvalue.h>
 #include <ComTerp/ctrlfunc.h>
 #include <ComTerp/strmfunc.h>
+#include <Attribute/attrlist.h>
 #include <OS/math.h>
 #include <iostream.h>
 #include <string.h>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 #if BUFSIZ>1024
 #undef BUFSIZ
@@ -194,7 +193,7 @@ char* ComTerpServ::fd_fgets(char* s, int
     int fd = Math::max(server->_fd, 1);
     char instr[BUFSIZ];
     FILE* ifptr = fd==0 ? stdin : server->handler()->rdfptr();
-    fileptr_filebuf fbuf(ifptr, ios_base::in);
+    FILEBUF(fbuf, ifptr, ios_base::in);
     istream in (&fbuf);
     in.get(instr, BUFSIZ, '\n');  // needs to be generalized with <vector.h>
     server->_instat = in.good(); 
@@ -229,7 +228,7 @@ int ComTerpServ::fd_fputs(const char* s,
 
     int fd = (int)server->_fd;
     FILE* ofptr = fd==1 ? stdout : server->handler()->wrfptr();
-    fileptr_filebuf fbuf(ofptr, ios_base::out);
+    FILEBUF(fbuf, ofptr, ios_base::out);
     ostream out(&fbuf);
     for (; outpos < bufsize-1 && s[outpos]; outpos++)
 	out.put(s[outpos]);
@@ -284,7 +283,7 @@ int ComTerpServ::runfile(const char* fil
       pop_servstate();
       return -1;
     }
-    fileptr_filebuf ibuf(ifptr, ios_base::in);
+    FILEBUF(ibuf, ifptr, ios_base::in);
     istream istr(&ibuf);
     ComValue* retval = nil;
     int status = 0;
@@ -334,7 +333,7 @@ int ComTerpServ::runfile(const char* fil
 	        snprintf(buf, BUFSIZ, "comterp(%s)", filename);
 	        err_print( stderr, buf );
                 FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
-	        fileptr_filebuf obuf(ofptr, ios_base::out);
+	        FILEBUF(obuf, ofptr, ios_base::out);
 		ostream ostr(&obuf);
 		ostr.flush();
 		status = -1;
@@ -371,7 +370,7 @@ int ComTerpServ::runfile(const char* fil
           snprintf(buf, BUFSIZ, "comterp(%s)", filename);
 	  err_print( stderr, buf );
           FILE* ofptr = handler() ? handler()->wrfptr() : stdout; 
-	  fileptr_filebuf obuf(ofptr, ios_base::out);
+	  FILEBUF(obuf, ofptr, ios_base::out);
 	  ostream ostr(&obuf);
 	  ostr.flush();
 	  status = -1;
@@ -432,10 +431,14 @@ ComValue ComTerpServ::run(const char* ex
     return (*_errbuf || status!=FUNCOK) ? ComValue::nullval() : pop_stack();
 }
 
+#include "/usr/include/malloc.h"
+
 ComValue ComTerpServ::run(postfix_token* tokens, int ntokens) {
     _errbuf[0] = '\0';
 
     push_servstate();
+
+    delete _pfbuf;
     _pfbuf = copy_postfix_tokens(tokens, ntokens);
     _pfnum = ntokens;
     _pfoff = 0;
@@ -444,10 +447,12 @@ ComValue ComTerpServ::run(postfix_token*
     err_str(_errbuf, BUFSIZ, "comterp");
 
     ComValue retval(*_errbuf ? ComValue::nullval() : pop_stack());
+    delete _pfbuf;
     _pfbuf = nil;
     _pfnum = 0;
     _pfoff = 0;
     pop_servstate();
+
     return retval;
 }
 
@@ -473,3 +478,44 @@ void ComTerpServ::add_defaults() {
     add_command("eval", new EvalFunc(this));
   }
 }
+
+AttributeValueList* ComTerpServ::parse_next_expr(FILE* fptr) {
+
+    /* save state for this interpreter */
+    push_servstate();
+    
+    /* install different inputs */
+    _inptr = fptr;
+    _infunc = (infuncptr)&fgets;
+    _eoffunc = (eoffuncptr)&feof;
+    _errfunc = (errfuncptr)&ferror;
+    _outfunc = nil;
+
+    /* save tokens to restore after the file has run */
+    int toklen;
+    postfix_token* tokbuf = copy_postfix_tokens(toklen);
+    int tokoff = _pfoff;
+    
+    /* parse a complete expression */
+    int status=0;
+    do {
+	status = parser(_inptr,	 _infunc, _eoffunc, _errfunc, NULL, NULL,
+			_buffer, _bufsiz, &_bufptr, _token, _toksiz, &_linenum,
+			&_pfbuf, &_pfsiz, &_pfnum);
+	if (status) 
+	    err_print( stdout, "parser" );
+	else
+	    for (int i = 0; i < _pfnum; i++) print_pfbuf(_pfbuf,i);
+    } while (status==0 && strlen(_buffer)>_bufptr);
+    // return _pfnum==0 || _pfbuf[_pfnum-1].type != TOK_EOF;
+
+    /* restore tokens */
+    load_postfix(tokbuf, toklen, tokoff);
+    delete tokbuf;
+    
+    /* restore state for this interpreter */
+    pop_servstate();
+
+    return nil;
+
+}
--- ivtools-1.2.11a1.orig/src/ComTerp/comterpserv.h
+++ ivtools-1.2.11a1/src/ComTerp/comterpserv.h
@@ -63,6 +63,9 @@ public:
     // re-initialization.
     virtual ComValue run(postfix_token*, int);
     // execute a buffer of postfix tokens and return the value.
+
+    AttributeValueList* parse_next_expr(FILE*);
+    // parse the next expression from a file.
     
     virtual int runfile(const char*, boolean popen_flag=0);
     // run interpreter on commands read from a file.
--- ivtools-1.2.11a1.orig/src/ComTerp/comvalue.cc
+++ ivtools-1.2.11a1/src/ComTerp/comvalue.cc
@@ -22,6 +22,7 @@
  * 
  */
 
+#include <cstdio>
 #include <Unidraw/Components/grview.h>
 #include <ComTerp/comfunc.h>
 #include <ComTerp/comvalue.h>
@@ -122,6 +123,7 @@ ComValue::ComValue(postfix_token* token)
     _narg = token->narg;
     _nkey = token->nkey;
     _nids = token->nids;  // nids not always used for number-of-ids
+    _linenum = token->ln;
 
     _command_symid = -1;
     _pedepth = 0;
@@ -135,6 +137,7 @@ ComValue& ComValue::operator= (const Com
     _nids = sv._nids;
     _pedepth = sv._pedepth;
     _bquote = sv._bquote;
+    _linenum = sv._linenum;
     #if 0  // duplicated ref_as_needed call in assignval()
     ref_as_needed();
     #endif
@@ -405,10 +408,32 @@ void* ComValue::geta(int id, int compid)
       return obj_val();
   } else {
     if (compid>=0 && object_compview()) {
-      if (((ComponentView*)obj_val())->GetSubject()->IsA(compid))
+      if (((ComponentView*)obj_val())->GetSubject() && 
+	  ((ComponentView*)obj_val())->GetSubject()->IsA(compid))
         return ((ComponentView*)obj_val())->GetSubject();
     }
     return nil;
   }
 }
 
+boolean ComValue::isa(int id, int compid) {
+  if (is_object(id)) {
+    return true;
+  }
+  if (compid>=0 && object_compview()) {
+    if (((ComponentView*)obj_val())->GetSubject() && 
+	((ComponentView*)obj_val())->GetSubject()->IsA(compid))
+      return true;
+  }
+  return false;
+}
+
+boolean ComValue::is_funcobj() {
+  ComValue tv = *this;
+  if (!comterp()) return false;  // required for FuncObj in a ComValue
+  if (is_symbol())
+    tv = ((ComTerp*)comterp())->lookup_symval(tv);
+  else
+    tv = *this;
+  return tv.is_object(FuncObj::class_symid());
+}
--- ivtools-1.2.11a1.orig/src/ComTerp/comvalue.h
+++ ivtools-1.2.11a1/src/ComTerp/comvalue.h
@@ -101,7 +101,9 @@ public:
     // assignment operator.
 
     virtual void* geta(int type, int compid=-1); 
-    // return a pointer if ObjectType matches
+    // return a pointer if ObjectType matches or compid is superclass
+    virtual boolean isa(int type, int compid=-1); 
+    // return true if ObjectType matches or compid is superclass
 
     int narg() const;
     // number of arguments associated with this command or keyword.
@@ -159,6 +161,15 @@ public:
     // returns reference to IntType ComValue with value of -1.
     static ComValue& twoval();
     // returns reference to IntType ComValue with value of 2.
+
+    unsigned linenum() const { return _linenum; }
+    // Get line number of command in script file.
+    void linenum(unsigned ln) { _linenum=ln; }
+    // Set line number of command in script file.
+
+    boolean is_funcobj();
+    // return true if ObjectType of FuncObj
+
 protected:
     void zero_vals() { _narg = _nkey = _nids = _pedepth = _bquote = 0; }
 
@@ -167,6 +178,7 @@ protected:
     int _nids;
     int _pedepth;
     int _bquote;
+    unsigned _linenum;
 
     static const ComTerp* _comterp;
     static ComValue _nullval;
--- ivtools-1.2.11a1.orig/src/ComTerp/ctrlfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/ctrlfunc.cc
@@ -22,6 +22,8 @@
  * 
  */
 
+#include <unistd.h>
+#include <cstdio>
 #include <fstream.h>
 #include <iostream>
 #include <ComTerp/comhandler.h>
@@ -41,12 +43,10 @@
 
 #define TITLE "CtrlFunc"
 
-#if __GNUC__>=3
 static char newline;
-#if __GNUC__>3||__GNUC_MINOR_>1
+#ifndef __APPLE__
 #include <ext/stdio_filebuf.h>
 #endif
-#endif
 
 using std::cerr;
 
@@ -137,7 +137,7 @@ void RunFunc::execute() {
         _comterp->set_args(path);
         const char* oldptr = path;
         char* newptr = runpath+strlen(runpath);
-        bufleft -+ strlen(runpath);
+        bufleft -= strlen(runpath);
         while(!isspace(*oldptr) && *oldptr && --bufleft)
             *newptr++ = *oldptr++;
         *newptr = '\0';
@@ -153,7 +153,11 @@ void RunFunc::execute() {
         fprintf(stderr, "READY(%d) runpath %s\n", depth, runpath);
 #endif
         depth++;
-	_comterp->runfile(runpath, popenv.is_true());
+	if( access( runpath, F_OK ) != -1 ) {
+	  _comterp->runfile(runpath, popenv.is_true());
+	} else {
+	  _comterp->runfile(runfilename.string_ptr(), popenv.is_true());
+	}
         if(_comterp->quitflag()) _comterp->quitflag(0);
         depth--;
 
@@ -191,12 +195,6 @@ void RemoteFunc::execute() {
 
 #ifdef HAVE_ACE
 
-#if __GNUC__==3&&__GNUC_MINOR__<1
-  fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
-  push_stack(ComValue::nullval());
-  return;
-#endif
-
   ACE_SOCK_STREAM *socket = nil;
   ACE_SOCK_Connector *conn = nil;
   SocketObj* socketobj = nil;
@@ -226,31 +224,6 @@ void RemoteFunc::execute() {
   } else
     return;
   
-#if 0
-#if __GNUC__<3
-  filebuf ofbuf;
-  ofbuf.attach(socket->get_handle());
-#elif __GNUC__<4 && !defined(__CYGWIN__)
-  fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out,
-			false, static_cast<size_t>(BUFSIZ));
-#else
-  fileptr_filebuf ofbuf((int)socket->get_handle(), ios_base::out,
-			static_cast<size_t>(BUFSIZ));
-#endif
-  ostream out(&ofbuf);
-  out << cmdstr;
-  if (cmdstr[strlen(cmdstr)-1] != '\n') out << "\n";
-  out.flush();
-#else
-#if 0
-  int i=0;
-  do {
-    if(write(socket->get_handle(), cmdstr+i++, 1)!=1)
-      fprintf(stderr, "Unexpected error writing byte to socket\n");
-  } while ( cmdstr[i]!='\0');
-  if (cmdstr[i-1] != '\n')  
-    write(socket->get_handle(), "\n", 1);
-#else
   int cmdlen = strlen(cmdstr);
   int newline_flag = cmdstr[cmdlen-1]=='\n';
   if (!newline_flag) cmdstr[cmdlen]='\n';
@@ -258,16 +231,7 @@ void RemoteFunc::execute() {
   if (nbytes != cmdlen+(newline_flag?0:1))
       fprintf(stderr, "write to socket failed\n");
   if (!newline_flag) cmdstr[cmdlen]='\0';
-#endif
-#endif
   if (nowaitv.is_false()) {
-#if __GNUC__<3
-    filebuf ifbuf;
-    ifbuf.attach(socket->get_handle());
-    istream in(&ifbuf);
-    char* buf;
-    in.gets(&buf);
-#else
     char buf[BUFSIZ];
     int i=0;
     do {
@@ -275,7 +239,6 @@ void RemoteFunc::execute() {
     } while (i<BUFSIZ-1 && buf[i-1]!='\n');
     if (buf[i-1]=='\n') buf[i]=0;
     // fprintf(stderr, "buf read back from remote %s", buf);
-#endif
     ComValue retval(comterpserv()->run(buf, true));
     push_stack(retval);
   }
@@ -346,12 +309,6 @@ void SocketFunc::execute() {
 
 #ifdef HAVE_ACE
 
-#if __GNUC__==3&&__GNUC_MINOR__<1
-  fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
-  push_stack(ComValue::nullval());
-  return;
-#endif
-
   if (hostv.is_string() && portv.is_known()) {
 
     const char* hoststr = hostv.string_ptr();
@@ -401,13 +358,15 @@ void EvalFunc::execute() {
   AttributeList* old_alist = NULL;
   if (alist) {
       old_alist = comterp()->get_attributes();
+      Resource::ref(old_alist);
       comterp()->set_attributes(alist);
   }
 
   // evaluate every string fixed argument on the stack and return in array
   int numargs = nargsfixed();
   if (numargs>1) {
-    AttributeValueList* avl = nil;
+
+   AttributeValueList* avl = nil;
     for (int i=0; i<numargs; i++) {
       ComValue argv (stack_arg(i));
       if (argv.is_nil()) break;
@@ -418,7 +377,7 @@ void EvalFunc::execute() {
         FuncObj* tokbuf = (FuncObj*)argv.obj_val();
         val = new ComValue(comterpserv()->run(tokbuf->toks(), tokbuf->ntoks()));
       }
-      if (val->is_nil() && symretv.is_true()) {
+      if (!val || val->is_nil() && symretv.is_true()) {
 	delete val;
 	val = new ComValue(argv.symbol_val(), AttributeValue::SymbolType);
       }
@@ -457,8 +416,9 @@ void EvalFunc::execute() {
   } else
     reset_stack();
   
-  if (old_alist)
-    comterp()->set_attributes(old_alist);
+  comterp()->set_attributes(old_alist);
+  Unref(old_alist);
+
   return;
 }
 
--- ivtools-1.2.11a1.orig/src/ComTerp/debugfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/debugfunc.cc
@@ -22,13 +22,9 @@
  * 
  */
 
-#if __GNUC__==2 && __GNUC_MINOR__<=7
-#else
+#include <cstdio>
 #include <vector>
-#endif
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 #include <ComTerp/comhandler.h>
 
@@ -82,10 +78,10 @@ void ComterpPauseFunc::execute_body(ComV
   comterp()->npause()++;
 
   comterp()->push_servstate();
-  fileptr_filebuf fbufin(comterp() && comterp()->handler() && comterp()->handler()->rdfptr() 
+  FILEBUF(fbufin, comterp() && comterp()->handler() && comterp()->handler()->rdfptr() 
 		 ? comterp()->handler()->rdfptr() : stdin, ios_base::in);
   istream in(&fbufin);
-  fileptr_filebuf fbufout(comterp()->handler() && comterp()->handler()->wrfptr()
+  FILEBUF(fbufout, comterp()->handler() && comterp()->handler()->wrfptr()
 		  ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
   ostream out(&fbufout);
 
@@ -173,6 +169,31 @@ void ComterpStackHeightFunc::execute() {
 }
 
 
+/*****************************************************************************/
+
+#include "/usr/include/malloc.h"
+
+ComterpMallInfoFunc::ComterpMallInfoFunc(ComTerp* comterp) : ComFunc(comterp) {
+}
+
+void ComterpMallInfoFunc::execute() {
+  reset_stack();
+  struct mallinfo mi;
+  mi = mallinfo();
+  printf("Total non-mmapped bytes (arena):       %d\n", mi.arena);
+  printf("# of free chunks (ordblks):            %d\n", mi.ordblks);
+  printf("# of free fastbin blocks (smblks):     %d\n", mi.smblks);
+  printf("# of mapped regions (hblks):           %d\n", mi.hblks);
+  printf("Bytes in mapped regions (hblkhd):      %d\n", mi.hblkhd);
+  printf("Max. total allocated space (usmblks):  %d\n", mi.usmblks);
+  printf("Free bytes held in fastbins (fsmblks): %d\n", mi.fsmblks);
+  printf("Total allocated space (uordblks):      %d\n", mi.uordblks);
+  printf("Total free space (fordblks):           %d\n", mi.fordblks);
+  printf("Topmost releasable block (keepcost):   %d\n", mi.keepcost);
+  push_stack(ComValue::zeroval());
+}
+
+
 
 
 
--- ivtools-1.2.11a1.orig/src/ComTerp/debugfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/debugfunc.h
@@ -52,7 +52,7 @@ public:
     virtual void execute();
     virtual void execute_body(ComValue&);
     virtual const char* docstring() { 
-	return "%s -- pause script execution until C/R"; }
+	return "%s([msgstr]) -- pause script execution until C/R"; }
     virtual boolean stepfunc() { return false; }
 
 };
@@ -78,4 +78,14 @@ public:
 	return "%s -- return stack height for debug purposes"; }
 };
 
+//: command to return attribute list of malloc info
+// mallinfo -- return attribute list of malloc info
+class ComterpMallInfoFunc : public ComFunc {
+public:
+    ComterpMallInfoFunc(ComTerp*);
+    virtual void execute();
+    virtual const char* docstring() { 
+	return "%s -- return attribute list of malloc info"; }
+};
+
 #endif /* !defined(_debugfunc_h) */
--- ivtools-1.2.11a1.orig/src/ComTerp/dotfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/dotfunc.cc
@@ -32,6 +32,7 @@
 
 #define TITLE "DotFunc"
 
+using std::cout;
 using std::cerr;
 
 /*****************************************************************************/
@@ -51,19 +52,19 @@ void DotFunc::execute() {
 	  (((Attribute*)before_part.obj_val())->Value()->is_unknown() || 
 	  ((Attribute*)before_part.obj_val())->Value()->is_attributelist())) &&
 	!before_part.is_attributelist()) {
-      cerr << "expression before \".\" needs to evaluate to a symbol or <AttributeList> (instead of "
+      cout << "WARNING: expression before \".\" needs to evaluate to a symbol or <AttributeList> (instead of "
 	   << symbol_pntr(before_part.type_symid());
       if (before_part.is_object())
-        cerr << " of class " << symbol_pntr(before_part.class_symid());
-      cerr << ")\n";
+        cout << " of class " << symbol_pntr(before_part.class_symid());
+      cout << ") -- line " << funcstate()->linenum() << "\n";
       return;
     }
     if (nargs()>1 && !after_part.is_string()) {
-      cerr << "expression after \".\" needs to be a symbol or evaluate to a symbol (instead of "
+      cout << "WARNING: expression after \".\" needs to be a symbol or evaluate to a symbol (instead of "
 	   << symbol_pntr(after_part.type_symid());
       if (before_part.is_object())
-        cerr << " for class " << symbol_pntr(before_part.class_symid());
-      cerr << ")\n";
+        cout << " for class " << symbol_pntr(before_part.class_symid());
+      cout << ") -- line " << funcstate()->linenum() << "\n";
       return;
     }
 
--- ivtools-1.2.11a1.orig/src/ComTerp/helpfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/helpfunc.cc
@@ -36,9 +36,7 @@ vv * FROM LOSS OF USE, DATA OR PROFITS,
 
 #include <iostream.h>
 #include <strstream>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 #include <streambuf>
 using std::streambuf;
 
@@ -84,19 +82,18 @@ void HelpFunc::execute() {
     str_flags = new boolean[nfuncs];
 
     for (int i=0; i<nfuncs; i++) {
-      ComValue& val = stack_arg(i, true);
+      ComValue val = stack_arg(i, true);
       if (val.is_type(AttributeValue::CommandType)) {
 	comfuncs[i] = (ComFunc*)val.obj_val();
 	command_ids[i] = val.command_symid();
 	str_flags[i] = false;
       } else if (val.is_type(AttributeValue::StringType)) {
-	void *vptr = nil;
+ 	void *vptr = nil;
 	comterp()->localtable()->find(vptr, val.string_val());
 	if (vptr && ((ComValue*)vptr)->is_command()) {
-	    comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val();
+	  comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val();
 	} else
 	  comfuncs[i] = nil;
-	command_ids[i] = val.string_val();
 	str_flags[i] = true;
       } else {
 	comfuncs[i] = nil;
@@ -163,24 +160,11 @@ void HelpFunc::execute() {
   reset_stack();
 
   std::strstreambuf sbuf;
-#if __GNUC__<3
-  filebuf fbuf;
-  if (comterp()->handler() && HELPOUT) {
-    int fd = Math::max(1, comterp()->handler()->get_handle());
-    fbuf.attach(fd);
-  } 
-  ostream outs( (comterp()->handler() && HELPOUT) ? ((streambuf*)&fbuf) : (streambuf*)&sbuf );
-  ostream *out = &outs;
-#else
-  fileptr_filebuf fbuf((comterp()->handler() && HELPOUT) && comterp()->handler()->wrfptr()
+  FILEBUF(fbuf, comterp()->handler() && HELPOUT && comterp()->handler()->wrfptr()
 	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
-#if 1
   ostream outs((comterp()->handler() && HELPOUT) ? (streambuf*)&fbuf : (streambuf*)&sbuf);
-#else
-  ostream outs((streambuf*)&fbuf);
-#endif
   ostream *out = &outs;
-#endif
+
 
   if (noargs) {
 
@@ -199,27 +183,21 @@ void HelpFunc::execute() {
 	  if (first) 
 	    first = false;
 	  else
-#if 0
-	    out->put('\n');
-#else
 	    *out << '\n';
-#endif
-#if __GNUC__<3
-	  out->form(comfuncs[i]->docstring2(), symbol_pntr(command_ids[i]));
-#else
 	  {
 	    char buffer[BUFSIZ];
 	    snprintf(buffer, BUFSIZ, 
 		     comfuncs[i]->docstring2(), symbol_pntr(command_ids[i]));
 	    *out << buffer;
 	  }
-#endif
 	  printed = true;
 	}
       }
-      if (!printed && command_ids[i]>=0) {
+     if (!printed && command_ids[i]>=0) {
+
 	/* if symid is smaller than the highest operator it must be one */
 	if (command_ids[i]>=0 && command_ids[i]<=opr_tbl_topstr()) {
+	  fprintf(stderr, "READY FOR OPER STUFF\n");
 	  int op_ids[OPTYPE_NUM];
 	  const char* opstr = symbol_pntr(command_ids[i]);
 	  unsigned int charcnt;
@@ -234,16 +212,12 @@ void HelpFunc::execute() {
 		  first = false;
 		else
 		  out->put('\n');
-#if __GNUC__<3
-		out->form(comfunc->docstring2(), symbol_pntr(value->command_symid()));
-#else
 		{
 		  char buffer[BUFSIZ];
 		  snprintf(buffer, BUFSIZ, 
 			   comfunc->docstring2(), symbol_pntr(value->command_symid()));
 		  *out << buffer;
 		}
-#endif
 	      } else 
 		out_form((*out), "unknown operator: %s\n", symbol_pntr(command_ids[i]));
 
@@ -266,8 +240,8 @@ void HelpFunc::execute() {
 
   if (!comterp()->handler() || !HELPOUT) {
     *out << '\0';
-    int help_str_symid = symbol_add(sbuf.str());
-    ComValue retval(sbuf.str()); 
+    // int help_str_symid = symbol_add(sbuf.str());
+    ComValue retval(sbuf.str());
     push_stack(retval);
   } else
     out->flush();
--- ivtools-1.2.11a1.orig/src/ComTerp/iofunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/iofunc.cc
@@ -36,6 +36,7 @@
 #include <fstream.h>
 #endif
 #include <streambuf>
+#include <unistd.h>
 
 #define TITLE "IoFunc"
 
@@ -116,49 +117,38 @@ void PrintFunc::execute() {
   const char* fstr = formatstr.is_string() ? formatstr.string_ptr() : "nil";
   ComValue::comterp(comterp());
 
-#if __GNUC__<3
   streambuf* strmbuf = nil;
   if (stringflag.is_false() && strflag.is_false() &&
       symbolflag.is_false() && symflag.is_false()) {
-    filebuf * fbuf = new filebuf();
-    strmbuf = fbuf;
-    if (comterp()->handler()) {
-      int fd = Math::max(1, comterp()->handler()->get_handle());
-      fbuf->attach(fd);
-    } else
-      fbuf->attach(fileno(errflag.is_false() ? stdout : stderr));
-  } else {
-    strmbuf = new std::strstreambuf();
-  }
-#else
-  streambuf* strmbuf = nil;
-  if (stringflag.is_false() && strflag.is_false() &&
-      symbolflag.is_false() && symflag.is_false()) {
-    fileptr_filebuf * fbuf = nil;
     if (comterp()->handler() && fileobjv.is_unknown() && errflag.is_false() && outflag.is_false()) {
-      fbuf = new fileptr_filebuf(comterp()->handler() && comterp()->handler()->wrfptr() 
-			 ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+      FILEBUFP(fbuf, comterp()->handler() && comterp()->handler()->wrfptr() 
+	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+      strmbuf = fbuf;
     } else if (fileobjv.is_known()) {
       FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid());
-      if (fileobj) 
-        fbuf = new fileptr_filebuf(fileobj->fptr(), ios_base::out);
-      else {
+      if (fileobj) {
+        FILEBUFP(fbuf, fileobj->fptr(), ios_base::out);
+	strmbuf = fbuf;
+      } else {
         PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid());
-        fbuf = new fileptr_filebuf(pipeobj ? pipeobj->wrfptr() : stdout, ios_base::out);
+        FILEBUFP(fbuf, pipeobj ? pipeobj->wrfptr() : stdout, ios_base::out);
+	strmbuf = fbuf;
       }
-    } else 
-      fbuf = new fileptr_filebuf(errflag.is_false() ? stdout : stderr, ios_base::out);
-    strmbuf = fbuf;
+    } else {
+      FILEBUFP(fbuf, errflag.is_false() ? stdout : stderr, ios_base::out);
+      strmbuf = fbuf;
+    }
   } else
     strmbuf = new std::strstreambuf();
-#endif
   ostream out(strmbuf);
 
   int narg = nargsfixed();
   if (narg==1) {
 
-    if (formatstr.is_string() && !prefixv.is_string())
+    if (formatstr.is_string() && !prefixv.is_string()) {
       out << formatstr.symbol_ptr();
+      out.flush();
+    }
     else {
       if (prefixv.is_string()) out << prefixv.symbol_ptr();
       out << formatstr;  // which could be arbitrary ComValue
@@ -257,6 +247,10 @@ void PrintFunc::execute() {
 	out_form(out, fbuf, nil);
 	break;
 	
+      case ComValue::ObjectType:
+	out_form(out, fbuf, symbol_pntr(printval.class_symid()));
+	break;
+	
       default:
 	break;
       }
@@ -274,8 +268,10 @@ void PrintFunc::execute() {
     int symbol_id = symbol_add(((std::strstreambuf*)strmbuf)->str());
     ComValue retval(symbol_id, ComValue::SymbolType);
     push_stack(retval);
-  } else
+  } else {
+    out.flush();
     push_stack(ComValue::blankval());
+  }
 
   delete strmbuf;
 
@@ -373,6 +369,7 @@ void OpenFileFunc::execute() {
     PipeObj* pipeobj = new PipeObj(filenamev.string_ptr());
     ComValue retval(PipeObj::class_symid(), (void*)pipeobj);
     push_stack(retval);
+#ifdef HAVE_ACE
     if (Component::use_unidraw()) {
       ComterpHandler* pipe_handler = new ComterpHandler(comterpserv());
       if (ComterpHandler::reactor_singleton()->register_handler(pipeobj->rdfd(), pipe_handler, 
@@ -382,6 +379,7 @@ void OpenFileFunc::execute() {
       }
       pipe_handler->log_only(1);
     }
+#endif
   } else {
     FileObj* fileobj = new FileObj(filenamev.string_ptr(), modev.is_string() ? modev.string_ptr() : "r", pipeflagv.is_true());
     if (fileobj->fptr())  {
--- ivtools-1.2.11a1.orig/src/ComTerp/listfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/listfunc.cc
@@ -122,12 +122,13 @@ void ListAtFunc::execute() {
 
   reset_stack();
 
-  if (listv.is_type(ComValue::ArrayType) && !nv.is_nil() && 
-      (nv.int_val()>=0 || insflag)) {
+  if (listv.is_type(ComValue::ArrayType) && 
+      (nv.is_nil() || nv.int_val()>=0 )) {
     AttributeValueList* avl = listv.array_val();
+    int nvv = nv.is_nil() ? avl->Number()-1 : nv.int_val();
     if (avl) {
       if (insflag) {
-	avl->Insert(nv.int_val(), new AttributeValue(insv));
+	avl->Insert(nvv, new AttributeValue(insv));
 	push_stack(insv);
 	return;
       } else if (setflag) {
@@ -136,21 +137,24 @@ void ListAtFunc::execute() {
 	push_stack(setv);
 	return;
       } else {
-	AttributeValue* retv = avl->Get(nv.int_val());
-	if (retv)
-	  push_stack(*retv);
-	else
+	AttributeValue* retv = avl->Get(nvv);
+	if (retv) {
+          ComValue rv = *retv;
+          if(rv.is_symbol()) rv.bquote(1);
+	  push_stack(rv);
+	} else
 	  push_stack(ComValue::blankval());
 	return;
       }
     }
   } else if (listv.is_object(AttributeList::class_symid())) {
     AttributeList* al = (AttributeList*)listv.obj_val();
-    if (al && nv.int_val()<al->Number()) {
+    int nvv = nv.is_nil() ? al->Number()-1 : nv.int_val();
+    if (al && nvv<al->Number()) {
       int count = 0;
       Iterator it;
       for (al->First(it); !al->Done(it); al->Next(it)) {
-	if (count==nv.int_val()) {
+	if (count==nvv) {
 	  ComValue retval(Attribute::class_symid(), (void*) al->GetAttr(it));
 	  if (insflag) {
 	    fprintf(stderr, "Insert not yet supported for AttributeList\n");
@@ -164,15 +168,16 @@ void ListAtFunc::execute() {
     }
   } else if (listv.is_string()) {
     const char* str = listv.string_ptr();
+    int nvv = nv.is_nil() ? strlen(str)-1 : nv.int_val();
     if(!setflag) {
       if(strlen(str) > nv.int_val()) {
-        ComValue retval(*(str+nv.int_val()), ComValue::CharType);
+        ComValue retval(*(str+nvv), ComValue::CharType);
         push_stack(retval);
         return;
       }
     } else {
-      if(nv.int_val()<strlen(str) && nv.int_val()>=0) {
-	*((char *)str+nv.int_val()) = setv.char_val();
+      if(nvv<strlen(str) && nvv>=0) {
+	*((char *)str+nvv) = setv.char_val();
 	ComValue retval(setv);
 	push_stack(retval);
 	return;
@@ -205,7 +210,7 @@ void ListSizeFunc::execute() {
       push_stack(retval);
       return;			  
     }
-  } else if (listv.is_string()) {
+  } else if (listv.is_string() || listv.is_symbol()) {
     ComValue retval((int)strlen(listv.symbol_ptr()), ComValue::IntType);
     push_stack(retval);
     return;
@@ -268,6 +273,9 @@ void ListIndexFunc::execute() {
   static int all_symid = symbol_add("all");
   ComValue allv(stack_key(all_symid));
   boolean allflag = allv.is_true();
+  static int substr_symid = symbol_add("substr");
+  ComValue substrv(stack_key(substr_symid));
+  boolean substrflag = substrv.is_true();
   reset_stack();
 
   AttributeValueList *nvl = allflag ? new AttributeValueList : nil;
@@ -280,12 +288,18 @@ void ListIndexFunc::execute() {
 	avl->First(it);
       int index= lastflag ? avl->Number()-1 : 0;
       while(!avl->Done(it)) {
+        int match;
 	AttributeValue* testv = avl->GetAttrVal(it);
-	comterp()->push_stack(*testv);
-	comterp()->push_stack(valv);
-	EqualFunc eqfunc(comterp());
-	eqfunc.exec(2,0);
-	if(comterp()->pop_stack().is_true()) {
+        if(!substrflag) {
+	  comterp()->push_stack(*testv);
+	  comterp()->push_stack(valv);
+	  EqualFunc eqfunc(comterp());
+	  eqfunc.exec(2,0);
+	  match =  comterp()->pop_stack().is_true();
+	} else {
+	  match = strstr(testv->string_ptr(), valv.string_ptr()) != NULL;
+	}
+	if(match) {
 	  if (allflag)
 	    nvl->Append(new AttributeValue(index, AttributeValue::IntType));
 	  else {
@@ -294,13 +308,14 @@ void ListIndexFunc::execute() {
 	    return;
 	  }
 	}
+	
 	if (lastflag)
 	  avl->Prev(it);
 	else
 	  avl->Next(it);
 	index += lastflag ? -1 : 1;
       };
-
+      
   } else if (listorstrv.is_string()) {
 
       if (valv.is_char()) {
--- ivtools-1.2.11a1.orig/src/ComTerp/listfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/listfunc.h
@@ -45,7 +45,7 @@ public:
     virtual void execute();
     virtual boolean post_eval() { return true; }
     virtual const char* docstring() { 
-      return "lst=%s([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream"; }
+      return "lst=%s([olst|strm|val] :strmlst :attr :size n) -- create list, copy list, or convert stream (unary $$)"; }
 };
 
 //: list member command for ComTerp.
@@ -85,14 +85,14 @@ public:
 
 
 //: list index command for ComTerp.
-// val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
+// val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
 class ListIndexFunc : public ComFunc {
 public:
     ListIndexFunc(ComTerp*);
 
     virtual void execute();
     virtual const char* docstring() { 
-      return "num=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found"; }
+      return "num=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found"; }
 };
 
 #endif /* !defined(_listfunc_h) */
--- ivtools-1.2.11a1.orig/src/ComTerp/mathfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/mathfunc.cc
@@ -73,6 +73,20 @@ void Log10Func::execute() {
     push_stack(result);
 }
 
+Log2Func::Log2Func(ComTerp* comterp) : ComFunc(comterp) {
+}
+
+void Log2Func::execute() {
+    ComValue operandx = stack_arg(0);
+    reset_stack();
+    if (operandx.is_nil()) {
+      push_stack(ComValue::nullval());
+      return;
+    }
+    ComValue result(log2(operandx.double_val()));
+    push_stack(result);
+}
+
 PowFunc::PowFunc(ComTerp* comterp) : ComFunc(comterp) {
 }
 
--- ivtools-1.2.11a1.orig/src/ComTerp/mathfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/mathfunc.h
@@ -67,6 +67,18 @@ public:
 
 };
 
+//: logarithmic (base 2) command for ComTerp.
+// dbl=log2(x) -- returns the base-2 logarithm of x.
+class Log2Func : public ComFunc {
+public:
+    Log2Func(ComTerp*);
+
+    virtual void execute();
+    virtual const char* docstring() { 
+      return "dbl=%s(x) -- returns the base-2 logarithm of x"; }
+
+};
+
 //: power command for ComTerp.
 // dbl=pow(x y) -- returns the value of x raised to the power of y.
 class PowFunc : public ComFunc {
--- ivtools-1.2.11a1.orig/src/ComTerp/numfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/numfunc.cc
@@ -35,6 +35,10 @@
 
 #define TITLE "NumFunc"
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
+
 /*****************************************************************************/
 
 NumFunc::NumFunc(ComTerp* comterp) : ComFunc(comterp) {
@@ -55,8 +59,8 @@ void NumFunc::promote(ComValue& op1, Com
     ComValue* greater = op1bigger ? &op1 : &op2;
     ComValue* lesser =  op1bigger ? &op2 : &op1;
 
-    /* skip promotion if first is string */
-    if (op1.type()==ComValue::StringType) return;
+    /* skip promotion if first is string or symbol */
+    if (op1.type()==ComValue::StringType || op1.type()==ComValue::SymbolType) return;
 
     /* first do the integral promotions if necessary */
     switch (greater->type()) {
@@ -189,13 +193,16 @@ AddFunc::AddFunc(ComTerp* comterp) : Num
 }
 
 void AddFunc::execute() {
-    ComValue& operand1 = stack_arg(0);
-    ComValue& operand2 = stack_arg(1);
+    ComValue operand1 = stack_arg(0);
+    ComValue operand2 = stack_arg(1);
+    const char* s1 = operand1.type_name();
+    const char* s2 = operand2.type_name();
     promote(operand1, operand2);
     ComValue result(operand1);
+    reset_stack();
 
     if (operand1.is_unknown() || operand2.is_unknown()) {
-      reset_stack();
+      fprintf(stderr, "Unknown add operand:  %s+%s (line %d)\n", s1, s2, funcstate()->linenum());
       push_stack(ComValue::nullval());
       return;
     }
@@ -236,14 +243,16 @@ void AddFunc::execute() {
 	result.double_ref() = operand1.double_val() + operand2.double_val();
 	break;
     case ComValue::StringType:
+    case ComValue::SymbolType:
         { // braces are work-around for gcc-2.8.1 bug in stack mgmt.
-             if (operand2.is_string()) {
+          if (operand2.is_string()) {
             int len1 = strlen(operand1.string_ptr()); 
             int len2 = strlen(operand2.string_ptr()); 
             char buffer[len1+len2+1];
             strcpy(buffer, operand1.string_ptr());
             strcpy(buffer+len1, operand2.string_ptr());
             result.string_ref()  = symbol_add(buffer);
+	    result.ref_as_needed();
             // symbol_reference(result.string_val());
           } else {
             int len1 = strlen(operand1.string_ptr()); 
@@ -252,6 +261,7 @@ void AddFunc::execute() {
             buffer[len1] = operand2.char_val();
             buffer[len1+1] = '\0';
             result.string_ref()  = symbol_add(buffer);
+	    result.ref_as_needed();
             // symbol_reference(result.string_val());
           }
 	}
@@ -269,8 +279,11 @@ void AddFunc::execute() {
         }
         break;
 
+    default: {
+        fprintf(stderr, "Unhandled add operand1 type %s (line %d)\n", operand1.type_name(), funcstate()->linenum());
+        }
+        break;
     }
-    reset_stack();
     push_stack(result);
 }
 
--- /dev/null
+++ ivtools-1.2.11a1/src/ComTerp/parsefunc.cc
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2015 Eta Compute Inc.
+ * Copyright (c) 2001 Scott E. Johnston
+ * Copyright (c) 1998 Vectaport Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ */
+
+#include <ComTerp/parsefunc.h>
+#include <ComTerp/iofunc.h>
+
+#include <Attribute/attrlist.h>
+#include <Attribute/attrvalue.h>
+
+#include <iostream.h>
+#if __GNUC__>=3
+#include <fstream.h>
+#endif
+
+#define TITLE "ParseFunc"
+
+
+/*****************************************************************************/ 
+ParseFunc::ParseFunc(ComTerp* comterp) : ComFunc(comterp) {
+}
+
+void ParseFunc::execute() {
+    ComValue fileobjv(stack_arg(0));
+    reset_stack();
+    
+    FileObj *fileobj = (FileObj*)fileobjv.geta(FileObj::class_symid());
+    FILE* fptr = NULL;
+    if (fileobj && fileobj->fptr()) {
+	fptr = fileobj->fptr();
+    } else {
+	PipeObj *pipeobj = (PipeObj*)fileobjv.geta(PipeObj::class_symid());
+	if (pipeobj && pipeobj->rdfptr()) 
+	    fptr = pipeobj->rdfptr();
+	else
+
+	    push_stack(ComValue::nullval());
+    }
+
+    comterpserv()->parse_next_expr(fptr);
+
+    push_stack(ComValue::trueval());
+    
+}
--- /dev/null
+++ ivtools-1.2.11a1/src/ComTerp/parsefunc.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015 Eta Compute Inc.
+ * Copyright (c) 2001 Scott E. Johnston
+ * Copyright (c) 1998,1999 Vectaport Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ */
+
+#if !defined(_parsefunc_h)
+#define _parsefunc_h
+
+#include <ComTerp/comfunc.h>
+
+class ComTerp;
+class AttributeValueList;
+
+//: parse a single expression from a file
+// parse(fileobj) -- parse a single expression from a file
+class ParseFunc : public ComFunc {
+public:
+    ParseFunc(ComTerp*);
+    virtual void execute();
+
+    virtual const char* docstring() { 
+      return "%s(fileobj) -- parse a single expression from a file"; }
+
+    AttributeValueList* parse_next_expr();
+};
+
+#endif /* !defined(_parsefunc_h) */
--- ivtools-1.2.11a1.orig/src/ComTerp/parser.cc
+++ ivtools-1.2.11a1/src/ComTerp/parser.cc
@@ -30,9 +30,7 @@
 
 #define TITLE "Parser"
 
-#if __GNUC__>=3
 static char newline;
-#endif
 
 /*****************************************************************************/
 
@@ -99,7 +97,7 @@ int Parser::print_next_expr()
 	err_print( stdout, "parser" );
     else
 	for (int i = 0; i < _pfnum; i++) print_pfbuf(_pfbuf,i);
-    return _pfbuf[_pfnum-1].type != TOK_EOF;
+    return _pfnum==0 || _pfbuf[_pfnum-1].type != TOK_EOF;
 }
 
 postfix_token* Parser::copy_postfix_tokens(int& ntokens) {
@@ -152,14 +150,9 @@ boolean Parser::skip_matched_parens() {
 
 char* Parser::istream_fgets(char* s, int n, void* instreamp) {
   istream& in  = *(istream*)instreamp;
-#if __GNUC__<3
-  char *instr;
-  in.gets(&instr);
-#else
   char instr[BUFSIZ];
   in.get(instr, BUFSIZ);  // needs to be generalized with <vector.h>
   in.get(newline);
-#endif
   if (in.good()) {
     int i = 0;
     for (; i<n-2; i++) {
--- ivtools-1.2.11a1.orig/src/ComTerp/postfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/postfunc.cc
@@ -52,8 +52,8 @@ PostFixFunc::PostFixFunc(ComTerp* comter
 
 void PostFixFunc::execute() {
   // print everything on the stack for this function
-  fileptr_filebuf fbuf(comterp()->handler() && comterp()->handler()->wrfptr()
-	       ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
+  FILEBUF(fbuf, comterp()->handler() && comterp()->handler()->wrfptr()
+	  ? comterp()->handler()->wrfptr() : stdout, ios_base::out);
   ostream out(&fbuf);
  
   boolean oldbrief = comterp()->brief();
@@ -256,11 +256,11 @@ BreakFunc::BreakFunc(ComTerp* comterp) :
 }
 
 void BreakFunc::execute() {
+  ComValue retval(stack_arg(0,true,ComValue::trueval()));
   reset_stack();
 
   SeqFunc::breakflag(1);
 
-  ComValue retval(ComValue::trueval());
   push_stack(retval);
   return;
 }
@@ -327,6 +327,7 @@ void FuncObjFunc::execute() {
       comterp()->postfix_echo(tokbuf, toklen);
     FuncObj* tokbufobj = new FuncObj(tokbuf, toklen);
     ComValue retval(FuncObj::class_symid(), (void*)tokbufobj);
+    retval.comterp(comterp());
     push_stack(retval);
   }
 }
--- ivtools-1.2.11a1.orig/src/ComTerp/postfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/postfunc.h
@@ -131,7 +131,7 @@ public:
 
     virtual void execute();
     virtual const char* docstring() { 
-      return "%s -- break out of for or while loop"; }
+      return "break([retval]) -- break out of for or while loop"; }
 
 };
 
--- ivtools-1.2.11a1.orig/src/ComTerp/scanner.h
+++ ivtools-1.2.11a1/src/ComTerp/scanner.h
@@ -25,7 +25,7 @@
  * Scanner returns a stream of tokens for the ComTerp language
  */
 
-#if !defined(scanner_h)
+#if !defined(_scanner_h)
 #define _scanner_h
 
 #include <ComTerp/lexscan.h>
--- ivtools-1.2.11a1.orig/src/ComTerp/strmfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/strmfunc.cc
@@ -38,6 +38,33 @@
 StrmFunc::StrmFunc(ComTerp* comterp) : ComFunc(comterp) {
 }
 
+void StrmFunc::print_stream(std::ostream& out, AttributeValue& streamv) {
+  static int indent=0;
+  if(!streamv.is_stream()) 
+    out << "NOT A STREAM\n";
+  else {
+    for (int i=0; i<indent; i++) out << ' ';
+    out << "func = " << (streamv.stream_func() ? symbol_pntr(((ComFunc*)streamv.stream_func())->funcid()) : "NOFUNC")
+              << ", avl = " << *streamv.stream_list() << "\n";
+    if (streamv.stream_func()==NULL) 
+      out << "Unexpected NOFUNC\n";
+    Iterator it;
+    streamv.stream_list()->First(it);
+    int j=0;
+    while(!streamv.stream_list()->Done(it)) {
+      if (streamv.stream_list()->GetAttrVal(it)->is_stream()) {
+        indent+=3;
+        out << "depth=" << indent/3 << ", argc="  << j << ":  ";
+        StrmFunc::print_stream(out, *streamv.stream_list()->GetAttrVal(it));
+        indent-=3;
+      }
+      j++;
+      streamv.stream_list()->Next(it);
+    }
+    out.flush();
+  }
+}
+
 /*****************************************************************************/
 
 int StreamFunc::_symid;
@@ -87,6 +114,12 @@ void StreamFunc::execute() {
       ComValue stream(snfunc, avl);
       stream.stream_mode(-1); // for internal use (use by this func)
       push_stack(stream);
+    } else {
+      AttributeValueList* avl = new AttributeValueList();
+      avl->Append(new AttributeValue(operand1));
+      ComValue stream(snfunc, avl);
+      stream.stream_mode(-1); // for internal use (use by this func)
+      push_stack(stream);
     }
     
   }
@@ -352,6 +385,7 @@ void NextFunc::execute() {
 }
 
 void NextFunc::execute_impl(ComTerp* comterp, ComValue& streamv) {
+
     _next_depth++;
 
     if (!streamv.is_stream()) {
@@ -361,6 +395,8 @@ void NextFunc::execute_impl(ComTerp* com
 
     int outside_stackh = comterp->stack_height();
 
+    // fprintf(stderr, "stream:  mode=%d, name=%s, depth=%d\n", streamv.stream_mode(), symbol_pntr(((ComFunc*)streamv.stream_func())->funcid()), _next_depth);
+
     if (streamv.stream_mode()<0) {
 
       /* internal execution -- handled by stream func */
@@ -397,12 +433,22 @@ void NextFunc::execute_impl(ComTerp* com
 	    if (val->stream_mode()<0 && val->stream_func()) {
 	      /* internal use */
 	      comterp->push_stack(*val);
+
+              // fprintf(stdout, "Stack before stream_func exec\n");
+              // comterp->print_stack();
+
 	      ((ComFunc*)val->stream_func())->exec(1,0);
 	    }else {
 
 	      /* external use */
 	      ComValue cval(*val);
+              // fprintf(stderr, "before: strm arg 0x%lx, stack_top %d\n", val, comterp->stack_height());
+
+              // fprintf(stdout, "Stack before NextFunc::execute_impl\n");
+              // comterp->print_stack();
+
 	      NextFunc::execute_impl(comterp, cval);
+              // fprintf(stderr, "after:  strm arg 0x%lx, stack_top %d\n", val, comterp->stack_height());
 
 	    }
 	    
@@ -434,6 +480,9 @@ void NextFunc::execute_impl(ComTerp* com
 	  avl->Next(i);
 	}
 
+        // fprintf(stdout, "Stack before streamed func %s\n", symbol_pntr(funcptr->funcid()));
+        // comterp->print_stack();
+
 	funcptr->exec(narg, nkey);
       }
 
@@ -489,10 +538,10 @@ FilterFunc::FilterFunc(ComTerp* comterp)
 
 void FilterFunc::execute() {
   ComValue streamv(stack_arg_post_eval(0));
-  ComValue filterv(stack_arg(1));
+  ComValue filterv(stack_arg_post_eval(1));
   reset_stack();
 
-  /* setup for filterenation */
+  /* setup for filtering */
   static FilterNextFunc* flfunc = nil;
   
   if (!flfunc) {
--- ivtools-1.2.11a1.orig/src/ComTerp/strmfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/strmfunc.h
@@ -39,6 +39,7 @@ class StrmFunc : public ComFunc {
 public:
     StrmFunc(ComTerp*);
 
+    static void print_stream(std::ostream& out, AttributeValue& streamv);
 };
 
 //: stream command
@@ -49,7 +50,7 @@ public:
     virtual void execute();
     virtual boolean post_eval() { return true; }
     virtual const char* docstring() { 
-      return "strm=%s(ostrm|list|attrlist) -- copy stream or convert list"; }
+      return "strm=%s(ostrm|list|attrlist|val) -- copy stream or convert list (unary $)"; }
 
     CLASS_SYMID("StreamFunc");
 
@@ -76,7 +77,7 @@ public:
     virtual void execute();
     virtual boolean post_eval() { return true; }
     virtual const char* docstring() { 
-      return ",, is the concat operator"; }
+      return ",, is the stream concat operator"; }
 
     CLASS_SYMID("ConcatFunc");
 
@@ -89,7 +90,7 @@ public:
 
     virtual void execute();
     virtual const char* docstring() { 
-      return "hidden func used by next command for ,, (concat) operator."; }
+      return "hidden func used by next command for ,, (stream concat) operator."; }
 
     CLASS_SYMID("ConcatNextFunc");
 
@@ -154,7 +155,7 @@ public:
     virtual void execute();
     virtual boolean post_eval() { return true; }
     virtual const char* docstring() { 
-      return "val=filter(strm classid)"; }
+      return "val=filter(strm classid) filter a stream for a given classid"; }
 
     CLASS_SYMID("FilterFunc");
 
@@ -172,5 +173,4 @@ public:
     CLASS_SYMID("FilterNextFunc");
 
 };
-
 #endif /* !defined(_strmfunc_h) */
--- ivtools-1.2.11a1.orig/src/ComTerp/symbolfunc.cc
+++ ivtools-1.2.11a1/src/ComTerp/symbolfunc.cc
@@ -255,35 +255,65 @@ SplitStrFunc::SplitStrFunc(ComTerp* comt
 }
 
 void SplitStrFunc::execute() {
+  ComValue zerov(0, ComValue::IntType);
   ComValue commav(',');
   ComValue symvalv(stack_arg(0));
   static int tokstr_symid = symbol_add("tokstr");
-  ComValue tokstrv(stack_key(tokstr_symid, false, commav));
+  ComValue tokstrv(stack_key(tokstr_symid, false, zerov));
   boolean tokstrflag = tokstrv.is_known();
   static int tokval_symid = symbol_add("tokval");
-  ComValue tokvalv(stack_key(tokval_symid, false, commav));
+  ComValue tokvalv(stack_key(tokval_symid, false, zerov));
   boolean tokvalflag = tokvalv.is_known();
+  static int keep_symid = symbol_add("keep");
+  ComValue keepflagv(stack_key(keep_symid));
+  boolean keepflag = keepflagv.is_true();
+  static int reverse_symid = symbol_add("reverse");
+  ComValue reverseflagv(stack_key(reverse_symid));
+  boolean reverseflag = reverseflagv.is_true();
   reset_stack();
 
+  boolean tokstr_charflag = tokstrv.is_type(ComValue::CharType);
+  if(tokstrv.is_type(ComValue::IntType)) tokstrv = commav;
+  if(tokvalv.is_type(ComValue::IntType)) tokvalv = commav;
+  
+
   if (symvalv.is_string()) {
     AttributeValueList* avl = new AttributeValueList();
     ComValue retval(avl);
     const char* str = symvalv.symbol_ptr();
+    const char* strbase = str;
     int len = strlen(str);
+    char delim = tokstrv.char_val();
+    char delimstr[2];
+    delimstr[0] = delim;
+    delimstr[1] = '\0';
     if (!tokstrflag && !tokvalflag) {
       for (int i=0; i<len; i++)
-	avl->Append(new AttributeValue(str[i]));
+        if (reverseflag) 
+	  avl->Prepend(new AttributeValue(str[i]));
+	else
+	  avl->Append(new AttributeValue(str[i]));
     } else if (tokstrflag) {
       char buffer[BUFSIZ];
       int bufoff = 0;
-      char delim = tokstrv.char_val();
       while (*str) {
         int delim1=0;
-        while(*str && (isspace(*str) || *str==delim)) {
+        while(*str && isspace(*str) || *str==delim) {
           if (*str==delim) {
             if ((delim1 || avl->Number()==0) && !isspace(delim) ) {
-              ComValue* comval = new ComValue(ComValue::nullval());
-              avl->Append(comval);
+	      if (keepflag) {
+		ComValue* comval = new ComValue(delimstr);
+		if (reverseflag) 
+		  avl->Prepend(comval);
+		else
+		  avl->Append(comval);
+	      } else {
+		ComValue* comval = new ComValue(ComValue::nullval());
+		if (reverseflag) 
+		  avl->Prepend(comval);
+		else
+		  avl->Append(comval);
+	      }
             } else
               delim1=1;
           }
@@ -291,20 +321,40 @@ void SplitStrFunc::execute() {
         }
 	if (!*str) {
           if (delim1 && !isspace(delim)) {
-            ComValue* comval = new ComValue(ComValue::nullval());
-            avl->Append(comval);
+	    if (keepflag) {
+	      ComValue* comval = new ComValue(delimstr);
+	      if (reverseflag)
+		avl->Prepend(comval);
+	      else
+		avl->Append(comval);
+	    } else {
+	      ComValue* comval = new ComValue(ComValue::nullval());
+	      if (reverseflag) 
+		avl->Prepend(comval);
+	      else
+		avl->Append(comval);
+	    }
           }
           break;
         }
-        while (*str && !isspace(*str) && *str!=delim && bufoff<BUFSIZ-1) {
+        // some uses need this, can't remember which
+         while (*str && (/**/tokstr_charflag?(*str!='\n'&&*str!='\r'):/**/!isspace(*str)) && *str!=delim && bufoff<BUFSIZ-1) {
           if(*str=='"') {
-            while(*str && (*str!='"' || *(str-1)!='\\') && bufoff<BUFSIZ-1) 
-              buffer[bufoff++] = *str++;
+            buffer[bufoff++] = *str++;
+            while(*str && *str!='"' && bufoff<BUFSIZ-1) {
+               buffer[bufoff++] = *str++;
+	    }
           }
           buffer[bufoff++] = *str++;
         }
+ 	if (keepflag & avl->Number()>0 ) {
+	  if (reverseflag)
+	    avl->Prepend(new ComValue(*str==delim ? delimstr : " "));
+	  else
+	    avl->Append(new ComValue(*str==delim ? delimstr : " "));
+	}
 	buffer[bufoff] = '\0';
-	avl->Append(new AttributeValue(buffer));
+	avl->Append(new ComValue(buffer));
 	bufoff=0;
       }
     } else {
@@ -317,7 +367,10 @@ void SplitStrFunc::execute() {
           if (*str==delim) {
               if((delim1 || avl->Number()==0) && !isspace(delim)) {
               ComValue* comval = new ComValue(ComValue::nullval());
-              avl->Append(comval);
+	      if (reverseflag) 
+		avl->Prepend(comval);
+	      else
+		avl->Append(comval);
             } else 
               delim1=1;
           }
@@ -326,16 +379,29 @@ void SplitStrFunc::execute() {
 	if (!*str) {
             if (delim1 && !isspace(delim)) {
             ComValue* comval = new ComValue(ComValue::nullval());
-            avl->Append(comval);
-          }
+	    if (reverseflag) 
+	      avl->Prepend(comval);
+	    else
+	      avl->Append(comval);
+	    }
           break;
         }
 	while (*str && !isspace(*str) && *str!=delim && bufoff<BUFSIZ-1) {
 	  buffer[bufoff++] = *str++;
 	}
+	if (keepflag) {
+	  ComValue* comval = new ComValue(*str==delim ? delimstr : " ");
+	  if (reverseflag)
+	    avl->Prepend(comval);
+	  else
+	    avl->Append(comval);
+	}
 	buffer[bufoff] = '\0';
         ComValue* comval = new ComValue(((ComTerpServ*)_comterp)->run(buffer, true /*nested*/));
-	avl->Append(comval);
+	if (reverseflag) 
+	  avl->Prepend(comval);
+	else
+	  avl->Append(comval);
 	bufoff=0;
       }
     }
@@ -465,6 +531,9 @@ void SubStrFunc::execute() {
   static int after_symid = symbol_add("after");
   ComValue afterflagv(stack_key(after_symid));
   boolean afterflag = afterflagv.is_true();
+  static int nonil_symid = symbol_add("nonil");
+  ComValue nonilflagv(stack_key(nonil_symid));
+  boolean nonilflag = nonilflagv.is_true();
   reset_stack();
 
   if (strv.is_unknown()) {
@@ -481,8 +550,15 @@ void SubStrFunc::execute() {
   }
   else {
     const char* foundstr = strstr(string, nv.symbol_ptr());
-    n = afterflag ?  strlen(string)-(foundstr-string) : foundstr-string;
-    offset = afterflag ? foundstr-string : 0;
+    if(foundstr==NULL) {
+      if(nonilflag)
+	push_stack(strv);
+      else
+	push_stack(ComValue::nullval());
+      return;
+    }
+    n = afterflag ?  strlen(string)-(foundstr-string)-strlen(nv.symbol_ptr()) : foundstr-string;
+    offset = afterflag ? foundstr-string+strlen(nv.symbol_ptr()) : 0;
   };
   if(n>0) { 
     char buffer[n+1];
@@ -491,7 +567,10 @@ void SubStrFunc::execute() {
     ComValue retval(buffer);
     push_stack(retval);
   } else
-    push_stack(ComValue::nullval());
+    if(nonilflag)
+      push_stack(strv);
+    else
+      push_stack(ComValue::nullval());
 }
 
 
--- ivtools-1.2.11a1.orig/src/ComTerp/symbolfunc.h
+++ ivtools-1.2.11a1/src/ComTerp/symbolfunc.h
@@ -121,7 +121,7 @@ public:
     virtual void execute();
 
     virtual const char* docstring() { 
-      return "lst=%s(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens)"; }
+      return "lst=%s(symbol|string :tokstr [delim] :tokval [delim] :keep :reverse) -- split symbol or string into list of characters (or tokens)"; }
 };
 
 //: command to join list of characters into a string object
@@ -149,14 +149,14 @@ public:
 
 
 //: command to extract a sub string
-// str=substr(str n :after) -- extract characters from a string
+// str=substr(str n :after :before) -- extract characters from a string
 class SubStrFunc : public ComFunc {
 public:
     SubStrFunc(ComTerp*);
     virtual void execute();
 
     virtual const char* docstring() { 
-      return "str=%s(str n|str :after) -- extract characters from a string"; }
+      return "str=%s(str n|str :after :nonil) -- extract characters from a string (:nonil return string if no match)"; }
 };
 
 
--- ivtools-1.2.11a1.orig/src/ComUnidraw/comeditor.cc
+++ ivtools-1.2.11a1/src/ComUnidraw/comeditor.cc
@@ -133,6 +133,7 @@ void ComEditor::InitCommands() {
 void ComEditor::AddCommands(ComTerp* comterp) {
     ((ComTerpServ*)comterp)->add_defaults();
 
+    comterp->add_command("depth", new GrDepthFunc(comterp));
     comterp->add_command("parent", new GrParentFunc(comterp));
     comterp->add_command("rect", new CreateRectFunc(comterp, this));
     comterp->add_command("rectangle", new CreateRectFunc(comterp, this));
@@ -249,7 +250,7 @@ void ComEditor::AddCommands(ComTerp* com
     comterp->add_command("desensitize", new DesensitizeCompFunc(comterp, this));
     comterp->add_command("sensitize", new SensitizeCompFunc(comterp, this));
 
-    #ifdef LEAKCHECK
+    #if defined(LEAKCHECK) 
     comterp->add_command("compleak", new CompLeakFunc(comterp));
     comterp->add_command("viewleak", new ViewLeakFunc(comterp));
     comterp->add_command("alistleak", new AlistLeakFunc(comterp));
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grdotfunc.cc
+++ ivtools-1.2.11a1/src/ComUnidraw/grdotfunc.cc
@@ -31,6 +31,7 @@
 #include <fstream>
 #include <iostream>
 
+using std::cout;
 using std::cerr;
 
 #define TITLE "GrDotFunc"
@@ -53,20 +54,20 @@ void GrDotFunc::execute() {
           ((Attribute*)before_part.obj_val())->Value()->object_compview())) &&
         !(before_part.is_attributelist()) && 
 	!(before_part.object_compview())) {
-      cerr << "expression before \".\" needs to evaluate to a symbol or <AttributeList> (instead of "
+      cout << "WARNING: expression before \".\" needs to evaluate to a symbol or <AttributeList> (instead of "
 	   << symbol_pntr(before_part.type_symid());
       if (before_part.is_object())
-        cerr << " of class " << symbol_pntr(before_part.class_symid());
-      cerr << ") -- grdotfunc.c\n";
+        cout << " of class " << symbol_pntr(before_part.class_symid());
+      cout << ") -- line " << funcstate()->linenum() << "\n";
       reset_stack();
       return;
     }
     if (!after_part.is_string()) {
-      cerr << "expression after \".\" needs to be a symbol or evaluate to a symbol (instead of "
+      cout << "WARNING: expression after \".\" needs to be a symbol or evaluate to a symbol (instead of "
 	   << symbol_pntr(after_part.type_symid());
       if (before_part.is_object())
-        cerr << " of class " << symbol_pntr(before_part.class_symid());
-      cerr << ") -- grdotfunc.c\n";
+        cout << " of class " << symbol_pntr(before_part.class_symid());
+      cout << ") -- line " << funcstate()->linenum() << "\n";
       reset_stack();
       return;
     }
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grfunc.cc
+++ ivtools-1.2.11a1/src/ComUnidraw/grfunc.cc
@@ -1421,6 +1421,10 @@ CompLeakFunc::CompLeakFunc(ComTerp* comt
 
 void CompLeakFunc::execute() {
   reset_stack();
+  if (OverlayComp::_leakchecker==nil) {
+    push_stack(ComValue::zeroval());
+    return;
+  }
   ComValue retval(OverlayComp::_leakchecker->alive(), ComValue::IntType);
   push_stack(retval);
 }
@@ -1432,6 +1436,10 @@ ViewLeakFunc::ViewLeakFunc(ComTerp* comt
 
 void ViewLeakFunc::execute() {
   reset_stack();
+  if (OverlayView::_leakchecker==nil) {
+    push_stack(ComValue::zeroval());
+    return;
+  }
   ComValue retval(OverlayView::_leakchecker->alive(), ComValue::IntType);
   push_stack(retval);
 }
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/grfunc.h
@@ -23,7 +23,7 @@
  * 
  */
 
-#if !defined(grfunc_h)
+#if !defined(_grfunc_h)
 #define _grfunc_h
 
 #include <leakchecker.h>
--- ivtools-1.2.11a1.orig/src/ComUnidraw/groupfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/groupfunc.h
@@ -21,7 +21,7 @@
  * 
  */
 
-#if !defined(groupfunc_h)
+#if !defined(_groupfunc_h)
 #define _groupfunc_h
 
 #include <ComUnidraw/unifunc.h>
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grstatfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/grstatfunc.h
@@ -21,7 +21,7 @@
  * 
  */
 
-#if !defined(grstatfunc_h)
+#if !defined(_grstatfunc_h)
 #define _grstatfunc_h
 
 #include <ComUnidraw/unifunc.h>
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grstrmfunc.cc
+++ ivtools-1.2.11a1/src/ComUnidraw/grstrmfunc.cc
@@ -121,3 +121,98 @@ void GrStreamFunc::execute() {
 
 #endif
 
+/*****************************************************************************/
+
+int GrDepthFunc::_symid;
+
+GrDepthFunc::GrDepthFunc(ComTerp* comterp) : StreamFunc(comterp) {
+}
+
+void GrDepthFunc::execute() {
+  ComValue compsv(stack_arg_post_eval(0));
+  reset_stack();
+  
+  if (compsv.object_compview()) {
+    
+    static GrDepthNextFunc* snfunc = nil;
+    if (!snfunc) {
+      snfunc = new GrDepthNextFunc(comterp());
+      snfunc->funcid(symbol_add("depthnext"));
+    }
+
+    AttributeValueList* avl = new AttributeValueList();
+    Component* comp = ((ComponentView*)compsv.obj_val())->GetSubject();
+    if (!comp->IsA(OVERLAYS_COMP)) {
+      push_stack(ComValue::nullval());
+      return;
+    }
+    OverlaysComp* ovcomps = (OverlaysComp*)comp;
+
+    ComValue* av = 
+      new ComValue(new OverlayViewRef(ovcomps), ovcomps->classid());
+    avl->Append(av);
+    avl->Append(new ComValue());
+    ComValue* av2 = 
+      new ComValue(new OverlayViewRef((OverlaysComp*)ovcomps->GetParent()), ovcomps->classid());
+    avl->Append(av2);
+    
+    ComValue stream(snfunc, avl);
+    stream.stream_mode(-1); // for internal use (use by this func)
+    stream.type(ComValue::StreamType);
+    push_stack(stream);
+    
+  }
+}
+
+/*****************************************************************************/
+
+int GrDepthNextFunc::_symid;
+
+GrDepthNextFunc::GrDepthNextFunc(ComTerp* comterp) : StrmFunc(comterp) {
+}
+
+void GrDepthNextFunc::execute() {
+  ComValue operand1(stack_arg(0));
+
+  /* invoked by next func */
+  reset_stack();
+  AttributeValueList* avl = operand1.stream_list();
+  if (avl) {
+    Iterator i;
+    avl->First(i);
+    ComValue* currval = (ComValue*)avl->GetAttrVal(i);
+    avl->Next(i);
+    ComValue* prevval = (ComValue*)avl->GetAttrVal(i);
+    avl->Next(i);
+    ComValue* stopval = (ComValue*)avl->GetAttrVal(i);
+    
+    /* depth-first seach */
+    if (currval->is_known()) {
+      OverlayComp* currcomp = (OverlayComp*)currval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+      OverlayComp* prevcomp = (OverlayComp*)prevval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+      OverlayComp* stopcomp = (OverlayComp*)stopval->geta(OverlayComp::class_symid(), OVERLAY_COMP);
+      OverlayComp* nextcomp = currcomp->DepthNext(prevcomp);
+      while(nextcomp && nextcomp==(OverlayComp*)currcomp->GetUp()) {
+	prevcomp=currcomp;
+	currcomp=nextcomp;
+        nextcomp = currcomp->DepthNext(prevcomp);
+      }
+      if(nextcomp && nextcomp!=stopcomp) {
+        ((OverlayViewRef*)currval->obj_val())->SetSubject(nextcomp);
+        if (!prevcomp) {
+          ComValue new_prevval(new OverlayViewRef(currcomp), currcomp->classid());;
+          *prevval = new_prevval;
+	} else
+	  ((OverlayViewRef*)prevval->obj_val())->SetSubject(currcomp);
+        ComValue av(new OverlayViewRef(nextcomp), nextcomp->classid());
+        push_stack(av);
+        return;
+      }
+    }
+    
+  }
+  push_stack(ComValue::nullval());
+
+  return;
+}
+
--- ivtools-1.2.11a1.orig/src/ComUnidraw/grstrmfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/grstrmfunc.h
@@ -37,11 +37,37 @@ public:
 
     virtual void execute();
     virtual const char* docstring() { 
-      return "strm=%s(ostrm|list|attrlist|compview) -- copy stream or convert list"; }
+      return "strm=%s(ostrm|list|attrlist|val|compview) -- copy stream or convert list (unary $)"; }
 
     CLASS_SYMID("GrStreamFunc");
 
 };
 
 
+
+//: stream depth-first command
+class GrDepthFunc : public StreamFunc {
+public:
+    GrDepthFunc(ComTerp*);
+
+    virtual void execute();
+    virtual const char* docstring() { 
+      return "strm=depth(compview) -- depth-first walk of comp tree using stream"; }
+
+    CLASS_SYMID("GrDepthFunc");
+
+};
+
+//: hidden func used by next command for stream depth command
+class GrDepthNextFunc : public StrmFunc {
+public:
+    GrDepthNextFunc(ComTerp*);
+
+    virtual void execute();
+    virtual const char* docstring() { 
+      return "hidden func used by next command for depth command"; }
+
+    CLASS_SYMID("GrDepthNextFunc");
+
+};
 #endif /* !defined(_grstrmfunc_h) */
--- ivtools-1.2.11a1.orig/src/ComUnidraw/highlightfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/highlightfunc.h
@@ -21,7 +21,7 @@
  * 
  */
 
-#if !defined(highlightfunc_h)
+#if !defined(_highlightfunc_h)
  #define _highlightfunc_h
 
 #include <ComUnidraw/unifunc.h>
--- ivtools-1.2.11a1.orig/src/ComUnidraw/pixelfunc.h
+++ ivtools-1.2.11a1/src/ComUnidraw/pixelfunc.h
@@ -21,7 +21,7 @@
  * 
  */
 
-#if !defined(pixelfunc_h)
+#if !defined(_pixelfunc_h)
 #define _pixelfunc_h
 
 #include <ComUnidraw/unifunc.h>
--- ivtools-1.2.11a1.orig/src/ComUnidraw/unifunc.cc
+++ ivtools-1.2.11a1/src/ComUnidraw/unifunc.cc
@@ -54,15 +54,14 @@
 #include <Unidraw/Graphic/graphic.h>
 #include <InterViews/transformer.h>
 #include <InterViews/window.h>
+#include <ComTerp/comhandler.h>
 #include <ComTerp/comterpserv.h>
 #include <ComTerp/comvalue.h>
 #include <Attribute/attrlist.h>
 #include <stdio.h>
 #include <strstream>
 #include <unistd.h>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 #include <string.h>
 #include <iostream>
 
@@ -409,48 +408,6 @@ void ExportFunc::execute() {
 #endif
 
 
-#if __GNUC__<3
-    filebuf fbuf;
-    if (file.is_type(ComValue::StringType))
-        fbuf.open(file.string_ptr(), "w");
-
-    else if (sock.is_true()) {
-#ifdef HAVE_ACE
-	ComTerpServ* terp = (ComTerpServ*)comterp();
-	ComterpHandler* handler = (ComterpHandler*)terp->handler();
-	if (handler) {
-	  ACE_SOCK_Stream peer = handler->peer();
-	  fbuf.attach(peer.get_handle());
-	}
-	else
-#endif
-	  fbuf.attach(fileno(stdout));
-    }
-
-    else {
-#ifdef HAVE_ACE
-        const char* hoststr = nil;
-        const char* portstr = nil;
-        hoststr = host.type()==ComValue::StringType ? host.string_ptr() : nil;
-        portstr = port.type()==ComValue::StringType ? port.string_ptr() : nil;
-        u_short portnum = portstr ? atoi(portstr) : port.ushort_val();
-    
-        if (portnum) {
-            socket = new ACE_SOCK_Stream;
-            ACE_SOCK_Connector conn;
-            ACE_INET_Addr addr (portnum, hoststr);
-    
-            if (conn.connect (*socket, addr) == -1)
-                ACE_ERROR ((LM_ERROR, "%p\n", "open"));
-            fbuf.attach(socket->get_handle());
-        } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) {
-            fbuf.attach(comterp()->handler()->get_handle());
-        } else
-#endif
-            fbuf.attach(fileno(stdout));
-    }
-
-#else
 
     filebuf* pfbuf;
     FILE* ofptr = nil;
@@ -467,11 +424,11 @@ void ExportFunc::execute() {
 	if (handler) {
 	  ACE_SOCK_Stream peer = handler->peer();
 	  ofptr = fdopen(peer.get_handle(), "r");
-	  pfbuf = new fileptr_filebuf(ofptr, output);
+	  FILEBUFP(pfbuf, ofptr, output);
 	}
 	else 
 #endif
-	  pfbuf = new fileptr_filebuf(stdout, output);
+	  FILEBUFP(pfbuf, stdout, output);
     }
 
     else {
@@ -489,24 +446,19 @@ void ExportFunc::execute() {
     
             if (conn.connect (*socket, addr) == -1)
                 ACE_ERROR ((LM_ERROR, "%p\n", "open"));
-            pfbuf = new fileptr_filebuf(ofptr = fdopen(socket->get_handle(), "r"), output);
+            FILEBUFP(pfbuf, ofptr = fdopen(socket->get_handle(), "r"), output);
         } else if (comterp()->handler() && comterp()->handler()->get_handle()>-1) {
-            pfbuf = new fileptr_filebuf(comterp()->handler()->rdfptr(), output);
+	  FILEBUFP(pfbuf, comterp()->handler()->rdfptr(), output);
         } else
 #endif
-            pfbuf = new fileptr_filebuf(stdout, output);
+	  FILEBUFP(pfbuf, stdout, output);
     }
 
-#endif
     ostream* out;
     if (string.is_true()||str.is_true())
       out = new std::strstream();
     else
-#if __GNUC__<3      
-      out = new ostream(&fbuf);
-#else
       out = new ostream(pfbuf);
-#endif
 
     if (!compviewv.is_array()) {
 
@@ -568,9 +520,7 @@ void ExportFunc::execute() {
     }
     delete out;
 
-#if __GNUC__>=3
     delete pfbuf;
-#endif    
     
 #ifdef HAVE_ACE
     if (sock.is_false() && socket) {
--- ivtools-1.2.11a1.orig/src/ComUtil/_lexscan.cc
+++ ivtools-1.2.11a1/src/ComUtil/_lexscan.cc
@@ -50,6 +50,7 @@ int _token_eol = 0;
 int _colon_ident = 1;
 int _percent_ident = 0;
 int _ignore_chars = 0;
+int _backslash_ids = 0;
 
 /* MACROS */
 
@@ -169,6 +170,7 @@ unsigned no_comment =           /* TRUE
    (begcmt_len == 0 || endcmt_len == 0);
 int index;
 char* infunc_retval;
+int bs_ident = 0;
 
 
 /* ----------------------------------------------------------------------- */
@@ -423,13 +425,22 @@ char* infunc_retval;
 	       token_state = TOK_STRING;
 	       break;
 
-	 /* Start of character constant */
+	       /* Start of character constant */
 	    case '\'':
 	       if (!_ignore_chars) {
 	           token_state = TOK_CHAR;
                    break;
 	       }
 
+	 /* Start of back-slashed identifier */
+	    case '\\':
+	       if (_backslash_ids) {
+	           token_state = TOK_IDENTIFIER;
+   	           TOKEN_ADD( CURR_CHAR );
+                   bs_ident=1;
+		   break;
+	       }
+
          /* Any other character must be an operator */	 
             default:
                token_state = TOK_OPERATOR;
@@ -457,10 +468,13 @@ char* infunc_retval;
       /*-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-IDENTIFIER-*/
 
       case TOK_IDENTIFIER:
-	 if( isident( CURR_CHAR ) || isdigit( CURR_CHAR ))
+         if( bs_ident && !isspace( CURR_CHAR) || 
+	     isident( CURR_CHAR ) || isdigit( CURR_CHAR ))
 	    TOKEN_ADD( CURR_CHAR )
-         else 
+         else {
+  	    bs_ident = 0;
             goto token_return;
+	 }
 	 break; /* end of TOK_KEYWORD and TOK_IDENTIFIER case */
 
 
--- ivtools-1.2.11a1.orig/src/ComUtil/_parser.cc
+++ ivtools-1.2.11a1/src/ComUtil/_parser.cc
@@ -266,7 +266,7 @@ static int rkg_instack(int prior)
 
 /* Output a token in its postfix order */
 #define PFOUT( toktype, tokid, narg_val, nkey_val, nids_val ) {\
-if(pfout(pfbuf,pfsiz,pfnum,toktype,tokid,narg_val,nkey_val,nids_val))\
+    if(pfout(pfbuf,pfsiz,pfnum,toktype,tokid,narg_val,nkey_val,nids_val,*linenum)) \
     goto error_return;}
 
 static int pfout(
@@ -278,7 +278,8 @@ unsigned        toktype, /* Token type *
 int             tokid,   /* Identifier that corresponds to this token */
 unsigned        narg_val,/* Number of arguments associated with this token */
 unsigned        nkey_val,/* Number of keywords associated with this token */
-unsigned        nids_val /* Number of ids associated with this token */
+unsigned        nids_val, /* Number of ids associated with this token */
+unsigned        linenum   /* Line number */
 
 		 )
 
@@ -300,6 +301,7 @@ unsigned        nids_val /* Number of id
    (*pfbuf+*pfnum)->narg = narg_val;
    (*pfbuf+*pfnum)->nkey = nkey_val;
    (*pfbuf+*pfnum)->v.symbolid = tokid;
+   (*pfbuf+*pfnum)->ln = linenum;
    ++*pfnum;
 
    return FUNCOK;
@@ -308,7 +310,7 @@ unsigned        nids_val /* Number of id
 
 /* set value in literal token */
 #define PFOUT_LITERAL( toktype, token ) {\
-if(pfout_literal(pfbuf,pfsiz,pfnum,toktype,token))\
+if(pfout_literal(pfbuf,pfsiz,pfnum,toktype,token,*linenum))	\
    goto error_return;}
 
 #define EMPTY_OPER_STACK {\
@@ -335,12 +337,13 @@ postfix_token** pfbuf,	/* Double pointer
 unsigned *      pfsiz,  /* Size of `pfbuf`. */
 unsigned *      pfnum,  /* Number of tokens returned in `pfbuf`. */
 unsigned        toktype,/* Token type */
-char *          token   /* Token buffer */
+char *          token,  /* Token buffer */
+unsigned        linenum /* Line number */
 
 )
 
 {
-    if(pfout(pfbuf,pfsiz,pfnum,toktype,0,0,0,0))
+    if(pfout(pfbuf,pfsiz,pfnum,toktype,0,0,0,0,linenum))
 	return FUNCBAD;
     memcpy(&(*pfbuf+*pfnum-1)->v.doublval, token, sizeof(double));
     return FUNCOK;
@@ -1098,10 +1101,25 @@ int status;
 	 }
 
       /* If left paren was encountered without a proceeding identifier   */
-      /* it is not to be associated with a command.  Push it on the      */
-      /* paren stack with a -1 indicator for the command id to show such.*/
-      /* Push the negated value of the token type onto the operator      */
-      /* stack, in order to distinguish it from the other operators.     */
+      /* and a binary operator expected, output any current expression.  */
+         if( expecting==OPTYPE_BINARY ) {
+	   while ( (OperStack[TopOfOperStack].oper_type != LEFTPAREN) &&
+		   (TopOfOperStack >= 0 ))
+	     {
+	       if (OperStack[TopOfOperStack].oper_type == OPERATOR)
+		 {
+		   OPERSTK_POP( temp_id );
+		   PFOUT( TOK_COMMAND, opr_tbl_commid( temp_id ),
+			  (opr_tbl_optype( temp_id ) == OPTYPE_BINARY ? 2 : 1), 0, 1 );
+		 }
+	     }
+	 }
+
+      /* If left paren was encountered without a proceeding identifier    */
+      /* it is not to be associated with a command.  Push it on the       */
+      /* paren stack with a -1 indicator for the command id to show that. */
+      /* Push the negated value of the token type onto the operator       */
+      /* stack, in order to distinguish it from the other operators.      */
 	 PARENSTK_PUSH( toktype, -1, 1 );
 	 OPERSTK_PUSH( -toktype, LEFTPAREN );
 
@@ -1334,7 +1352,7 @@ int status;
    /*      whitespace from the current token.                               */
    /*   4) If the next token is an operator, it is not a binary operator    */
    /*   5) If _sticky_matched_delims is true, and the next token is not an  */
-   /*      operator, then it can't be a matching delimeter.                 */
+   /*      operator, then it can't be a matching delimiter.                 */
       if( !done && TopOfParenStack < 0 && expecting == OPTYPE_BINARY ) {
 
 	 if( NextToklen == 0 ) 
--- ivtools-1.2.11a1.orig/src/ComUtil/comerr.cc
+++ ivtools-1.2.11a1/src/ComUtil/comerr.cc
@@ -171,7 +171,7 @@ Return Value:  error number if last erro
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
--- ivtools-1.2.11a1.orig/src/ComUtil/comterp.err
+++ ivtools-1.2.11a1/src/ComUtil/comterp.err
@@ -176,7 +176,7 @@
 /* "Attempted read/write before file open" */
 
 #define ERR_TXTUT_DELIM			 6001
-/* "Input string begins with internal delimeter: .!#ID#" */
+/* "Input string begins with internal delimiter: .!#ID#" */
 
 #define ERR_TXTUT_FOPEN			 6002
 /* "Error during file open" */
--- ivtools-1.2.11a1.orig/src/ComUtil/comterp.h
+++ ivtools-1.2.11a1/src/ComUtil/comterp.h
@@ -140,6 +140,7 @@ typedef struct postfix_token_struct
    int narg;            /* Number of arguments to command */
    int nkey;		/* Number of keywords to command */
    int nids;		/* Number of ids in compound command name */
+   int ln;		/* Line number */
 } postfix_token;
 
 #define PAREN_STACK_EXPERIMENT
--- ivtools-1.2.11a1.orig/src/ComUtil/errsys.cc
+++ ivtools-1.2.11a1/src/ComUtil/errsys.cc
@@ -131,7 +131,7 @@ static struct {
 {5205, "Type identifier is outside table limits"},
 {5206, "Type identifier is for an empty table entry"},
 {6000, "Attempted read/write before file open"},
-{6001, "Input string begins with internal delimeter: .!#ID#"},
+{6001, "Input string begins with internal delimiter: .!#ID#"},
 {6002, "Error during file open"},
 {3000, "Unknown command supplied to interpreter: %s"},
 {3001, "Divide by zero"},
@@ -212,14 +212,14 @@ See Also:  err_read, err_set, err_get, e
     }
 
     if (!fptr) {
-	strcpy( fullpath, RELLIBALLDIR );
+	strcpy( fullpath, "RELLIBALLDIR" );
 	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
 	strcat( fullpath, errfile );
 	fptr = fopen(fullpath, "r");
     }
     
     if (!fptr) {
-	strcpy( fullpath, ABSLIBALLDIR );
+	strcpy( fullpath, "ABSLIBALLDIR" );
 	if (fullpath[strlen(fullpath)-1] != '/') strcat( fullpath, "/" );
 	strcat( fullpath, errfile );
 	fptr = fopen(fullpath, "r");
@@ -293,7 +293,7 @@ See Also:  err_readfile, err_open, err_s
       int i=0;
       while(default_errmsgs[i].msg!=NULL&&default_errmsgs[i].id!=errnum) i++;
       if (!default_errmsgs[i].msg) {
-          KANIL1( "errnum not found", errnum );
+          KANIL1( "errnum not found %d", errnum );
       } else 
           return default_errmsgs[i].msg;
       }
@@ -673,7 +673,7 @@ Return Value:  no error return
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
@@ -780,7 +780,7 @@ Return Value:  pointer to error I/O file
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
@@ -838,7 +838,7 @@ Return Value:  count of current error me
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
--- ivtools-1.2.11a1.orig/src/ComUtil/optable.cc
+++ ivtools-1.2.11a1/src/ComUtil/optable.cc
@@ -101,7 +101,6 @@ struct _opr_tbl_default_entry {
   {" ",          "space",              140,        FALSE,      OPTYPE_BINARY },
   {".",          "dot",                130,        FALSE,      OPTYPE_BINARY },
   {"`",          "bquote",             125,        TRUE,       OPTYPE_UNARY_PREFIX },
-  {"$",          "stream",             125,        TRUE,       OPTYPE_UNARY_PREFIX },
   {"!",          "negate",             110,        TRUE,       OPTYPE_UNARY_PREFIX },
   {"~",          "bit_not",            110,        TRUE,       OPTYPE_UNARY_PREFIX },
   {"++",         "incr",               110,        TRUE,       OPTYPE_UNARY_PREFIX },
@@ -131,6 +130,8 @@ struct _opr_tbl_default_entry {
   {"||",         "or",                 40,         FALSE,      OPTYPE_BINARY },
   {",",          "tuple",              35,         FALSE,      OPTYPE_BINARY },
   {",,",         "concat",             33,         FALSE,      OPTYPE_BINARY },
+  {"$",          "stream",             32,         TRUE,       OPTYPE_UNARY_PREFIX },
+  {"$$",         "list",               32,         TRUE,       OPTYPE_UNARY_PREFIX },
   {"%=",         "mod_assign",         30,         TRUE,       OPTYPE_BINARY },
   {"*=",         "mpy_assign",         30,         TRUE,       OPTYPE_BINARY },
   {"+=",         "add_assign",         30,         TRUE,       OPTYPE_BINARY },
@@ -878,7 +879,7 @@ Return Value:  maximum priority in opera
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
@@ -915,7 +916,7 @@ Return Value:  0 if OK, -1 if Error
 
 Parameters:  none
 
-
+*/
 /*!
 Description:
 
--- ivtools-1.2.11a1.orig/src/ComUtil/popen2.cc
+++ ivtools-1.2.11a1/src/ComUtil/popen2.cc
@@ -42,7 +42,7 @@
  */      
 pid_t popen2(const char *shell_cmd, int *p_fd_in, int *p_fd_out)
 {
-#if 0
+#if 1
   //CREATING  TWO  PIPES:
   int fds_processInput[2];  //pipe  for  process  input
   int fds_processOutput[2]; //pipe  for  process  output
@@ -53,11 +53,26 @@ pid_t popen2(const char *shell_cmd, int
     exit(1);
   }
    
+#if 0
   if(pipe2(fds_processOutput, O_NONBLOCK) != 0) //create  process  output  pipe
   {
     fprintf(stderr, "pipe (process output) failed\n");
     exit(1);
   }
+#else
+  if(pipe(fds_processOutput) != 0) //create  process  output  pipe
+  {
+    fprintf(stderr, "pipe (process output) failed\n");
+    exit(1);
+  }
+  int flags;
+  for(int i=0; i<2; i++) {
+      flags = fcntl(fds_processOutput[i], F_GETFL, 0);
+      flags |= O_NONBLOCK;
+      fcntl(fds_processOutput[i], F_SETFL, flags);
+  }
+#endif
+
    
   //FORKING  A  CHILD  PROCESS:
   pid_t pid;
--- ivtools-1.2.11a1.orig/src/ComUtil/symbols.cc
+++ ivtools-1.2.11a1/src/ComUtil/symbols.cc
@@ -70,7 +70,6 @@ static int symid_alloc_num;
 /* These are used when you have lots of memory */
 #define SYMID_ALLOC_NUM_HIGH      256
 
-
 /* reverse index to speed up symbol table insertion */
 #define REVERSE_TABLE
 #if defined(REVERSE_TABLE)
@@ -80,6 +79,8 @@ implementStrTable(ReverseSymbolTable,int
 ReverseSymbolTable* _reverse_table = nil;
 #endif
 
+char	*strnew(const char *);
+
 /*=============*/
 
 /*!
@@ -205,7 +206,7 @@ main()
     }
     pntr = symid_beg + id;	/* index into entry of interest */
     pntr->nchars = n;		/* number of non-NULL characters */
-    pntr->symstr = strdup(string);	/* make copy of string */
+    pntr->symstr = strnew(string);	/* make copy of string */
     pntr->instances = 1;		/* set first instance of this symbol */
 
     /* add to reverse index */
--- ivtools-1.2.11a1.orig/src/ComUtil/txtutil.cc
+++ ivtools-1.2.11a1/src/ComUtil/txtutil.cc
@@ -101,10 +101,10 @@ returned, otherwise `txtstr` is appended
         return(-1);
     }
 
-    /* Check for string beginning with internal delimeter */
+    /* Check for string beginning with internal delimiter */
     if ( !strncmp(txtstr, ".!#ID#",6))
     {
-        /* String begins with internal delimeter string */
+        /* String begins with internal delimiter string */
         COMERR_SET(ERR_TXTUT_DELIM);
         return(-1);
     }
@@ -191,7 +191,7 @@ the current file position to be reset.
         Currid = id;
         fseek(fd,0L,SEEK_SET);
 
-        /* Search for .!#ID#id delimeter */
+        /* Search for .!#ID#id delimiter */
         sprintf( cmpstr, ".!#ID#%d\n",id);
         while( (tst = fgets(txtstr, 256, fd)) != NULL )
             if (!strcmp(txtstr, cmpstr)) break;
@@ -361,7 +361,7 @@ kwsearch.
     while( (tst = fgets(rdptr, 256, fd)) != NULL )
     {
 
-        /* Check for .!#ID#id delimeter */
+        /* Check for .!#ID#id delimiter */
         if (!strncmp(rdptr, ".!#ID#",6)) 
             id = atoi(&rdptr[6]);
         else
@@ -422,7 +422,7 @@ Description:
 
 `txtprint` searchs the text table and prints out entry `id`.
 Any string beginning with `ignorestr` are NOT printed.  This is
-useful for user defined delimeters within a block of text, specifically
+useful for user-defined delimiters within a block of text, specifically
 the .!#KW# identifiers for COMTERP.
 !*/
 
--- ivtools-1.2.11a1.orig/src/ComUtil/util.h
+++ ivtools-1.2.11a1/src/ComUtil/util.h
@@ -313,7 +313,11 @@ struct token
 #define         EXPR_TYPE       struct token
 
 /* Error handling macros */
-#define TITLE_PRINT {if( TITLE ) fprintf( stderr, "%s:  ", TITLE ); }
+#if defined(TITLE)
+#define TITLE_PRINT { fprintf( stderr, "%s:  ", TITLE ); }
+#else
+#define TITLE_PRINT {}
+#endif
 
 #define breakpt() {}
 
--- ivtools-1.2.11a1.orig/src/Dispatch/dispatcher.cc
+++ ivtools-1.2.11a1/src/Dispatch/dispatcher.cc
@@ -393,6 +393,10 @@ void ChildQueue::notify() {
 #define NOFILE 256
 #endif
 
+#ifndef NOFILE
+#define NOFILE 256
+#endif
+
 Dispatcher::Dispatcher() {
     _nfds = 0;
     _rmask = new FdMask;
--- ivtools-1.2.11a1.orig/src/Dispatch/rpcregistry.cc
+++ ivtools-1.2.11a1/src/Dispatch/rpcregistry.cc
@@ -40,6 +40,12 @@
 #if defined(__linux__) || defined(__FreeBSD__)
 #include <stdio.h>
 #endif
+
+// GNU HURD has no fixed limit
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 4096
+#endif
+
 // Print a short error message describing the last error encountered
 // during a call to a system function.
 
--- ivtools-1.2.11a1.orig/src/DrawServ/ackback-handler.cc
+++ ivtools-1.2.11a1/src/DrawServ/ackback-handler.cc
@@ -23,10 +23,15 @@
 
 #ifdef HAVE_ACE
 
+#include <iosfwd>
 using namespace std;
 #include <vector>
 #include <err.h>
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include <DrawServ/ackback-handler.h>
 #include <DrawServ/draweditor.h>
 #include <DrawServ/drawkit.h>
@@ -135,7 +140,7 @@ void AckBackHandler::set_handle (ACE_HAN
 
 int  AckBackHandler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask)
 {
-  fprintf(stderr, "AckBackHandler::handle_close called with mask 0x%x\n", mask);
+  fprintf(stderr, "AckBackHandler::handle_close called with mask 0x%lx\n", mask);
   if(_timer_started && !ComterpHandler::reactor_singleton()->cancel_timer(_timerid, nil))
     cerr << "unable to cancel timerid " << _timerid << "\n";
   else
--- ivtools-1.2.11a1.orig/src/DrawServ/drawcatalog.cc
+++ ivtools-1.2.11a1/src/DrawServ/drawcatalog.cc
@@ -37,9 +37,7 @@
 #include <iostream.h>
 #include <stdio.h>
 #include <string.h>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 /*****************************************************************************/
 
@@ -60,28 +58,16 @@ boolean DrawCatalog::Retrieve (const cha
         _valid = true;
 
     } else {
-#if __GNUC__<3
-        filebuf fbuf;
-#else
         filebuf* pfbuf = nil;
-#endif
 	if (strcmp(name, "-") == 0) {
-#if __GNUC__<3
-	    _valid = fbuf.attach(fileno(stdin)) != 0;
-#else
-	    pfbuf = new fileptr_filebuf(stdin, input);
+	    FILEBUFP(pfbuf, stdin, input);
 	    _valid = 1;
-#endif
 	    name = nil;
 	} else {
 	    fptr = fopen(name, "r");
 	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
-#if __GNUC__<3
-	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
-#else
-	    pfbuf = new fileptr_filebuf(fptr, input);
+	    FILEBUFP(pfbuf, fptr, input);
 	    _valid = fptr ? 1 : 0;
-#endif
 	    if (compressed) {
 		int namelen = strlen(name);
 		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
@@ -90,17 +76,13 @@ boolean DrawCatalog::Retrieve (const cha
 	}
 	
         if (_valid) {
-#if __GNUC__<3
-	    istream in(&fbuf);
-#else
 	    istream in(pfbuf);
-#endif
 	    const char* command = "drawserv";
 	    int len = strlen(command)+1;
 	    char buf[len];
 
 	    char ch;
-	    while (isspace(ch = in.get())); in.putback(ch);
+	    while (isspace(ch = in.get())) {}; in.putback(ch);
 	    ParamList::parse_token(in, buf, len);
 	    if (strcmp(buf, "drawserv") == 0) { 
 		comp = new DrawIdrawComp(in, name, _parent);
@@ -116,9 +98,7 @@ boolean DrawCatalog::Retrieve (const cha
 		comp = nil;
 	    }
         }
-#if __GNUC__>=3
 	delete pfbuf;
-#endif
     }
     
     if (fptr) {
--- ivtools-1.2.11a1.orig/src/DrawServ/drawfunc.cc
+++ ivtools-1.2.11a1/src/DrawServ/drawfunc.cc
@@ -82,12 +82,6 @@ void DrawLinkFunc::execute() {
   ComValue userv(stack_key(user_sym));
   reset_stack();
 
-#if __GNUC__==3&&__GNUC_MINOR__<1
-  fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
-  push_stack(ComValue::nullval());
-  return;
-#endif
-
   DrawLink* link = nil;
 
   /* creating a new link to remote drawserv */
@@ -97,19 +91,11 @@ void DrawLinkFunc::execute() {
     if (statev.int_val()==DrawLink::one_way && 
 	((DrawServ*)unidraw)->cycletest
 	(sidv.uint_val(), hostv.string_ptr(), userv.string_ptr(), pidv.int_val())) {
-#if 1
-#if __GNUC__<4 && !defined(__CYGWIN__)
-      fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, false, static_cast<size_t>(BUFSIZ));
-#else
-      fileptr_filebuf obuf(comterp()->handler()->get_handle(), ios_base::out, static_cast<size_t>(BUFSIZ));
-#endif
+      FILEBUF(obuf, comterp()->handler()->wrfptr(), ios_base::out);
       ostream out(&obuf);
       out << "ackback(cycle)\n";
       out.flush();
       comterp()->quit();
-#else
-      comterp()->handler()->destroy();
-#endif
       return;
     }
     
@@ -203,11 +189,6 @@ void SessionIdFunc::execute() {
 
   reset_stack();
 
-#if __GNUC__==3&&__GNUC_MINOR__<1
-  fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n");
-  push_stack(ComValue::nullval());
-  return;
-#endif
   DrawServHandler* handler = comterp() ? (DrawServHandler*)comterp()->handler() : nil;
   DrawLink* link = handler ? (DrawLink*)handler->drawlink() : nil;
   
@@ -233,6 +214,7 @@ void SessionIdFunc::execute() {
 
 /*****************************************************************************/
 
+#ifdef HAVE_ACE
 GraphicIdFunc::GraphicIdFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
 }
 
@@ -292,6 +274,7 @@ void ChangeIdFunc::execute() {
   }
 }
 
+#endif /* defined(HAVE_ACE) */
 
 /*****************************************************************************/
 
--- ivtools-1.2.11a1.orig/src/DrawServ/drawfunc.h
+++ ivtools-1.2.11a1/src/DrawServ/drawfunc.h
@@ -47,6 +47,7 @@ public:
 	return "%s([sid osid :pid pid :user namestr :host hoststr :hostid hostid :remap] | :all) -- command to manage session id's"; }
 };
 
+#ifdef HAVE_ACE
 //: command to send message between remote selections
 // grid(id selector :state selected :request newselector :grant oldselector) -- command to send message between remote selections
 class GraphicIdFunc : public UnidrawFunc {
@@ -66,6 +67,7 @@ public:
     virtual const char* docstring() { 
 	return "%s(id) -- command to change session (or graphic id) to use local session id"; }
 };
+#endif /* defined(HAVE_ACE) */
 
 //: command to return point list associated with a graphic
 // ptlist=points(compview) -- return point list from compview graphic
--- ivtools-1.2.11a1.orig/src/DrawServ/drawlink.cc
+++ ivtools-1.2.11a1/src/DrawServ/drawlink.cc
@@ -25,6 +25,9 @@
  * Implementation of Drawlink class.
  */
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 #include <DrawServ/ackback-handler.h>
 #include <DrawServ/drawlink.h>
 #include <DrawServ/drawserv.h>
@@ -56,9 +59,11 @@ DrawLink::DrawLink (const char* hostname
   _remote_linkid = -1;
   _state = state;
 
+#ifdef HAVE_ACE
   _addr = nil;
   _socket = nil;
   _conn = nil;
+#endif
 
   _comhandler = nil;
   _ackhandler = nil;
@@ -99,11 +104,7 @@ int DrawLink::open() {
     if (ComterpHandler::reactor_singleton()->register_handler(ackhandler(), ACE_Event_Handler::READ_MASK|ACE_Event_Handler::TIMER_MASK)==-1)
       fprintf(stderr, "drawserv: error registering ackback handler (handle==%d)\n", _socket->get_handle());
 
-#if __GNUC__<4 && !defined(__CYGWIN__)
-    fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, false, static_cast<size_t>(BUFSIZ));
-#else
-    fileptr_filebuf obuf(_socket->get_handle(), ios_base::out, static_cast<size_t>(BUFSIZ));
-#endif
+    FILEBUF(obuf, fdopen(_socket->get_handle(), "w"), ios_base::out);
     ostream out(&obuf);
     out << "drawlink(\"";
     char buffer[HOST_NAME_MAX];
@@ -138,6 +139,7 @@ int DrawLink::open() {
 }
 
 int DrawLink::close() {
+#ifdef HAVE_ACE
   fprintf(stderr, "Closing link to %s (%s) port # %d (lid=%d, rid=%d)\n", 
 	  hostname(), althostname(), portnum(), local_linkid(), remote_linkid());
   if (comhandler()) comhandler()->drawlink(nil);
@@ -152,6 +154,8 @@ int DrawLink::close() {
     if (_socket->close () == -1)
       ACE_ERROR ((LM_ERROR, "%p\n", "close"));
   }
+#endif
+  return 1;
 }
 
 void DrawLink::hostname(const char* host) {
@@ -169,8 +173,12 @@ void DrawLink::althostname(const char* a
 }
 
 int DrawLink::handle() {
-  if (_socket) return _socket->get_handle();
-  else return -1;
+#ifdef HAVE_ACE
+  if (_socket) 
+    return _socket->get_handle();
+  else 
+#endif
+    return -1;
 }
 
 unsigned DrawLink::sid_lookup(unsigned int sid) {
@@ -181,8 +189,10 @@ unsigned DrawLink::sid_lookup(unsigned i
 }
 
 void DrawLink::sid_change(unsigned int& id) {
+#ifdef HAVE_ACE
   if (_incomingsidtable_size==0) return;
   id = sid_lookup(id & DrawServ::SessionIdMask) | (id & DrawServ::GraphicIdMask);
+#endif
   return;
 }
 
--- ivtools-1.2.11a1.orig/src/DrawServ/drawlink.h
+++ ivtools-1.2.11a1/src/DrawServ/drawlink.h
@@ -79,7 +79,7 @@ public:
     int close();
     // close link to remote DrawServ
 
-    int up() { state() == two_way; }
+    int up() { return state() == two_way; }
     // return 1 if link up, 0 if down
 
     int ok() { return _ok; }
--- ivtools-1.2.11a1.orig/src/DrawServ/drawlinklist.cc
+++ ivtools-1.2.11a1/src/DrawServ/drawlinklist.cc
@@ -60,10 +60,14 @@ void DrawLinkList::add_drawlink(DrawLink
 }
 
 DrawLink* DrawLinkList::find_drawlink(GraphicId* grid) {
+#ifdef HAVE_ACE
   void* ptr = nil;
   ((DrawServ*)unidraw)->sessionidtable()->find(ptr, grid->selector());
   SessionId* sessionid = (SessionId*)ptr;
   return (DrawLink*) (sessionid ? sessionid->drawlink() : nil);
+#else
+  return NULL;
+#endif
 }
 
 DrawLink* DrawLinkList::Link (UList* r) {
--- ivtools-1.2.11a1.orig/src/DrawServ/drawserv.cc
+++ ivtools-1.2.11a1/src/DrawServ/drawserv.cc
@@ -25,6 +25,9 @@
  * Implementation of DrawServ class.
  */
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 #include <DrawServ/ackback-handler.h>
 #include <DrawServ/draweditor.h>
 #include <DrawServ/drawkit.h>
@@ -368,11 +371,7 @@ void DrawServ::DistributeCmdString(const
     if (link && link != orglink && link->state()==DrawLink::two_way) {
       int fd = link->handle();
       if (fd>=0) {
-#if __GNUC__<4 && !defined(__CYGWIN__)
-	fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast<size_t>(BUFSIZ));
-#else
-	fileptr_filebuf fbuf(fd, ios_base::out, static_cast<size_t>(BUFSIZ));
-#endif
+	FILEBUF(fbuf, fdopen(fd, "w"), ios_base::out);
 	ostream out(&fbuf);
 	out << cmdstring;
 	out << "\n";
@@ -390,11 +389,7 @@ void DrawServ::SendCmdString(DrawLink* l
   if (link) {
     int fd = link->handle();
     if (fd>=0) {
-#if __GNUC__<4 && !defined(__CYGWIN__)
-      fileptr_filebuf fbuf(fd, ios_base::out, false, static_cast<size_t>(BUFSIZ));
-#else
-      fileptr_filebuf fbuf(fd, ios_base::out, static_cast<size_t>(BUFSIZ));
-#endif
+      FILEBUF(fbuf, fdopen(fd, "w"), ios_base::out);
       ostream out(&fbuf);
       out << cmdstring;
       out << "\n";
@@ -640,9 +635,9 @@ void DrawServ::print_gridtable() {
   printf("----------  ----------  ----------  ----------  --------\n");
   while(it.more()) {
     GraphicId* grid = (GraphicId*)it.cur_value();
-    printf("0x%08x  0x%08x  0x%08x  0x%08x  %s\n", 
-	   (unsigned int)it.cur_key(), grid, grid->grcomp(),
-	   grid->selector(), LinkSelection::selected_string(grid->selected()));
+    printf("0x%08x  0x%08lx  0x%08lx  0x%08lx  %s\n", 
+	   (unsigned int)it.cur_key(), (unsigned long)grid, (unsigned long)grid->grcomp(),
+	   (unsigned long)grid->selector(), LinkSelection::selected_string(grid->selected()));
     it.next();
   }
 }
@@ -655,8 +650,8 @@ void DrawServ::print_sidtable() {
   while(it.more()) {
     SessionId* sid = (SessionId*)it.cur_value();
     DrawLink* link = sid->drawlink();
-    printf("0x%08x  0x%08x  0x%08x  %4d  %4d  %6d  %6d  %16s  %16s\n", 
-	   sid->sid(), sid->osid(), link, 
+    printf("0x%08x  0x%08x  0x%08lx  %4d  %4d  %6d  %6d  %16s  %16s\n", 
+	   sid->sid(), sid->osid(), (unsigned long)link, 
 	   link ? link->local_linkid() : 9999, link ? link->remote_linkid() : 9999, 
 	   sid->pid(), sid->hostid(), sid->username(), sid->hostname());
     it.next();
--- ivtools-1.2.11a1.orig/src/DrawServ/grid.cc
+++ ivtools-1.2.11a1/src/DrawServ/grid.cc
@@ -40,6 +40,7 @@
 
 GraphicId::GraphicId (unsigned int sessionid) 
 {
+#ifdef HAVE_ACE
   _comp = nil;
   if (sessionid != 0) {
     _id = DrawServ::unique_grid();
@@ -49,21 +50,26 @@ GraphicId::GraphicId (unsigned int sessi
   } else {
     _id = _sid = 0;
   }
+#endif
 }
 
 GraphicId::~GraphicId () 
 {
+#ifdef HAVE_ACE
   GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable();
   table->remove(_id&_sid);
+#endif
 }
 
 void GraphicId::id(unsigned int id) {
+#ifdef HAVE_ACE
   GraphicIdTable* table = ((DrawServ*)unidraw)->gridtable();
   if (_id!=0 && _sid!=0) 
     table->remove(_id&_sid);
   _id = id & DrawServ::GraphicIdMask;
   _sid = id & DrawServ::SessionIdMask;
   table->insert(id, this);
+#endif
 }
 
 /*****************************************************************************/
@@ -92,6 +98,7 @@ GraphicIds::~GraphicIds ()
 }
 
 void GraphicId::grcomp(GraphicComp* comp) {
+#ifdef HAVE_ACE
   if (comp==_comp) return;
   CompIdTable* table = ((DrawServ*)unidraw)->compidtable();
   if (_comp) {
@@ -100,4 +107,5 @@ void GraphicId::grcomp(GraphicComp* comp
   } 
   _comp = comp;
   table->insert((void*)comp, (void*)this);
+#endif
 }
--- ivtools-1.2.11a1.orig/src/DrawServ/linkselection.cc
+++ ivtools-1.2.11a1/src/DrawServ/linkselection.cc
@@ -25,6 +25,8 @@
  * Implementation of LinkSelection class.
  */
 
+#ifdef HAVE_ACE
+
 #include <DrawServ/draweditor.h>
 #include <DrawServ/drawserv.h>
 #include <DrawServ/grid.h>
@@ -184,3 +186,5 @@ void LinkSelection::AddComp(OverlayComp*
   Append(ov);
   Update(_editor->GetViewer());
 }
+
+#endif
--- ivtools-1.2.11a1.orig/src/DrawServ/rcdialog.cc
+++ ivtools-1.2.11a1/src/DrawServ/rcdialog.cc
@@ -27,6 +27,8 @@
  * RemoteConnectDialog related classes
  */
 
+#ifdef HAVE_ACE
+
 #include <DrawServ/drawlink.h>
 #include <DrawServ/drawlinklist.h>
 #include <DrawServ/drawserv.h>
@@ -49,7 +51,7 @@
 #include <InterViews/style.h>
 #include <InterViews/window.h>
 
-#include <stdio.h>
+#include <cstdio>
 #include <stdlib.h>
 using namespace std;
 #include <vector>
@@ -384,3 +386,5 @@ void ConnectionsDialogImpl::update_text(
   vbuf.push_back('\0');
   ete_->text(&vbuf[0] ? &vbuf[0] : "", update);
 }
+
+#endif
--- ivtools-1.2.11a1.orig/src/DrawServ/rcdialog.h
+++ ivtools-1.2.11a1/src/DrawServ/rcdialog.h
@@ -29,6 +29,8 @@
 #ifndef rcdialog_h
 #define rcdialog_h
 
+#ifdef HAVE_ACE
+
 #include <InterViews/action.h>
 #include <Unidraw/editor.h>
 
@@ -77,3 +79,4 @@ protected:
 #include <InterViews/_leave.h>
 
 #endif
+#endif
--- ivtools-1.2.11a1.orig/src/FrameUnidraw/framecatalog.cc
+++ ivtools-1.2.11a1/src/FrameUnidraw/framecatalog.cc
@@ -56,28 +56,18 @@ boolean FrameCatalog::Retrieve (const ch
         _valid = true;
 
     } else {
-#if __GNUC__<3
-        filebuf fbuf;
-#else
         filebuf* pfbuf = nil;
-#endif
 	if (strcmp(name, "-") == 0) {
-#if __GNUC__<3
-	    _valid = fbuf.attach(fileno(stdin)) != 0;
-#else
-	    pfbuf = new fileptr_filebuf(stdin, input);
+	    FILEBUFP(pfbuf, stdin, input);
 	    _valid = 1;
-#endif
 	    name = nil;
 	} else {
 	    fptr = fopen(name, "r");
 	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
-#if __GNUC__<3
-	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
-#else
-	    pfbuf = fptr ? new fileptr_filebuf(fptr, input) : nil;
+            if (fptr) {
+ 	        FILEBUFP(pfbuf, fptr, input);
+	    }
 	    _valid = fptr ? 1 : 0;
-#endif
 	    if (compressed) {
 		int namelen = strlen(name);
 		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
@@ -86,14 +76,10 @@ boolean FrameCatalog::Retrieve (const ch
 	}
 
         if (_valid) {
-#if __GNUC__<3
-	    istream in(&fbuf);
-#else
 	    istream in(pfbuf);
-#endif
 
 	    char ch;
-	    while (isspace(ch = in.get())); in.putback(ch);
+	    while (isspace(ch = in.get())) {}; in.putback(ch);
 	    ParamList::parse_token(in, sbuf, SBUFSIZE);
 	    if (strcmp(sbuf, "flipbook") == 0 || 
 		strcmp(sbuf, "frame-idraw") == 0) { 
@@ -115,9 +101,7 @@ boolean FrameCatalog::Retrieve (const ch
 	    }
         }
 
-#if __GNUC__>=3
 	delete pfbuf;
-#endif
     }
 
     if (fptr) {
--- ivtools-1.2.11a1.orig/src/FrameUnidraw/framefunc.h
+++ ivtools-1.2.11a1/src/FrameUnidraw/framefunc.h
@@ -21,7 +21,7 @@
  * 
  */
 
-#if !defined(framefunc_h)
+#if !defined(_framefunc_h)
 #define _framefunc_h
 
 #include <ComUnidraw/unifunc.h>
--- ivtools-1.2.11a1.orig/src/GraphUnidraw/graphcatalog.cc
+++ ivtools-1.2.11a1/src/GraphUnidraw/graphcatalog.cc
@@ -25,6 +25,8 @@
  * GraphCatalog implementation.
  */
 
+#include <cstdio>
+
 #include <OverlayUnidraw/paramlist.h>
 
 #include <GraphUnidraw/graphcatalog.h>
@@ -52,9 +54,7 @@
 #include <stdio.h>
 #include <stream.h>
 #include <string.h>
-#if __GNUC__>=3
 #include <fstream.h>
-#endif
 
 /*****************************************************************************/
 
@@ -75,28 +75,16 @@ boolean GraphCatalog::Retrieve (const ch
         _valid = true;
 
     } else {
-#if __GNUC__<3
-        filebuf fbuf;
-#else
 	filebuf* pfbuf = nil;
-#endif
 	if (strcmp(name, "-") == 0) {
-#if __GNUC__<3
-	    _valid = fbuf.attach(fileno(stdin)) != 0;
-#else
-	    pfbuf = new fileptr_filebuf(stdin, input);
+	    FILEBUFP(pfbuf, stdin, input);
 	    _valid = 1;
-#endif
 	    name = nil;
 	} else {
 	    fptr = fopen(name, "r");
 	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
-#if __GNUC__<3
-	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
-#else
-	    pfbuf = new fileptr_filebuf(fptr, input);
+	    FILEBUFP(pfbuf, fptr, input);
 	    _valid = fptr ? 1 : 0;
-#endif
 	    if (compressed) {
 		int namelen = strlen(name);
 		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
@@ -105,14 +93,10 @@ boolean GraphCatalog::Retrieve (const ch
 	}
 
         if (_valid) {
-#if __GNUC__<3
-	    istream in(&fbuf);
-#else
 	    istream in(pfbuf);
-#endif
 
 	    char ch;
-	    while (isspace(ch = in.get())); in.putback(ch);
+	    while (isspace(ch = in.get())) {}; in.putback(ch);
 	    ParamList::parse_token(in, sbuf, SBUFSIZE);
 	    if (strcmp(sbuf, "graphdraw") == 0 || 
 		strcmp(sbuf, "netdraw") == 0 || 
@@ -131,9 +115,7 @@ boolean GraphCatalog::Retrieve (const ch
 		comp = nil;
 	    }
         }
-#if __GNUC__>=3
 	delete pfbuf;
-#endif
     }
 
     if (fptr) {
--- ivtools-1.2.11a1.orig/src/GraphUnidraw/graphdata.h
+++ ivtools-1.2.11a1/src/GraphUnidraw/graphdata.h
@@ -39,6 +39,7 @@ class GraphData {
 public:
     GraphData() {}
     virtual boolean IsA(ClassId) = 0;
+    virtual ~GraphData() {}
 };
 
 //: command data for storing edge information.
--- ivtools-1.2.11a1.orig/src/GraphUnidraw/nodecomp.cc
+++ ivtools-1.2.11a1/src/GraphUnidraw/nodecomp.cc
@@ -178,23 +178,25 @@ NodeComp::NodeComp(GraphComp* graph)
     _node = new TopoNode(this);
     _reqlabel = true;
 
-    Picture* pic = new Picture();
-    SF_Ellipse* ellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic);
-    ellipse->SetPattern(unidraw->GetCatalog()->FindGrayLevel(1));
-    TextGraphic* txt = new TextGraphic(graph->GetFile(), stdgraphic);
-    ellipse->Align(4, txt, 4); // same as Center in IV-2_6/InterViews/alignment.h
-    pic->Append(ellipse, txt);
-    SetGraphic(pic);
-
-    GraphGraphic();
-
-    // kludge to fix ps: fonts are collected from comp\'s graphic, so we
-    // need to add the font to the picture\'s gs
-    pic->FillBg(ellipse->BgFilled() && !ellipse->GetBgColor()->None());
-    pic->SetColors(ellipse->GetFgColor(), ellipse->GetBgColor());
-    pic->SetPattern(ellipse->GetPattern());
-    pic->SetBrush(ellipse->GetBrush());
-    pic->SetFont(txt->GetFont());
+    if (unidraw) {
+      Picture* pic = new Picture();
+      SF_Ellipse* ellipse = new SF_Ellipse(0, 0, xradius, yradius, stdgraphic);
+      ellipse->SetPattern(unidraw->GetCatalog()->FindGrayLevel(1));
+      TextGraphic* txt = new TextGraphic(graph->GetFile()?graph->GetFile():"", stdgraphic);
+      ellipse->Align(4, txt, 4); // same as Center in IV-2_6/InterViews/alignment.h
+      pic->Append(ellipse, txt);
+      SetGraphic(pic);
+      
+      GraphGraphic();
+      
+      // kludge to fix ps: fonts are collected from comp\'s graphic, so we
+      // need to add the font to the picture\'s gs
+      pic->FillBg(ellipse->BgFilled() && !ellipse->GetBgColor()->None());
+      pic->SetColors(ellipse->GetFgColor(), ellipse->GetBgColor());
+      pic->SetPattern(ellipse->GetPattern());
+      pic->SetBrush(ellipse->GetBrush());
+      pic->SetFont(txt->GetFont());
+    }
 }
 
 NodeComp::NodeComp(OverlayComp* parent) : OverlayComp(nil, parent) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/adjuster2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/adjuster2_6.cc
@@ -75,16 +75,16 @@ void Adjuster::Init(Interactor* i, int d
     plain = nil;
     hit = nil;
     mask = nil;
-    input = new Sensor(onoffEvents);
-    input->Catch(UpEvent);
-    input->Catch(DownEvent);
+    input_ = new Sensor(onoffEvents);
+    input_->Catch(UpEvent);
+    input_->Catch(DownEvent);
 }    
 
 void Adjuster::Reconfig() {
-    Painter* p = new Painter(output);
+    Painter* p = new Painter(output_);
     p->Reference();
-    Unref(output);
-    output = p;
+    Unref(output_);
+    output_ = p;
     shape->width = mask->Width();
     shape->height = mask->Height();
 }
@@ -190,9 +190,9 @@ void Adjuster::Redraw(IntCoord, IntCoord
     IntCoord x = (xmax+1 - mask->Width())/2;
     IntCoord y = (ymax+1 - mask->Height())/2;
     if (highlighted) {
-        output->Stencil(canvas, x, y, hit, mask);
+        output_->Stencil(canvas, x, y, hit, mask);
     } else {
-        output->Stencil(canvas, x, y, plain, mask);
+        output_->Stencil(canvas, x, y, plain, mask);
     }
 }
 
--- ivtools-1.2.11a1.orig/src/IV-2_6/banner.cc
+++ ivtools-1.2.11a1/src/IV-2_6/banner.cc
@@ -55,7 +55,7 @@ void Banner::Init(char* lt, char* m, cha
 void Banner::Reconfig() {
     int w;
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     lw = left == nil ? 0 : f->Width(left);
     mw = middle == nil ? 0 : f->Width(middle);
     rw = right == nil ? 0 : f->Width(right);
@@ -68,9 +68,9 @@ void Banner::Reconfig() {
     shape->height = f->Height() + 2*pad;
     shape->Rigid(0, hfil, 0, 0);
     Unref(inverse);
-    inverse = new Painter(output);
+    inverse = new Painter(output_);
     inverse->Reference();
-    inverse->SetColors(output->GetBgColor(), output->GetFgColor());
+    inverse->SetColors(output_->GetBgColor(), output_->GetFgColor());
 }
 
 Banner::~Banner() {
@@ -78,7 +78,7 @@ Banner::~Banner() {
 }
 
 void Banner::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
-    Painter* p = highlight ? inverse : output;
+    Painter* p = highlight ? inverse : output_;
     p->ClearRect(canvas, x1, y1, x2, y2);
     if (right != nil && rx <= x2) {
 	p->MoveTo(rx, pad);
--- ivtools-1.2.11a1.orig/src/IV-2_6/border2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/border2_6.cc
@@ -43,7 +43,7 @@ Border::Border(const char* name, int t)
 Border::~Border() { }
 
 void Border::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
-    output->FillRect(canvas, x1, y1, x2, y2);
+    output_->FillRect(canvas, x1, y1, x2, y2);
 }
 
 void Border::DefaultThickness(int t) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/button2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/button2_6.cc
@@ -41,6 +41,7 @@
 #include <InterViews/Bitmaps/radio.bm>
 #include <OS/math.h>
 #include <string.h>
+#include <inttypes.h>
 
 #include <IV-2_6/_enter.h>
 
@@ -157,9 +158,9 @@ void Button::Init(ButtonState* s, void*
     hit = false;
     subject->Attach(this);
     Update();
-    input = new Sensor(updownEvents);
-    input->Catch(EnterEvent);
-    input->Catch(LeaveEvent);
+    input_ = new Sensor(updownEvents);
+    input_->Catch(EnterEvent);
+    input_->Catch(LeaveEvent);
 }
 
 Button::~Button() {
@@ -325,9 +326,9 @@ void TextButton::Reconfig() {
 
 void TextButton::MakeBackground() {
     Unref(background);
-    background = new Painter(output);
+    background = new Painter(output_);
     background->Reference();
-    background->SetColors(output->GetBgColor(), output->GetFgColor());
+    background->SetColors(output_->GetBgColor(), output_->GetFgColor());
 
     static Pattern* gray_pat;
     if (gray_pat == nil) {
@@ -343,7 +344,7 @@ void TextButton::MakeBackground() {
 
 void TextButton::MakeShape() {
     if (text != nil) {
-	const Font* f = output->GetFont();
+	const Font* f = output_->GetFont();
 	shape->width += f->Width(text);
 	shape->height += f->Height();
     }
@@ -357,7 +358,7 @@ TextButton::~TextButton() {
 }
 
 PushButton::PushButton(
-    const char* str, ButtonState* s, int v
+    const char* str, ButtonState* s, intptr_t v
 ) : TextButton(str, s, (void*)v) {
     Init();
 }
@@ -369,7 +370,7 @@ PushButton::PushButton(
 }
 
 PushButton::PushButton(
-    const char* name, const char* str, ButtonState* s, int v
+    const char* name, const char* str, ButtonState* s, intptr_t v
 ) : TextButton(name, str, s, (void*)v) {
     Init();
 }
@@ -391,13 +392,13 @@ void PushButton::Reconfig() {
     MakeBackground();
     if (shape->Undefined()) {
 	MakeShape();
-	shape->width += output->GetFont()->Width("    ");
+	shape->width += output_->GetFont()->Width("    ");
 	shape->height += 2*pad;
     }
 }
 
 void PushButton::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
-    output->ClearRect(canvas, x1, y1, x2, y2);
+    output_->ClearRect(canvas, x1, y1, x2, y2);
     Refresh();
 }
 
@@ -423,15 +424,15 @@ void PushButton::Refresh() {
     x[13] = xmax - r - r; y[13] = 0;
     x[14] = r + r; y[14] = 0;
     x[15] = r; y[15] = 0;
-    tx = (xmax - output->GetFont()->Width(text))/2;
+    tx = (xmax - output_->GetFont()->Width(text))/2;
     ty = pad;
     if (chosen || hit) {
-	output->FillBSpline(canvas, x, y, 16);
+	output_->FillBSpline(canvas, x, y, 16);
 	background->Text(canvas, text, tx, ty);
     } else {
 	background->FillRect(canvas, 0, 0, xmax, ymax);
-	output->ClosedBSpline(canvas, x, y, 16);
-	output->Text(canvas, text, tx, ty);
+	output_->ClosedBSpline(canvas, x, y, 16);
+	output_->Text(canvas, text, tx, ty);
     }
     if (!enabled) {
 	grayout->FillRect(canvas, 0, 0, xmax, ymax);
@@ -445,7 +446,7 @@ static Bitmap* radioChosen;
 static Bitmap* radioBoth;
 
 RadioButton::RadioButton(
-    const char* str, ButtonState* s, int v
+    const char* str, ButtonState* s, intptr_t v
 ) : TextButton(str, s, (void*)v) {
     Init();
 }
@@ -457,7 +458,7 @@ RadioButton::RadioButton(
 }
 
 RadioButton::RadioButton(
-    const char* name, const char* str, ButtonState* s, int v
+    const char* name, const char* str, ButtonState* s, intptr_t v
 ) : TextButton(name, str, s, (void*)v) {
     Init();
 }
@@ -506,12 +507,12 @@ void RadioButton::Reconfig() {
 }
 
 void RadioButton::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
-    int h = output->GetFont()->Height();
+    int h = output_->GetFont()->Height();
     int r = radio_plain_width;
-    output->ClearRect(canvas, x1, y1, x2, y2);
+    output_->ClearRect(canvas, x1, y1, x2, y2);
     IntCoord tx = r + sep;
     IntCoord ty = (ymax + 1 - h) / 2;
-    output->Text(canvas, text, tx, ty);
+    output_->Text(canvas, text, tx, ty);
     Refresh();
 }
 
@@ -519,13 +520,13 @@ void RadioButton::Refresh() {
     IntCoord x = 0;
     IntCoord y = (ymax+1 - radio_plain_height)/2;
     if (!hit && !chosen) {
-        output->Stencil(canvas, x, y, radioPlain, radioMask);
+        output_->Stencil(canvas, x, y, radioPlain, radioMask);
     } else if (hit && !chosen) {
-        output->Stencil(canvas, x, y, radioHit, radioMask);
+        output_->Stencil(canvas, x, y, radioHit, radioMask);
     } else if (!hit && chosen) {
-        output->Stencil(canvas, x, y, radioChosen, radioMask);
+        output_->Stencil(canvas, x, y, radioChosen, radioMask);
     } else if (hit && chosen) {
-        output->Stencil(canvas, x, y, radioBoth, radioMask);
+        output_->Stencil(canvas, x, y, radioBoth, radioMask);
     }
     if (!enabled) {
 	grayout->FillRect(canvas, 0, 0, xmax, ymax);
@@ -533,7 +534,7 @@ void RadioButton::Refresh() {
 }
 
 CheckBox::CheckBox(
-    const char* str, ButtonState* s, int on, int off
+    const char* str, ButtonState* s, intptr_t on, intptr_t off
 ) : TextButton(str, s, (void*)on) {
     Init((void*)off);
 }
@@ -545,7 +546,7 @@ CheckBox::CheckBox(
 }
 
 CheckBox::CheckBox(
-    const char* name, const char* str, ButtonState* s, int on, int off
+    const char* name, const char* str, ButtonState* s, intptr_t on, intptr_t off
 ) : TextButton(name, str, s, (void*)on) {
     Init((void*)off);
 }
@@ -594,17 +595,17 @@ void CheckBox::Update() {
 }
 
 void CheckBox::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
-    int h = output->GetFont()->Height();
+    int h = output_->GetFont()->Height();
     int t = HalfCheckBoxSize(h);
-    output->ClearRect(canvas, x1, y1, x2, y2);
+    output_->ClearRect(canvas, x1, y1, x2, y2);
     IntCoord tx = 2*t + sep;
     IntCoord ty = (ymax + 1 - h) / 2;
-    output->Text(canvas, text, tx, ty);
+    output_->Text(canvas, text, tx, ty);
     Refresh();
 }
 
 void CheckBox::Refresh() {
-    int h = output->GetFont()->Height();
+    int h = output_->GetFont()->Height();
     int t = HalfCheckBoxSize(h);
     IntCoord cx = t;
     IntCoord cy = (ymax + 1)/2;
@@ -612,14 +613,14 @@ void CheckBox::Refresh() {
     IntCoord right = cx + t;
     IntCoord bottom = cy - t;
     IntCoord top = cy + t;
-    output->Rect(canvas, left, bottom, right, top);
+    output_->Rect(canvas, left, bottom, right, top);
     background->FillRect(canvas, left+1, bottom+1, right-1, top-1);
     if (hit) {
-	output->Rect(canvas, left+1, bottom+1, right-1, top-1);
+	output_->Rect(canvas, left+1, bottom+1, right-1, top-1);
     }
     if (chosen) {
-	output->Line(canvas, left, bottom, right, top);
-	output->Line(canvas, left, top, right, bottom);
+	output_->Line(canvas, left, bottom, right, top);
+	output_->Line(canvas, left, top, right, bottom);
     }
     if (!enabled) {
 	grayout->FillRect(canvas, 0, 0, xmax, ymax);
--- ivtools-1.2.11a1.orig/src/IV-2_6/control.cc
+++ ivtools-1.2.11a1/src/IV-2_6/control.cc
@@ -43,11 +43,11 @@ void Control::Init(const char* name, Int
     parent_ = nil;
     state_ = new ControlState;
     state_->Attach(this);
-    input = new Sensor;
-    input->Catch(EnterEvent);
-    input->Catch(LeaveEvent);
-    input->Catch(DownEvent);
-    input->Catch(UpEvent);
+    input_ = new Sensor;
+    input_->Catch(EnterEvent);
+    input_->Catch(LeaveEvent);
+    input_->Catch(DownEvent);
+    input_->Catch(UpEvent);
     if (i != nil) {
 	Insert(i);
     }
--- ivtools-1.2.11a1.orig/src/IV-2_6/filebrowser.cc
+++ ivtools-1.2.11a1/src/IV-2_6/filebrowser.cc
@@ -54,6 +54,11 @@ extern "C" {
 
 static const unsigned int max_filename_length = 256;
 
+// No MAXPATHLEN on GNU Hurd, cobble something up.
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 4096
+#endif
+
 class FBDirectory {       
 public:
     FBDirectory(const char* name);
--- ivtools-1.2.11a1.orig/src/IV-2_6/frame.cc
+++ ivtools-1.2.11a1/src/IV-2_6/frame.cc
@@ -74,7 +74,7 @@ void Frame::Reconfig() {
 }
 
 void Frame::Resize() {
-    canvas->SetBackground(output->GetBgColor());
+    canvas->SetBackground(output_->GetBgColor());
     Place(interior(), left, bottom, xmax - right, ymax - top);
 }
 
@@ -83,16 +83,16 @@ void Frame::Redraw(IntCoord x1, IntCoord
     register IntCoord t = ymax - top;
 
     if (x1 < left) {
-        output->FillRect(canvas, 0, 0, left-1, t);
+        output_->FillRect(canvas, 0, 0, left-1, t);
     }
     if (y1 < bottom) {
-        output->FillRect(canvas, left, 0, xmax, bottom-1);
+        output_->FillRect(canvas, left, 0, xmax, bottom-1);
     }
     if (x2 > r) {
-        output->FillRect(canvas, r+1, bottom, xmax, ymax);
+        output_->FillRect(canvas, r+1, bottom, xmax, ymax);
     }
     if (y2 > t) {
-        output->FillRect(canvas, 0, t+1, r, ymax);
+        output_->FillRect(canvas, 0, t+1, r, ymax);
     }
 }
 
@@ -105,8 +105,8 @@ void Frame::Redraw(IntCoord x1, IntCoord
 ShowFrame::~ShowFrame() { }
 
 void ShowFrame::Init() {
-    input = onoffEvents;
-    input->Reference();
+    input_ = onoffEvents;
+    input_->Reference();
 }
 
 void ShowFrame::Handle(Event& e) {
@@ -196,11 +196,11 @@ void BorderFrame::Redraw(IntCoord x1, In
     if (normal) {
 	Frame::Redraw(x1, y1, x2, y2);
     } else {
-	const Pattern* save = output->GetPattern();
+	const Pattern* save = output_->GetPattern();
 	Resource::ref(save);
-	output->SetPattern(new Pattern(Pattern::gray));
+	output_->SetPattern(new Pattern(Pattern::gray));
 	Frame::Redraw(x1, y1, x2, y2);
-	output->SetPattern(save);
+	output_->SetPattern(save);
 	Resource::unref(save);
     }
 }
@@ -245,41 +245,41 @@ void ShadowFrame::Redraw(IntCoord x1, In
 
     /* borders */
     if (x1 < left) {
-        output->FillRect(canvas, left-1, bottom-1, left-1, t);
+        output_->FillRect(canvas, left-1, bottom-1, left-1, t);
     }
     if (y1 < bottom) {
-        output->FillRect(canvas, left, bottom-1, r+1, bottom-1);
+        output_->FillRect(canvas, left, bottom-1, r+1, bottom-1);
     }
     if (x2 > r) {
-        output->FillRect(canvas, r+1, bottom, r+1, t+1);
+        output_->FillRect(canvas, r+1, bottom, r+1, t+1);
     }
     if (y2 > t) {
-        output->FillRect(canvas, left-1, t+1, r, t+1);
+        output_->FillRect(canvas, left-1, t+1, r, t+1);
     }
 
     /* shadows */
     if (left > 1 && x1 < left-1) {
-        output->FillRect(canvas, 0, v, left-2, ymax-v);
+        output_->FillRect(canvas, 0, v, left-2, ymax-v);
     }
     if (bottom > 1 && y1 < bottom-1) {
-        output->FillRect(canvas, h, 0, xmax-h, bottom-2);
+        output_->FillRect(canvas, h, 0, xmax-h, bottom-2);
     }
     if (right > 1 && x2 > r+1) {
-        output->FillRect(canvas, r+2, v, xmax, ymax-v);
+        output_->FillRect(canvas, r+2, v, xmax, ymax-v);
     }
     if (top > 1 && y2 > t+1) {
-        output->FillRect(canvas, h, t+2, xmax-h, ymax);
+        output_->FillRect(canvas, h, t+2, xmax-h, ymax);
     }
 
     /* corner */
     if (left > 1 && bottom > 1 && x1 < left-1 && y1 < bottom-1) {
-        output->FillRect(canvas, 0, 0, h - 1, v - 1);
+        output_->FillRect(canvas, 0, 0, h - 1, v - 1);
     } else if (left > 1 && top > 1 && x1 < left-1 && y2 > t+1) {
-        output->FillRect(canvas, 0, ymax - v + 1, h - 1, ymax);
+        output_->FillRect(canvas, 0, ymax - v + 1, h - 1, ymax);
     } else if (right > 1 && bottom > 1 && x2 > r+1 && y1 < bottom-1) {
-        output->FillRect(canvas, xmax - h + 1, 0, xmax, v - 1);
+        output_->FillRect(canvas, xmax - h + 1, 0, xmax, v - 1);
     } else if (right > 1 && top > 1 && x1 > r+1 && y2 > t+1) {
-        output->FillRect(canvas, xmax - h + 1, ymax - v + 1, xmax, ymax);
+        output_->FillRect(canvas, xmax - h + 1, ymax - v + 1, xmax, ymax);
     }
 }
 
@@ -361,7 +361,7 @@ void MarginFrame::Reconfig() {
 }
 
 void MarginFrame::Resize() {
-    canvas->SetBackground(output->GetBgColor());
+    canvas->SetBackground(output_->GetBgColor());
 
     IntCoord hextra = (xmax+1) - shape->width;
     IntCoord h = hmargin;
--- ivtools-1.2.11a1.orig/src/IV-2_6/interactor.cc
+++ ivtools-1.2.11a1/src/IV-2_6/interactor.cc
@@ -61,8 +61,8 @@ void Interactor::Init() {
     perspective = nil;
     xmax = 0;
     ymax = 0;
-    input = nil;
-    output = nil;
+    input_ = nil;
+    output_ = nil;
     classname = nil;
     instance = nil;
     style = new Style;
@@ -80,8 +80,8 @@ void Interactor::Init() {
 }
 
 Interactor::~Interactor() {
-    Resource::unref(input);
-    Resource::unref(output);
+    Resource::unref(input_);
+    Resource::unref(output_);
     delete window;
     delete shape;
     Resource::unref(style);
@@ -309,8 +309,8 @@ void Interactor::Config(World* w) {
 	parent = nil;
     }
     world = w;
-    Resource::unref(output);
-    output = nil;
+    Resource::unref(output_);
+    output_ = nil;
     DoConfig(false);
 }
 
@@ -332,10 +332,10 @@ void Interactor::DoConfig(boolean parent
     boolean reversed = parentReversed;
     if (parent != nil) {
 	/* cast to workaround DEC C++ compiler bug */
-	output = ((Interactor*)parent)->output;
+	output_ = ((Interactor*)parent)->output_;
     }
     DefaultConfig(reversed);
-    Resource::ref(output);
+    Resource::ref(output_);
 
     Interactor* children[100];
     Interactor** a;
@@ -412,18 +412,18 @@ void Interactor::DefaultConfig(boolean&
 	}
     }
 
-    if (output == nil) {
-	output = new Painter;
-    } else if (!swap_colors && f == output->GetFont() &&
-	fg == output->GetFgColor() && bg == output->GetBgColor()
+    if (output_ == nil) {
+	output_ = new Painter;
+    } else if (!swap_colors && f == output_->GetFont() &&
+	fg == output_->GetFgColor() && bg == output_->GetBgColor()
     ) {
 	return;
     } else {
-	output = new Painter(output);
+	output_ = new Painter(output_);
     }
 
     if (f != nil) {
-	output->SetFont(f);
+	output_->SetFont(f);
     }
 
     if (swap_colors) {
@@ -431,7 +431,7 @@ void Interactor::DefaultConfig(boolean&
 	fg = bg;
 	bg = c;
     }
-    output->SetColors(fg, bg);
+    output_->SetColors(fg, bg);
 }
 
 /*
--- ivtools-1.2.11a1.orig/src/IV-2_6/matcheditor.cc
+++ ivtools-1.2.11a1/src/IV-2_6/matcheditor.cc
@@ -89,9 +89,5 @@ boolean MatchEditor::HandleChar (char c)
             Select(length, text->Length());
         }
     }
-    if (done && left == right) {
-        return true;
-    } else {
-        return false;
-    }
+    return (done && left == right);
 }
--- ivtools-1.2.11a1.orig/src/IV-2_6/menu2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/menu2_6.cc
@@ -125,16 +125,16 @@ void MenuShadow::Resize() {
 
 void MenuShadow::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
     if (x2 >= depth_ && y1 <= ymax - depth_) {
-	const Pattern* p = output->GetPattern();
+	const Pattern* p = output_->GetPattern();
 	Resource::ref(p);
-	boolean b = output->BgFilled();
-	output->SetPattern(halftone);
-	output->FillBg(false);
+	boolean b = output_->BgFilled();
+	output_->SetPattern(halftone);
+	output_->FillBg(false);
 	IntCoord left = Math::max(x1, depth_);
 	IntCoord top = Math::min(y2, ymax - depth_);
-	output->FillRect(canvas, left, y1, x2, top);
-	output->FillBg(b);
-	output->SetPattern(p);
+	output_->FillRect(canvas, left, y1, x2, top);
+	output_->FillBg(b);
+	output_->SetPattern(p);
 	Resource::unref(p);
     }
 }
--- ivtools-1.2.11a1.orig/src/IV-2_6/message.cc
+++ ivtools-1.2.11a1/src/IV-2_6/message.cc
@@ -74,7 +74,7 @@ void Message::Reconfig () {
     if (a != nil) {
 	pad = atoi(a);
     }
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->width = pad + f->Width(text) + pad;
     shape->height = pad + f->Height() + pad;
     shape->hshrink = pad + pad;
@@ -89,16 +89,16 @@ void Message::Realign (Alignment a) {
 void Message::Redraw (IntCoord l, IntCoord b, IntCoord r, IntCoord t) {
     IntCoord x = 0, y = 0;
     Align(alignment, shape->width, shape->height, x, y);
-    output->Clip(canvas, l, b, r, t);
+    output_->Clip(canvas, l, b, r, t);
     if (highlighted) {
-	output->SetColors(output->GetBgColor(), output->GetFgColor());
+	output_->SetColors(output_->GetBgColor(), output_->GetFgColor());
     }
-    output->ClearRect(canvas, l, b, r, t);
-    output->Text(canvas, text, x + pad, y + pad);
+    output_->ClearRect(canvas, l, b, r, t);
+    output_->Text(canvas, text, x + pad, y + pad);
     if (highlighted) {
-	output->SetColors(output->GetBgColor(), output->GetFgColor());
+	output_->SetColors(output_->GetBgColor(), output_->GetFgColor());
     }
-    output->NoClip();
+    output_->NoClip();
 }
 
 void Message::Highlight (boolean b) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/panner2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/panner2_6.cc
@@ -131,14 +131,14 @@ void Slider::Init (Interactor* i) {
     *shown = *view;
     shape->vstretch = shape->vshrink = 0;
     prevl = prevb = prevr = prevt = 0;
-    input = new Sensor(updownEvents);
+    input_ = new Sensor(updownEvents);
 }
 
 void Slider::Reconfig () {
-    Painter* p = new Painter(output);
+    Painter* p = new Painter(output_);
     p->Reference();
-    Unref(output);
-    output = p;
+    Unref(output_);
+    output_ = p;
 
     const char* attrib = GetAttribute("syncScroll");
     syncScroll = attrib != nil &&
@@ -164,14 +164,14 @@ void Slider::Reshape (Shape& ns) {
 
 void Slider::Draw () {
     if (canvas != nil) {
-	output->SetPattern(new Pattern(Pattern::lightgray));
-	output->FillRect(canvas, 0, 0, xmax, ymax);
-	output->SetPattern(new Pattern(int(Pattern::clear)));
-	output->FillRect(canvas, left, bottom, right, top);
-	output->SetPattern(new Pattern(Pattern::solid));
-	output->Rect(canvas, left, bottom, right, top);
-	output->Line(canvas, left+1, bottom-1, right+1, bottom-1);
-	output->Line(canvas, right+1, bottom-1, right+1, top-1);
+	output_->SetPattern(new Pattern(Pattern::lightgray));
+	output_->FillRect(canvas, 0, 0, xmax, ymax);
+	output_->SetPattern(new Pattern(int(Pattern::clear)));
+	output_->FillRect(canvas, left, bottom, right, top);
+	output_->SetPattern(new Pattern(Pattern::solid));
+	output_->Rect(canvas, left, bottom, right, top);
+	output_->Line(canvas, left+1, bottom-1, right+1, bottom-1);
+	output_->Line(canvas, right+1, bottom-1, right+1, top-1);
 
 	prevl = left; prevb = bottom;
 	prevr = right; prevt = top;
@@ -181,9 +181,9 @@ void Slider::Draw () {
 void Slider::Redraw (
     IntCoord left, IntCoord bottom, IntCoord right, IntCoord top
 ) {
-    output->Clip(canvas, left, bottom, right, top);
+    output_->Clip(canvas, left, bottom, right, top);
     Draw();
-    output->NoClip();
+    output_->NoClip();
 }
 
 inline IntCoord Slider::ViewX (IntCoord x) {
@@ -262,7 +262,7 @@ void Slider::Slide (Event& e) {
     boolean control = e.control;
 
     Listen(allEvents);
-    SlidingRect r(output, canvas, left, bottom, right, top, e.x, e.y);
+    SlidingRect r(output_, canvas, left, bottom, right, top, e.x, e.y);
     CalcLimits(e);
     do {
 	switch (e.eventType) {
@@ -287,7 +287,7 @@ void Slider::Slide (Event& e) {
 
     r.GetCurrent(newleft, newbot, dummy, dummy);
     Move(ViewX(newleft - left), ViewY(newbot - bottom));
-    Listen(input);
+    Listen(input_);
 }
 
 void Slider::Jump (Event& e) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/rubband.cc
+++ ivtools-1.2.11a1/src/IV-2_6/rubband.cc
@@ -28,35 +28,17 @@
 
 #include <IV-2_6/InterViews/rubband.h>
 #include <IV-2_6/InterViews/painter.h>
+#include <OS/math.h>
 #include <math.h>
 
-static float DEGS_PER_RAD = 180.0 / M_PI;
-
 float Rubberband::Angle (IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1) {
-    float dx, dy, angle;
-
-    dx = float(x1 - x0);
-    dy = float(y1 - y0);
-    if (dx != 0) {
-        angle = DEGS_PER_RAD * atan(dy/dx);
-    } else if (dy < 0) {
-        angle = -90;
-    } else {
-        angle = 90;
-    }
-    if (dx < 0) {
-        angle += 180;
-    }
-    return angle;
+    return degrees(atan2f(y1 - y0, x1 - x0));
 }
 
 float Rubberband::Distance(
     IntCoord x0, IntCoord y0, IntCoord x1, IntCoord y1
 ) {
-    float dx = x0 - x1;
-    float dy = y0 - y1;
-
-    return sqrt(dx*dx + dy*dy);
+    return hypotf(x0-x1, y0-y1);
 }
 
 Rubberband::Rubberband (Painter* p, Canvas* c, IntCoord x, IntCoord y) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/rubcurve.cc
+++ ivtools-1.2.11a1/src/IV-2_6/rubcurve.cc
@@ -128,7 +128,7 @@ RubberCircle::RubberCircle(
 void RubberCircle::OriginalRadii(int& xr, int& yr) {
     IntCoord dx = radiusx - centerx;
     IntCoord dy = radiusy - centery;
-    int radius = Math::round(sqrt(dx*dx + dy*dy));
+    int radius = Math::round(hypot(dx, dy));
     xr = radius;
     yr = radius;
 }
@@ -136,7 +136,7 @@ void RubberCircle::OriginalRadii(int& xr
 void RubberCircle::CurrentRadii(int& xr, int& yr) {
     IntCoord dx = trackx - centerx;
     IntCoord dy = tracky - centery;
-    int radius = Math::round(sqrt(dx*dx + dy*dy));
+    int radius = Math::round(hypot(dx, dy));
     xr = radius;
     yr = radius;
 }
@@ -561,7 +561,7 @@ RotatingLineList::~RotatingLineList() {
 }
 
 void RotatingLineList::Update() {
-    float angle = (CurrentAngle() - OriginalAngle()) * M_PI/180.0;
+    float angle = radians(CurrentAngle() - OriginalAngle());
     float cosine = cos(angle);
     float sine = sin(angle);
     float tx, ty;
--- ivtools-1.2.11a1.orig/src/IV-2_6/rubline.cc
+++ ivtools-1.2.11a1/src/IV-2_6/rubline.cc
@@ -196,7 +196,7 @@ void RotatingLine::GetCurrent(
     dy1 = double(refy - centery);
     dx2 = double(trackx - centerx);
     dy2 = double(tracky - centery);
-    hprod = sqrt((dx1*dx1 + dy1*dy1) * (dx2*dx2 + dy2*dy2));
+    hprod = hypot(dx1,dy1) * hypot(dx2,dy2);
     if (hprod != 0.0) {
         cos = (dx1*dx2 + dy1*dy2) / hprod;
         sin = (dx1*dy2 - dx2*dy1) / hprod;
--- ivtools-1.2.11a1.orig/src/IV-2_6/rubrect.cc
+++ ivtools-1.2.11a1/src/IV-2_6/rubrect.cc
@@ -286,7 +286,7 @@ void RotatingRect::GetCurrent(
     dy1 = double(refy - centery);
     dx2 = double(trackx - centerx);
     dy2 = double(tracky - centery);
-    hprod = sqrt((dx1*dx1 + dy1*dy1) * (dx2*dx2 + dy2*dy2));
+    hprod = hypot(dx1, dy1) * hypot(dx2, dy2);
     if (hprod != 0.0) {
         cos = (dx1*dx2 + dy1*dy2) / hprod;
         sin = (dx1*dy2 - dx2*dy1) / hprod;
--- ivtools-1.2.11a1.orig/src/IV-2_6/scene.cc
+++ ivtools-1.2.11a1/src/IV-2_6/scene.cc
@@ -221,7 +221,7 @@ void MonoScene::DoInsert(Interactor* i,
 }
 
 void MonoScene::DoChange(Interactor*) {
-    if (output != nil) {
+    if (output_ != nil) {
 	Reconfig();
     }
 }
@@ -237,8 +237,8 @@ void MonoScene::Reconfig() {
 }
 
 void MonoScene::Resize() {
-    if (output != nil && GetCanvasType() != CanvasInputOnly) {
-	canvas->SetBackground(output->GetBgColor());
+    if (output_ != nil && GetCanvasType() != CanvasInputOnly) {
+	canvas->SetBackground(output_->GetBgColor());
     }
     if (interior_ != nil) {
 	Place(interior_, 0, 0, xmax, ymax);
--- ivtools-1.2.11a1.orig/src/IV-2_6/scroller2_6.cc
+++ ivtools-1.2.11a1/src/IV-2_6/scroller2_6.cc
@@ -59,10 +59,10 @@ void Scroller::Init() {
     view->Attach(this);
     shown = new Perspective;
     shape->Rigid();
-    input = new Sensor;
-    input->Catch(DownEvent);
-    input->Catch(UpEvent);
-    input->Catch(MotionEvent);
+    input_ = new Sensor;
+    input_->Catch(DownEvent);
+    input_->Catch(UpEvent);
+    input_->Catch(MotionEvent);
 }
 
 Scroller::~Scroller() {
@@ -71,16 +71,16 @@ Scroller::~Scroller() {
 }
 
 void Scroller::MakeBackground() {
-    Painter* bg = new Painter(output);
+    Painter* bg = new Painter(output_);
     bg->ref();
-    Resource::unref(output);
-    output = bg;
+    Resource::unref(output_);
+    output_ = bg;
     static Pattern* pat;
     if (pat == nil) {
 	pat = new Pattern(Pattern::lightgray);
 	pat->Reference();
     }
-    output->SetPattern(pat);
+    output_->SetPattern(pat);
 }
 
 void Scroller::Resize() {
@@ -90,7 +90,7 @@ void Scroller::Resize() {
 inline void Scroller::Background(
     IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2
 ) {
-    output->FillRect(canvas, x1, y1, x2, y2);
+    output_->FillRect(canvas, x1, y1, x2, y2);
 }
 
 HScroller::HScroller(Interactor* i, int n) : Scroller(i, n) {
@@ -188,37 +188,37 @@ void VScroller::GetBarInfo(
 }
 
 inline void HScroller::Bar(IntCoord x, int width) {
-    output->ClearRect(canvas, x, inset+1, x+width-1, ymax-inset-1);
+    output_->ClearRect(canvas, x, inset+1, x+width-1, ymax-inset-1);
 }
 
 inline void VScroller::Bar(IntCoord y, int height) {
-    output->ClearRect(canvas, inset+1, y, xmax-inset-1, y+height-1);
+    output_->ClearRect(canvas, inset+1, y, xmax-inset-1, y+height-1);
 }
 
 inline void HScroller::Outline(IntCoord x, int width) {
-    output->Rect(canvas, x, inset, x+width-1, ymax-inset);
+    output_->Rect(canvas, x, inset, x+width-1, ymax-inset);
 }
 
 inline void VScroller::Outline(IntCoord y, int height) {
-    output->Rect(canvas, inset, y, xmax-inset, y+height-1);
+    output_->Rect(canvas, inset, y, xmax-inset, y+height-1);
 }
 
 inline void HScroller::Border(IntCoord x) {
-    output->Line(canvas, x, inset, x, ymax-inset);
+    output_->Line(canvas, x, inset, x, ymax-inset);
 }
 
 inline void VScroller::Border(IntCoord y) {
-    output->Line(canvas, inset, y, xmax-inset, y);
+    output_->Line(canvas, inset, y, xmax-inset, y);
 }
 
 inline void HScroller::Sides(IntCoord x1, IntCoord x2) {
-    output->Line(canvas, x1, inset, x2, inset);
-    output->Line(canvas, x1, ymax-inset, x2, ymax-inset);
+    output_->Line(canvas, x1, inset, x2, inset);
+    output_->Line(canvas, x1, ymax-inset, x2, ymax-inset);
 }
 
 inline void VScroller::Sides(IntCoord y1, IntCoord y2) {
-    output->Line(canvas, inset, y1, inset, y2);
-    output->Line(canvas, xmax-inset, y1, xmax-inset, y2);
+    output_->Line(canvas, inset, y1, inset, y2);
+    output_->Line(canvas, xmax-inset, y1, xmax-inset, y2);
 }
 
 void HScroller::Redraw(IntCoord x1, IntCoord y1, IntCoord x2, IntCoord y2) {
@@ -290,7 +290,7 @@ IntCoord HScroller::Slide(register Event
     w = e.x - x1;
 
     boolean syncing = (syncScroll && !e.control) || (!syncScroll && e.control);
-    SlidingRect r(output, canvas, x1+1, inset+1, x2-1, ymax-inset-1, e.x, 0);
+    SlidingRect r(output_, canvas, x1+1, inset+1, x2-1, ymax-inset-1, e.x, 0);
     r.Draw();
 
     for (;;) {
@@ -343,7 +343,7 @@ IntCoord VScroller::Slide(register Event
     h = e.y - y1;
 
     boolean syncing = (syncScroll && !e.control) || (!syncScroll && e.control);
-    SlidingRect r(output, canvas, inset+1, y1+1, xmax-inset-1, y2-1, 0, e.y );
+    SlidingRect r(output_, canvas, inset+1, y1+1, xmax-inset-1, y2-1, 0, e.y );
     r.Draw();
 
     for (;;) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/strbrowser.cc
+++ ivtools-1.2.11a1/src/IV-2_6/strbrowser.cc
@@ -68,9 +68,9 @@ void StringBrowser::Init (
     const int defaultSize = 256;
 
     SetClassName("StringBrowser");
-    input = new Sensor;
-    input->Catch(DownEvent);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(DownEvent);
+    input_->Catch(KeyEvent);
 
     strbufsize = selbufsize = defaultSize;
     strbuf = new char*[strbufsize];
@@ -95,7 +95,7 @@ void StringBrowser::Init (
 void StringBrowser::InitTextDisplay () {
     delete display;
     display = new TextDisplay;
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->CaretStyle(NoCaret);
 
     for (int i = 0; i < strcount; ++i) {
@@ -103,7 +103,7 @@ void StringBrowser::InitTextDisplay () {
     }
 
     if (canvas != nil) {
-        output->ClearRect(canvas, 0, 0, xmax, ymax);
+        output_->ClearRect(canvas, 0, 0, xmax, ymax);
     }
 }
 
@@ -174,15 +174,15 @@ static int BufFind (
 }
 
 void StringBrowser::Insert (const char* s, int index) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     register Perspective* p = perspective;
 
     char* copy = new char[strlen(s)+1];
     strcpy(copy, s);
     BufInsert(copy, index, strbuf, strbufsize, strcount);
 
-    if (output != nil) {
-	p->width = Math::max(p->width, output->GetFont()->Width(s));
+    if (output_ != nil) {
+	p->width = Math::max(p->width, output_->GetFont()->Width(s));
     }
     p->height += lineheight;
     p->cury += lineheight;
@@ -196,7 +196,7 @@ void StringBrowser::Insert (const char*
 
 void StringBrowser::Replace (const char* s, int index) {
     if (index < strcount) {
-	display->Draw(output, canvas);
+	display->Draw(output_, canvas);
 	register Perspective* p = perspective;
 
 	char* old_string = String(index);
@@ -205,8 +205,8 @@ void StringBrowser::Replace (const char*
 	strcpy(copy, s);
 	strbuf[index] = copy;
 
-	if (output != nil) {
-	    p->width = Math::max(p->width, output->GetFont()->Width(s));
+	if (output_ != nil) {
+	    p->width = Math::max(p->width, output_->GetFont()->Width(s));
 	}
 	p->Update();
 
@@ -216,13 +216,13 @@ void StringBrowser::Replace (const char*
 
 void StringBrowser::Remove (int index) {
     if (0 <= index && index < strcount) {
-        display->Draw(output, canvas);
+        display->Draw(output_, canvas);
         register Perspective* p = perspective;
 	char* string = String(index);
 
 	if (
-	    output != nil && p->width > columns * shape->hunits &&
-	    p->width == output->GetFont()->Width(string)
+	    output_ != nil && p->width > columns * shape->hunits &&
+	    p->width == output_->GetFont()->Width(string)
 	) {
 	    UpdateWidth();
 	}
@@ -265,7 +265,7 @@ void StringBrowser::Clear () {
 void StringBrowser::Select (int index) {
     if (index < strcount && !Selected(index)) {
         BufInsert(String(index), selcount, selbuf, selbufsize, selcount);
-        display->Draw(output, canvas);
+        display->Draw(output_, canvas);
         display->Style(index, 0, index+1, -1, highlight);
     }
 }
@@ -275,7 +275,7 @@ void StringBrowser::Unselect (int index)
 
     if (index < strcount && (selindex = SelectionIndex(index)) >= 0) {
         BufRemove(selindex, selbuf, selcount);
-        display->Draw(output, canvas);
+        display->Draw(output_, canvas);
         display->Style(index, 0, index+1, -1, Plain);
     }
 }
@@ -438,7 +438,7 @@ void StringBrowser::Reconfig () {
 		hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
 	    ),
 	    new Bitmap(hand_mask_bits, hand_mask_width, hand_mask_height),
-	    output->GetFgColor(), output->GetBgColor()
+	    output_->GetFgColor(), output_->GetBgColor()
         );
 
         upCursor = new Cursor(
@@ -446,7 +446,7 @@ void StringBrowser::Reconfig () {
 		ufast_bits, ufast_width, ufast_height, ufast_x_hot, ufast_y_hot
 	    ),
 	    new Bitmap(ufast_mask_bits, ufast_mask_width, ufast_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
 
         dnCursor = new Cursor(
@@ -454,11 +454,11 @@ void StringBrowser::Reconfig () {
 		dfast_bits, dfast_width, dfast_height, dfast_x_hot, dfast_y_hot
 	    ),
 	    new Bitmap(dfast_mask_bits, dfast_mask_width, dfast_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
     }
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->hunits = f->Width("n");
     shape->vunits = f->Height();
     lineheight = shape->vunits;
@@ -471,9 +471,9 @@ void StringBrowser::Reconfig () {
 }
 
 void StringBrowser::UpdateWidth () {
-    if (output != nil) {
+    if (output_ != nil) {
 	Perspective* p = perspective;
-	const Font* f = output->GetFont();
+	const Font* f = output_->GetFont();
 	p->width = columns * shape->hunits;
 
 	for (int i = 0; i < Count(); ++i) {
@@ -509,14 +509,14 @@ void StringBrowser::Resize () {
     InitPerspective(perspective->curwidth == 0);
 
     if (lineheight != 0) {
-	display->Draw(output, canvas);
+	display->Draw(output_, canvas);
 	display->LineHeight(lineheight);
 	display->Resize(0, -lineheight, xmax, ymax);
     }
 }
 
 void StringBrowser::Redraw (IntCoord l, IntCoord b, IntCoord r, IntCoord t) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Redraw(l, b, r, t);
 }
 
@@ -531,7 +531,7 @@ void StringBrowser::SelectAll () {
     for (int i = 0; i < strcount; ++i) {
         BufInsert(strbuf[i], i, selbuf, selbufsize, selcount);
     }
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Style(0, 0, strcount, -1, highlight);
 }
 
@@ -543,7 +543,7 @@ void StringBrowser::Unselect (int dot, i
 
 void StringBrowser::UnselectAll () {
     selcount = 0;
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Style(0, 0, strcount, 0, Plain);
 }
 
@@ -570,7 +570,7 @@ void StringBrowser::ScrollTo (int x, int
     int topmargin = p->height - p->curheight - p->cury;
     int line = (lineheight == 0) ? 0 : topmargin / lineheight;
 
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Scroll(line, -p->curx, ymax);
 }
 
--- ivtools-1.2.11a1.orig/src/IV-2_6/strchooser.cc
+++ ivtools-1.2.11a1/src/IV-2_6/strchooser.cc
@@ -57,8 +57,8 @@ StringChooser::StringChooser(
 StringChooser::~StringChooser() { }
 
 void StringChooser::Init(StringEditor* se, StringBrowser* sb) {
-    input = new Sensor;
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(KeyEvent);
     _sedit = se;
     _browser = sb;
     _focus = _sedit;
--- ivtools-1.2.11a1.orig/src/IV-2_6/streditor.cc
+++ ivtools-1.2.11a1/src/IV-2_6/streditor.cc
@@ -78,9 +78,9 @@ void StringEditor::Init (ButtonState* s,
     done = strcpy(new char[strlen(d) + 1], d);
     display = new TextDisplay();
     display->CaretStyle(NoCaret);
-    input = new Sensor();
-    input->Catch(KeyEvent);
-    input->Catch(DownEvent);
+    input_ = new Sensor();
+    input_->Catch(KeyEvent);
+    input_->Catch(DownEvent);
     Message(sample);
 }
 
@@ -106,7 +106,7 @@ void StringEditor::Reconfig () {
 		hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
 	    ),
 	    new Bitmap(hand_mask_bits, hand_mask_width, hand_mask_height),
-	    output->GetFgColor(), output->GetBgColor()
+	    output_->GetFgColor(), output_->GetBgColor()
 	);
 
         leftCursor = new Cursor(
@@ -114,7 +114,7 @@ void StringEditor::Reconfig () {
 		lfast_bits, lfast_width, lfast_height, lfast_x_hot, lfast_y_hot
 	    ),
 	    new Bitmap(lfast_mask_bits, lfast_mask_width, lfast_mask_height),
-	    output->GetFgColor(), output->GetBgColor()
+	    output_->GetFgColor(), output_->GetBgColor()
         );
 
         rightCursor = new Cursor(
@@ -122,24 +122,24 @@ void StringEditor::Reconfig () {
 		rfast_bits, rfast_width, rfast_height, rfast_x_hot, rfast_y_hot
 	    ),
 	    new Bitmap(rfast_mask_bits, rfast_mask_width, rfast_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
     }
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->Rect(f->Width(sample), f->Height());
     shape->Rigid(hfil, hfil, 0, 0);
     display->LineHeight(f->Height());
 }
 
 void StringEditor::Resize () {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Resize(0, 0, xmax, ymax);
     Select(left, right);
 }
 
 void StringEditor::Redraw (IntCoord l, IntCoord b, IntCoord r, IntCoord t) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Redraw(l, b, r, t);
 }
 
@@ -148,7 +148,7 @@ void StringEditor::Message (const char*
     text->Insert(0, t, strlen(t));
     int bol = text->BeginningOfLine(0);
     int eol = text->EndOfLine(0);
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->ReplaceText(0, text->Text(bol, eol), eol - bol);
     Select(eol);
 }
@@ -158,7 +158,7 @@ void StringEditor::Select (int l) {
 }
 
 void StringEditor::Select (int l, int r) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     int origin = display->Left(0, 0);
     if (display->Left(0, r - 1) < 0) {
         origin += xmax/2 - display->Left(0, r - 1);
@@ -173,7 +173,7 @@ void StringEditor::Select (int l, int r)
 }
 
 void StringEditor::DoSelect (int l, int r) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     if (l > r) {
         int tmp = r;
         r = l;
@@ -283,7 +283,7 @@ boolean StringEditor::HandleChar (char c
 }
 
 void StringEditor::InsertText (const char* t, int len) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     if (left != right) {
         text->Delete(left, right-left);
         display->DeleteText(0, left, right-left);
@@ -301,7 +301,7 @@ void StringEditor::InsertText (const cha
 void StringEditor::Handle (Event& e) {
     boolean done = false;
     World* world = GetWorld();
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->CaretStyle(BarCaret);
     do {
         switch (e.eventType) {
--- ivtools-1.2.11a1.orig/src/IV-2_6/texteditor.cc
+++ ivtools-1.2.11a1/src/IV-2_6/texteditor.cc
@@ -134,7 +134,7 @@ void TextEditor::Reconfig () {
 		hand_bits, hand_width, hand_height, hand_x_hot, hand_y_hot
 	    ),
 	    new Bitmap(hand_mask_bits, hand_mask_width, hand_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
 
         upCursor = new Cursor(
@@ -142,7 +142,7 @@ void TextEditor::Reconfig () {
 		ufast_bits, ufast_width, ufast_height, ufast_x_hot, ufast_y_hot
 	    ),
 	    new Bitmap(ufast_mask_bits, ufast_mask_width, ufast_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
 
         dnCursor = new Cursor(
@@ -150,11 +150,11 @@ void TextEditor::Reconfig () {
 		dfast_bits, dfast_width, dfast_height, dfast_x_hot, dfast_y_hot
 	    ),
 	    new Bitmap(dfast_mask_bits, dfast_mask_width, dfast_mask_height),
-            output->GetFgColor(), output->GetBgColor()
+            output_->GetFgColor(), output_->GetBgColor()
         );
     }
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->hunits = f->Width("n");
     shape->vunits = f->Height();
     shape->Rect(shape->hunits*shapecolumns, shape->vunits*shaperows);
@@ -166,7 +166,7 @@ void TextEditor::Reconfig () {
 
 void TextEditor::Resize () {
     if (canvas != nil) {
-        display->Draw(output, canvas);
+        display->Draw(output_, canvas);
         display->Resize(0, 0, xmax, ymax);
         int topmargin = (
             perspective->height - perspective->curheight - perspective->cury
@@ -188,7 +188,7 @@ void TextEditor::Resize () {
 
 void TextEditor::Redraw (IntCoord l, IntCoord b, IntCoord r, IntCoord t) {
     if (canvas != nil) {
-        display->Draw(output, canvas);
+        display->Draw(output_, canvas);
         display->Redraw(l, b, r, t);
     }
 }
@@ -205,7 +205,7 @@ void TextEditor::Adjust (Perspective& np
 void TextEditor::Edit (TextBuffer* t, int index) {
     delete display;
     display = new TextDisplay();
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->LineHeight(lineheight);
     display->TabWidth(tabsize * shape->hunits);
     text = t;
@@ -229,7 +229,7 @@ void TextEditor::Edit (TextBuffer* t, in
     Select(index);
     ScrollToSelection(true);
     canvas = c;
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     display->Redraw(0, 0, xmax, ymax);
 }
 
@@ -237,7 +237,7 @@ void TextEditor::InsertText (const char*
     count = text->Insert(dot, s, count);
     int sline = text->LineNumber(dot);
     int fline = text->LineNumber(dot + count);
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     if (sline == fline) {
         int offset = text->LineOffset(dot);
         display->InsertText(sline, offset, text->Text(dot), count);
@@ -278,7 +278,7 @@ void TextEditor::DeleteText (int count)
     int sline = text->LineNumber(start);
     int fline = text->LineNumber(finish);
     text->Delete(start, count);
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     if (sline == fline) {
         int offset = text->LineOffset(start);
         display->DeleteText(sline, offset, count);
@@ -444,7 +444,7 @@ void TextEditor::BackwardPage (int count
 }
 
 void TextEditor::ScrollToSelection (boolean always) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     int line = text->LineNumber(dot);
     int offset = text->LineOffset(dot);
     IntCoord l = display->Left(line, offset);
@@ -509,7 +509,7 @@ void TextEditor::Select (int d, int m) {
     int oldr = Math::max(dot, mark);
     int newl = Math::min(d, m);
     int newr = Math::max(d, m);
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     if (oldl == oldr && newl != newr) {
         display->CaretStyle(NoCaret);
     }
@@ -568,7 +568,7 @@ void TextEditor::Select (int d, int m) {
 }
 
 int TextEditor::Locate (IntCoord x, IntCoord y) {
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     int line = display->LineNumber(y);
     int index = display->LineIndex(line, x);
     int l = text->LineIndex(line);
--- ivtools-1.2.11a1.orig/src/IV-2_6/tray.cc
+++ ivtools-1.2.11a1/src/IV-2_6/tray.cc
@@ -2010,7 +2010,7 @@ void Tray::DoRemove(Interactor* i) {
 void Tray::Resize() {
     register TrayElement* e;
 
-    canvas->SetBackground(output->GetBgColor());
+    canvas->SetBackground(output_->GetBgColor());
     if (bg != nil) {
 	Place(bg, 0, 0, xmax, ymax);
     }
--- ivtools-1.2.11a1.orig/src/IV-2_6/viewport.cc
+++ ivtools-1.2.11a1/src/IV-2_6/viewport.cc
@@ -80,7 +80,7 @@ void Viewport::Reconfig() {
     perspective->curheight = cheight;
     perspective->sx = s->hunits;
     perspective->sy = s->vunits;
-    background = new Painter(output);
+    background = new Painter(output_);
     background->Reference();
     background->SetPattern(new Pattern(Pattern::lightgray));
 }
@@ -128,7 +128,7 @@ static void AlignHelper(Alignment a, int
 }
 
 void Viewport::Resize() {
-    canvas->SetBackground(output->GetBgColor());
+    canvas->SetBackground(output_->GetBgColor());
     float px = XPos();
     float py = YPos();
     float zx = XMag();
--- ivtools-1.2.11a1.orig/src/IV-2_6/xinter.cc
+++ ivtools-1.2.11a1/src/IV-2_6/xinter.cc
@@ -64,7 +64,7 @@ boolean Interactor::ValidCanvas(Canvas*
 }
 
 void Interactor::request(Requisition& r) const {
-    if (output == nil) {
+    if (output_ == nil) {
 	Interactor* i = (Interactor*)this;
 	i->Config(World::current());
     }
@@ -234,7 +234,7 @@ void Interactor::pick(Canvas*, const All
     ) {
 	Event& e = *(Event*)ep;
 	e.GetInfo();
-	Sensor* s = cursensor == nil ? input : cursensor;
+	Sensor* s = cursensor == nil ? input_ : cursensor;
 	if ((s != nil && s->Caught(e)) || grabbing) {
 	    e.target = this;
 	    e.y = ymax - e.y;
@@ -275,7 +275,7 @@ boolean InteractorHandler::event(Event&
     default:
 	break;
     }
-    Sensor* s = i->cursensor == nil ? i->input : i->cursensor;
+    Sensor* s = i->cursensor == nil ? i->input_ : i->cursensor;
     if (s != nil && s->Caught(e)) {
 	i->Handle(e);
     }
@@ -362,7 +362,7 @@ void InteractorWindow::set_attributes()
     Mask m = ExposureMask;
     Sensor* input = i->cursensor;
     if (input == nil) {
-	input = i->input;
+	input = i->input_;
 	i->cursensor = input;
     }
     if (input != nil) {
--- ivtools-1.2.11a1.orig/src/IV-X11/xdrag.cc
+++ ivtools-1.2.11a1/src/IV-X11/xdrag.cc
@@ -21,6 +21,8 @@
  * SOFTWARE.
  */
 
+#include <cstdio>
+
 #include <InterViews/cursor.h>
 #include <InterViews/event.h>
 #include <InterViews/handler.h>
--- ivtools-1.2.11a1.orig/src/IV-X11/xwindow.cc
+++ ivtools-1.2.11a1/src/IV-X11/xwindow.cc
@@ -26,6 +26,9 @@
  * X11-dependent window and display implementation
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include "wtable.h"
 #include <InterViews/bitmap.h>
 #include <InterViews/canvas.h>
@@ -56,7 +59,9 @@
 #include <OS/string.h>
 #include <OS/table.h>
 #include <X11/Xatom.h>
+// #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
+// #endif
 #include <iostream.h>
 #include <fstream>
 
@@ -69,9 +74,11 @@ using std::cerr;
 #if !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__APPLE__)
 #if !defined(__linux__) && !defined(__CYGWIN__)
 /* no standard place for this */
+#ifndef HAVE_SYS_IOCTL_H
 extern "C" {
     extern int ioctl(int, int, ...);
 }
+#endif
 #else 
 #include <asm/socket.h>
 #endif
--- ivtools-1.2.11a1.orig/src/IVGlyph/exportchooser.cc
+++ ivtools-1.2.11a1/src/IVGlyph/exportchooser.cc
@@ -27,6 +27,8 @@
  * ExportChooser -- select a file/command to export graphics to
  */
 
+#include <cstdio>
+
 #include <IVGlyph/exportchooser.h>
 #include <IVGlyph/enumform.h>
 #include <IVGlyph/textform.h>
@@ -53,7 +55,6 @@
 #include <OS/string.h>
 
 #include <iostream.h>
-#include <stdio.h>
 #include <string.h>
 
 implementActionCallback(ExportChooserImpl)
--- ivtools-1.2.11a1.orig/src/IVGlyph/fieldedit.cc
+++ ivtools-1.2.11a1/src/IVGlyph/fieldedit.cc
@@ -21,6 +21,8 @@
  * 
  */
 
+#include <cstdio>
+
 #include <IVGlyph/fieldedit.h>
 #include <IVGlyph/figure.h>
 #include <IVGlyph/textbuff.h>
--- ivtools-1.2.11a1.orig/src/IVGlyph/figure.cc
+++ ivtools-1.2.11a1/src/IVGlyph/figure.cc
@@ -217,15 +217,8 @@ boolean Graphic31::manipulating (const E
                     float ldy = ly-cy; float ldx = lx-cx;
                     float dy = y-cy; float dx = x-cx;
 
-                    float cur = atan(ldy/ldx)/pi*180.0;
-                    float last = atan(dy/dx)/pi*180.0;
-
-                    if (ldx < 0.0) {
-                        cur += 180.0;
-                    }
-                    if (dx < 0.0) {
-                        last += 180.0;
-                    }
+		    float cur = degrees(atan2f(ldy, ldx));
+		    float last = degrees(atan2f(dy, dx));
                         
                     rotate(cur-last, cx, cy);
                     ts._last = e;
--- ivtools-1.2.11a1.orig/src/IVGlyph/globals.cc
+++ ivtools-1.2.11a1/src/IVGlyph/globals.cc
@@ -15,7 +15,7 @@ PointObj::PointObj (Coord x, Coord y) {
 PointObj::PointObj (PointObj* p) { _x = p->_x; _y = p->_y; }
 
 float PointObj::Distance (PointObj& p) {
-    return sqrt(float(square(_x - p._x) + square(_y - p._y)));
+    return hypotf(_x - p._x, _y - p._y);
 }
 
 /*****************************************************************************/
--- ivtools-1.2.11a1.orig/src/IVGlyph/globals.h
+++ ivtools-1.2.11a1/src/IVGlyph/globals.h
@@ -150,11 +150,8 @@ inline void exch (int& a, int& b) {
 inline int square(int a) { return a *= a; }
 inline Coord square(Coord a) { return a *= a; }
 
-inline Coord degrees(Coord rad) { return rad * 180.0 / M_PI; }
-inline Coord radians(Coord deg) { return deg * M_PI / 180.0; }
-
 inline Coord Distance(Coord x0, Coord y0, Coord x1, Coord y1) {
-    return sqrt(Coord(square(x0 - x1) + square(y0 - y1)));
+    return hypot(x0-x1,y0-y1);
 }
 
 inline void ArrayCopy (
--- ivtools-1.2.11a1.orig/src/IVGlyph/grabber.bm
+++ ivtools-1.2.11a1/src/IVGlyph/grabber.bm
@@ -2,7 +2,7 @@
 #define grabber_height 16
 #define grabber_x_hot 2
 #define grabber_y_hot 7
-static char grabber_bits[] = {
+static unsigned char grabber_bits[] = {
    0x00, 0x00, 0x80, 0x03, 0x60, 0x0e, 0x90, 0x14, 0x08, 0x29, 0x64, 0x52,
    0x98, 0xe4, 0x04, 0x85, 0x8a, 0x80, 0x9a, 0x80, 0x62, 0x40, 0x04, 0x40,
    0x08, 0x20, 0x10, 0x20, 0x60, 0x10, 0x40, 0x10};
--- ivtools-1.2.11a1.orig/src/IVGlyph/grabberMask.bm
+++ ivtools-1.2.11a1/src/IVGlyph/grabberMask.bm
@@ -2,7 +2,7 @@
 #define grabberMask_height 16
 #define grabberMask_x_hot 2
 #define grabberMask_y_hot 7
-static char grabberMask_bits[] = {
+static unsigned char grabberMask_bits[] = {
    0x00, 0x00, 0x80, 0x03, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f,
    0x98, 0xff, 0x04, 0xff, 0x8e, 0xff, 0x9e, 0xff, 0xfe, 0x7f, 0xfc, 0x7f,
    0xf8, 0x3f, 0xf0, 0x3f, 0xe0, 0x1f, 0xc0, 0x1f};
--- ivtools-1.2.11a1.orig/src/IVGlyph/texteditor.cc
+++ ivtools-1.2.11a1/src/IVGlyph/texteditor.cc
@@ -78,7 +78,7 @@ void TE_Editor::Reconfig()
    WidgetKit& kit = *WidgetKit::instance();
    kit.push_style();
    kit.style(style_);
-   Painter* p = new Painter(output);
+   Painter* p = new Painter(output_);
 //   p->SetColors(kit.foreground(), kit.background());
    Display* d = Session::instance()->default_display();
    const Color* bg = Color::lookup(d, "#aaaaaa");
@@ -87,8 +87,8 @@ void TE_Editor::Reconfig()
    p->SetColors(kit.foreground(), bg);
    if (font_ != nil)
       p->SetFont(font_);
-   Resource::unref(output);
-   output = p;
+   Resource::unref(output_);
+   output_ = p;
    TextEditor::Reconfig();
    kit.pop_style();
 }
--- ivtools-1.2.11a1.orig/src/InterViews/bevel.cc
+++ ivtools-1.2.11a1/src/InterViews/bevel.cc
@@ -247,7 +247,7 @@ void Bevel::left_arrow(
 ) {
     Coord center_y = (bottom + top) * 0.5;
     float slope = ((top - bottom) / (right - left)) * 0.5;
-    float delta_x = thickness / sqrt(slope * slope + 1);
+    float delta_x = thickness / hypot(slope, 1);
     float delta_y = slope * delta_x;
 
     c->new_path();
@@ -288,7 +288,7 @@ void Bevel::right_arrow(
 ) {
     Coord center_y = (bottom + top) * 0.5;
     float slope = ((top - bottom) / (right - left)) * 0.5;
-    float delta_x = thickness / sqrt(slope * slope + 1);
+    float delta_x = thickness / hypot(slope, 1);
     float delta_y = slope * delta_x;
 
     c->new_path();
@@ -329,7 +329,7 @@ void Bevel::up_arrow(
 ) {
     Coord center_x = (left + right) * 0.5;
     float slope = 2 * ((top - bottom) / (right - left));
-    float delta_x = thickness / sqrt(slope * slope + 1);
+    float delta_x = thickness / hypot(slope, 1);
     float delta_y = slope * delta_x;
 
     c->new_path();
@@ -370,7 +370,7 @@ void Bevel::down_arrow(
 ) {
     Coord center_x = (left + right) * 0.5;
     float slope = 2* ((top - bottom) / (right - left));
-    float delta_x = thickness / sqrt(slope * slope + 1);
+    float delta_x = thickness / hypot(slope, 1);
     float delta_y = slope * delta_x;
 
     c->new_path();
--- ivtools-1.2.11a1.orig/src/InterViews/field.cc
+++ ivtools-1.2.11a1/src/InterViews/field.cc
@@ -106,8 +106,8 @@ FieldStringEditor::FieldStringEditor(
     kit_ = kit;
     style_ = style;
     Resource::ref(style);
-    delete input;
-    input = nil;
+    delete input_;
+    input_ = nil;
 }
 
 FieldStringEditor::~FieldStringEditor() {
@@ -115,8 +115,8 @@ FieldStringEditor::~FieldStringEditor()
 }
 
 void FieldStringEditor::print(Printer* p, const Allocation& a) const {
-    const Font* f = output->GetFont();
-    const Color* fg = output->GetFgColor();
+    const Font* f = output_->GetFont();
+    const Color* fg = output_->GetFgColor();
     FontBoundingBox b;
     f->font_bbox(b);
     Coord x = a.left(), y = a.bottom() + b.font_descent();
@@ -141,7 +141,7 @@ void FieldStringEditor::pick(
 
 void FieldStringEditor::press(const Event& event) {
     Event e;
-    display->Draw(output, canvas);
+    display->Draw(output_, canvas);
     switch (event.pointer_button()) {
     case Event::left:
 	do_select(e);
@@ -301,11 +301,11 @@ void FieldStringEditor::paste(SelectionM
 void FieldStringEditor::Reconfig() {
     kit_->push_style();
     kit_->style(style_);
-    Painter* p = new Painter(output);
+    Painter* p = new Painter(output_);
     p->SetColors(kit_->foreground(), kit_->background());
     p->SetFont(kit_->font());
-    Resource::unref(output);
-    output = p;
+    Resource::unref(output_);
+    output_ = p;
     StringEditor::Reconfig();
     kit_->pop_style();
 }
--- ivtools-1.2.11a1.orig/src/InterViews/hit.cc
+++ ivtools-1.2.11a1/src/InterViews/hit.cc
@@ -379,7 +379,7 @@ void HitImpl::add_item(
 
 /*
  * The way we specify targets is the opposite of how we store them:
- * "item(depth, 0)" is the most recently targetted item at that depth.
+ * "item(depth, 0)" is the most recently targeted item at that depth.
  * So, we use "used_ - 1 - t" as the appropriate target index.
  */
 
--- ivtools-1.2.11a1.orig/src/InterViews/printer.cc
+++ ivtools-1.2.11a1/src/InterViews/printer.cc
@@ -26,6 +26,7 @@
  * Printer - draw for PostScript printer
  */
 
+#include <cstdio>
 #include <InterViews/bitmap.h>
 #include <InterViews/brush.h>
 #include <InterViews/color.h>
@@ -373,7 +374,7 @@ void Printer::character(
         out << "\\" << char(c);
     } else if (c > 127) {
 #ifdef __GNUC__
-	out_form(out, "\\%03o", c);
+	out_form(out, "\\%03lo", c);
 #else
 	out << "\\";
         int old_width = out.width(3);
--- ivtools-1.2.11a1.orig/src/InterViews/regexp.cc
+++ ivtools-1.2.11a1/src/InterViews/regexp.cc
@@ -26,9 +26,12 @@
  * Regexp - regular expression searching
  */
 
+#include <cstdio>
 #include <InterViews/regexp.h>
 #include <stream.h>
 #include <string.h>
+#include <iostream>
+#include <fstream>
 using std::cerr;
 
 /*
--- ivtools-1.2.11a1.orig/src/InterViews/transformer.cc
+++ ivtools-1.2.11a1/src/InterViews/transformer.cc
@@ -30,8 +30,6 @@
 #include <OS/math.h>
 #include <math.h>
 
-static const double RADPERDEG = M_PI/180.0;
-
 Transformer::Transformer() {
     identity_ = true;
     mat00 = mat11 = 1;
@@ -141,7 +139,7 @@ void Transformer::skew(float sx, float s
 void Transformer::rotate(float angle) {
     float tmp1, tmp2, m00, m01, m10, m11, m20, m21;
 
-    angle *= RADPERDEG;
+    angle = radians(angle);
     tmp1 = cos(angle);
     tmp2 = sin(angle);
     
--- ivtools-1.2.11a1.orig/src/Makefile.am
+++ ivtools-1.2.11a1/src/Makefile.am
@@ -13,6 +13,7 @@ ComTerp/_comutil.h ComTerp/comvalue.h Co
 ComTerp/ctrlfunc.h ComTerp/debugfunc.h ComTerp/dotfunc.h		\
 ComTerp/helpfunc.h ComTerp/iofunc.h ComTerp/lexscan.h			\
 ComTerp/listfunc.h ComTerp/mathfunc.h ComTerp/numfunc.h			\
+ComTerp/parsefunc.h							\
 ComTerp/parser.h ComTerp/postfunc.h ComTerp/randfunc.h			\
 ComTerp/scanner.h ComTerp/statfunc.h ComTerp/strmfunc.h			\
 ComTerp/symbolfunc.h ComTerp/typefunc.h ComTerp/xformfunc.h		\
@@ -97,4 +98,4 @@ TopoFace/toponode.h UniIdraw/idarrow.h U
 UniIdraw/idarrows.h UniIdraw/idcatalog.h UniIdraw/idclasses.h		\
 UniIdraw/idcmds.h UniIdraw/idcomp.h UniIdraw/idcreator.h		\
 UniIdraw/iddialogs.h UniIdraw/ided.h UniIdraw/idkybd.h			\
-UniIdraw/idvars.h UniIdraw/idversion.h
+UniIdraw/idvars.h
--- ivtools-1.2.11a1.orig/src/OS/string.cc
+++ ivtools-1.2.11a1/src/OS/string.cc
@@ -22,6 +22,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <cstdio>
 #include <OS/string.h>
 #include <ctype.h>
 #include <string.h>
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/aceimport.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/aceimport.cc
@@ -23,6 +23,10 @@
 
 #ifdef HAVE_ACE
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include <OverlayUnidraw/aceimport.h>
 
 #include <OverlayUnidraw/oved.h>
@@ -80,28 +84,8 @@ UnidrawImportHandler::handle_timeout (co
 int
 UnidrawImportHandler::handle_input (ACE_HANDLE fd)
 {
-#if 0
-    if (!_inptr) {
-        _filebuf = new filebuf();
-	boolean valid = _filebuf->attach(fd) != 0;
-	_inptr = new istream(_filebuf);
-        _import_cmd->instream(_inptr);
-    }
-    int ch;
-    ch = _inptr->get();
-    if (ch != EOF && _inptr->good()) {
-      _inptr->putback(ch);
-      _import_cmd->Execute();
-    }
-    return _inptr->good() ? 0 : -1;
-#else
-#if __GNUC__<3
-    filebuf fbuf;
-    if(fbuf.attach(fd)==0) return -1;
-#else
     if (!_infptr) _infptr = fdopen(fd, "r");
-    fileptr_filebuf fbuf(_infptr, ios_base::in);
-#endif
+    FILEBUF(fbuf, _infptr, ios_base::in);
     istream in(&fbuf);
     int ch = in.get();
     if (ch != EOF && in.good()) {
@@ -110,7 +94,6 @@ UnidrawImportHandler::handle_input (ACE_
       _import_cmd->Execute();
     }
     return -1;  /* only return -1, which indicates input handling is fini */
-#endif
 }
 
 int
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/aceimport.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/aceimport.h
@@ -39,6 +39,11 @@ class OvImportCmd;
 #include <fstream.h>
 #include <iosfwd>
 
+// GNU HURD has no fixed limit
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 4096
+#endif
+
 //: handler for import by socket into OverlayUnidraw.
 class UnidrawImportHandler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
 {
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/algebra3.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/algebra3.h
@@ -59,13 +59,16 @@ enum {PA, PB, PC, PD};		    // planes
 enum {RED, GREEN, BLUE};	    // colors
 enum {KA, KD, KS, ES};		    // phong coefficients
 
-// Linux already defines these
-#if 0
 //
 //	PI
 //
+#ifndef M_PI
 const double M_PI = 3.14159265358979323846;		// per CRC handbook, 14th. ed.
+#endif
+#ifndef M_PI_2
 const double M_PI_2 = (M_PI/2.0);				// PI/2
+#endif
+#ifndef M2_PI
 const double M2_PI = (M_PI*2.0);				// PI*2
 #endif
 
@@ -1239,7 +1242,7 @@ inline mat3 translation2D(const vec2& v)
 		vec3(0.0, 0.0, 1.0)); }
 
 inline mat3 rotation2D(const vec2& Center, const double angleDeg) {
-    double  angleRad = angleDeg * M_PI / 180.0,
+    double  angleRad = radians(angleDeg),
 	    c = cos(angleRad),
 	    s = sin(angleRad);
 
@@ -1266,7 +1269,7 @@ inline mat4 translation3D(const vec3& v)
 		vec4(0.0, 0.0, 0.0, 1.0)); }
 
 inline mat4 rotation3D(vec3 Axis, const double angleDeg) {
-    double  angleRad = angleDeg * M_PI / 180.0,
+    double  angleRad = radians(angleDeg),
 	    c = cos(angleRad),
 	    s = sin(angleRad),
 	    t = 1.0 - c;
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/clippoly.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/clippoly.cc
@@ -31,6 +31,9 @@
 #include <stream.h>
 #include <OS/math.h>
 
+using std::cerr;
+using std::endl;
+
 void clippoly(ClipOperation op, 
 	      int n1, float* x1, float* y1, int n2, float* x2, float* y2,
 	      int& npolys, int*& ni, float**& x, float**& y
@@ -216,7 +219,7 @@ void clippoly(ClipOperation op,
 	}
 	break;
     default:
-	cerr << "Error: uknown clippoly operation" << endl;
+	std::cerr << "Error: unknown clippoly operation" << std::endl;
 	break;
     }
 
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/grayraster.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/grayraster.cc
@@ -40,6 +40,11 @@
 #include <OS/memory.h>
 #include <IV-X11/xdisplay.h>
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #undef max
 #undef min
 
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/leafwalker.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/leafwalker.h
@@ -26,7 +26,7 @@
  */
 
 #ifndef leafwalker_h
-#define leafwalke_h
+#define leafwalker_h
 
 #include <OverlayUnidraw/ovcomps.h>
 
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovcatalog.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovcatalog.cc
@@ -188,22 +188,6 @@ boolean OverlayCatalog::Retrieve (const
         _valid = true;
 
     } else {
-#if __GNUC__<3	  
-        filebuf fbuf;
-	if (strcmp(name, "-") == 0) {
-	    _valid = fbuf.attach(fileno(stdin)) != 0;
-	    name = nil;
-	} else {
-	    fptr = fopen(name, "r");
-	    fptr = OvImportCmd::CheckCompression(fptr, name, compressed);
-	    _valid = fptr ? fbuf.attach(fileno(fptr)) != 0 : false;
-	    if (compressed) {
-		int namelen = strlen(name);
-		if (strcmp(name+namelen-3,".gz")==0) name[namelen-3] = '\0';
-		else if (strcmp(name+namelen-2,".Z")==0) name[namelen-2] = '\0';
-	    }
-	}
-#else
 	boolean stdin_flag = strcmp(name, "-")==0;
 	if (!stdin_flag) {
 	  fptr = fopen(name, "r");
@@ -219,8 +203,7 @@ boolean OverlayCatalog::Retrieve (const
 	  name = nil;
 	}
 	if (!_valid && !ParamList::urltest(name)) return false;
-        fileptr_filebuf fbuf(stdin_flag ? stdin : fptr, ios_base::in);
-#endif
+        FILEBUF(fbuf, stdin_flag ? stdin : fptr, ios_base::in);
 	
         if (_valid || ParamList::urltest(name)) {
 	    istream in(&fbuf);
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovcomps.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovcomps.cc
@@ -71,10 +71,16 @@ extern "C"
 }
 #endif
 
+// No MAXPATHLEN on GNU Hurd, cobble something up.
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 4096
+#endif
+
 #ifdef LEAKCHECK
 LeakChecker* OverlayComp::_leakchecker = nil;
 #endif
 
+ComTerp* OverlayComp::_comterp = nil;
 
 /*****************************************************************************/
 
@@ -988,6 +994,7 @@ int OverlaysComp::GetIndexForComp (Overl
     Next(it);
   }
   if (Done(it)) return -1;
+  return 0;
 }
 
 int OverlaysComp::Count() {
@@ -1008,7 +1015,7 @@ void OverlaysComp::Append (GraphicComp*
     Graphic* g = comp->GetGraphic();
 
     _comps->Append(new UList(comp));
-    if (g != nil) GetGraphic()->Append(g);
+    if (g != nil && GetGraphic()) GetGraphic()->Append(g);
 
     SetParent(comp, this);
 }
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovcomps.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovcomps.h
@@ -31,6 +31,7 @@
 
 #include <leakchecker.h>
 
+#include <ComTerp/comterp.h>
 #include <UniIdraw/idcomp.h>
 #include <InterViews/observe.h>
 #include <Attribute/classid.h>
@@ -186,6 +187,15 @@ public:
     virtual void ClearVisit() { visited(false); }
     // clear visit mark 
 
+    virtual OverlayComp* GetUp() { return (OverlayComp*)GetParent(); }
+    // usually same as parent
+
+    static void comterp(ComTerp* terp) { _comterp = terp; }
+    // set static ComTerp pointer
+
+    static ComTerp* comterp() { return _comterp; }
+    // get static ComTerp pointer
+
 protected:
     ParamList* GetParamList();
     // return ParamList of required/optional/keyword arguments to be read
@@ -206,6 +216,7 @@ protected:
     OverlayComp* _parent;
     AttributeList* _attrlist;
     boolean _notify_deferred;
+    static ComTerp* _comterp;
 
 friend class OverlayScript;
 friend class OverlaysScript;
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovdialog.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovdialog.cc
@@ -49,9 +49,9 @@ PanDialog::PanDialog () : BasicDialog(
     _medit->Message("");
     _medit->Match("%f %f", false);
 
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
@@ -123,9 +123,9 @@ ZoomDialog::ZoomDialog () : BasicDialog(
     _medit->Message("");
     _medit->Match("%f", false);
 
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
@@ -197,9 +197,9 @@ PageDialog::PageDialog () : BasicDialog(
     _medit->Message("");
     _medit->Match("%f %f", false);
 
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovfile.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovfile.cc
@@ -223,13 +223,8 @@ int OverlayFileScript::ReadPathName (ist
       OvImportCmd impcmd((Editor*)nil);
       FILE* fptr = popen(pathname, "r");
       if (fptr) {
-#if __GNUC__<3
-	ifstream ifs;
-	ifs.rdbuf()->attach(fileno(fptr));
-#else
-	fileptr_filebuf fbuf(fptr, ios_base::in);
+	FILEBUF(fbuf, fptr, ios_base::in);
 	istream ifs(&fbuf);
-#endif
 	OverlayComp* child = (OverlayComp*) impcmd.Import(ifs);
 	if (child) {
 	  filecomp->Append(child);
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovimport.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovimport.cc
@@ -121,9 +121,7 @@ implementPtrList(FileList,FILE)
 implementPtrList(StreamList,istream)
 implementPtrList(HandlerList,ReadImageHandler)
 
-#if __GNUC__>=3
 static char newline;
-#endif
 
 
 /*****************************************************************************/
@@ -467,14 +465,9 @@ int ReadImageHandler::process(const char
 
     if (pos >= 0) { 
 
-#if __GNUC__<3
-      char* buffer;
-      in.gets(&buffer);
-#else
       char buffer[BUFSIZ];
       in.get(buffer, BUFSIZ);
       in.get(newline);
-#endif
 
       if (strncmp(buffer, "P6", 2)) {
         cerr << "only binary ppms (magic P6) supported at this time" << endl;
@@ -483,21 +476,13 @@ int ReadImageHandler::process(const char
 
       u_long width, height;
       do { 
-#if __GNUC__<3	
-        in.gets(&buffer);
-#else
 	in.get(buffer,BUFSIZ);
 	in.get(newline);
-#endif
       } while (buffer[0] == '#');
-      sscanf(buffer, "%d %d", &width, &height);
+      sscanf(buffer, "%ld %ld", &width, &height);
 
-#if __GNUC__<3	
-      in.gets(&buffer);
-#else
       in.get(buffer,BUFSIZ);
       in.get(newline);
-#endif
       int maxval;
       sscanf(buffer, "%d", &maxval);
       if (maxval != 255) {
@@ -604,18 +589,11 @@ int ReadImageHandler::inputReady(int fd)
 
     clr_fl(_fd, O_NONBLOCK);
 
-#if __GNUC__<3
-    ifstream* ifs = new ifstream;
-    ifs->rdbuf()->attach(_fd);
-#else
     FILE* ifptr = fdopen(_fd, "r");
-    fileptr_filebuf* fbuf = new fileptr_filebuf(ifptr, ios_base::in);
+    FILEBUFP(fbuf,ifptr, ios_base::in);
     istream* ifs = new istream(fbuf);
-#endif
     _helper.add_stream(ifs);
-#if __GNUC__>=3
     _helper.add_file(ifptr);
-#endif
     boolean empty;
 
     int newfd;
@@ -675,6 +653,7 @@ int ReadImageHandler::inputReady(int fd)
       return -1;              // don't ever call me again (i.e., detach me)
     } 
   }
+  return -1;
 }
 
 // -------------------------------------------------------------------------
@@ -1000,7 +979,7 @@ const char* OvImportCmd::ReadCreator (is
 	} else if (strcmp(line, "%%EndComments\n") == 0) {
 	  break;
 	}
-      } while (in.getline(line, linesz) != NULL);
+      } while (in.getline(line, linesz));
       chcnt = 0;
       if (!*creator) strcpy(creator, "PostScript");
     }
@@ -1098,13 +1077,8 @@ void OvImportCmd::Execute () {
       } else if (!is_url()) {
 	fptr = popen(path_, "r");
 	if (fptr) {
-#if __GNUC__<3
-	  ifstream* ifs = new ifstream;
-          ifs->rdbuf()->attach(fileno(fptr));
-#else
-	  fileptr_filebuf* fbuf = new fileptr_filebuf(fptr, ios_base::in);
+	  FILEBUFP(fbuf, fptr, ios_base::in);
 	  istream* ifs = new istream(fbuf);
-#endif
 	  inptr_ = ifs;
 	}
       }	
@@ -1407,13 +1381,8 @@ GraphicComp* OvImportCmd::Import (const
     
 
     if (fptr) {
-#if __GNUC__<3
-      ifstream* in = new ifstream;
-      in->rdbuf()->attach(fileno(fptr));
-#else
-      fileptr_filebuf* fbuf = new fileptr_filebuf(fptr, ios_base::in);
+      FILEBUFP(fbuf, fptr, ios_base::in);
       istream* in = new istream(fbuf);
-#endif
       helper_->add_stream(in);
 
       if ((chooser_ && (chooser_->auto_convert() || chooser_->from_command())))
@@ -1478,7 +1447,7 @@ GraphicComp* OvImportCmd::Import (istrea
     char buf[len];
 
     char ch;
-    while (isspace(ch = instrm.get())); instrm.putback(ch);
+    while (isspace(ch = instrm.get())) {}; instrm.putback(ch);
 
     OvImportCmd::FileType filetype;
     const char* creator = ReadCreator(instrm, filetype);
@@ -1496,28 +1465,18 @@ GraphicComp* OvImportCmd::Import (istrea
 	gunzip_fptr = popen(buffer, "r");
         helper.add_pipe(gunzip_fptr);
 	if (gunzip_fptr) {
-#if __GNUC__<3
-	  ifstream* ifs = new ifstream;
-          ifs->rdbuf()->attach(fileno(gunzip_fptr));
-#else
-	  fileptr_filebuf* fbuf = new fileptr_filebuf(gunzip_fptr, ios_base::in);
+	  FILEBUFP(fbuf, gunzip_fptr, ios_base::in);
 	  istream* ifs = new istream(fbuf);
-#endif
           helper.add_stream(ifs);
 	  in = gunzip_in = ifs;
 	}
       } else {
 	int newfd = Pipe_Filter(instrm, "gunzip -c");
 	if (newfd != -1) {
-#if __GNUC__<3
-	  ifstream* ifs = new ifstream;
-          ifs->rdbuf()->attach(newfd);
-#else
 	  FILE* ifptr = fdopen(newfd, "r");
-	  fileptr_filebuf* fbuf = new fileptr_filebuf(ifptr, ios_base::in);
+	  FILEBUFP(fbuf, ifptr, ios_base::in);
 	  istream* ifs = new istream(fbuf);
 	  helper.add_file(ifptr);
-#endif
 	  helper.add_stream(ifs);
 	  in = gunzip_in = ifs;
 	}
@@ -1547,24 +1506,19 @@ GraphicComp* OvImportCmd::Import (istrea
 	  if (pathname && !return_fd && !cmdflag) {
 	    char buffer[BUFSIZ];
 	    if (compressed) 
-	      sprintf(buffer, "tf=`ivtmpnam`;gunzip -c %s | pstoedit -f idraw - $tf.%s;cat $tf.*;rm $tf.*", pathname, "%d");
+	      sprintf(buffer, "tf=`tempname`;gunzip -c %s | pstoedit -f idraw - $tf.%s;cat $tf.*;rm $tf.*", pathname, "%d");
 	    else
-	      sprintf(buffer, "tf=`ivtmpnam`;pstoedit -f idraw %s $tf.%s;cat $tf.*;rm $tf.*", pathname, "%d");
+	      sprintf(buffer, "tf=`tempname`;pstoedit -f idraw %s $tf.%s;cat $tf.*;rm $tf.*", pathname, "%d");
 	    pptr = popen(buffer, "r");
 	    cerr << "input opened with " << buffer << "\n";
 	    if (pptr) 
 	      new_fd = fileno(pptr);
 	  } else 
-	    new_fd = Pipe_Filter(*in, "tf=`ivtmpnam`;pstoedit -f idraw - $tf.%d;cat $tf.*;rm $tf.*");
-#if __GNUC__<3
-	  ifstream new_in;
-          new_in.rdbuf()->attach(new_fd);
-#else
+	    new_fd = Pipe_Filter(*in, "tf=`tempname`;pstoedit -f idraw - $tf.%d;cat $tf.*;rm $tf.*");
 	  FILE* ifptr = fdopen(new_fd, "r");
 	  helper.add_file(ifptr);
-	  fileptr_filebuf fbuf(ifptr, ios_base::in);
+	  FILEBUF(fbuf, ifptr, ios_base::in);
 	  istream new_in(&fbuf);
-#endif
 	  comp = catalog->ReadPostScript(new_in);
 	  if (pptr) pclose(pptr);
 	} else
@@ -1594,13 +1548,8 @@ GraphicComp* OvImportCmd::Import (istrea
 	  FILE* pptr = popen(buffer, "r");
 	  if (pptr) {
 	    cerr << "input opened with " << buffer << "\n";
-#if __GNUC__<3
-	    ifstream new_in;
-            new_in.rdbuf()->attach(fileno(pptr));
-#else
-	    fileptr_filebuf fbuf(pptr, ios_base::in);
+	    FILEBUF(fbuf, pptr, ios_base::in);
 	    istream new_in(&fbuf);
-#endif
 	    comp = PNM_Image(new_in);
 	    pclose(pptr);
 	  }
@@ -1613,18 +1562,10 @@ GraphicComp* OvImportCmd::Import (istrea
       if (pathname && !return_fd && strcmp(pathname,"-")!=0 && !compressed) 
 	comp = TIFF_Image(pathname);
       else {
-	/* ivtiftopnm (part of ivtools) is a stdin/stdout wrapper to tifftopnm */
-	/* tiftopnm is the older name for ivtiftopnm */
-	if (OverlayKit::bincheck("tifftopnm")) { 
-	  if (OverlayKit::bincheck("ivtiftopnm"))
-	    comp = PNM_Image_Filter(*in, return_fd, pnmfd, "ivtiftopnm");
-	  else if (OverlayKit::bincheck("tiftopnm"))
-	    comp = PNM_Image_Filter(*in, return_fd, pnmfd, "tiftopnm");
-	  else
-	    cerr << "ivtiftopnm or tiftopnm not found (part of ivtools)\n";
-	} else {
-	    cerr << "tifftopnm not found (part of netpbm)\n";
-	}
+	if (OverlayKit::bincheck("convert"))
+	  comp = PNM_Image_Filter(*in, return_fd, pnmfd, "convert tiff:- pnm:-");
+	else
+	  cerr << "convert(1), part of ImageMagick(1), not found\n";
       }
 
     } else if (strncmp(creator, "X11", 3)==0) {
@@ -1646,9 +1587,9 @@ GraphicComp* OvImportCmd::Import (istrea
 	  char buffer[BUFSIZ];
 	  if (dithermap_flag) {
 	    if (compressed) 
-	      sprintf(buffer, "cm=`ivtmpnam`;stdcmapppm>$cm;gunzip -c %s | djpeg -map $cm -dither fs -pnm;rm $cm", pathname);
+	      sprintf(buffer, "cm=`tempname`;stdcmapppm>$cm;gunzip -c %s | djpeg -map $cm -dither fs -pnm;rm $cm", pathname);
 	    else
-	      sprintf(buffer, "cm=`ivtmpnam`;stdcmapppm>$cm;djpeg -map $cm -dither fs -pnm %s;rm $cm", pathname);
+	      sprintf(buffer, "cm=`tempname`;stdcmapppm>$cm;djpeg -map $cm -dither fs -pnm %s;rm $cm", pathname);
 	  } else {
 	    if (compressed) 
 	      sprintf(buffer, "gunzip -c %s | djpeg  -pnm", pathname);
@@ -1659,19 +1600,14 @@ GraphicComp* OvImportCmd::Import (istrea
           helper.add_pipe(pptr);
 	  if (pptr) {
 	    cerr << "input opened with " << buffer << "\n";
-#if __GNUC__<3
-	    ifstream* new_in = new ifstream;
-            new_in->rdbuf()->attach(fileno(pptr));
-#else
-	    fileptr_filebuf* fbuf = new fileptr_filebuf(pptr, ios_base::in);
+	    FILEBUFP(fbuf, pptr, ios_base::in);
 	    istream* new_in = new istream(fbuf);
-#endif
             helper.add_stream(new_in);
 	    comp = PNM_Image(*new_in);
 	  }
 	} else {
 	  if (dithermap_flag) 
-	    comp = PNM_Image_Filter(*in, return_fd, pnmfd, "cm=`ivtmpnam`;stdcmapppm>$cm;djpeg -map $cm -dither fs -pnm;rm $cm");
+	    comp = PNM_Image_Filter(*in, return_fd, pnmfd, "cm=`tempname`;stdcmapppm>$cm;djpeg -map $cm -dither fs -pnm;rm $cm");
 	  else 
 	    comp = PNM_Image_Filter(*in, return_fd, pnmfd, "djpeg -pnm");
 	}
@@ -1689,20 +1625,15 @@ GraphicComp* OvImportCmd::Import (istrea
 	  FILE* pptr = popen(buffer, "r");
 	  if (pptr) {
 	    cerr << "input opened with " << buffer << "\n";
-#if __GNUC__<3
-	    ifstream new_in;
-            new_in.rdbuf()->attach(fileno(pptr));
-#else
-	    fileptr_filebuf fbuf(pptr, ios_base::in);
+	    FILEBUF(fbuf, pptr, ios_base::in);
 	    istream new_in(&fbuf);
-#endif
 	    comp = PNM_Image(new_in);
 	    pclose(pptr);
 	  }
 	} else	
 	  comp = PNM_Image_Filter(*in, return_fd, pnmfd, "pngtopnm");
       } else 
-	cerr << "pnmtopgm not found (part of ivtools)\n";
+	cerr << "pngtopnm not found\n";
     }
 
 
@@ -1952,39 +1883,22 @@ GraphicComp* OvImportCmd::PGM_Image (ist
 
 OverlayRaster* OvImportCmd::PGM_Raster (istream& in, boolean ascii) {
  
-#if __GNUC__<3 
-    char* buffer;
-    in.gets(&buffer);
-#else
     char buffer[BUFSIZ];
     in.get(buffer, BUFSIZ);
     in.get(newline);
-#endif
 
     do {  // CREATOR and other comments
-#if __GNUC__<3 
-        in.gets(&buffer);
-#else
 	in.get(buffer, BUFSIZ);
 	in.get(newline);
-#endif
     } while (buffer[0] == '#');
 
     int nrows, ncols;
     if (sscanf(buffer, "%d %d", &ncols, &nrows)==1) {
-#if __GNUC__<3 
-          in.gets(&buffer);
-#else
 	  in.get(buffer, BUFSIZ);
 	  in.get(newline);
-#endif
           sscanf(buffer, "%d", &nrows);
     }
-#if __GNUC__<3 
-    in.gets(&buffer);
-#else
     in.get(buffer, BUFSIZ, '\n');
-#endif
     int maxval;
     sscanf(buffer, "%d", &maxval);
 
@@ -2390,31 +2304,18 @@ GraphicComp* OvImportCmd::PPM_Image (ist
 
 
 OverlayRaster* OvImportCmd::PPM_Raster (istream& in, boolean ascii) {
-#if __GNUC__<3
-    char* buffer;
-    in.gets(&buffer); // read magic number
-#else
     char buffer[BUFSIZ];
     in.get(buffer,BUFSIZ);
     in.get(newline);
-#endif
 
     do { // CREATOR and other comments
-#if __GNUC__<3
-        in.gets(&buffer);
-#else
 	in.get(buffer,BUFSIZ);
 	in.get(newline);
-#endif
     } while (buffer[0] == '#');
     int nrows, ncols;
     sscanf(buffer, "%d %d", &ncols, &nrows);
-#if __GNUC__<3
-    in.gets(&buffer);
-#else
     in.get(buffer,BUFSIZ);
     in.get(newline);
-#endif
     int maxval;
     sscanf(buffer, "%d", &maxval);
     if (maxval != 255) {
@@ -2459,22 +2360,15 @@ GraphicComp* OvImportCmd::PNM_Image_Filt
     fd = outfd;
   }
   else {
-#if __GNUC__<3    
-    ifstream in2;
-    in2.rdbuf()->attach(outfd);
-#else
     FILE* infptr = fdopen(outfd, "r");
-    fileptr_filebuf fbuf(infptr, ios_base::in);
+    FILEBUF(fbuf, infptr, ios_base::in);
     istream in2(&fbuf);
-#endif
 
     comp = PNM_Image(in2);
 
     if(close(outfd)==-1)
       cerr << "error in parent closing last end of the pipes\n";
-#if __GNUC__>=3
     if (infptr) fclose(infptr);
-#endif
   }
 
   return comp;
@@ -2536,24 +2430,12 @@ int OvImportCmd::Pipe_Filter (istream& i
     } else
       if(close(pipe1[0])==-1) 
 	cerr << "error in child close of front end of pipe\n";
-#if __GNUC__<3
-    ofstream out;
-    out.rdbuf()->attach(pipe1[1]);
-    char buffer[BUFSIZ];
-    while (!in.eof() && in.good()) {
-      in.read(buffer, BUFSIZ);
-      if (!in.eof() || in.gcount())
-	out.write(buffer, in.gcount());
-    }
-    out.flush();
-#else
     char buffer[BUFSIZ];
     while (!in.eof() && in.good()) {
       in.read(buffer, BUFSIZ);
       if (!in.eof() || in.gcount())
 	write(pipe1[1], buffer, in.gcount());
     }
-#endif
     if(close(pipe1[1])==-1)
       cerr << "error in child closing its output pipe\n";
     int status;
@@ -2574,6 +2456,7 @@ int OvImportCmd::Pipe_Filter (istream& i
     else 
       return pipe1[0]; 
   }
+  return -1;
 }
 
 GraphicComp*  OvImportCmd::PNM_Image (istream& in, const char* creator) {
@@ -2717,34 +2600,21 @@ GraphicComp* OvImportCmd::PBM_Image (ist
 Bitmap* OvImportCmd::PBM_Bitmap (istream& in) {
     Bitmap* bitmap = nil;
   
-#if __GNUC__<3
-    char* buffer;
-    in.gets(&buffer);
-#else
     char buffer[BUFSIZ];
     in.get(buffer,BUFSIZ);
     in.get(newline);
-#endif
 
     boolean asciiflag = strncmp("P1", buffer, 2) == 0;
   
     do { // CREATOR and other comments
-#if __GNUC__<3
-        in.gets(&buffer);
-#else
 	in.get(buffer,BUFSIZ);
 	in.get(newline);
-#endif
     } while (buffer[0] == '#');
 
     int nrows, ncols;
     if (sscanf(buffer, "%d %d", &ncols, &nrows)==1) {
-#if __GNUC__<3
-          in.gets(&buffer);
-#else
 	  in.get(buffer,BUFSIZ);
 	  in.get(newline);
-#endif
           sscanf(buffer, "%d", &nrows);
     }
     void* nilpointer = nil;
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovkit.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovkit.cc
@@ -509,7 +509,7 @@ Glyph* OverlayKit::MakeToolbar() {
     const LayoutKit& layout = *LayoutKit::instance();
     Style* s = kit.style();
 
-    /* tools shared between pallettes */
+    /* tools shared between palettes */
     ToolButton* select;
     ToolButton* move;
     ToolButton* scale;
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovkit.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovkit.h
@@ -128,7 +128,7 @@ public:
     virtual Glyph* MakeStates();
     // make state views in the chrome.
     virtual Glyph* MakeToolbar();
-    // make tool pallette.
+    // make tool palette.
 
     static OverlayKit* Instance();
     // default instance of OverlayKit.
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovpanner.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovpanner.cc
@@ -172,14 +172,14 @@ void OverlaySlider::Init (Interactor* i)
     *shown = *view;
     shape->vstretch = shape->vshrink = 0;
     prevl = prevb = prevr = prevt = 0;
-    input = new Sensor(updownEvents);
+    input_ = new Sensor(updownEvents);
 }
 
 void OverlaySlider::Reconfig () {
-    Painter* p = new Painter(output);
+    Painter* p = new Painter(output_);
     p->Reference();
-    Unref(output);
-    output = p;
+    Unref(output_);
+    output_ = p;
 
     const char* attrib = GetAttribute("syncScroll");
     syncScroll = attrib != nil &&
@@ -205,20 +205,20 @@ void OverlaySlider::Reshape (Shape& ns)
 
 void OverlaySlider::Draw () {
     if (canvas != nil) {
-	output->SetPattern(new Pattern(Pattern::lightgray));
-	output->FillRect(canvas, 0, 0, xmax, ymax);
-	output->SetPattern(new Pattern(Pattern::clear));
-	output->FillRect(canvas, left, bottom, right, top);
-	output->SetPattern(new Pattern(Pattern::solid));
-	output->Rect(canvas, left, bottom, right, top);
+	output_->SetPattern(new Pattern(Pattern::lightgray));
+	output_->FillRect(canvas, 0, 0, xmax, ymax);
+	output_->SetPattern(new Pattern(Pattern::clear));
+	output_->FillRect(canvas, left, bottom, right, top);
+	output_->SetPattern(new Pattern(Pattern::solid));
+	output_->Rect(canvas, left, bottom, right, top);
 #ifdef Line
 #undef Line
-	output->Line(canvas, left+1, bottom-1, right+1, bottom-1);
-	output->Line(canvas, right+1, bottom-1, right+1, top-1);
+	output_->Line(canvas, left+1, bottom-1, right+1, bottom-1);
+	output_->Line(canvas, right+1, bottom-1, right+1, top-1);
 #define Line _lib_iv(Line)
 #else
-	output->Line(canvas, left+1, bottom-1, right+1, bottom-1);
-	output->Line(canvas, right+1, bottom-1, right+1, top-1);
+	output_->Line(canvas, left+1, bottom-1, right+1, bottom-1);
+	output_->Line(canvas, right+1, bottom-1, right+1, top-1);
 #endif
 
 	prevl = left; prevb = bottom;
@@ -229,9 +229,9 @@ void OverlaySlider::Draw () {
 void OverlaySlider::Redraw (
     IntCoord left, IntCoord bottom, IntCoord right, IntCoord top
 ) {
-    output->Clip(canvas, left, bottom, right, top);
+    output_->Clip(canvas, left, bottom, right, top);
     Draw();
-    output->NoClip();
+    output_->NoClip();
 }
 
 inline IntCoord OverlaySlider::ViewX (IntCoord x) {
@@ -310,7 +310,7 @@ void OverlaySlider::Slide (Event& e) {
     boolean control = e.control;
 
     Listen(allEvents);
-    SlidingRect r(output, canvas, left, bottom, right, top, e.x, e.y);
+    SlidingRect r(output_, canvas, left, bottom, right, top, e.x, e.y);
     CalcLimits(e);
     do {
 	switch (e.eventType) {
@@ -335,7 +335,7 @@ void OverlaySlider::Slide (Event& e) {
 
     r.GetCurrent(newleft, newbot, dummy, dummy);
     Move(ViewX(newleft - left), ViewY(newbot - bottom));
-    Listen(input);
+    Listen(input_);
 }
 
 void OverlaySlider::Jump (Event& e) {
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovraster.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovraster.cc
@@ -83,6 +83,9 @@ implementList(CopyStringList,CopyString)
 boolean RasterOvComp::_use_gray_raster = false;
 boolean RasterOvComp::_warned = false;
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
 
 /*****************************************************************************/
 
@@ -1845,7 +1848,7 @@ static float dist(
 ) {
     float xd = x2 - x1;
     float yd = y2 - y1;
-    return sqrt((xd*xd) + (yd*yd));
+    return hypot(xd, yd);;
 }
 
 
@@ -2030,9 +2033,8 @@ boolean OverlayRaster::write (ostream& o
     ColorIntensity r, g, b;
     int ir, ig, ib;
     float alpha;	
-    for (y; y < h; y++) {
-      x = 0;
-      for (x; x < w; x++) {
+    for (; y < h; y++) {
+      for (x=0; x < w; x++) {
 	peek(x, y, r, g, b, alpha);
 	int ir = (int)(r*255);
 	int ig = (int)(g*255);	
@@ -2049,9 +2051,9 @@ boolean OverlayRaster::write (ostream& o
     int x = 0;	
     int y = 0;
     unsigned int byte;
-    for (y; y < h; y++) {
+    for (; y < h; y++) {
       x = 0;
-      for (x; x < w; x++) {
+      for (; x < w; x++) {
 	graypeek(x, y, byte);
 	out << byte;
 	if (!(y == h-1 && x == w-1))
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/ovviewer.cc
+++ ivtools-1.2.11a1/src/OverlayUnidraw/ovviewer.cc
@@ -365,7 +365,7 @@ void OverlayViewer::Manipulate (Manipula
     GetCanvas()->window()->ungrab_pointer();
 
     m->Effect(e);
-    Listen(input);
+    Listen(input_);
 }
 
 void OverlayViewer::ScreenToDrawing(float xscreen, float yscreen, 
--- ivtools-1.2.11a1.orig/src/OverlayUnidraw/setattrbyexpr.h
+++ ivtools-1.2.11a1/src/OverlayUnidraw/setattrbyexpr.h
@@ -37,7 +37,7 @@ class AttrDialog;
 //: command to set attributes on a component by evaluating an expression.
 // This command checks for a non-empty selection in the current editor,
 // then pops up a dialog box for entering attribute expressions to evaluate.
-// symbols on the right hand side of an assigment operator are used to
+// symbols on the right hand side of an assignment operator are used to
 // look up and return values from the property list (AttributeList) of
 // a component.  symbols on the left-hand side of an assignment operator are
 // used to create or modify an entry in the same component property list.
--- ivtools-1.2.11a1.orig/src/TIFF/tif_dir.c
+++ ivtools-1.2.11a1/src/TIFF/tif_dir.c
@@ -239,7 +239,7 @@ TIFFSetField1(tif, tag, ap)
 			td->td_orientation = v;
 		break;
 	case TIFFTAG_SAMPLESPERPIXEL:
-		/* XXX should cross check -- e.g. if pallette, then 1 */
+		/* XXX should cross check -- e.g. if palette, then 1 */
 		v = va_arg(ap, int);
 		if (v == 0)
 			goto badvalue;
--- ivtools-1.2.11a1.orig/src/Time/Date.cc
+++ ivtools-1.2.11a1/src/Time/Date.cc
@@ -60,6 +60,8 @@ Log: Date.c,v
   Modified by Vectaport, Inc.
 */
 
+#include <cstdio>
+
 #include <Time/Date.h>
 #include <Time/Time_.h>
 #include <OS/string.h>
@@ -68,7 +70,10 @@ Log: Date.c,v
 using namespace std;
 #include <ctype.h>
 #include <string.h>
-#include <stdio.h>
+#include <iostream>
+
+using std::setfill;
+using std::setw;
 
 #define	THIS	Date
 #define	BASE	Object
--- ivtools-1.2.11a1.orig/src/Time/Date.h
+++ ivtools-1.2.11a1/src/Time/Date.h
@@ -15,7 +15,7 @@ Author:
 	Computer Systems Laboratory, DCRT
 	National Institutes of Health
 	Bethesda, MD 20892
-
+*/
 /* Log:	Date.h,v 
  * Revision 3.11  92/07/26  14:32:05  sandy
  * include directive in form '#include <nihcl/foo.h>'
--- ivtools-1.2.11a1.orig/src/Time/Time.cc
+++ ivtools-1.2.11a1/src/Time/Time.cc
@@ -23,19 +23,20 @@ Function:
 	
 Provides an object that represents a Time, stored as the number of
 seconds since January 1, 1901, GMT.
-
+*/
 /*
   Modified by Vectaport Inc.  - added operator << plus other small stuff.
 */
 
+#include <cstdio>
+
 #include <Time/Date.h>
 #include <Time/Time_.h>
 #include <iomanip>
 using namespace std;
 
-#include <stdio.h>
-
-const unsigned VERSION =2;
+using std::setfill;
+using std::setw;
 
 #define	THIS	Time
 #define	BASE	Object
--- ivtools-1.2.11a1.orig/src/Time/Time_.h
+++ ivtools-1.2.11a1/src/Time/Time_.h
@@ -12,7 +12,7 @@ Author:
 	Computer Systems Laboratory, DCRT
 	National Institutes of Health
 	Bethesda, MD 20892
-
+*/
 /* Log:	Time.h,v 
  * Revision 3.11  92/07/26  14:33:59  sandy
  * include directive in form '#include <nihcl/foo.h>'
@@ -32,42 +32,33 @@ Author:
 #define	TIME_H
 
 
-#if defined(SYSV) && ! defined(hpux)
-
-#include <time.h>
-
-#define TIME_ZONE timezone
-#define DST_OBSERVED daylight
-#define BASE_CLASSES BASE::desc()
-#define MEMBER_CLASSES
-#define VIRTUAL_BASE_CLASSES Object::desc()
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
-//moved from Time.c
-
-#if defined(BSD) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
-
+#ifdef HAVE_TIME_H
 #if defined(__APPLE__)
+#include <time.h>
+#else
 #include_next <time.h>
 #endif
+#endif
 
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-  #if defined(__NetBSD__)
-    #include </usr/include/sys/time.h>
-  #endif
- 
 #endif
 
+#if defined(SYSV) && ! defined(hpux)
 
-#if defined(hpux)
-  #include <time.h>
-#endif
+#define TIME_ZONE timezone
+#define DST_OBSERVED daylight
+#define BASE_CLASSES BASE::desc()
+#define MEMBER_CLASSES
+#define VIRTUAL_BASE_CLASSES Object::desc()
 
+#endif
 
 #if defined(linux) || defined(__sun) || defined(__alpha) || defined(__CYGWIN__)
-#include <sys/time.h>
-
   #if defined(__DECCXX) || (defined(__sun) && !defined(__svr4__))
     extern "C" {
     int gettimeofday(struct timeval *tp, struct timezone *tzp);
@@ -85,7 +76,6 @@ Author:
 #include <OS/types.h>
 #if !defined(__APPLE_)
 #include <iostream.h>
-#include_next <time.h>
 #else
 #include <iosfwd>
 #include <iostream>
--- ivtools-1.2.11a1.orig/src/Time/obstime.cc
+++ ivtools-1.2.11a1/src/Time/obstime.cc
@@ -21,6 +21,7 @@
  * 
  */
 
+#include <cstdio>
 #include <Time/obstime.h>
 
 ObservableTime::ObservableTime(Time* th) {
--- ivtools-1.2.11a1.orig/src/Time/timeglyph.cc
+++ ivtools-1.2.11a1/src/Time/timeglyph.cc
@@ -21,6 +21,8 @@
  * 
  */
 
+#include <cstdio>
+
 #include <InterViews/enter-scope.h>
 #include <Time/Time_.h>
 #include <Time/Date.h>
@@ -35,7 +37,6 @@
 #include <InterViews/layout.h>
 #include <InterViews/style.h>
 #include <OS/string.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
--- ivtools-1.2.11a1.orig/src/TopoFace/fgeomobjs.cc
+++ ivtools-1.2.11a1/src/TopoFace/fgeomobjs.cc
@@ -25,6 +25,7 @@
  * Implementation of geometrical objects with floating point coordinates.
  */
 
+#include <cstdio>
 #include <TopoFace/fgeomobjs.h>
 #include <Unidraw/Graphic/util.h>
 #include <Unidraw/ulist.h>
@@ -49,7 +50,7 @@ FPointObj::FPointObj (float x, float y)
 FPointObj::FPointObj (FPointObj* p) { _x = p->_x; _y = p->_y; }
 
 float FPointObj::Distance (FPointObj& p) {
-    return sqrt(float(square(_x - p._x) + square(_y - p._y)));
+    return hypot(_x - p._x, _y - p._y);
 }
 
 /*****************************************************************************/
--- ivtools-1.2.11a1.orig/src/UniIdraw/idarrowhead.cc
+++ ivtools-1.2.11a1/src/UniIdraw/idarrowhead.cc
@@ -97,7 +97,7 @@ float Arrowhead::UnscaledLength (float l
     inverse.Transform(x0, y0, tx0, ty0);
     inverse.Transform(x1, y1, tx1, ty1);
 
-    return hypot(tx0-tx1, ty0-ty1);
+    return hypot(tx0 - tx1, ty0 - ty1);
 }
 
 void Arrowhead::draw (Canvas* c, Graphic* gs) {
--- ivtools-1.2.11a1.orig/src/UniIdraw/idarrows.cc
+++ ivtools-1.2.11a1/src/UniIdraw/idarrows.cc
@@ -225,7 +225,7 @@ void ArrowLine::SetArrows (boolean h, bo
     _head = h ? new Arrowhead(_x0, _y0, width, height) : nil;
     _tail = t ? new Arrowhead(_x1, _y1, width, height) : nil;
 
-    float angle = atan2(_y0-_y1, _x0-_x1)*180/M_PI;
+    float angle = degrees(atan2f(_y0-_y1, _x0-_x1));
 
     if (h) _head->Rotate(angle-90, _x0, _y0);
     if (t) _tail->Rotate(angle+90, _x1, _y1);
@@ -429,8 +429,8 @@ void ArrowMultiLine::SetArrows (boolean
     _head = h ? new Arrowhead(x()[0], y()[0], width, height) : nil;
     _tail = t ? new Arrowhead(x()[l], y()[l], width, height) : nil;
 
-    float head_angle = atan2(y()[0]-y()[1], x()[0]-x()[1])*180/M_PI;
-    float tail_angle = atan2(y()[k]-y()[l], x()[k]-x()[l])*180/M_PI;
+    float head_angle = degrees(atan2f(y()[0]-y()[1], x()[0]-x()[1]));
+    float tail_angle = degrees(atan2f(y()[k]-y()[l], x()[k]-x()[l]));
 
     if (h) _head->Rotate(head_angle-90, x()[0], y()[0]);
     if (t) _tail->Rotate(tail_angle+90, x()[l], y()[l]);
@@ -623,8 +623,8 @@ void ArrowOpenBSpline::SetArrows (boolea
     _head = h ? new Arrowhead(x()[0], y()[0], width, height) : nil;
     _tail = t ? new Arrowhead(x()[l], y()[l], width, height) : nil;
 
-    float head_angle = atan2(y()[0]-y()[3], x()[0]-x()[3])*180/M_PI;
-    float tail_angle = atan2(y()[k]-y()[l], x()[k]-x()[l])*180/M_PI;
+    float head_angle = degrees(atan2f(y()[0]-y()[3], x()[0]-x()[3]));
+    float tail_angle = degrees(atan2f(y()[k]-y()[l], x()[k]-x()[l]));
 
     if (h) _head->Rotate(head_angle-90, x()[0], y()[0]);
     if (t) _tail->Rotate(tail_angle+90, x()[l], y()[l]);
--- ivtools-1.2.11a1.orig/src/UniIdraw/idcmds.cc
+++ ivtools-1.2.11a1/src/UniIdraw/idcmds.cc
@@ -24,13 +24,16 @@
  * Implementation of idraw-specific commands.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "ided.h"
 #include "idclasses.h"
 #include "idcmds.h"
 #include "idcomp.h"
 #include "iddialogs.h"
 #include "idvars.h"
-#include "idversion.h"
 
 #include <Unidraw/dialogs.h>
 #include <Unidraw/catalog.h>
@@ -285,7 +288,7 @@ Command* AboutCmd::Copy () {
 
 void AboutCmd::Execute () {
     Editor* ed = GetEditor();
-    AcknowledgeDialog dialog(VERSION);
+    AcknowledgeDialog dialog(PACKAGE_NAME " (" PACKAGE_TARNAME ") " PACKAGE_VERSION);
 
     ed->InsertDialog(&dialog);
     dialog.Acknowledge();
--- ivtools-1.2.11a1.orig/src/UniIdraw/iddialogs.cc
+++ ivtools-1.2.11a1/src/UniIdraw/iddialogs.cc
@@ -54,9 +54,9 @@ MoveDialog::MoveDialog () : BasicDialog(
     _medit->Match("%f %f", false);
 
     _units = new ButtonState('p');
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
@@ -151,9 +151,9 @@ ScaleDialog::ScaleDialog () : BasicDialo
     _medit->Message("");
     _medit->Match("%f %f", false);
 
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
@@ -225,9 +225,9 @@ RotateDialog::RotateDialog () : BasicDia
     _medit->Message("");
     _medit->Match("%f", false);
 
-    input = new Sensor;
-    Ref(input);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    Ref(input_);
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
--- ivtools-1.2.11a1.orig/src/UniIdraw/idvars.cc
+++ ivtools-1.2.11a1/src/UniIdraw/idvars.cc
@@ -174,10 +174,10 @@ PSColor* ArrowInteractor::GetFgColor ()
 PSColor* ArrowInteractor::GetBgColor () { return _bg; }
 
 void ArrowInteractor::Reconfig () { 
-    Painter* p = new Painter(output);
+    Painter* p = new Painter(output_);
     Ref(p);
-    Unref(output);
-    output = p;
+    Unref(output_);
+    output_ = p;
 }
 
 void ArrowInteractor::Redraw (Coord, Coord, Coord, Coord) {
@@ -185,36 +185,36 @@ void ArrowInteractor::Redraw (Coord, Coo
     Coord x[3], y[3];
 
     if (canvas != nil) {
-	output->ClearRect(canvas, 0, 0, xmax, ymax);
+	output_->ClearRect(canvas, 0, 0, xmax, ymax);
 
 	if (_brush->None()) {
-	    const Font* f = output->GetFont();
+	    const Font* f = output_->GetFont();
 	    int width = f->Width(none);
 	    int height = f->Height();
 
-	    output->MoveTo((xmax - width + 1)/2, (ymax - height + 1)/2);
-	    output->Text(canvas, none);
+	    output_->MoveTo((xmax - width + 1)/2, (ymax - height + 1)/2);
+	    output_->Text(canvas, none);
 
 	} else {
-            const Color* origfg = output->GetFgColor();
-            const Color* origbg = output->GetBgColor();
+            const Color* origfg = output_->GetFgColor();
+            const Color* origbg = output_->GetBgColor();
             Resource::ref(origfg);
             Resource::ref(origbg);
 
-	    output->SetBrush(_brush);
-            output->SetColors(_fg, _bg);
+	    output_->SetBrush(_brush);
+            output_->SetColors(_fg, _bg);
 #if __GNUC__>=2 && __GNUC_MINOR__>=5 || __GNUC__>=3
 #undef Line
-	    output->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
+	    output_->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
 #define Line _lib_iv(Line)
 #else
-	    output->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
+	    output_->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
 #endif /* Line */
 
 	    /* remove the dashing for the arrowheads */
 	    if (_head || _tail) 
 	        if (_brush->dashed())
-		    output->SetBrush(new PSBrush(0, _brush->Width()));
+		    output_->SetBrush(new PSBrush(0, _brush->Width()));
 
 	    if (_head) {
 		x[2] = x[0] = xmax-ARROWX;
@@ -224,10 +224,10 @@ void ArrowInteractor::Redraw (Coord, Coo
 		y[2] = ymax/2 + ARROWY;
 #if __GNUC__>=2 && __GNUC_MINOR__>=5 || __GNUC__>=3
 #undef MultiLine
-		output->MultiLine(canvas, x, y, 3);
+		output_->MultiLine(canvas, x, y, 3);
 #define MultiLine _lib_iv(MultiLine)
 #else
-		output->MultiLine(canvas, x, y, 3);
+		output_->MultiLine(canvas, x, y, 3);
 #endif /* MultiLine */
 	    }
 	    if (_tail) {
@@ -238,19 +238,19 @@ void ArrowInteractor::Redraw (Coord, Coo
 		y[2] = ymax/2 + ARROWY;
 #if __GNUC__>=2 && __GNUC_MINOR__>=5 || __GNUC__>=3
 #undef MultiLine
-		output->MultiLine(canvas, x, y, 3);
+		output_->MultiLine(canvas, x, y, 3);
 #define MultiLine _lib_iv(MultiLine)
 #else
-		output->MultiLine(canvas, x, y, 3);
+		output_->MultiLine(canvas, x, y, 3);
 #endif /* MultiLine */
 	    }
 
             if (_brush->Width() == 0) {
-                CenterText("0", output, xmax, ymax);
-                output->Text(canvas, "0");
+                CenterText("0", output_, xmax, ymax);
+                output_->Text(canvas, "0");
             }
 
-            output->SetColors(origfg, origbg);
+            output_->SetColors(origfg, origbg);
             Resource::unref(origfg);
             Resource::unref(origbg);
 	}
--- ivtools-1.2.11a1.orig/src/Unidraw/catalog.cc
+++ ivtools-1.2.11a1/src/Unidraw/catalog.cc
@@ -660,7 +660,7 @@ void Catalog::ReadExtraData (
     for (int i = 0; !in.eof() && !FoundDelim(delim, *extra_data); ++i) {
         char c;
         in.get(c);
-        extra_data->Insert((void*)(unsigned int)c, i);
+        extra_data->Insert((void*)(intptr_t)c, i);
     }
 }
 
@@ -1987,22 +1987,22 @@ void Catalog::Register (Tool* o, const c
 
 class VoidIntElem : public UMapElem {
 public:
-    VoidIntElem(void*, int);
+    VoidIntElem(void*, intptr_t);
 
     virtual void* id();
     virtual void* tag();
 private:
     void* _object;
-    int _id;
+    intptr_t _id;
 };
 
-VoidIntElem::VoidIntElem (void* object, int id) {
+VoidIntElem::VoidIntElem (void* object, intptr_t id) {
     _object = object;
     _id = id;
 }
 
 void* VoidIntElem::id () { return _object; }
-void* VoidIntElem::tag () { return (void*) _id; }
+void* VoidIntElem::tag () { return (void*) (long)_id; }
 
 /*****************************************************************************/
 
@@ -2064,7 +2064,7 @@ inline ObjectMapElem* ObjectMap::Find (v
     return (ObjectMapElem*) _objKeys.Find(obj);
 }
 
-inline ObjectMapElem* ObjectMap::Find (int id) {
+inline ObjectMapElem* ObjectMap::Find (intptr_t id) {
     return (ObjectMapElem*) _idKeys.Find((void*) id);
 }
 
@@ -2075,17 +2075,17 @@ ObjectMap::ObjectMap (
     _id = id;
 }
 
-void ObjectMap::Register (void* obj, int id) {
+void ObjectMap::Register (void* obj, intptr_t id) {
     VoidIntElem* elem = new VoidIntElem(obj, id);
     UMap::Register(elem);
     ObjectMapElem* objElem = new ObjectMapElem(elem);
     ObjectMapElem* idElem = new ObjectMapElem(elem);
     _objKeys.Register(obj, objElem);
-    _idKeys.Register((void*) id, idElem);
+    _idKeys.Register((void*) (long) id, idElem);
 }
 
 void ObjectMap::Register (
-    void* obj, int id, ClassId orig_id, const char* delim, UArray* extra_data
+    void* obj, intptr_t id, ClassId orig_id, const char* delim, UArray* extra_data
 ) {
     VoidIntElem* elem = new VoidIntElem(obj, id);
     UMap::Register(elem);
@@ -2094,7 +2094,7 @@ void ObjectMap::Register (
     );
     ObjectMapElem* idElem = new ObjectMapElem(elem);
     _objKeys.Register(obj, objElem);
-    _idKeys.Register((void*) id, idElem);
+    _idKeys.Register((void*) (long) id, idElem);
 }
 
 void ObjectMap::Unregister (void* obj) {
@@ -2106,19 +2106,19 @@ void ObjectMap::Unregister (void* obj) {
     }
 }
 
-void ObjectMap::Unregister (int id) {
+void ObjectMap::Unregister (intptr_t id) {
     ObjectMapElem* idElem = Find(id);
 
     if (idElem != nil) {
         _objKeys.Unregister(idElem->GetObject());
-        _idKeys.Unregister((void*) id);
+        _idKeys.Unregister((void*) (long) id);
     }
 }
 
 void* ObjectMap::GetClient () { return _client; }
 ClassId ObjectMap::GetClientId () { return _id; }
 
-void* ObjectMap::GetObject (int id) { 
+void* ObjectMap::GetObject (intptr_t id) {
     ObjectMapElem* idElem = Find(id);
     return (idElem == nil) ? nil : idElem->GetObject();
 }
--- ivtools-1.2.11a1.orig/src/Unidraw/dialogs.cc
+++ ivtools-1.2.11a1/src/Unidraw/dialogs.cc
@@ -122,8 +122,8 @@ AcknowledgeDialog::AcknowledgeDialog (
     const char* title, const char* subtitle
 ) : BasicDialog(new ButtonState, title, subtitle) {
     Insert(Interior());
-    input = new Sensor(noEvents);
-    input->Catch(KeyEvent);
+    input_ = new Sensor(noEvents);
+    input_->Catch(KeyEvent);
 }    
 
 void AcknowledgeDialog::Acknowledge () {
@@ -165,8 +165,8 @@ ConfirmDialog::ConfirmDialog (
     const char* title, const char* subtitle
 ) : BasicDialog(new ButtonState, title, subtitle) {
     Insert(Interior());
-    input = new Sensor(noEvents);
-    input->Catch(KeyEvent);
+    input_ = new Sensor(noEvents);
+    input_->Catch(KeyEvent);
 }    
 
 inline boolean Confirmed (int v) {
@@ -424,7 +424,7 @@ Interactor* PrintDialog::Interior () {
                         "send to printer via a command, or ", _dest, true
                     ),
                     new VGlue(space/3, 0),
-                    new RadioButton("save in file:", _dest, int(false))
+                    new RadioButton("save in file:", _dest, intptr_t(false))
                 )
             ),
             new VGlue(space, 0),
@@ -454,8 +454,8 @@ GridDialog::GridDialog () : BasicDialog(
     _medit->Match("%f %f");
 
     _units = new ButtonState('p');
-    input = new Sensor;
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     SelectMessage();
--- ivtools-1.2.11a1.orig/src/Unidraw/editor.cc
+++ ivtools-1.2.11a1/src/Unidraw/editor.cc
@@ -47,6 +47,10 @@
 declarePtrList(EditorImpl,TransientWindow)
 implementPtrList(EditorImpl,TransientWindow)
 
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 /*****************************************************************************/
 
 static void DetachComponentViews (Editor* ed) {
--- ivtools-1.2.11a1.orig/src/Unidraw/geomobjs.cc
+++ ivtools-1.2.11a1/src/Unidraw/geomobjs.cc
@@ -25,6 +25,8 @@
  * Implementation of geometrical objects used by Graphic.
  */
 
+#include <cstdio>
+
 #include <Unidraw/Graphic/geomobjs.h>
 #include <Unidraw/Graphic/util.h>
 #include <Unidraw/ulist.h>
@@ -51,7 +53,7 @@ PointObj::PointObj (Coord x, Coord y) {
 PointObj::PointObj (PointObj* p) { _x = p->_x; _y = p->_y; }
 
 float PointObj::Distance (PointObj& p) {
-    return sqrt(float(square(_x - p._x) + square(_y - p._y)));
+    return hypot(_x - p._x, _y - p._y);
 }
 
 /*****************************************************************************/
--- ivtools-1.2.11a1.orig/src/Unidraw/grblock.cc
+++ ivtools-1.2.11a1/src/Unidraw/grblock.cc
@@ -243,7 +243,7 @@ void GraphicBlock::Update () {
 
 void GraphicBlock::Draw () {
     if (canvas != nil) {
-	output->ClearRect(canvas, 0, 0, xmax, ymax);
+	output_->ClearRect(canvas, 0, 0, xmax, ymax);
 	if (_graphic != nil) {
 	    _graphic->Draw(canvas, 0, 0, xmax, ymax);
 	}
@@ -252,7 +252,7 @@ void GraphicBlock::Draw () {
 
 void GraphicBlock::Redraw (Coord l, Coord b, Coord r, Coord t) {
     if (canvas != nil) {
-	output->ClearRect(canvas, l, b, r, t);
+	output_->ClearRect(canvas, l, b, r, t);
 	if (_graphic != nil) {
 	    _graphic->DrawClipped(canvas, l, b, r, t);
 	}
@@ -382,9 +382,9 @@ void GraphicBlock::Highlight (boolean on
     if (_highlighted != on) {
         _highlighted = on;
 
-        const Color* fg = output->GetFgColor();
-        const Color* bg = output->GetBgColor();
-        output->SetColors(bg, fg);
+        const Color* fg = output_->GetFgColor();
+        const Color* bg = output_->GetBgColor();
+        output_->SetColors(bg, fg);
 
         if (_graphic != nil) {
             PSColor* fg = _graphic->GetFgColor();
@@ -468,7 +468,7 @@ void GraphicBlock::RateScroll (Event& e)
         if (dx == 0 && dy == 0) {
             SetCursor(origCursor);
         } else {
-            double angle = atan2(dy, dx)*180/M_PI;
+	     double angle = degrees(atan2(dy, dx));
 
             if (angle < -157.5) {
                 SetCursor(kit.rfast_cursor());
--- ivtools-1.2.11a1.orig/src/Unidraw/pin.cc
+++ ivtools-1.2.11a1/src/Unidraw/pin.cc
@@ -386,7 +386,7 @@ void PinGraphic::getExtent (
 
     transform(fx - PIN_RAD, fy, rx, ry, gs);
     transform(fx, fy, cx, cy, gs);
-    rad = sqrt(square(rx - cx) + square(ry - cy));
+    rad = hypot(rx - cx, ry - cy);
     l = cx - rad;
     b = cy - rad;
     tol = 0;
--- ivtools-1.2.11a1.orig/src/Unidraw/slot.cc
+++ ivtools-1.2.11a1/src/Unidraw/slot.cc
@@ -268,7 +268,7 @@ static void Correct (
 
     float x0 = 0, y0 = 0, x1 = length, y1 = 0;
     corr.TransformRect(x0, y0, x1, y1);
-    length = Math::round(sqrt(square(x0-x1) + square(y0-y1)));
+    length = Math::round(hypot(x0 - x1, y0 - y1));
 }
 
 Command* SlotView::InterpGraphicCompManip (Manipulator* m) {
--- ivtools-1.2.11a1.orig/src/Unidraw/stateviews.cc
+++ ivtools-1.2.11a1/src/Unidraw/stateviews.cc
@@ -89,7 +89,7 @@ void TextInteractor::SetText (const char
 const char* TextInteractor::GetText () { return _text; }
 
 void TextInteractor::Align () {
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     int width = f->Width(_text);
     int height = f->Height();
     Coord x;
@@ -105,11 +105,11 @@ void TextInteractor::Align () {
         x = xmax - width - HPAD;
         break;
     }
-    output->MoveTo(x, (ymax - height+ 1)/2);
+    output_->MoveTo(x, (ymax - height+ 1)/2);
 }
 
 void TextInteractor::Reconfig () {
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     int width = f->Width(_text);
 
     shape->Rect(width + 2*HPAD, f->Height() + 2*VPAD);
@@ -119,8 +119,8 @@ void TextInteractor::Reconfig () {
 void TextInteractor::Redraw (Coord, Coord, Coord, Coord) {
     if (canvas != nil) {
 	Align();
-        output->ClearRect(canvas, 0, 0, xmax, ymax);
-	output->Text(canvas, _text);
+        output_->ClearRect(canvas, 0, 0, xmax, ymax);
+	output_->Text(canvas, _text);
     }
 }
 
@@ -339,13 +339,13 @@ void FontVarView::Init () {
 /*****************************************************************************/
 
 static void CenterText (
-    const char* text, Painter* output, Coord xmax, Coord ymax
+    const char* text, Painter* output_, Coord xmax, Coord ymax
 ) {
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     int width = f->Width(text);
     int height = f->Height();
 
-    output->MoveTo((xmax - width + 1)/2, (ymax - height + 1)/2);
+    output_->MoveTo((xmax - width + 1)/2, (ymax - height + 1)/2);
 }
 
 /*****************************************************************************/
@@ -406,12 +406,12 @@ PSColor* BrushInteractor::GetFgColor ()
 PSColor* BrushInteractor::GetBgColor () { return _bg; }
 
 void BrushInteractor::Reconfig () { 
-    Painter* tmp = output;
-    output = new Painter(tmp);
-    Ref(output);
+    Painter* tmp = output_;
+    output_ = new Painter(tmp);
+    Ref(output_);
     Unref(tmp);
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->width = max(f->Width(NONE) + 2*HPAD, VIEW_WIDTH);
     shape->height = max(f->Height() + 2*VPAD, VIEW_HEIGHT);
 
@@ -420,34 +420,34 @@ void BrushInteractor::Reconfig () {
 
 void BrushInteractor::Redraw (Coord, Coord, Coord, Coord) {
     if (canvas != nil) {
-	output->ClearRect(canvas, 0, 0, xmax, ymax);
+	output_->ClearRect(canvas, 0, 0, xmax, ymax);
 
 	if (_brush->None()) {
-	    CenterText(NONE, output, xmax, ymax);
-	    output->Text(canvas, NONE);
+	    CenterText(NONE, output_, xmax, ymax);
+	    output_->Text(canvas, NONE);
 
 	} else {
-            const Color* origfg = output->GetFgColor();
-            const Color* origbg = output->GetBgColor();
+            const Color* origfg = output_->GetFgColor();
+            const Color* origbg = output_->GetBgColor();
             Resource::ref(origfg);
             Resource::ref(origbg);
 
-	    output->SetBrush(_brush);
-            output->SetColors(_fg, _bg);
+	    output_->SetBrush(_brush);
+            output_->SetColors(_fg, _bg);
 #if __GNUC__>=2 && __GNUC_MINOR__>=5 || __GNUC__>=3
 #undef Line
-	    output->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
+	    output_->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
 #define Line _lib_iv(Line)
 #else
-	    output->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
+	    output_->Line(canvas, HPAD, ymax/2, xmax-HPAD, ymax/2);
 #endif /* Line */
 
             if (_brush->Width() == 0) {
-                CenterText("0", output, xmax, ymax);
-                output->Text(canvas, "0");
+                CenterText("0", output_, xmax, ymax);
+                output_->Text(canvas, "0");
             }
 
-            output->SetColors(origfg, origbg);
+            output_->SetColors(origfg, origbg);
             Resource::unref(origfg);
             Resource::unref(origbg);
 	}
@@ -559,12 +559,12 @@ PSColor* PatternInteractor::GetFgColor (
 PSColor* PatternInteractor::GetBgColor () { return _bg; }
 
 void PatternInteractor::Reconfig () {
-    Painter* tmp = output;
-    output = new Painter(tmp);
-    Ref(output);
+    Painter* tmp = output_;
+    output_ = new Painter(tmp);
+    Ref(output_);
     Unref(tmp);
 
-    const Font* f = output->GetFont();
+    const Font* f = output_->GetFont();
     shape->width = max(f->Width(NONE) + 2*HPAD, VIEW_WIDTH);
     shape->height = max(f->Height() + 2*VPAD, VIEW_HEIGHT);
 
@@ -573,24 +573,24 @@ void PatternInteractor::Reconfig () {
 
 void PatternInteractor::Redraw (Coord, Coord, Coord, Coord) {
     if (canvas != nil) {
-	output->ClearRect(canvas, 0, 0, xmax, ymax);
+	output_->ClearRect(canvas, 0, 0, xmax, ymax);
 
 	if (_pattern->None()) {
-	    CenterText(NONE, output, xmax, ymax);
-	    output->Text(canvas, NONE);
+	    CenterText(NONE, output_, xmax, ymax);
+	    output_->Text(canvas, NONE);
 
 	} else {
-            const Color* origfg = output->GetFgColor();
-            const Color* origbg = output->GetBgColor();
+            const Color* origfg = output_->GetFgColor();
+            const Color* origbg = output_->GetBgColor();
             Resource::ref(origfg);
             Resource::ref(origbg);
 
-	    output->SetPattern(_pattern);
-            output->SetColors(_fg, _bg);
-	    output->FillRect(canvas, HPAD, VPAD, xmax-HPAD, ymax-VPAD);
-	    output->Rect(canvas, HPAD, VPAD, xmax-HPAD, ymax-VPAD);
+	    output_->SetPattern(_pattern);
+            output_->SetColors(_fg, _bg);
+	    output_->FillRect(canvas, HPAD, VPAD, xmax-HPAD, ymax-VPAD);
+	    output_->Rect(canvas, HPAD, VPAD, xmax-HPAD, ymax-VPAD);
 
-            output->SetColors(origfg, origbg);
+            output_->SetColors(origfg, origbg);
             Resource::unref(origfg);
             Resource::unref(origbg);
 	}
--- ivtools-1.2.11a1.orig/src/Unidraw/viewer.cc
+++ ivtools-1.2.11a1/src/Unidraw/viewer.cc
@@ -208,7 +208,7 @@ void Viewer::Init(
     }
     _damage = new Damage;
     _orientation = orientation;
-    input = new Sensor(updownEvents);
+    input_ = new Sensor(updownEvents);
 
     Init(ed, gv, page, grid);
     shape->width = w;
@@ -239,7 +239,7 @@ Viewer::~Viewer () {
     delete _gview;
 }
 
-void Viewer::Reconfig () { _damage->SetPainter(output); }
+void Viewer::Reconfig () { _damage->SetPainter(output_); }
 
 void Viewer::Update () {
     Selection* s = GetSelection();
@@ -337,7 +337,7 @@ void Viewer::InitRubberband (Rubberband*
 void Viewer::InitTextDisplay (TextDisplay* td, Painter* p) {
     if (!p->BgFilled()) {
         p->FillBg(true);
-        p->SetColors(nil, output->GetBgColor());
+        p->SetColors(nil, output_->GetBgColor());
     }
     td->Draw(p, canvas);
 }
@@ -521,7 +521,7 @@ void Viewer::Manipulate (Manipulator* m,
     } while (b);
 
     m->Effect(e);
-    Listen(input);
+    Listen(input_);
 }
 
 static Transformer* ComputeRel (Viewer* v, Transformer* t) {
--- ivtools-1.2.11a1.orig/src/comdraw/README
+++ ivtools-1.2.11a1/src/comdraw/README
@@ -85,6 +85,8 @@ compview=frame([index]) -- return compos
 val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list.
 num=size(list|attrlist|str|compview) -- return size of a list (or string)
 compview=parent(compview) -- get parent of graphic
+strm=depth(comps) -- depth-first walk of comp tree using stream
+
 
 VIEWER COMMANDS
 
--- ivtools-1.2.11a1.orig/src/comdraw/main.cc
+++ ivtools-1.2.11a1/src/comdraw/main.cc
@@ -26,6 +26,10 @@
  * comdraw main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #ifdef HAVE_ACE
 #include <ComUnidraw/comterp-acehandler.h>
 #include <OverlayUnidraw/aceimport.h>
@@ -49,7 +53,6 @@
 #include <stream.h>
 #include <string.h>
 #include <math.h>
-#include <version.h>
 #include <iostream>
 
 using std::cerr;
@@ -298,9 +301,11 @@ int main (int argc, char** argv) {
     // Register COMTERP_QUIT_HANDLER to receive SIGINT commands.  When received,
     // COMTERP_QUIT_HANDLER becomes "set" and thus, the event loop below will
     // exit.
+#if 0
     if (ComterpHandler::reactor_singleton()->register_handler 
 	     (SIGINT, COMTERP_QUIT_HANDLER::instance ()) == -1)
         cerr << "comdraw:  unable to register quit handler with ACE reactor\n";
+#endif
 
 #endif
     int exit_status = 0;
@@ -332,7 +337,9 @@ int main (int argc, char** argv) {
 	}
 #endif
 
-	fprintf(stderr, "ivtools-%s comdraw: see \"man comdraw\" or type help here for command info\n", VersionString);
+	fprintf(stderr,
+		"ivtools-%s comdraw: see \"man comdraw\" or type help here for command info\n",
+		PACKAGE_VERSION);
 	unidraw->Run();
     }
 
--- ivtools-1.2.11a1.orig/src/comterp_/README
+++ ivtools-1.2.11a1/src/comterp_/README
@@ -4,11 +4,12 @@ NAME
 SYNOPSIS
      comterp
      comterp remote
-     comterp server 'portnum'
-     comterp logger 'portnum'
-     comterp client 'host' 'portnum' ['file']
-     comterp telcat 'host' 'portnum' ['file']
-     comterp run 'file'	
+     comterp server "portnum"
+     comterp logger "portnum"
+     comterp client "host" "portnum" ["file"]
+     comterp telcat "host" "portnum" ["file"]
+     comterp run "file"	
+     comterp "expr"
 
 DESCRIPTION
 
@@ -43,32 +44,36 @@ Invoke a single command interpreter, lik
 remote command for accessing other comterp's in server mode.
 
 
-comterp server 'portnum'
+comterp server "portnum"
 
 Listens for and accept connections on portnum, then setup a command
 interpreter to wait for and process commands from that connection.
 
-comterp logger 'portnum'
+comterp logger "portnum"
 
 Listens for and accept connections on portnum, then simply forward
 the incoming messages to stdout, while ack'ing back with newlines. For
 debugging purposes, not really a use of the interpreter.
 
-comterp client 'host' 'portnum' ['file']
+comterp client "host" "portnum" ["file"]
 
 Connect to a portnum on a host and send/receive new-line terminated
 text buffers.  For debugging purposes, not really a use of the
 interpreter.
 
-comterp telcat 'host' 'portnum' ['file']
+comterp telcat "host" "portnum" ["file"]
 
 Connect to a portnum on a host, cat the file, then close the
 connection.  Not really a use of the interpreter either.
 
-comterp run 'file'
+comterp run "file"
 
 Run contents of file then exit.
 
+comterp "expr"
+
+Evaluate single expression then exit.
+
 
 OPERATOR TABLE
 
@@ -76,7 +81,6 @@ OPERATOR TABLE
     ---------     ------------         --------    -----       ----
     .             dot                  130         L-to-R      binary
     `             bquote               125         R-to-L      unary-prefix
-    $             stream               125         R-to-L      unary-prefix
     !             negate               110         R-to-L      unary-prefix
     ~             bit_not              110         R-to-L      unary-prefix
     ++            incr                 110         R-to-L      unary-prefix
@@ -105,7 +109,9 @@ OPERATOR TABLE
     &&            and                  41          L-to-R      binary
     ||            or                   40          L-to-R      binary
     ,             tuple                35          L-to-R      binary
-    ,,            concat               33          L-to-R      binary
+    ,,            stream concat        33          L-to-R      binary
+    $             stream               32          R-to-L      unary-prefix
+    $$            list                 32          R-to-L      unary-prefix
     %=            mod_assign           30          R-to-L      binary
     *=            mpy_assign           30          R-to-L      binary
     +=            add_assign           30          R-to-L      binary
@@ -128,6 +134,8 @@ dbl=log(x) -- returns the natural logari
 
 dbl=log10(x) -- returns the base-10 logarithm of x
 
+dbl=log2(x) -- returns the base-2 logarithm of x
+
 dbl=pow(x y) -- returns the value of x raised to the power of y
 
 dbl=acos(x) -- returns the arc cosine of x in radians
@@ -190,16 +198,18 @@ val=at(list|attrlist|str n :set val :ins
 
 num=size(list|attrlist|str) -- return size of a list (or string)
 
-val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
+val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
 
 STREAM COMMANDS:
 
 val=next(strm) -- return next value from stream
 
-strm=stream(ostrm|list|attrlist) -- copy stream or convert list
+strm=stream(ostrm|list|attrlist|val) -- copy stream or convert list
 
 cnt=each(strm) -- traverse stream returning its length
 
+comp=filter(comps classid) -- filter stream of comps for matching classid
+
 CONTROL COMMANDS (using post evaluation):
 
 val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true,
@@ -216,7 +226,7 @@ val=switch(val key-body-pairs) -- switch
 
 continue -- skip to next iteration of for or while loop
 
-break -- break out of for or while loop
+break([retval]) -- break out of for or while loop
 
 OTHER COMMANDS
 
@@ -226,7 +236,7 @@ optable() -- print contents of operator
 
 val=trace([flag] :get) -- toggle or set trace mode
 
-pause()  -- pause script execution until C/R
+pause([msgstr])  -- pause script execution until C/R
 
 step() -- toggle stepwise script execution
 
@@ -254,11 +264,11 @@ str=symstr(sym) -- return string version
 
 n=strref(str|symid) -- return string reference count
 
-lst=split(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens).
+lst=split(symbol|string :tokstr [delim] :tokval [delim] :keep :reverse) -- split symbol or string into list of characters (or tokens).
 
 str=join(clist :sym) -- join list of characters into string
 
-str=substr(str n|str :after) -- extract characters from a string
+str=substr(str n|str :after :nonil) -- extract characters from a string (:nonil returns string if no match)
 
 bool=eq(str1 str2 :n len) -- partial string comparison
 
@@ -268,6 +278,8 @@ postfix(arg1 [arg2 [arg3 ... [argn]]]) -
 (with [narg|nkey] after defined commands, {narg|nkey} after undefined commands,
 (narg) after keys, and a * following post-evaluation commands)
 
+parse(fileobj) -- parse a single expression from a file
+
 arr=posteval(arg1 [arg2 [arg3 ... [argn]]]) -- post-evaluate every fixed 
 argument (until nil) and return array
 
@@ -298,6 +310,10 @@ mute([flag]) -- set or toggle mute flag
 
 nil([...]) -- accept any arguments and return nil
 
+true([...]) -- accept any arguments and return true
+
+false([...]) -- accept any arguments and return false
+
 c=char(num :u) -- convert any numeric to a char
 
 s=short(num :u) -- convert any numeric to a short
--- ivtools-1.2.11a1.orig/src/comterp_/main.cc
+++ ivtools-1.2.11a1/src/comterp_/main.cc
@@ -21,6 +21,11 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cstdio>
+
 #ifdef HAVE_ACE
 #include <ComTerp/comhandler.h>
 #include <ace/SOCK_Connector.h>
@@ -38,9 +43,8 @@ static const char *const SERVER_HOST = A
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include <version.h>
-
 #include <ComTerp/comterpserv.h>
+#include <ComTerp/comvalue.h>
 
 
 #if BUFSIZ>1024
@@ -71,6 +75,8 @@ int main(int argc, char *argv[]) {
     boolean client_flag = argc>1 && strcmp(argv[1], "client") == 0;
     boolean telcat_flag = argc>1 && strcmp(argv[1], "telcat") == 0;
     boolean run_flag = argc>1 && strcmp(argv[1], "run") == 0;
+    boolean expr_flag = argc>1 && !server_flag && !logger_flag && 
+                        !remote_flag && !client_flag && !telcat_flag && !run_flag;
 
 #ifdef HAVE_ACE
     if (server_flag || logger_flag) {
@@ -109,9 +115,9 @@ int main(int argc, char *argv[]) {
 	}
 
         // Perform logging service until COMTERP_QUIT_HANDLER receives SIGINT.
-        while (COMTERP_QUIT_HANDLER::instance ()->is_set () == 0)
+        while (COMTERP_QUIT_HANDLER::instance ()->is_set () == 0) {
             ComterpHandler::reactor_singleton()->handle_events ();
-    
+	}
         return 0;
     }
     if (client_flag || telcat_flag) {
@@ -132,24 +138,15 @@ int main(int argc, char *argv[]) {
 
     FILE* inptr = argc>=5 ? fopen(argv[4], "r") : stdin;
 
+    FILE* ofptr = nil;
+
     if (!telcat_flag) {
       
-#if __GNUC__<3
-      filebuf obuf;
-      obuf.attach(server.get_handle());
-#else
-      FILE* ofptr = nil;
-      fileptr_filebuf obuf(ofptr = fdopen(server.get_handle(), "w"), ios_base::out);
-#endif
+      FILEBUF(obuf, ofptr = fdopen(server.get_handle(), "w"), ios_base::out);
       ostream out(&obuf);
       
-#if __GNUC__<3
-      filebuf ibuf;
-      ibuf.attach(server.get_handle());
-#else
       FILE* ifptr = nil;
-      fileptr_filebuf ibuf(ifptr = fdopen(server.get_handle(), "r"), ios_base::in);
-#endif
+      FILEBUF(ibuf, ifptr = fdopen(server.get_handle(), "r"), ios_base::in);
       
       istream in(&ibuf);
       
@@ -158,19 +155,6 @@ int main(int argc, char *argv[]) {
 	if (feof(inptr)) break;
 	out << buffer;
 	out.flush();
-#if __GNUC__<3
-	char* inbuf;
-	char ch;
-	ch = in.get();
-	if (ch == '>')
-	  ch = in.get(); // ' '
-	else {
-	  in.unget();
-	  in.gets(&inbuf);
-	  if (client_flag) 
-	    cout << inbuf << "\n";
-	}
-#else
 	char inbuf[BUFSIZ];
 	char ch;
 	ch = in.get();
@@ -183,10 +167,9 @@ int main(int argc, char *argv[]) {
 	  if (client_flag) 
 	    cout << inbuf << "\n";
 	}
-#endif
       }
 
-#if __GNUC__>=3
+#ifndef __APPLE__
       if (ofptr) fclose(ofptr);
       if (ifptr) fclose(ifptr);
 #endif
@@ -194,22 +177,11 @@ int main(int argc, char *argv[]) {
     } else if (inptr) {
 
 
-#if __GNUC__<3
-      filebuf inbuf;
-      inbuf.attach(fileno(inptr));
-#else
-      fileptr_filebuf inbuf(inptr, ios_base::in);
-#endif
+      FILEBUF(inbuf, inptr, ios_base::in);
       istream in(&inbuf);
       
 
-#if __GNUC__<3
-      filebuf obuf;
-      obuf.attach(server.get_handle());
-#else
-      FILE* ofptr = nil;
-      fileptr_filebuf obuf(fdopen(server.get_handle(), "w"), ios_base::out);
-#endif
+      FILEBUF(obuf, fdopen(server.get_handle(), "w"), ios_base::out);
       ostream out(&obuf);
 
       char buffer[BUFSIZ*BUFSIZ];
@@ -219,7 +191,7 @@ int main(int argc, char *argv[]) {
 	  out.write(buffer, in.gcount());
       }
       out.flush();
-#if __GNUC__>=3
+#ifndef __APPLE__
       if (ofptr) fclose(ofptr);
 #endif
     } else 
@@ -243,7 +215,9 @@ int main(int argc, char *argv[]) {
       if (S_ISREG(buf.st_mode) || S_ISFIFO(buf.st_mode))
 	terp->disable_prompt();
       else
-	fprintf(stderr, "ivtools-%s comterp: type help for more info\n", VersionString);
+	fprintf(stderr,
+		"ivtools-%s comterp: type help for more info\n",
+		PACKAGE_VERSION);
       return terp->run();
     } else {
       ComTerpServ* terp = new ComTerpServ();
@@ -253,6 +227,12 @@ int main(int argc, char *argv[]) {
 	terp->set_args(argc-3, argv+2);
 	terp->runfile(rfile);
 	return 0;
+      } if (expr_flag) {
+	terp->brief(1);
+	ComValue::comterp(terp);
+        ComValue comval(terp->run(argv[1]));
+        cout << comval << '\n';
+        return 0;
       } else {
 	
 	struct stat buf;
@@ -269,7 +249,9 @@ int main(int argc, char *argv[]) {
         if (S_ISREG(buf.st_mode) || S_ISFIFO(buf.st_mode))
 	  terp->disable_prompt();
 	else
-	  fprintf(stderr, "ivtools-%s comterp:  type help for more info\n", VersionString);
+	  fprintf(stderr,
+		  "ivtools-%s comterp:  type help for more info\n",
+		  PACKAGE_VERSION);
 	return terp->run();
       }
     }
--- ivtools-1.2.11a1.orig/src/dclock/dface.cc
+++ ivtools-1.2.11a1/src/dclock/dface.cc
@@ -38,12 +38,12 @@ implementIOCallback(DFace)
 static const int FadeDelay = 10000;
 
 void DFace::DrawFace () {
-    output->ClearRect(canvas, 0, 0, xmax, ymax);
+    output_->ClearRect(canvas, 0, 0, xmax, ymax);
 }
 
 void DFace::DrawColon () {
-    output->FillPolygon(canvas, colon[0].x, colon[0].y, colon[0].count);
-    output->FillPolygon(canvas, colon[1].x, colon[1].y, colon[1].count);
+    output_->FillPolygon(canvas, colon[0].x, colon[0].y, colon[0].count);
+    output_->FillPolygon(canvas, colon[1].x, colon[1].y, colon[1].count);
 }
 
 void DFace::DrawAMPM (Painter *painter) {
@@ -61,7 +61,7 @@ void DFace::DrawAMPM (Painter *painter)
 
 void DFace::DrawDate () {
     if (showDate && date.len != 0) {
-	const Font* f = output->GetFont();
+	const Font* f = output_->GetFont();
 	Coord dateYPos = ymax - f->Height();
 	Coord dateXPos = 2;
 
@@ -70,21 +70,21 @@ void DFace::DrawDate () {
 	int dayDateWidth = f->Width( date.text, 10 );
 	int wholeWidth = f->Width( date.text, date.len );
 
-	output->ClearRect(canvas, 0, ymax - f->Height(), xmax, ymax);
+	output_->ClearRect(canvas, 0, ymax - f->Height(), xmax, ymax);
 	if (wholeWidth < availWidth) {
-	    output->Text(canvas, date.text, date.len, dateXPos, dateYPos);
+	    output_->Text(canvas, date.text, date.len, dateXPos, dateYPos);
 	} else if (dayDateWidth < availWidth) {
-	    output->Text(canvas, date.text, 10, dateXPos, dateYPos);
+	    output_->Text(canvas, date.text, 10, dateXPos, dateYPos);
 	} else if (dayWidth < availWidth) {
-	    output->Text(canvas, date.text, 3, dateXPos, dateYPos);
+	    output_->Text(canvas, date.text, 3, dateXPos, dateYPos);
 	}
     }
 }
 
 void DFace::DrawBorder () {
     if (showDate && showTime) {
-	int ypos = ymax - output->GetFont()->Height() - 2;
-	output->Line(canvas, 0, ypos, xmax, ypos);
+	int ypos = ymax - output_->GetFont()->Height() - 2;
+	output_->Line(canvas, 0, ypos, xmax, ypos);
     }
 }
 
@@ -140,11 +140,11 @@ void DFace::Set (char *today, int hours,
 
 	if (AMPMmode == BLANK) {
 	    AMPMmode = newAMPM;
-	    DrawAMPM(output);
+	    DrawAMPM(output_);
 	} else if (AMPMmode != newAMPM) {
 	    DrawAMPM(invertor);				// erase old
 	    AMPMmode = newAMPM;
-	    DrawAMPM(output);				// draw new
+	    DrawAMPM(output_);				// draw new
 	}
     }
     if (showDate && strcmp(date.text, today) != 0) {
@@ -182,20 +182,20 @@ DFace::DFace (
     shape->Rect(width, height);
     shape->Rigid(hfil, hfil, vfil, vfil);
     invertor = nil;
-    input = new Sensor;
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(KeyEvent);
     tick = new IOCallback(DFace)(this, &DFace::Tick);
 }
 
 void DFace::Reconfig () {
     Unref(invertor);
-    invertor = new Painter(output);
+    invertor = new Painter(output_);
     invertor->Reference();
     invertor->SetColors(invertor->GetBgColor(), invertor->GetFgColor());
-    ht->Reconfig(output);
-    hu->Reconfig(output);
-    mt->Reconfig(output);
-    mu->Reconfig(output);
+    ht->Reconfig(output_);
+    hu->Reconfig(output_);
+    mt->Reconfig(output_);
+    mu->Reconfig(output_);
 }
 
 DFace::~DFace () {
@@ -214,7 +214,7 @@ void DFace::Resize () {
     int h = ymax;
     if (showDate) {
 	// adjust vertical size for date
-	h -= output->GetFont()->Height();
+	h -= output_->GetFont()->Height();
     }
     // resize colon
     for (i = 0; i < colon[0].count; i++) {
@@ -241,9 +241,9 @@ void DFace::Resize () {
 }
 
 void DFace::Redraw (Coord left, Coord bottom, Coord right, Coord top) {
-    output->Clip(canvas, left, bottom, right, top);
+    output_->Clip(canvas, left, bottom, right, top);
     Draw();
-    output->NoClip();
+    output_->NoClip();
 }
 
 void DFace::RedrawList (int, Coord[], Coord[], Coord[], Coord[]) {
@@ -257,7 +257,7 @@ void DFace::Draw () {
     }
     if (showTime) {
 	DrawColon();
-	DrawAMPM(output);
+	DrawAMPM(output_);
 	ht->Redraw();
 	hu->Redraw();
 	mt->Redraw();
--- ivtools-1.2.11a1.orig/src/drawserv_/main.cc
+++ ivtools-1.2.11a1/src/drawserv_/main.cc
@@ -27,6 +27,10 @@
  * drawserv main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #ifdef HAVE_ACE
 #include <DrawServ/drawserv-handler.h>
 #include <OverlayUnidraw/aceimport.h>
@@ -56,7 +60,6 @@
 #include <stream.h>
 #include <string.h>
 #include <math.h>
-#include <version.h>
 #include <fstream>
 #include <iostream>
 
@@ -283,9 +286,11 @@ int main (int argc, char** argv) {
     // Register COMTERP_QUIT_HANDLER to receive SIGINT commands.  When received,
     // COMTERP_QUIT_HANDLER becomes "set" and thus, the event loop below will
     // exit.
+#if 0
     if (ComterpHandler::reactor_singleton()->register_handler 
 	     (SIGINT, COMTERP_QUIT_HANDLER::instance ()) == -1)
         cerr << "drawserv:  unable to register quit handler with ACE reactor\n";
+#endif
 
 #endif
 
@@ -321,9 +326,11 @@ int main (int argc, char** argv) {
 #endif
 	  cerr << "drawserv: unable to open stdin with ACE\n";
 	ed->SetComTerp(stdin_handler->comterp());
-	fprintf(stderr, "ivtools-%s drawserv: type help here for command info\n", VersionString);
+	fprintf(stderr,
+		"ivtools-%s drawserv: type help here for command info\n",
+		PACKAGE_VERSION);
 #else
-	fprintf(stderr, "ivtools-%s drawserv", VersionString);
+	fprintf(stderr, "ivtools-%s drawserv", PACKAGE_VERSION);
 #endif
 
 	unidraw->Run();
--- ivtools-1.2.11a1.orig/src/drawtool/README
+++ ivtools-1.2.11a1/src/drawtool/README
@@ -17,8 +17,8 @@ the following features:
 	- graphical object attribute annotations
 
 drawtool is derived from idraw, and implements the same set of
-pulldown commands and pallette of toolbuttons.  Read the idraw man
-page for details on that part of the drawtool user interace.  This
+pulldown commands and palette of toolbuttons.  Read the idraw man
+page for details on that part of the drawtool user interface.  This
 page lists only the extensions to idraw embodied in drawtool.
 
 drawtool saves and restores documents in a readable text format.  This
--- ivtools-1.2.11a1.orig/src/drawtool/main.cc
+++ ivtools-1.2.11a1/src/drawtool/main.cc
@@ -28,8 +28,14 @@
  * Overlay editor main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #ifdef HAVE_ACE
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
 #include <OverlayUnidraw/aceimport.h>
 #include <AceDispatch/ace_dispatcher.h>
 #include <ComTerp/comhandler.h>
@@ -48,7 +54,6 @@
 #include <stream.h>
 #include <string.h>
 #include <math.h>
-#include <version.h>
 #include <iostream>
 #include <fstream>
 
@@ -263,10 +268,11 @@ int main (int argc, char** argv) {
     // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
     // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
     // exit.
+#if 0
     if (ComterpHandler::reactor_singleton()->register_handler 
 	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
         cerr << "drawtool:  unable to register quit handler with ACE reactor\n";
-
+#endif
 #endif
 
     if (argc > 2) {
@@ -279,7 +285,7 @@ int main (int argc, char** argv) {
 	OverlayEditor* ed = new OverlayEditor(initial_file);
 
 	unidraw->Open(ed);
-	cerr << "ivtools-" << VersionString 
+	cerr << "ivtools-" << PACKAGE_VERSION
 	     << " drawtool: see \"man drawtool\" for more info\n"; 
 	unidraw->Run();
     }
--- ivtools-1.2.11a1.orig/src/flipbook/main.cc
+++ ivtools-1.2.11a1/src/flipbook/main.cc
@@ -26,6 +26,10 @@
  * Frame editor main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #ifdef HAVE_ACE
 #include <ComUnidraw/comterp-acehandler.h>
 #include <OverlayUnidraw/aceimport.h>
@@ -44,7 +48,6 @@
 #include <stream.h>
 #include <string.h>
 #include <math.h>
-#include <version.h>
 #include <iostream>
 
 using std::cerr;
@@ -284,9 +287,11 @@ int main (int argc, char** argv) {
     // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
     // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
     // exit.
+#if 0
     if (ComterpHandler::reactor_singleton()->register_handler 
 	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
         cerr << "flipbook:  unable to register quit handler with ACE reactor\n";
+#endif
 
 #endif
     if (argc > 2) {
@@ -313,7 +318,9 @@ int main (int argc, char** argv) {
 #endif
 	
 
-	fprintf(stderr, "ivtools-%s flipbook: see \"man flipbook\" or type help here for command info\n", VersionString);
+	fprintf(stderr,
+		"ivtools-%s flipbook: see \"man flipbook\" or type help here for command info\n",
+		PACKAGE_VERSION);
 	unidraw->Run();
     }
 
--- ivtools-1.2.11a1.orig/src/glyphs/examples3.1/print/main.cc
+++ ivtools-1.2.11a1/src/glyphs/examples3.1/print/main.cc
@@ -1,3 +1,5 @@
+#include <cstdio>
+
 #include <IV-look/dialogs.h>
 #include <IV-look/kit.h>
 #include <InterViews/background.h>
--- ivtools-1.2.11a1.orig/src/glyphs/morpher/glyphviewer.cc
+++ ivtools-1.2.11a1/src/glyphs/morpher/glyphviewer.cc
@@ -272,7 +272,7 @@ void GlyphViewer::rate_scroll () {
     Coord dy = _y - _ly;
     
     if (dx != 0.0 && dy != 0.0) {
-        double angle = atan2(dy, dx)*180/M_PI;
+        double angle = degrees(atan2(dy, dx));
         
         if (angle < -157.5) {
             w->cursor(kit->rfast_cursor());
--- ivtools-1.2.11a1.orig/src/glyphs/strchooser/main.cc
+++ ivtools-1.2.11a1/src/glyphs/strchooser/main.cc
@@ -125,7 +125,7 @@ declareActionCallback(Session)
 declareActionCallback(App)
 implementActionCallback(App)
 
-main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
   Session * session =  new Session("strchooser", argc, argv, options, properties);
   LayoutKit &    lk = *LayoutKit::instance();
   WidgetKit *    wk =  MFKit::instance();
--- ivtools-1.2.11a1.orig/src/graphdraw/main.cc
+++ ivtools-1.2.11a1/src/graphdraw/main.cc
@@ -26,6 +26,10 @@
  * Graph editor main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #ifdef HAVE_ACE
 #include <ComUnidraw/comterp-acehandler.h>
 #include <OverlayUnidraw/aceimport.h>
@@ -43,7 +47,6 @@
 #include <stream.h>
 #include <string.h>
 #include <math.h>
-#include <version.h>
 
 #include <iostream>
 #include <fstream>
@@ -270,10 +273,11 @@ int main (int argc, char** argv) {
     // Register IMPORT_QUIT_HANDLER to receive SIGINT commands.  When received,
     // IMPORT_QUIT_HANDLER becomes "set" and thus, the event loop below will
     // exit.
+#if 0
     if (ComterpHandler::reactor_singleton()->register_handler 
 	     (SIGINT, IMPORT_QUIT_HANDLER::instance ()) == -1)
         cerr << "graphdraw:  unable to register quit handler with ACE reactor\n";
-
+#endif
 #endif
 
     const char* initial_file = (argc == 2) ? argv[1] : nil;
@@ -294,7 +298,7 @@ int main (int argc, char** argv) {
 	ed->SetComTerp(stdin_handler->comterp());
 #endif
 	
-    cerr << "ivtools-" << VersionString 
+    cerr << "ivtools-" << PACKAGE_VERSION
 	 << " graphdraw: see \"man graphdraw\" or type help here for command info\n";
     unidraw->Run();
 
--- ivtools-1.2.11a1.orig/src/iclass/classbuffer.cc
+++ ivtools-1.2.11a1/src/iclass/classbuffer.cc
@@ -46,6 +46,11 @@
 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
 #endif
 
+// No MAXPATHLEN on GNU Hurd, cobble something up.
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 4096
+#endif
+
 /*****************************************************************************/
 
 static const int MINTEXTSIZE = 10000;
--- ivtools-1.2.11a1.orig/src/iclass/classeditor.cc
+++ ivtools-1.2.11a1/src/iclass/classeditor.cc
@@ -64,9 +64,9 @@ ClassEditor::ClassEditor (
 
 void ClassEditor::Init (ButtonState* bs, const char* done) {
     SetClassName("ClassEditor");
-    input = new Sensor;
-    input->Catch(DownEvent);
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(DownEvent);
+    input_->Catch(KeyEvent);
 
     _state = bs;
     _done = done;
--- ivtools-1.2.11a1.orig/src/iclass/dialogs.cc
+++ ivtools-1.2.11a1/src/iclass/dialogs.cc
@@ -59,8 +59,8 @@ static const int MAX_PATH_LENGTH = 256;
 /*****************************************************************************/
 
 BasicDialog::BasicDialog () : Dialog(new ButtonState, nil) {
-    input = new Sensor;
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(KeyEvent);
 }
 
 boolean BasicDialog::Accept () {
@@ -148,8 +148,8 @@ void AcknowledgeDialog::Acknowledge () {
 
 ConfirmDialog::ConfirmDialog (const char* msg) {
     Insert(Interior(msg));
-    input = new Sensor(noEvents);
-    input->Catch(KeyEvent);
+    input_ = new Sensor(noEvents);
+    input_->Catch(KeyEvent);
 }    
 
 inline boolean Confirmed (int v) {
--- ivtools-1.2.11a1.orig/src/iclass/iclass.cc
+++ ivtools-1.2.11a1/src/iclass/iclass.cc
@@ -167,8 +167,8 @@ void IClass::Init (ClassBuffer* cb) {
     _lastFile = nil;
     _completions = nil;
 
-    input = new Sensor;
-    input->Catch(KeyEvent);
+    input_ = new Sensor;
+    input_->Catch(KeyEvent);
 
     Insert(Interior());
     UpdateClassesBrowser();
@@ -688,7 +688,7 @@ void IClass::BackwardSearchCmd () {
 
 void IClass::GotoCmd () {
     if (_goto == nil) {
-        int width = output->GetFont()->Width("9999999");
+        int width = output_->GetFont()->Width("9999999");
         _goto = new StringDialog("Go to line:", width);
     }
 
--- ivtools-1.2.11a1.orig/src/iclass/main.cc
+++ ivtools-1.2.11a1/src/iclass/main.cc
@@ -24,6 +24,7 @@
  * InterViews class browser main program.
  */
 
+#include <cstdio>
 #include "classbuffer.h"
 #include "iclass.h"
 
--- ivtools-1.2.11a1.orig/src/idraw/main.cc
+++ ivtools-1.2.11a1/src/idraw/main.cc
@@ -24,6 +24,10 @@
  * Idraw editor main program.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <UniIdraw/idcatalog.h>
 #include <UniIdraw/idcreator.h>
 #include <UniIdraw/ided.h>
@@ -34,8 +38,6 @@
 
 #include <stream.h>
 
-#include <version.h>
-
 #include <iostream>
 #include <fstream>
 
@@ -153,7 +155,7 @@ int main (int argc, char** argv) {
 	IdrawEditor* ed = new IdrawEditor(initial_file);
 
 	unidraw->Open(ed);
-	cerr << "ivtools-" << VersionString 
+	cerr << "ivtools-" << PACKAGE_VERSION
 	     << " idraw: see \"man idraw\" for more info\n"; 
 	unidraw->Run();
     }
--- ivtools-1.2.11a1.orig/src/include/IV-2_6/InterViews/button.h
+++ ivtools-1.2.11a1/src/include/IV-2_6/InterViews/button.h
@@ -30,6 +30,7 @@
 #ifndef ivlook2_6_button_h
 #define ivlook2_6_button_h
 
+#include <inttypes.h>
 #include <IV-2_6/InterViews/interactor.h>
 #include <IV-2_6/InterViews/subject.h>
 
@@ -113,9 +114,9 @@ private:
 
 class PushButton : public TextButton {
 public:
-    PushButton(const char*, ButtonState*, int);
+    PushButton(const char*, ButtonState*, intptr_t);
     PushButton(const char*, ButtonState*, void*);
-    PushButton(const char*, const char*, ButtonState*, int);
+    PushButton(const char*, const char*, ButtonState*, intptr_t);
     PushButton(const char*, const char*, ButtonState*, void*);
     virtual ~PushButton();
 
@@ -129,9 +130,9 @@ private:
 
 class RadioButton : public TextButton {
 public:
-    RadioButton(const char*, ButtonState*, int);
+    RadioButton(const char*, ButtonState*, intptr_t);
     RadioButton(const char*, ButtonState*, void*);
-    RadioButton(const char*, const char*, ButtonState*, int);
+    RadioButton(const char*, const char*, ButtonState*, intptr_t);
     RadioButton(const char*, const char*, ButtonState*, void*);
     virtual ~RadioButton();
 
@@ -145,9 +146,9 @@ private:
 
 class CheckBox : public TextButton {
 public:
-    CheckBox(const char*, ButtonState*, int, int);
+    CheckBox(const char*, ButtonState*, intptr_t, intptr_t);
     CheckBox(const char*, ButtonState*, void*, void*);
-    CheckBox(const char*, const char*, ButtonState*, int, int);
+    CheckBox(const char*, const char*, ButtonState*, intptr_t, intptr_t);
     CheckBox(const char*, const char*, ButtonState*, void*, void*);
     virtual ~CheckBox();
 
--- ivtools-1.2.11a1.orig/src/include/IV-2_6/InterViews/interactor.h
+++ ivtools-1.2.11a1/src/include/IV-2_6/InterViews/interactor.h
@@ -135,8 +135,8 @@ protected:
     Perspective* perspective;		/* portion displayed */
     Coord xmax;				/* canvas->Width() - 1 */
     Coord ymax;				/* canvas->Height() - 1 */
-    Sensor* input;			/* normal input event interest */
-    Painter* output;			/* normal output parameters */
+    Sensor* input_;			/* normal input event interest */
+    Painter* output_;			/* normal output parameters */
 
     virtual void Redraw(Coord left, Coord bottom, Coord right, Coord top);
     virtual void RedrawList(int n, Coord[], Coord[], Coord[], Coord[]);
--- ivtools-1.2.11a1.orig/src/include/IV-look/ol_kit.h
+++ ivtools-1.2.11a1/src/include/IV-look/ol_kit.h
@@ -35,7 +35,7 @@ class OLKit : public WidgetKit {
  *  OpenLook ==> WidgetKit mappings:
  *
  *    exclusive setting	      ==>  radio_button
- *    non-exclusive setting   ==>  pallette_button
+ *    non-exclusive setting   ==>  palette_button
  *    exclusive menu setting  ==>  radio_menu_item
  *    non-exclusive setting   ==>  radio_menu_item(*)
  *    scrolling button	      ==>  {up,down,left,down}_mover
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/big_checkmark.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/big_checkmark.bm
@@ -1,6 +1,6 @@
 #define checkmark_width 16
 #define checkmark_height 16
-static char checkmark_bits[] = {
+static unsigned char checkmark_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x18,
    0x00, 0x0c, 0x00, 0x06, 0x18, 0x03, 0xbe, 0x01, 0xfc, 0x01, 0xf8, 0x00,
    0xf0, 0x00, 0x60, 0x00, 0x40, 0x00, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/checkmark.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/checkmark.bm
@@ -2,5 +2,5 @@
 #define checkmark_height 12
 #define checkmark_x_hot 0
 #define checkmark_y_hot 9
-static char checkmark_bits[] = {
+static unsigned char checkmark_bits[] = {
    0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x32, 0x1f, 0x1f, 0x1e, 0x0c, 0x08};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/chkbox.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkbox.bm
@@ -2,7 +2,7 @@
 #define checkbox_plain_height 16
 #define checkbox_plain_x_hot 0
 #define checkbox_plain_y_hot 11
-static char checkbox_plain_bits[] = {
+static unsigned char checkbox_plain_bits[] = {
    0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40,
    0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40,
    0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/chkboxBoth.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxBoth.bm
@@ -2,7 +2,7 @@
 #define checkbox_both_height 16
 #define checkbox_both_x_hot 0
 #define checkbox_both_y_hot 11
-static char checkbox_both_bits[] = {
+static unsigned char checkbox_both_bits[] = {
    0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x36, 0x6c, 0x76, 0x6e,
    0xe6, 0x67, 0xc6, 0x63, 0xc6, 0x63, 0xe6, 0x67, 0x76, 0x6e, 0x36, 0x6c,
    0x06, 0x60, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/chkboxChosen.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxChosen.bm
@@ -2,7 +2,7 @@
 #define checkbox_chosen_height 16
 #define checkbox_chosen_x_hot 0
 #define checkbox_chosen_y_hot 11
-static char checkbox_chosen_bits[] = {
+static unsigned char checkbox_chosen_bits[] = {
    0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0x32, 0x4c, 0x72, 0x4e,
    0xe2, 0x47, 0xc2, 0x43, 0xc2, 0x43, 0xe2, 0x47, 0x72, 0x4e, 0x32, 0x4c,
    0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/chkboxHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/chkboxHit.bm
@@ -2,7 +2,7 @@
 #define checkbox_hit_height 16
 #define checkbox_hit_x_hot 0
 #define checkbox_hit_y_hot 11
-static char checkbox_hit_bits[] = {
+static unsigned char checkbox_hit_bits[] = {
    0x00, 0x00, 0xfe, 0x7f, 0xfe, 0x7f, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60,
    0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60, 0x06, 0x60,
    0x06, 0x60, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/dfast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dfast.bm
@@ -2,7 +2,7 @@
 #define dfast_height 16
 #define dfast_x_hot 8
 #define dfast_y_hot 7
-static char dfast_bits[] = {
+static unsigned char dfast_bits[] = {
    0x00, 0x00, 0xfc, 0x7f, 0x08, 0x20, 0x10, 0x10, 0x20, 0x08, 0x40, 0x04,
    0x80, 0x02, 0x00, 0x01, 0xfc, 0x7f, 0x08, 0x20, 0x10, 0x10, 0x20, 0x08,
    0x40, 0x04, 0x80, 0x02, 0x00, 0x01, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/dfastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dfastMask.bm
@@ -2,7 +2,7 @@
 #define dfast_mask_height 16
 #define dfast_mask_x_hot 8
 #define dfast_mask_y_hot 7
-static char dfast_mask_bits[] = {
+static unsigned char dfast_mask_bits[] = {
    0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
    0xc0, 0x07, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x1f,
    0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03, 0x00, 0x01};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/dmover.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmover.bm
@@ -2,6 +2,6 @@
 #define dmover_plain_height 11
 #define dmover_plain_x_hot 5
 #define dmover_plain_y_hot 5
-static char dmover_plain_bits[] = {
+static unsigned char dmover_plain_bits[] = {
    0x00, 0x00, 0xf8, 0x00, 0x88, 0x01, 0x88, 0x01, 0x8e, 0x03, 0x02, 0x06,
    0x04, 0x07, 0x88, 0x03, 0xd0, 0x01, 0xe0, 0x00, 0x40, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/dmoverHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmoverHit.bm
@@ -2,6 +2,6 @@
 #define dmover_hit_height 11
 #define dmover_hit_x_hot 6
 #define dmover_hit_y_hot 6
-static char dmover_hit_bits[] = {
+static unsigned char dmover_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x10, 0x01, 0x10, 0x01, 0x1c, 0x07,
    0x04, 0x04, 0x08, 0x02, 0x10, 0x01, 0xa0, 0x00, 0x40, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/dmoverMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/dmoverMask.bm
@@ -2,6 +2,6 @@
 #define dmover_mask_height 11
 #define dmover_mask_x_hot 6
 #define dmover_mask_y_hot 6
-static char dmover_mask_bits[] = {
+static unsigned char dmover_mask_bits[] = {
    0x00, 0x00, 0xf8, 0x00, 0xf8, 0x01, 0xf8, 0x01, 0xfe, 0x03, 0xfe, 0x07,
    0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0x40, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/enlarge.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlarge.bm
@@ -2,7 +2,7 @@
 #define enlarger_plain_height 15
 #define enlarger_plain_x_hot 12
 #define enlarger_plain_y_hot 6
-static char enlarger_plain_bits[] = {
+static unsigned char enlarger_plain_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x38, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x80, 0x01, 0x03, 0x00,
    0x60, 0x00, 0x0c, 0x00, 0x18, 0x00, 0x30, 0x00, 0xf8, 0x01, 0x3f, 0x00,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/enlargeHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlargeHit.bm
@@ -2,7 +2,7 @@
 #define enlarger_hit_height 15
 #define enlarger_hit_x_hot 12
 #define enlarger_hit_y_hot 5
-static char enlarger_hit_bits[] = {
+static unsigned char enlarger_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
    0x00, 0xee, 0x00, 0x00, 0xc0, 0x01, 0x07, 0x00, 0x30, 0x00, 0x18, 0x00,
    0xf0, 0x83, 0x1f, 0x00, 0x10, 0x01, 0x11, 0x00, 0xf0, 0xff, 0x1f, 0x00,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/enlargeMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/enlargeMask.bm
@@ -2,7 +2,7 @@
 #define enlarger_mask_height 15
 #define enlarger_mask_x_hot 12
 #define enlarger_mask_y_hot 6
-static char enlarger_mask_bits[] = {
+static unsigned char enlarger_mask_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
    0x00, 0xfe, 0x00, 0x00, 0xc0, 0xff, 0x07, 0x00, 0xf0, 0xff, 0x1f, 0x00,
    0xf0, 0xff, 0x1f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/hand.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/hand.bm
@@ -2,7 +2,7 @@
 #define hand_height 16
 #define hand_x_hot 8
 #define hand_y_hot 8
-static char hand_bits[] = {
+static unsigned char hand_bits[] = {
    0x80, 0x00, 0x40, 0x09, 0x48, 0x16, 0x54, 0x12, 0x54, 0x12, 0x64, 0x52,
    0x64, 0xb2, 0x68, 0xb2, 0x48, 0x92, 0x4a, 0x92, 0x15, 0x80, 0x19, 0x40,
    0x12, 0x40, 0x04, 0x40, 0x08, 0x20, 0x10, 0x20};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/handMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/handMask.bm
@@ -2,7 +2,7 @@
 #define hand_mask_height 16
 #define hand_mask_x_hot 8
 #define hand_mask_y_hot 8
-static char hand_mask_bits[] = {
+static unsigned char hand_mask_bits[] = {
    0x80, 0x00, 0xc0, 0x09, 0xc8, 0x1f, 0xdc, 0x1f, 0xdc, 0x1f, 0xfc, 0x5f,
    0xfc, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xfa, 0xff, 0xf7, 0xff, 0xff, 0x7f,
    0xfe, 0x7f, 0xfc, 0x7f, 0xf8, 0x3f, 0xf0, 0x3f};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/ldfast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ldfast.bm
@@ -2,7 +2,7 @@
 #define ldfast_height 16
 #define ldfast_x_hot 6
 #define ldfast_y_hot 9
-static char ldfast_bits[] = {
+static unsigned char ldfast_bits[] = {
    0x00, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0x01, 0x40, 0x02, 0x40, 0x04,
    0x42, 0x08, 0x46, 0x10, 0x4a, 0x20, 0xd2, 0x7f, 0x22, 0x00, 0x42, 0x00,
    0x82, 0x00, 0x02, 0x01, 0xfe, 0x03, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/ldfastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ldfastMask.bm
@@ -2,7 +2,7 @@
 #define ldfast_mask_height 16
 #define ldfast_mask_x_hot 6
 #define ldfast_mask_y_hot 9
-static char ldfast_mask_bits[] = {
+static unsigned char ldfast_mask_bits[] = {
    0x60, 0x00, 0xe0, 0x00, 0xe0, 0x01, 0xe0, 0x03, 0xe0, 0x07, 0xe3, 0x0f,
    0xe7, 0x1f, 0xef, 0x3f, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
    0xff, 0x01, 0xff, 0x03, 0xff, 0x07, 0xff, 0x07};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lfast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lfast.bm
@@ -2,7 +2,7 @@
 #define lfast_height 16
 #define lfast_x_hot 8
 #define lfast_y_hot 7
-static char lfast_bits[] = {
+static unsigned char lfast_bits[] = {
    0x00, 0x00, 0x80, 0x40, 0xc0, 0x60, 0xa0, 0x50, 0x90, 0x48, 0x88, 0x44,
    0x84, 0x42, 0x82, 0x41, 0x84, 0x42, 0x88, 0x44, 0x90, 0x48, 0xa0, 0x50,
    0xc0, 0x60, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lfastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lfastMask.bm
@@ -2,7 +2,7 @@
 #define lfast_mask_height 16
 #define lfast_mask_x_hot 8
 #define lfast_mask_y_hot 7
-static char lfast_mask_bits[] = {
+static unsigned char lfast_mask_bits[] = {
    0x80, 0xc1, 0xc0, 0xe1, 0xe0, 0xf1, 0xf0, 0xf9, 0xf8, 0xfd, 0xfc, 0xff,
    0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfc, 0xff, 0xf8, 0xfd, 0xf0, 0xf9,
    0xe0, 0xf1, 0xc0, 0xe1, 0x80, 0xc1, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lmover.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmover.bm
@@ -2,6 +2,6 @@
 #define lmover_plain_height 11
 #define lmover_plain_x_hot 5
 #define lmover_plain_y_hot 5
-static char lmover_plain_bits[] = {
+static unsigned char lmover_plain_bits[] = {
    0x00, 0x00, 0x60, 0x00, 0x50, 0x00, 0xc8, 0x03, 0x04, 0x06, 0x02, 0x06,
    0x04, 0x06, 0xc8, 0x07, 0xd0, 0x07, 0xe0, 0x00, 0xc0, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lmoverHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmoverHit.bm
@@ -2,6 +2,6 @@
 #define lmover_hit_height 11
 #define lmover_hit_x_hot 6
 #define lmover_hit_y_hot 6
-static char lmover_hit_bits[] = {
+static unsigned char lmover_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0x90, 0x07, 0x08, 0x04,
    0x04, 0x04, 0x08, 0x04, 0x90, 0x07, 0xa0, 0x00, 0xc0, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lmoverMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lmoverMask.bm
@@ -2,6 +2,6 @@
 #define lmover_mask_height 11
 #define lmover_mask_x_hot 6
 #define lmover_mask_y_hot 5
-static char lmover_mask_bits[] = {
+static unsigned char lmover_mask_bits[] = {
    0x00, 0x00, 0x60, 0x00, 0x70, 0x00, 0xf8, 0x03, 0xfc, 0x07, 0xfe, 0x07,
    0xfc, 0x07, 0xf8, 0x07, 0xf0, 0x07, 0xe0, 0x00, 0xc0, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lufast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lufast.bm
@@ -2,7 +2,7 @@
 #define lufast_height 16
 #define lufast_x_hot 6
 #define lufast_y_hot 6
-static char lufast_bits[] = {
+static unsigned char lufast_bits[] = {
    0x00, 0x00, 0xfe, 0x03, 0x02, 0x01, 0x82, 0x00, 0x42, 0x00, 0x22, 0x00,
    0xd2, 0x7f, 0x4a, 0x20, 0x46, 0x10, 0x42, 0x08, 0x40, 0x04, 0x40, 0x02,
    0x40, 0x01, 0xc0, 0x00, 0x40, 0x00, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/lufastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/lufastMask.bm
@@ -2,7 +2,7 @@
 #define lufast_mask_height 16
 #define lufast_mask_x_hot 6
 #define lufast_mask_y_hot 6
-static char lufast_mask_bits[] = {
+static unsigned char lufast_mask_bits[] = {
    0xff, 0x07, 0xff, 0x07, 0xff, 0x03, 0xff, 0x01, 0xff, 0x00, 0xff, 0xff,
    0xff, 0xff, 0xff, 0x7f, 0xef, 0x3f, 0xe7, 0x1f, 0xe3, 0x0f, 0xe0, 0x07,
    0xe0, 0x03, 0xe0, 0x01, 0xe0, 0x00, 0x60, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/page.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/page.bm
@@ -2,7 +2,7 @@
 #define page_plain_height 30
 #define page_plain_x_hot 10
 #define page_plain_y_hot 21
-static char page_plain_bits[] = {
+static unsigned char page_plain_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x04, 0x18, 0x00,
    0x04, 0x28, 0x00, 0x04, 0x48, 0x00, 0x04, 0x88, 0x00, 0x04, 0x08, 0x01,
    0x04, 0x08, 0x02, 0x04, 0xf8, 0x07, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/pageBoth.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageBoth.bm
@@ -2,7 +2,7 @@
 #define page_both_height 30
 #define page_both_x_hot 10
 #define page_both_y_hot 21
-static char page_both_bits[] = {
+static unsigned char page_both_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0xfc, 0x3f, 0x00,
    0x0c, 0x7c, 0x00, 0x0c, 0xfc, 0x00, 0x0c, 0xfc, 0x01, 0x0c, 0xfc, 0x03,
    0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0x00, 0x06,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/pageChosen.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageChosen.bm
@@ -2,7 +2,7 @@
 #define page_chosen_height 30
 #define page_chosen_x_hot 10
 #define page_chosen_y_hot 21
-static char page_chosen_bits[] = {
+static unsigned char page_chosen_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0xfc, 0x3f, 0x00,
    0x0c, 0x6c, 0x00, 0x0c, 0xcc, 0x00, 0x0c, 0x8c, 0x01, 0x0c, 0x0c, 0x03,
    0x0c, 0x0c, 0x06, 0x0c, 0xfc, 0x07, 0x0c, 0xfc, 0x07, 0x0c, 0x00, 0x06,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/pageHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/pageHit.bm
@@ -2,7 +2,7 @@
 #define page_hit_height 30
 #define page_hit_x_hot 10
 #define page_hit_y_hot 21
-static char page_hit_bits[] = {
+static unsigned char page_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x04, 0x18, 0x00,
    0x04, 0x38, 0x00, 0x04, 0x78, 0x00, 0x04, 0xf8, 0x00, 0x04, 0xf8, 0x01,
    0x04, 0xf8, 0x03, 0x04, 0xf8, 0x07, 0x04, 0x00, 0x04, 0x04, 0x00, 0x04,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/radio.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radio.bm
@@ -2,6 +2,6 @@
 #define radio_plain_height 11
 #define radio_plain_x_hot 5
 #define radio_plain_y_hot 5
-static char radio_plain_bits[] = {
+static unsigned char radio_plain_bits[] = {
    0x70, 0x00, 0x8c, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x04, 0x01, 0x04,
    0x01, 0x04, 0x02, 0x02, 0x02, 0x02, 0x8c, 0x01, 0x70, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/radioBoth.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioBoth.bm
@@ -2,6 +2,6 @@
 #define radio_both_height 11
 #define radio_both_x_hot 5
 #define radio_both_y_hot 5
-static char radio_both_bits[] = {
+static unsigned char radio_both_bits[] = {
    0x70, 0x00, 0xfc, 0x01, 0x8e, 0x03, 0x76, 0x03, 0xfb, 0x06, 0xfb, 0x06,
    0xfb, 0x06, 0x76, 0x03, 0x8e, 0x03, 0xfc, 0x01, 0x70, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/radioChosen.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioChosen.bm
@@ -2,6 +2,6 @@
 #define radio_chosen_height 11
 #define radio_chosen_x_hot 5
 #define radio_chosen_y_hot 5
-static char radio_chosen_bits[] = {
+static unsigned char radio_chosen_bits[] = {
    0x70, 0x00, 0x8c, 0x01, 0x02, 0x02, 0x72, 0x02, 0xf9, 0x04, 0xf9, 0x04,
    0xf9, 0x04, 0x72, 0x02, 0x02, 0x02, 0x8c, 0x01, 0x70, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/radioHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioHit.bm
@@ -2,6 +2,6 @@
 #define radio_hit_height 11
 #define radio_hit_x_hot 5
 #define radio_hit_y_hot 5
-static char radio_hit_bits[] = {
+static unsigned char radio_hit_bits[] = {
    0x70, 0x00, 0xfc, 0x01, 0x8e, 0x03, 0x06, 0x03, 0x03, 0x06, 0x03, 0x06,
    0x03, 0x06, 0x06, 0x03, 0x8e, 0x03, 0xfc, 0x01, 0x70, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/radioMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/radioMask.bm
@@ -2,6 +2,6 @@
 #define radio_mask_height 11
 #define radio_mask_x_hot 5
 #define radio_mask_y_hot 5
-static char radio_mask_bits[] = {
+static unsigned char radio_mask_bits[] = {
    0x70, 0x00, 0xfc, 0x01, 0xfe, 0x03, 0xfe, 0x03, 0xff, 0x07, 0xff, 0x07,
    0xff, 0x07, 0xfe, 0x03, 0xfe, 0x03, 0xfc, 0x01, 0x70, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rdfast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rdfast.bm
@@ -2,7 +2,7 @@
 #define rdfast_height 16
 #define rdfast_x_hot 9
 #define rdfast_y_hot 9
-static char rdfast_bits[] = {
+static unsigned char rdfast_bits[] = {
    0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x02, 0x40, 0x02, 0x20, 0x02,
    0x10, 0x42, 0x08, 0x62, 0x04, 0x52, 0xfe, 0x4b, 0x00, 0x44, 0x00, 0x42,
    0x00, 0x41, 0x80, 0x40, 0xc0, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rdfastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rdfastMask.bm
@@ -2,7 +2,7 @@
 #define rdfast_mask_height 16
 #define rdfast_mask_x_hot 9
 #define rdfast_mask_y_hot 9
-static char rdfast_mask_bits[] = {
+static unsigned char rdfast_mask_bits[] = {
    0x00, 0x06, 0x00, 0x07, 0x80, 0x07, 0xc0, 0x07, 0xe0, 0x07, 0xf0, 0xc7,
    0xf8, 0xe7, 0xfc, 0xf7, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
    0x80, 0xff, 0xc0, 0xff, 0xe0, 0xff, 0xe0, 0xff};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/reducer.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducer.bm
@@ -2,7 +2,7 @@
 #define reducer_plain_height 15
 #define reducer_plain_x_hot 12
 #define reducer_plain_y_hot 5
-static char reducer_plain_bits[] = {
+static unsigned char reducer_plain_bits[] = {
    0x00, 0x7c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
    0xf8, 0x00, 0x3e, 0x00, 0x38, 0x00, 0x38, 0x00, 0xc8, 0x00, 0x26, 0x00,
    0x08, 0x83, 0x21, 0x00, 0x30, 0x6c, 0x18, 0x00, 0xc0, 0x10, 0x06, 0x00,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/reducerHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducerHit.bm
@@ -2,7 +2,7 @@
 #define reducer_hit_height 15
 #define reducer_hit_x_hot 12
 #define reducer_hit_y_hot 7
-static char reducer_hit_bits[] = {
+static unsigned char reducer_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00,
    0x80, 0x00, 0x02, 0x00, 0x40, 0x00, 0x04, 0x00, 0x3f, 0x00, 0xf8, 0x01,
    0x07, 0x00, 0xc0, 0x01, 0x19, 0x00, 0x30, 0x01, 0x61, 0x00, 0x0c, 0x01,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/reducerMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/reducerMask.bm
@@ -2,7 +2,7 @@
 #define reducer_mask_height 15
 #define reducer_mask_x_hot 12
 #define reducer_mask_y_hot 8
-static char reducer_mask_bits[] = {
+static unsigned char reducer_mask_bits[] = {
    0x00, 0x7c, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00,
    0xf8, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x01,
    0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x01,
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rfast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rfast.bm
@@ -2,7 +2,7 @@
 #define rfast_height 16
 #define rfast_x_hot 7
 #define rfast_y_hot 7
-static char rfast_bits[] = {
+static unsigned char rfast_bits[] = {
    0x00, 0x00, 0x02, 0x01, 0x06, 0x03, 0x0a, 0x05, 0x12, 0x09, 0x22, 0x11,
    0x42, 0x21, 0x82, 0x41, 0x42, 0x21, 0x22, 0x11, 0x12, 0x09, 0x0a, 0x05,
    0x06, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rfastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rfastMask.bm
@@ -2,7 +2,7 @@
 #define rfast_mask_height 16
 #define rfast_mask_x_hot 7
 #define rfast_mask_y_hot 7
-static char rfast_mask_bits[] = {
+static unsigned char rfast_mask_bits[] = {
    0x83, 0x01, 0x87, 0x03, 0x8f, 0x07, 0x9f, 0x0f, 0xbf, 0x1f, 0xff, 0x3f,
    0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff, 0x3f, 0xbf, 0x1f, 0x9f, 0x0f,
    0x8f, 0x07, 0x87, 0x03, 0x83, 0x01, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rmover.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmover.bm
@@ -2,6 +2,6 @@
 #define rmover_plain_height 11
 #define rmover_plain_x_hot 5
 #define rmover_plain_y_hot 5
-static char rmover_plain_bits[] = {
+static unsigned char rmover_plain_bits[] = {
    0x00, 0x00, 0x30, 0x00, 0x50, 0x00, 0x9e, 0x00, 0x02, 0x01, 0x02, 0x02,
    0x02, 0x07, 0x9e, 0x03, 0xdc, 0x01, 0xf0, 0x00, 0x60, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rmoverHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmoverHit.bm
@@ -2,6 +2,6 @@
 #define rmover_hit_height 11
 #define rmover_hit_x_hot 6
 #define rmover_hit_y_hot 6
-static char rmover_hit_bits[] = {
+static unsigned char rmover_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xa0, 0x00, 0x3c, 0x01, 0x04, 0x02,
    0x04, 0x04, 0x04, 0x02, 0x3c, 0x01, 0xa0, 0x00, 0x60, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rmoverMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rmoverMask.bm
@@ -2,6 +2,6 @@
 #define rmover_mask_height 11
 #define rmover_mask_x_hot 5
 #define rmover_mask_y_hot 5
-static char rmover_mask_bits[] = {
+static unsigned char rmover_mask_bits[] = {
    0x00, 0x00, 0x30, 0x00, 0x70, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0xfe, 0x03,
    0xfe, 0x07, 0xfe, 0x03, 0xfc, 0x01, 0xf0, 0x00, 0x60, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rufast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rufast.bm
@@ -2,7 +2,7 @@
 #define rufast_height 16
 #define rufast_x_hot 9
 #define rufast_y_hot 6
-static char rufast_bits[] = {
+static unsigned char rufast_bits[] = {
    0x00, 0x00, 0xc0, 0x7f, 0x80, 0x40, 0x00, 0x41, 0x00, 0x42, 0x00, 0x44,
    0xfe, 0x4b, 0x04, 0x52, 0x08, 0x62, 0x10, 0x42, 0x20, 0x02, 0x40, 0x02,
    0x80, 0x02, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/rufastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/rufastMask.bm
@@ -2,7 +2,7 @@
 #define rufast_mask_height 16
 #define rufast_mask_x_hot 9
 #define rufast_mask_y_hot 6
-static char rufast_mask_bits[] = {
+static unsigned char rufast_mask_bits[] = {
    0xe0, 0xff, 0xe0, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xff, 0xff, 0xff,
    0xff, 0xff, 0xfe, 0xff, 0xfc, 0xf7, 0xf8, 0xe7, 0xf0, 0xc7, 0xe0, 0x07,
    0xc0, 0x07, 0x80, 0x07, 0x00, 0x07, 0x00, 0x06};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/ufast.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ufast.bm
@@ -2,7 +2,7 @@
 #define ufast_height 16
 #define ufast_x_hot 8
 #define ufast_y_hot 8
-static char ufast_bits[] = {
+static unsigned char ufast_bits[] = {
    0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, 0x10,
    0x08, 0x20, 0xfc, 0x7f, 0x00, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08,
    0x10, 0x10, 0x08, 0x20, 0xfc, 0x7f, 0x00, 0x00};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/ufastMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/ufastMask.bm
@@ -2,7 +2,7 @@
 #define ufast_mask_height 16
 #define ufast_mask_x_hot 8
 #define ufast_mask_y_hot 8
-static char ufast_mask_bits[] = {
+static unsigned char ufast_mask_bits[] = {
    0x00, 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
    0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f,
    0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/umover.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umover.bm
@@ -2,6 +2,6 @@
 #define umover_plain_height 11
 #define umover_plain_x_hot 5
 #define umover_plain_y_hot 5
-static char umover_plain_bits[] = {
+static unsigned char umover_plain_bits[] = {
    0x00, 0x00, 0x20, 0x00, 0x50, 0x00, 0x88, 0x00, 0x04, 0x01, 0x02, 0x02,
    0x8e, 0x07, 0x88, 0x07, 0x88, 0x01, 0xf8, 0x01, 0xf0, 0x01};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/umoverHit.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umoverHit.bm
@@ -2,6 +2,6 @@
 #define umover_hit_height 11
 #define umover_hit_x_hot 6
 #define umover_hit_y_hot 6
-static char umover_hit_bits[] = {
+static unsigned char umover_hit_bits[] = {
    0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x10, 0x01, 0x08, 0x02,
    0x04, 0x04, 0x1c, 0x07, 0x10, 0x01, 0x10, 0x01, 0xf0, 0x01};
--- ivtools-1.2.11a1.orig/src/include/InterViews/Bitmaps/umoverMask.bm
+++ ivtools-1.2.11a1/src/include/InterViews/Bitmaps/umoverMask.bm
@@ -2,6 +2,6 @@
 #define umover_mask_height 11
 #define umover_mask_x_hot 5
 #define umover_mask_y_hot 5
-static char umover_mask_bits[] = {
+static unsigned char umover_mask_bits[] = {
    0x00, 0x00, 0x20, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xfe, 0x03,
    0xfe, 0x07, 0xf8, 0x07, 0xf8, 0x01, 0xf8, 0x01, 0xf0, 0x01};
--- ivtools-1.2.11a1.orig/src/include/InterViews/resource.h
+++ ivtools-1.2.11a1/src/include/InterViews/resource.h
@@ -29,6 +29,7 @@
 #ifndef iv_resource_h
 #define iv_resource_h
 
+#include <ignores.h>
 #include <InterViews/enter-scope.h>
 
 //: shared reference-counted objects.
--- ivtools-1.2.11a1.orig/src/include/Makefile.am
+++ ivtools-1.2.11a1/src/include/Makefile.am
@@ -112,6 +112,6 @@ IV-X11/Xundefs.h IV-X11/xevent.h IV-X11/
 IV-X11/xraster.h IV-X11/xdrag.h IV-X11/xfont.h IV-X11/xcursor.h		\
 IV-X11/Xlib.h IV-X11/xbitmap.h IV-X11/xselection.h IV-X11/Xutil.h	\
 ivstd/iosfwd ivstd/signal.h ivstd/string.h ivstd/leakchecker.h		\
-ivstd/version.h ivstd/malloc.h ivstd/stdio.h ivstd/math.h ivstd/nan.h	\
+ivstd/malloc.h ivstd/stdio.h ivstd/math.h ivstd/nan.h			\
 ivstd/iostream.h ivstd/fstream.h ivstd/osfcn.h ivstd/stdlib.h		\
 ivstd/stream.h
--- ivtools-1.2.11a1.orig/src/include/OS/math.h
+++ ivtools-1.2.11a1/src/include/OS/math.h
@@ -107,4 +107,20 @@ inline boolean Math::equal(double x, dou
     return x - y < e && y - x < e;
 }
 
+#ifndef M_PI
+const double M_PI = 3.14159265358979323846;		// per CRC handbook, 14th. ed.
+#endif
+#ifndef M_PI_2
+const double M_PI_2 = (M_PI/2.0);				// PI/2
+#endif
+#ifndef M2_PI
+const double M2_PI = (M_PI*2.0);				// PI*2
+#endif
+
+inline float degrees(float rad) { return rad * (float)(180 / M_PI); }
+inline float radians(float deg) { return deg * (float)(M_PI / 180); }
+
+inline double degrees(double rad) { return rad * (180 / M_PI); }
+inline double radians(double deg) { return deg * (M_PI / 180); }
+
 #endif
--- ivtools-1.2.11a1.orig/src/include/OS/string.h
+++ ivtools-1.2.11a1/src/include/OS/string.h
@@ -29,6 +29,8 @@
  * String - simple (non-copying) string class
  */
 
+#include <ignores.h>
+#include <cstdio>
 #include <OS/enter-scope.h>
 
 #include <iosfwd>
--- ivtools-1.2.11a1.orig/src/include/TIFF/tiff.h
+++ ivtools-1.2.11a1/src/include/TIFF/tiff.h
@@ -198,7 +198,7 @@ typedef	enum {
 #define	TIFFTAG_PREDICTOR		317	/* prediction scheme w/ LZW */
 #define	TIFFTAG_WHITEPOINT		318	/* image white point */
 #define	TIFFTAG_PRIMARYCHROMATICITIES	319	/* !primary chromaticities */
-#define	TIFFTAG_COLORMAP		320	/* RGB map for pallette image */
+#define	TIFFTAG_COLORMAP		320	/* RGB map for palette image */
 #define	TIFFTAG_HALFTONEHINTS		321	/* !highlight+shadow info */
 #define	TIFFTAG_TILEWIDTH		322	/* !rows/data tile */
 #define	TIFFTAG_TILELENGTH		323	/* !cols/data tile */
--- ivtools-1.2.11a1.orig/src/include/Unidraw/Graphic/geomobjs.h
+++ ivtools-1.2.11a1/src/include/Unidraw/Graphic/geomobjs.h
@@ -28,6 +28,8 @@
 #ifndef unidraw_graphic_geomobjs_h
 #define unidraw_graphic_geomobjs_h
 
+#include <cstdio>
+
 #include <IV-2_6/InterViews/defs.h>
 #include <Unidraw/enter-scope.h>
 #include <InterViews/resource.h>
--- ivtools-1.2.11a1.orig/src/include/Unidraw/Graphic/graphic.h
+++ ivtools-1.2.11a1/src/include/Unidraw/Graphic/graphic.h
@@ -171,7 +171,7 @@ public:
     virtual void uncacheChildren();
     virtual void invalidateCaches();
 /*
- * Graphics state concatentation operations.
+ * Graphics state concatenation operations.
  */
 public:
     virtual void concatGS(Graphic* a, Graphic* b, Graphic* dest);
--- ivtools-1.2.11a1.orig/src/include/Unidraw/Graphic/util.h
+++ ivtools-1.2.11a1/src/include/Unidraw/Graphic/util.h
@@ -25,7 +25,7 @@
  */
 
 #ifndef unidraw_graphic_util_h
-#define unidraw_util_h
+#define unidraw_graphic_util_h
 
 #include <IV-2_6/InterViews/defs.h>
 #include <Unidraw/enter-scope.h>
@@ -43,11 +43,8 @@ inline void exch (int& a, int& b) {
 inline int square(int a) { return a *= a; }
 inline float square(float a) { return a *= a; }
 
-inline float degrees(float rad) { return rad * 180.0 / M_PI; }
-inline float radians(float deg) { return deg * M_PI / 180.0; }
-
 inline float Distance(Coord x0, Coord y0, Coord x1, Coord y1) {
-    return sqrt(float(square(x0 - x1) + square(y0 - y1)));
+    return hypotf(x0 - x1, y0 - y1);
 }
 
 inline void ArrayCopy (
--- ivtools-1.2.11a1.orig/src/include/Unidraw/catalog.h
+++ ivtools-1.2.11a1/src/include/Unidraw/catalog.h
@@ -27,6 +27,7 @@
 #ifndef unidraw_catalog_h
 #define unidraw_catalog_h
 
+#include <inttypes.h>
 #include <Unidraw/classes.h>
 #include <Unidraw/uformat.h>
 #include <Unidraw/uhash.h>
@@ -248,18 +249,18 @@ class ObjectMap : public UMap {
 public:
     ObjectMap(void* client, ClassId clientId);
 
-    void Register(void* obj, int id);
+    void Register(void* obj, intptr_t id);
     void Register(
-        void* obj, int id, ClassId orig_id, const char* delim,
+        void* obj, intptr_t id, ClassId orig_id, const char* delim,
         UArray* extra_data
     );
     void Unregister(void* obj);
-    void Unregister(int id);
+    void Unregister(intptr_t id);
 
     void* GetClient();
     ClassId GetClientId();
 
-    void* GetObject(int id);
+    void* GetObject(intptr_t id);
     unsigned long GetId(void* obj);
 
     ClassId GetOrigClassId(void* obj);
@@ -267,7 +268,7 @@ public:
     UArray* GetExtraData(void* obj);
 protected:
     ObjectMapElem* Find(void*);
-    ObjectMapElem* Find(int);
+    ObjectMapElem* Find(intptr_t);
 protected:
     UHashTable _objKeys, _idKeys;
     void* _client;
--- ivtools-1.2.11a1.orig/src/include/Unidraw/globals.h
+++ ivtools-1.2.11a1/src/include/Unidraw/globals.h
@@ -27,6 +27,8 @@
 #ifndef unidraw_globals_h
 #define unidraw_globals_h
 
+#include <ignores.h>
+
 #include <IV-2_6/InterViews/defs.h>
 #include <Unidraw/enter-scope.h>
 
--- /dev/null
+++ ivtools-1.2.11a1/src/include/ivstd/fstream
@@ -0,0 +1,1571 @@
+#if  !defined(__APPLE_CC__) || __APPLE_CC__==1
+#include_next <fstream>
+#else
+// -*- C++ -*-
+//===------------------------- fstream ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FSTREAM
+#define _LIBCPP_FSTREAM
+
+/*
+    fstream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_filebuf
+    : public basic_streambuf<charT, traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.9.1.2 Constructors/destructor:
+    basic_filebuf();
+    basic_filebuf(basic_filebuf&& rhs);
+    virtual ~basic_filebuf();
+
+    // 27.9.1.3 Assign/swap:
+    basic_filebuf& operator=(basic_filebuf&& rhs);
+    void swap(basic_filebuf& rhs);
+
+    // 27.9.1.4 Members:
+    bool is_open() const;
+    basic_filebuf* open(const char* s, ios_base::openmode mode);
+    basic_filebuf* open(const string& s, ios_base::openmode mode);
+    basic_filebuf* open(FILE* fp, ios_base::openmode mode);
+    basic_filebuf* close();
+
+protected:
+    // 27.9.1.5 Overridden virtual functions:
+    virtual streamsize showmanyc();
+    virtual int_type underflow();
+    virtual int_type uflow();
+    virtual int_type pbackfail(int_type c = traits_type::eof());
+    virtual int_type overflow (int_type c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* s, streamsize n);
+    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type sp,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual int sync();
+    virtual void imbue(const locale& loc);
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+typedef basic_filebuf<char>    filebuf;
+typedef basic_filebuf<wchar_t> wfilebuf;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ifstream
+    : public basic_istream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ifstream();
+    explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+    explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+    basic_ifstream(basic_ifstream&& rhs);
+
+    basic_ifstream& operator=(basic_ifstream&& rhs);
+    void swap(basic_ifstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* s, ios_base::openmode mode = ios_base::in);
+    void open(const string& s, ios_base::openmode mode = ios_base::in);
+    void open(FILE* fp, ios_base::openmode mode = ios_base::in);
+    void close();
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+typedef basic_ifstream<char>    ifstream;
+typedef basic_ifstream<wchar_t> wifstream;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ofstream
+    : public basic_ostream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ofstream();
+    explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+    explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+    basic_ofstream(basic_ofstream&& rhs);
+
+    basic_ofstream& operator=(basic_ofstream&& rhs);
+    void swap(basic_ofstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* s, ios_base::openmode mode = ios_base::out);
+    void open(const string& s, ios_base::openmode mode = ios_base::out);
+    void open(FILE* fp, ios_base::openmode mode = ios_base::out);
+    void close();
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+typedef basic_ofstream<char>    ofstream;
+typedef basic_ofstream<wchar_t> wofstream;
+
+template <class charT, class traits=char_traits<charT> >
+class basic_fstream
+    : public basic_iostream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_fstream();
+    explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    explicit basic_fstream(FILE* fp, ios_base::openmode mode = ios_base::in|ios_base::out);
+    basic_fstream(basic_fstream&& rhs);
+
+    basic_fstream& operator=(basic_fstream&& rhs);
+    void swap(basic_fstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    void open(FILE* fp, ios_base::openmode mode = ios_base::in|ios_base::out);
+    void close();
+};
+
+template <class charT, class traits>
+  void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+typedef basic_fstream<char>    fstream;
+typedef basic_fstream<wchar_t> wfstream;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ostream>
+#include <istream>
+#include <__locale>
+#include <cstdio>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_filebuf
+    : public basic_streambuf<_CharT, _Traits>
+{
+public:
+    typedef _CharT                           char_type;
+    typedef _Traits                          traits_type;
+    typedef typename traits_type::int_type   int_type;
+    typedef typename traits_type::pos_type   pos_type;
+    typedef typename traits_type::off_type   off_type;
+    typedef typename traits_type::state_type state_type;
+
+    // 27.9.1.2 Constructors/destructor:
+    basic_filebuf();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_filebuf(basic_filebuf&& __rhs);
+#endif
+    virtual ~basic_filebuf();
+
+    // 27.9.1.3 Assign/swap:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_filebuf& operator=(basic_filebuf&& __rhs);
+#endif
+    void swap(basic_filebuf& __rhs);
+
+    // 27.9.1.4 Members:
+    bool is_open() const;
+    basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+    basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+    basic_filebuf* open(FILE* fd, ios_base::openmode __mode);
+    basic_filebuf* close();
+
+protected:
+    // 27.9.1.5 Overridden virtual functions:
+    virtual int_type underflow();
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+    virtual int_type overflow (int_type __c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual int sync();
+    virtual void imbue(const locale& __loc);
+
+private:
+    int __fpflag;
+    char*       __extbuf_;
+    const char* __extbufnext_;
+    const char* __extbufend_;
+    char __extbuf_min_[8];
+    size_t __ebs_;
+    char_type* __intbuf_;
+    size_t __ibs_;
+    FILE* __file_;
+    const codecvt<char_type, char, state_type>* __cv_;
+    state_type __st_;
+    state_type __st_last_;
+    ios_base::openmode __om_;
+    ios_base::openmode __cm_;
+    bool __owns_eb_;
+    bool __owns_ib_;
+    bool __always_noconv_;
+
+    bool __read_mode();
+    void __write_mode();
+};
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf()
+    : __fpflag(0),
+      __extbuf_(0),
+      __extbufnext_(0),
+      __extbufend_(0),
+      __ebs_(0),
+      __intbuf_(0),
+      __ibs_(0),
+      __file_(0),
+      __cv_(nullptr),
+      __st_(),
+      __st_last_(),
+      __om_(0),
+      __cm_(0),
+      __owns_eb_(false),
+      __owns_ib_(false),
+      __always_noconv_(false)
+{
+    if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
+    {
+        __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
+        __always_noconv_ = __cv_->always_noconv();
+    }
+    setbuf(0, 4096);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
+    : basic_streambuf<_CharT, _Traits>(__rhs)
+{
+    if (__rhs.__extbuf_ == __rhs.__extbuf_min_)
+    {
+        __extbuf_ = __extbuf_min_;
+        __extbufnext_ = __extbuf_ + (__rhs.__extbufnext_ - __rhs.__extbuf_);
+        __extbufend_ = __extbuf_ + (__rhs.__extbufend_ - __rhs.__extbuf_);
+    }
+    else
+    {
+        __extbuf_ = __rhs.__extbuf_;
+        __extbufnext_ = __rhs.__extbufnext_;
+        __extbufend_ = __rhs.__extbufend_;
+    }
+    __ebs_ = __rhs.__ebs_;
+    __intbuf_ = __rhs.__intbuf_;
+    __ibs_ = __rhs.__ibs_;
+    __file_ = __rhs.__file_;
+    __cv_ = __rhs.__cv_;
+    __st_ = __rhs.__st_;
+    __st_last_ = __rhs.__st_last_;
+    __om_ = __rhs.__om_;
+    __cm_ = __rhs.__cm_;
+    __owns_eb_ = __rhs.__owns_eb_;
+    __owns_ib_ = __rhs.__owns_ib_;
+    __always_noconv_ = __rhs.__always_noconv_;
+    if (__rhs.pbase())
+    {
+        if (__rhs.pbase() == __rhs.__intbuf_)
+            this->setp(__intbuf_, __intbuf_ + (__rhs. epptr() - __rhs.pbase()));
+        else
+            this->setp((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
+        this->pbump(__rhs. pptr() - __rhs.pbase());
+    }
+    else if (__rhs.eback())
+    {
+        if (__rhs.eback() == __rhs.__intbuf_)
+            this->setg(__intbuf_, __intbuf_ + (__rhs.gptr() - __rhs.eback()),
+                                  __intbuf_ + (__rhs.egptr() - __rhs.eback()));
+        else
+            this->setg((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
+                       (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
+    }
+    __rhs.__extbuf_ = 0;
+    __rhs.__extbufnext_ = 0;
+    __rhs.__extbufend_ = 0;
+    __rhs.__ebs_ = 0;
+    __rhs.__intbuf_ = 0;
+    __rhs.__ibs_ = 0;
+    __rhs.__file_ = 0;
+    __rhs.__st_ = state_type();
+    __rhs.__st_last_ = state_type();
+    __rhs.__om_ = 0;
+    __rhs.__cm_ = 0;
+    __rhs.__owns_eb_ = false;
+    __rhs.__owns_ib_ = false;
+    __rhs.setg(0, 0, 0);
+    __rhs.setp(0, 0);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>&
+basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
+{
+    close();
+    swap(__rhs);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::~basic_filebuf()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        close();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
+{
+    basic_streambuf<char_type, traits_type>::swap(__rhs);
+    if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+    {
+        _VSTD::swap(__extbuf_, __rhs.__extbuf_);
+        _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
+        _VSTD::swap(__extbufend_, __rhs.__extbufend_);
+    }
+    else
+    {
+        ptrdiff_t __ln = __extbufnext_ - __extbuf_;
+        ptrdiff_t __le = __extbufend_ - __extbuf_;
+        ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
+        ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
+        if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+        {
+            __extbuf_ = __rhs.__extbuf_;
+            __rhs.__extbuf_ = __rhs.__extbuf_min_;
+        }
+        else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
+        {
+            __rhs.__extbuf_ = __extbuf_;
+            __extbuf_ = __extbuf_min_;
+        }
+        __extbufnext_ = __extbuf_ + __rn;
+        __extbufend_ = __extbuf_ + __re;
+        __rhs.__extbufnext_ = __rhs.__extbuf_ + __ln;
+        __rhs.__extbufend_ = __rhs.__extbuf_ + __le;
+    }
+    _VSTD::swap(__ebs_, __rhs.__ebs_);
+    _VSTD::swap(__intbuf_, __rhs.__intbuf_);
+    _VSTD::swap(__ibs_, __rhs.__ibs_);
+    _VSTD::swap(__file_, __rhs.__file_);
+    _VSTD::swap(__cv_, __rhs.__cv_);
+    _VSTD::swap(__st_, __rhs.__st_);
+    _VSTD::swap(__st_last_, __rhs.__st_last_);
+    _VSTD::swap(__om_, __rhs.__om_);
+    _VSTD::swap(__cm_, __rhs.__cm_);
+    _VSTD::swap(__owns_eb_, __rhs.__owns_eb_);
+    _VSTD::swap(__owns_ib_, __rhs.__owns_ib_);
+    _VSTD::swap(__always_noconv_, __rhs.__always_noconv_);
+    if (this->eback() == (char_type*)__rhs.__extbuf_min_)
+    {
+        ptrdiff_t __n = this->gptr() - this->eback();
+        ptrdiff_t __e = this->egptr() - this->eback();
+        this->setg((char_type*)__extbuf_min_,
+                   (char_type*)__extbuf_min_ + __n,
+                   (char_type*)__extbuf_min_ + __e);
+    }
+    else if (this->pbase() == (char_type*)__rhs.__extbuf_min_)
+    {
+        ptrdiff_t __n = this->pptr() - this->pbase();
+        ptrdiff_t __e = this->epptr() - this->pbase();
+        this->setp((char_type*)__extbuf_min_,
+                   (char_type*)__extbuf_min_ + __e);
+        this->pbump(__n);
+    }
+    if (__rhs.eback() == (char_type*)__extbuf_min_)
+    {
+        ptrdiff_t __n = __rhs.gptr() - __rhs.eback();
+        ptrdiff_t __e = __rhs.egptr() - __rhs.eback();
+        __rhs.setg((char_type*)__rhs.__extbuf_min_,
+                   (char_type*)__rhs.__extbuf_min_ + __n,
+                   (char_type*)__rhs.__extbuf_min_ + __e);
+    }
+    else if (__rhs.pbase() == (char_type*)__extbuf_min_)
+    {
+        ptrdiff_t __n = __rhs.pptr() - __rhs.pbase();
+        ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
+        __rhs.setp((char_type*)__rhs.__extbuf_min_,
+                   (char_type*)__rhs.__extbuf_min_ + __e);
+        __rhs.pbump(__n);
+    }
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_filebuf<_CharT, _Traits>::is_open() const
+{
+    return __file_ != 0;
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    basic_filebuf<_CharT, _Traits>* __rt = 0;
+    if (__file_ == 0)
+    {
+        __rt = this;
+        const char* __mdstr;
+        switch (__mode & ~ios_base::ate)
+        {
+        case ios_base::out:
+        case ios_base::out | ios_base::trunc:
+            __mdstr = "w";
+            break;
+        case ios_base::out | ios_base::app:
+        case ios_base::app:
+            __mdstr = "a";
+            break;
+        case ios_base::in:
+            __mdstr = "r";
+            break;
+        case ios_base::in | ios_base::out:
+            __mdstr = "r+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc:
+            __mdstr = "w+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app:
+        case ios_base::in | ios_base::app:
+            __mdstr = "a+";
+            break;
+        case ios_base::out | ios_base::binary:
+        case ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "wb";
+            break;
+        case ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::app | ios_base::binary:
+            __mdstr = "ab";
+            break;
+        case ios_base::in | ios_base::binary:
+            __mdstr = "rb";
+            break;
+        case ios_base::in | ios_base::out | ios_base::binary:
+            __mdstr = "r+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "w+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::in | ios_base::app | ios_base::binary:
+            __mdstr = "a+b";
+            break;
+        default:
+            __rt = 0;
+            break;
+        }
+        if (__rt)
+        {
+            __file_ = fopen(__s, __mdstr);
+            if (__file_)
+            {
+                __om_ = __mode;
+                if (__mode & ios_base::ate)
+                {
+                    if (fseek(__file_, 0, SEEK_END))
+                    {
+                        fclose(__file_);
+                        __file_ = 0;
+                        __rt = 0;
+                    }
+                }
+            }
+            else
+                __rt = 0;
+        }
+    }
+    return __rt;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    return open(__s.c_str(), __mode);
+}
+
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(FILE* fp, ios_base::openmode __mode)
+{
+    basic_filebuf<_CharT, _Traits>* __rt = 0;
+    if (__file_ == 0)
+    {
+        __rt = this;
+        const char* __mdstr;
+        switch (__mode & ~ios_base::ate)
+        {
+        case ios_base::out:
+        case ios_base::out | ios_base::trunc:
+            __mdstr = "w";
+            break;
+        case ios_base::out | ios_base::app:
+        case ios_base::app:
+            __mdstr = "a";
+            break;
+        case ios_base::in:
+            __mdstr = "r";
+            break;
+        case ios_base::in | ios_base::out:
+            __mdstr = "r+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc:
+            __mdstr = "w+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app:
+        case ios_base::in | ios_base::app:
+            __mdstr = "a+";
+            break;
+        case ios_base::out | ios_base::binary:
+        case ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "wb";
+            break;
+        case ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::app | ios_base::binary:
+            __mdstr = "ab";
+            break;
+        case ios_base::in | ios_base::binary:
+            __mdstr = "rb";
+            break;
+        case ios_base::in | ios_base::out | ios_base::binary:
+            __mdstr = "r+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "w+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::in | ios_base::app | ios_base::binary:
+            __mdstr = "a+b";
+            break;
+        default:
+            __rt = 0;
+            break;
+        }
+        if (__rt)
+        {
+            __file_ = fp;
+            __fpflag = 1;
+            if (__file_)
+            {
+                __om_ = __mode;
+                if (__mode & ios_base::ate)
+                {
+                    if (fseek(__file_, 0, SEEK_END))
+                    {
+                        fclose(__file_);
+                        __file_ = 0;
+                        __rt = 0;
+                    }
+                }
+            }
+            else
+                __rt = 0;
+        }
+    }
+    return __rt;
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::close()
+{
+    basic_filebuf<_CharT, _Traits>* __rt = 0;
+    if (__file_ && !__fpflag)
+    {
+        __rt = this;
+        unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
+        if (sync())
+            __rt = 0;
+        if (fclose(__h.release()) == 0)
+            __file_ = 0;
+        else
+            __rt = 0;
+
+    } else {
+      __file_ = 0;
+      __rt = 0;
+    }
+    return __rt;
+}
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::underflow()
+{
+    if (__file_ == 0)
+        return traits_type::eof();
+    bool __initial = __read_mode();
+    char_type __1buf;
+    if (this->gptr() == 0)
+        this->setg(&__1buf, &__1buf+1, &__1buf+1);
+    const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
+    int_type __c = traits_type::eof();
+    if (this->gptr() == this->egptr())
+    {
+        memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+        if (__always_noconv_)
+        {
+            size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
+            __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
+            if (__nmemb != 0)
+            {
+                this->setg(this->eback(),
+                           this->eback() + __unget_sz,
+                           this->eback() + __unget_sz + __nmemb);
+                __c = traits_type::to_int_type(*this->gptr());
+            }
+        }
+        else
+        {
+            memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+            __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
+            __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
+            size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
+                                 static_cast<size_t>(__extbufend_ - __extbufnext_));
+            codecvt_base::result __r;
+            __st_last_ = __st_;
+            size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
+            if (__nr != 0)
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (!__cv_)
+                    throw bad_cast();
+#endif
+                __extbufend_ = __extbufnext_ + __nr;
+                char_type*  __inext;
+                __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
+                                       this->eback() + __unget_sz,
+                                       this->eback() + __ibs_, __inext);
+                if (__r == codecvt_base::noconv)
+                {
+                    this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
+                    __c = traits_type::to_int_type(*this->gptr());
+                }
+                else if (__inext != this->eback() + __unget_sz)
+                {
+                    this->setg(this->eback(), this->eback() + __unget_sz, __inext);
+                    __c = traits_type::to_int_type(*this->gptr());
+                }
+            }
+        }
+    }
+    else
+        __c = traits_type::to_int_type(*this->gptr());
+    if (this->eback() == &__1buf)
+        this->setg(0, 0, 0);
+    return __c;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c)
+{
+    if (__file_ && this->eback() < this->gptr())
+    {
+        if (traits_type::eq_int_type(__c, traits_type::eof()))
+        {
+            this->gbump(-1);
+            return traits_type::not_eof(__c);
+        }
+        if ((__om_ & ios_base::out) ||
+            traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+        {
+            this->gbump(-1);
+            *this->gptr() = traits_type::to_char_type(__c);
+            return __c;
+        }
+    }
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
+{
+    if (__file_ == 0)
+        return traits_type::eof();
+    __write_mode();
+    char_type __1buf;
+    char_type* __pb_save = this->pbase();
+    char_type* __epb_save = this->epptr();
+    if (!traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        if (this->pptr() == 0)
+            this->setp(&__1buf, &__1buf+1);
+        *this->pptr() = traits_type::to_char_type(__c);
+        this->pbump(1);
+    }
+    if (this->pptr() != this->pbase())
+    {
+        if (__always_noconv_)
+        {
+            size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+            if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
+                return traits_type::eof();
+        }
+        else
+        {
+            char* __extbe = __extbuf_;
+            codecvt_base::result __r;
+            do
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (!__cv_)
+                    throw bad_cast();
+#endif
+                const char_type* __e;
+                __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
+                                        __extbuf_, __extbuf_ + __ebs_, __extbe);
+                if (__e == this->pbase())
+                    return traits_type::eof();
+                if (__r == codecvt_base::noconv)
+                {
+                    size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+                    if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
+                        return traits_type::eof();
+                }
+                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+                {
+                    size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+                    if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+                        return traits_type::eof();
+                    if (__r == codecvt_base::partial)
+                    {
+                        this->setp((char_type*)__e, this->pptr());
+                        this->pbump(this->epptr() - this->pbase());
+                    }
+                }
+                else
+                    return traits_type::eof();
+            } while (__r == codecvt_base::partial);
+        }
+        this->setp(__pb_save, __epb_save);
+    }
+    return traits_type::not_eof(__c);
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
+{
+    this->setg(0, 0, 0);
+    this->setp(0, 0);
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+    __ebs_ = __n;
+    if (__ebs_ > sizeof(__extbuf_min_))
+    {
+        if (__always_noconv_ && __s)
+        {
+            __extbuf_ = (char*)__s;
+            __owns_eb_ = false;
+        }
+        else
+        {
+            __extbuf_ = new char[__ebs_];
+            __owns_eb_ = true;
+        }
+    }
+    else
+    {
+        __extbuf_ = __extbuf_min_;
+        __ebs_ = sizeof(__extbuf_min_);
+        __owns_eb_ = false;
+    }
+    if (!__always_noconv_)
+    {
+        __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
+        if (__s && __ibs_ >= sizeof(__extbuf_min_))
+        {
+            __intbuf_ = __s;
+            __owns_ib_ = false;
+        }
+        else
+        {
+            __intbuf_ = new char_type[__ibs_];
+            __owns_ib_ = true;
+        }
+    }
+    else
+    {
+        __ibs_ = 0;
+        __intbuf_ = 0;
+        __owns_ib_ = false;
+    }
+    return this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
+                                        ios_base::openmode)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!__cv_)
+        throw bad_cast();
+#endif
+    int __width = __cv_->encoding();
+    if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
+        return pos_type(off_type(-1));
+    // __width > 0 || __off == 0
+    int __whence;
+    switch (__way)
+    {
+    case ios_base::beg:
+        __whence = SEEK_SET;
+        break;
+    case ios_base::cur:
+        __whence = SEEK_CUR;
+        break;
+    case ios_base::end:
+        __whence = SEEK_END;
+        break;
+    default:
+        return pos_type(off_type(-1));
+    }
+#if _WIN32
+    if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
+        return pos_type(off_type(-1));
+    pos_type __r = ftell(__file_);
+#else
+    if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
+        return pos_type(off_type(-1));
+    pos_type __r = ftello(__file_);
+#endif
+    __r.state(__st_);
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
+{
+    if (__file_ == 0 || sync())
+        return pos_type(off_type(-1));
+#if _WIN32
+    if (fseek(__file_, __sp, SEEK_SET))
+        return pos_type(off_type(-1));
+#else
+    if (fseeko(__file_, __sp, SEEK_SET))
+        return pos_type(off_type(-1));
+#endif
+    __st_ = __sp.state();
+    return __sp;
+}
+
+template <class _CharT, class _Traits>
+int
+basic_filebuf<_CharT, _Traits>::sync()
+{
+    if (__file_ == 0)
+        return 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!__cv_)
+        throw bad_cast();
+#endif
+    if (__cm_ & ios_base::out)
+    {
+        if (this->pptr() != this->pbase())
+            if (overflow() == traits_type::eof())
+                return -1;
+        codecvt_base::result __r;
+        do
+        {
+            char* __extbe;
+            __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
+            size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+            if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+                return -1;
+        } while (__r == codecvt_base::partial);
+        if (__r == codecvt_base::error)
+            return -1;
+        if (fflush(__file_))
+            return -1;
+    }
+    else if (__cm_ & ios_base::in)
+    {
+        off_type __c;
+        state_type __state = __st_last_;
+        bool __update_st = false;
+        if (__always_noconv_)
+            __c = this->egptr() - this->gptr();
+        else
+        {
+            int __width = __cv_->encoding();
+            __c = __extbufend_ - __extbufnext_;
+            if (__width > 0)
+                __c += __width * (this->egptr() - this->gptr());
+            else
+            {
+                if (this->gptr() != this->egptr())
+                {
+                    const int __off =  __cv_->length(__state, __extbuf_,
+                                                     __extbufnext_,
+                                                     this->gptr() - this->eback());
+                    __c += __extbufnext_ - __extbuf_ - __off;
+                    __update_st = true;
+                }
+            }
+        }
+#if _WIN32
+        if (fseek(__file_, -__c, SEEK_CUR))
+            return -1;
+#else
+        if (fseeko(__file_, -__c, SEEK_CUR))
+            return -1;
+#endif
+        if (__update_st)
+            __st_ = __state;
+        __extbufnext_ = __extbufend_ = __extbuf_;
+        this->setg(0, 0, 0);
+        __cm_ = 0;
+    }
+    return 0;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
+{
+    sync();
+    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+    bool __old_anc = __always_noconv_;
+    __always_noconv_ = __cv_->always_noconv();
+    if (__old_anc != __always_noconv_)
+    {
+        this->setg(0, 0, 0);
+        this->setp(0, 0);
+        // invariant, char_type is char, else we couldn't get here
+        if (__always_noconv_)  // need to dump __intbuf_
+        {
+            if (__owns_eb_)
+                delete [] __extbuf_;
+            __owns_eb_ = __owns_ib_;
+            __ebs_ = __ibs_;
+            __extbuf_ = (char*)__intbuf_;
+            __ibs_ = 0;
+            __intbuf_ = 0;
+            __owns_ib_ = false;
+        }
+        else  // need to obtain an __intbuf_.
+        {     // If __extbuf_ is user-supplied, use it, else new __intbuf_
+            if (!__owns_eb_ && __extbuf_ != __extbuf_min_)
+            {
+                __ibs_ = __ebs_;
+                __intbuf_ = (char_type*)__extbuf_;
+                __owns_ib_ = false;
+                __extbuf_ = new char[__ebs_];
+                __owns_eb_ = true;
+            }
+            else
+            {
+                __ibs_ = __ebs_;
+                __intbuf_ = new char_type[__ibs_];
+                __owns_ib_ = true;
+            }
+        }
+    }
+}
+
+template <class _CharT, class _Traits>
+bool
+basic_filebuf<_CharT, _Traits>::__read_mode()
+{
+    if (!(__cm_ & ios_base::in))
+    {
+        this->setp(0, 0);
+        if (__always_noconv_)
+            this->setg((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + __ebs_,
+                       (char_type*)__extbuf_ + __ebs_);
+        else
+            this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
+        __cm_ = ios_base::in;
+        return true;
+    }
+    return false;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::__write_mode()
+{
+    if (!(__cm_ & ios_base::out))
+    {
+        this->setg(0, 0, 0);
+        if (__ebs_ > sizeof(__extbuf_min_))
+        {
+            if (__always_noconv_)
+                this->setp((char_type*)__extbuf_,
+                           (char_type*)__extbuf_ + (__ebs_ - 1));
+            else
+                this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
+        }
+        else
+            this->setp(0, 0);
+        __cm_ = ios_base::out;
+    }
+}
+
+// basic_ifstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ifstream
+    : public basic_istream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ifstream();
+    explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
+    explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ifstream(basic_ifstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ifstream& operator=(basic_ifstream&& __rhs);
+#endif
+    void swap(basic_ifstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* __s, ios_base::openmode __mode = ios_base::in);
+    void open(const string& __s, ios_base::openmode __mode = ios_base::in);
+    void open(int fd, ios_base::openmode __mode = ios_base::in);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream()
+    : basic_istream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
+    : basic_istream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode | ios_base::in) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
+    : basic_istream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode | ios_base::in) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
+    : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>&
+basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
+{
+    basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
+{
+    basic_istream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_ifstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_ifstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::in))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::in))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
+{
+    if (__sb_.open(fd, __mode | ios_base::in))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ifstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+// basic_ofstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ofstream
+    : public basic_ostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ofstream();
+    explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
+    explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ofstream(basic_ofstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ofstream& operator=(basic_ofstream&& __rhs);
+#endif
+    void swap(basic_ofstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* __s, ios_base::openmode __mode = ios_base::out);
+    void open(const string& __s, ios_base::openmode __mode = ios_base::out);
+    void open(int fd, ios_base::openmode __mode = ios_base::out);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream()
+    : basic_ostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
+    : basic_ostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode | ios_base::out) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
+    : basic_ostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode | ios_base::out) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
+    : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>&
+basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
+{
+    basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
+{
+    basic_ostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_ofstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_ofstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::out))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::out))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
+{
+    if (__sb_.open(fd, __mode | ios_base::out))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ofstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+// basic_fstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_fstream
+    : public basic_iostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_fstream();
+    explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    explicit basic_fstream(int fd, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_fstream(basic_fstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_fstream& operator=(basic_fstream&& __rhs);
+#endif
+    void swap(basic_fstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    void open(int fd, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream()
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(int fd, ios_base::openmode __mode)
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(fd, __mode) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
+    : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>&
+basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
+{
+    basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
+{
+    basic_iostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_fstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_fstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(int fd, ios_base::openmode __mode)
+{
+    if (__sb_.open(fd, __mode))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_fstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FSTREAM
+#endif  // defined(__APPLE__)
--- ivtools-1.2.11a1.orig/src/include/ivstd/fstream.h
+++ ivtools-1.2.11a1/src/include/ivstd/fstream.h
@@ -1,17 +1,27 @@
 #ifndef _iv_fstream_
 #define _iv_fstream_
-#include_next <fstream>
-#if __GNUC__>=3
+#include <fstream>
+#include <cstdio>
 #define input ios_base::in
 #define output ios_base::out
-#if __GNUC__>3 || __GNUC__==3 && __GNUC_MINOR__>0 /* && !defined(__APPLE__) */
+#if !defined(__APPLE_CC__) || __APPLE_CC__==1
 #include <ext/stdio_filebuf.h>
 #define fileptr_filebuf __gnu_cxx::stdio_filebuf<char>
 #else
 #define fileptr_filebuf filebuf
 #endif
+#if !defined(__APPLE_CC__) || __APPLE_CC__==1
+#define FILEBUF(bufname, fptr, mode)		\
+     fileptr_filebuf bufname(fptr, mode)
+#define FILEBUFP(bufname, fptr, mode)	\
+     fileptr_filebuf* bufname = new fileptr_filebuf(fptr, mode)
 #else
-#define input "r"
-#define output "w"
+#define FILEBUF(bufname, fptr, mode)		\
+     fileptr_filebuf bufname; \
+     bufname.open(fptr, mode); 
+#define FILEBUFP(bufname, fptr, mode) \
+     fileptr_filebuf* bufname = new fileptr_filebuf; \
+     bufname -> open(fptr,mode);
 #endif
+
 #endif
--- /dev/null
+++ ivtools-1.2.11a1/src/include/ivstd/ignores.h
@@ -0,0 +1,7 @@
+#ifdef __llvm__
+#pragma GCC diagnostic ignored "-Wdangling-else"
+#pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
+#pragma GCC diagnostic ignored "-Wparentheses"
+#pragma GCC diagnostic ignored "-Wformat-security"
+#endif
+
--- ivtools-1.2.11a1.orig/src/include/ivstd/iostream.h
+++ ivtools-1.2.11a1/src/include/ivstd/iostream.h
@@ -1,5 +1,6 @@
 #ifndef _iv_iostream_h_
 #define _iv_iostream_h_
+#include <cstdio>
 #include <iosfwd>
 #include_next <iostream>
 
--- ivtools-1.2.11a1.orig/src/include/ivstd/stdlib.h
+++ ivtools-1.2.11a1/src/include/ivstd/stdlib.h
@@ -1,5 +1,6 @@
 #ifndef _ivstd_stdlib
 #define _ivstd_stdlib
+#include <ignores.h>
 #if defined(__cplusplus)
 #include_next <stdlib.h>
 #else
--- ivtools-1.2.11a1.orig/src/man/man1/comdraw.1
+++ ivtools-1.2.11a1/src/man/man1/comdraw.1
@@ -1,9 +1,9 @@
 .TH COMDRAW 1 
-.SH COMDRAW
+.SH NAME
 comdraw \- drawtool with distributed command interpreter
 .SH SYNOPSIS
 .B comdraw 
-[-port n] [-import n] ['X-params'] [file]
+[\-port n] [\-import n] ['X-params'] [file]
 .SH DESCRIPTION
 comdraw is a drawing editor with integrated command interpreter the
 user can interact with via stdin and stdout (or via telnet if ACE is
@@ -93,6 +93,8 @@ graphical object assigned to an interpre
  val=at(list|attrlist|compview n :set val :ins val) -- return (or set or insert after) the nth item in a list.
  num=size(list|attrlist|compview) -- return size of a list.
  compview=parent(compview) -- get parent of graphic
+ comp=depth(comps) -- depth-first walk of comp tree
+
 
 .SH VIEWER COMMANDS
 
@@ -161,7 +163,7 @@ barplot([var_str value_float] [...] :tit
 .SH OTHER COMMANDS
 
  acknowledgebox(msgstr) -- popup an acknowledge dialog box
- confirmbox(msgstr) -- popup a confirmation dialog box, and return 1, 0, or -1 if cancelled
+ confirmbox(msgstr) -- popup a confirmation dialog box, and return 1, 0, or \-1 if cancelled
 
  run(filename) -- run commands from file
  quit() -- quit this interpreter
@@ -189,16 +191,16 @@ with ACE.
 processing.
 
 .B \-theight n,
-(or "-th n") selects the automatic raster tiling height.
+(or "\-th n") selects the automatic raster tiling height.
 
 .B \-twidth n,
-(or "-tw n") selects the automatic raster tiling width.
+(or "\-tw n") selects the automatic raster tiling width.
 
 .B \-tile,
  enables the automatic raster tiling.
 
 .PP
-Also see the -help message and the drawtool and idraw man pages for
+Also see the \-help message and the drawtool and idraw man pages for
 further options.
 
 .SH SEE ALSO  
--- ivtools-1.2.11a1.orig/src/man/man1/comterp.1
+++ ivtools-1.2.11a1/src/man/man1/comterp.1
@@ -1,5 +1,5 @@
 .TH COMTERP 1 
-.SH COMTERP
+.SH NAME
 comterp \- distributed command interpreter demonstrator
 .SH SYNOPSIS
 .B comterp
@@ -8,19 +8,22 @@ comterp \- distributed command interpret
 remote
 .br
 .B comterp 
-server 'portnum'
+server "portnum"
 .br
 .B comterp 
-logger 'portnum'
+logger "portnum"
 .br
 .B comterp 
-client 'host' 'portnum' ['file']
+client "host" "portnum" ["file"]
 .br
 .B comterp 
-telcat 'host' 'portnum' ['file']
+telcat "host" "portnum" ["file"]
 .br
 .B comterp 
-run 'file'  
+run "file"  
+.br
+.B comterp 
+"expr"
 .br
 .SH DESCRIPTION
 comterp demonstrates the command interpreter incorporated into
@@ -53,32 +56,35 @@ comterp remote
 Invoke a single command interpreter, like the default, and include a
 remote command for accessing other comterp's in server mode.
 
-comterp server 'portnum'
+comterp server "portnum"
 
 Listens for and accept connections on portnum, then setup a command
 interpreter to wait for and process commands from that connection.
 
-comterp logger 'portnum'
+comterp logger "portnum"
 
 Listens for and accept connections on portnum, then simply forward
 the incoming messages to stdout, while ack'ing back with newlines. For
 debugging purposes, not really a use of the interpreter.
 
-comterp client 'host' 'portnum' ['file']
+comterp client "host" "portnum" ["file"]
 
 Connect to a portnum on a host and send/receive new-line terminated
 text buffers.  For debugging purposes, not really a use of the
 interpreter.
 
-comterp telcat 'host' 'portnum' ['file']
+comterp telcat "host" "portnum" ["file"]
 
 Connect to a portnum on a host, cat the file, then close the
 connection.  Not really a use of the interpreter either.
 
-comterp run 'file'
+comterp run "file"
 
 Run contents of file then exit.
 
+comterp "expr"
+
+Evaluate single expression then exit.
 
 .SH OPERATOR TABLE
 .nf
@@ -86,7 +92,6 @@ Run contents of file then exit.
     ---------  ------------   --------    -----       ----
     .          dot            130         R-to-L      binary
     `          bquote         125         R-to-L      unary-prefix
-    $          stream         125         R-to-L      unary-prefix
     !          negate         110         R-to-L      unary-prefix
     ~          bit_not        110         R-to-L      unary-prefix
     ++         incr           110         R-to-L      unary-prefix
@@ -115,7 +120,9 @@ Run contents of file then exit.
     &&         and            41          L-to-R      binary
     ||         or             40          L-to-R      binary
     ,          tuple          35          L-to-R      binary
-    ,,         concat         33          L-to-R      binary
+    ,,         stream concat  33          L-to-R      binary
+    $          stream         32          R-to-L      unary-prefix
+    $$         list           32          R-to-L      unary-prefix
     %=         mod_assign     30          R-to-L      binary
     *=         mpy_assign     30          R-to-L      binary
     +=         add_assign     30          R-to-L      binary
@@ -139,6 +146,8 @@ Run contents of file then exit.
 
  dbl=log10(x) -- returns the base-10 logarithm of x
 
+ dbl=log2(x) -- returns the base-2 logarithm of x
+
  dbl=pow(x y) -- returns the value of x raised to the power of y
 
  dbl=acos(x) -- returns the arc cosine of x in radians
@@ -202,16 +211,18 @@ Run contents of file then exit.
 
  num=size(list|attrlist|str) -- return size of a list (or string)
 
- val=index(list|str val|char|str :last :all) -- return index of value (or char or string) in list (or string), nil if not found.
+ val=index(list|str val|char|str :last :all :substr) -- return index of value (or char or string) in list (or string), nil if not found.
 
 .SH STREAM COMMANDS:
  
  val=next(stream) -- return next value from stream
 
- strm=stream(ostrm|list|attrlist) -- copy stream or convert list
+ strm=stream(ostrm|list|attrlist|val) -- copy stream or convert list
 
  cnt=each(strm) -- traverse stream returning its length
 
+ comp=filter(comps classid) -- filter stream of comps for matching classid
+
 .SH CONTROL COMMANDS (using post evaluation):
 
  val=cond(testexpr trueexpr falseexpr) -- evaluate testexpr, and if true, evaluate and return trueexpr, otherwise evaluate and return falseexpr
@@ -224,13 +235,17 @@ Run contents of file then exit.
 
  val=switch(val key-body-pairs) -- switch statement (:casen for pos., :case_n for neg., otherwise :symbol)
 
+ continue -- skip to next iteration of for or while loop
+
+ break([retval]) -- break out of for or while loop
+
 .SH OTHER COMMANDS
 
  help(cmdname [cmdname ...] :all :posteval) -- help for commands
 
  val=trace([flag] :get) -- toggle or set trace mode
 
- pause()  -- pause script execution until C/R
+ pause([msgstr])  -- pause script execution until C/R
 
  step() -- toggle stepwise script execution
 
@@ -258,11 +273,11 @@ Run contents of file then exit.
 
  n=strref(str|symid) -- return string reference count
 
- lst=split(symbol|string :tokstr [delim] :tokval [delim]) -- split symbol or string into list of characters (or tokens).
+ lst=split(symbol|string :tokstr [delim] :tokval [delim] :keep :reverse) -- split symbol or string into list of characters (or tokens).
 
  str=join(clist :sym) -- join list of characters into string
 
- str=substr(str n|str :after) -- extract characters from a string
+ str=substr(str n|str :after :nonil) -- extract characters from a string (:nonil returns string if no match)
 
  bool=eq(str1 str2 :n len) -- partial string comparison
 
@@ -270,6 +285,8 @@ Run contents of file then exit.
 
  postfix(arg1 [arg2 [arg3 ... [argn]]]) -- echo unevaluated postfix arguments (with [narg|nkey] after defined commands, {narg|nkey} after undefined commands, (narg) after keys, and a * following post-evaluation commands)
 
+ parse(fileobj) -- parse a single expression from a file
+
  arr=posteval(arg1 [arg2 [arg3 ... [argn]]]) -- post-evaluate every fixed argument (until nil) and return array
 				 
  sym=attrname(attribute) -- return name field of dotted pair
@@ -298,6 +315,10 @@ Run contents of file then exit.
 
  nil([...]) -- accept any arguments and return nil
 
+ true([...]) -- accept any arguments and return true
+
+ false([...]) -- accept any arguments and return false
+
  c=char(num :u) -- convert any numeric to a char
 
  s=short(num :u) -- convert any numeric to a short
--- ivtools-1.2.11a1.orig/src/man/man1/drawtool.1
+++ ivtools-1.2.11a1/src/man/man1/drawtool.1
@@ -3,7 +3,7 @@
 drawtool \- idraw with extensions
 .SH SYNOPSIS
 .B drawtool 
-.I -import n ['X-params'] [file]
+.I \-import n ['X-params'] [file]
 .SH DESCRIPTION
 drawtool is an extended version of idraw (originally from the
 InterViews 3.1).  Based on the ivtools OverlayUnidraw library, it adds
@@ -20,8 +20,8 @@ the following features:
 - graphical object attribute annotations
 .PP
 drawtool is derived from idraw, and implements the same set of
-pulldown commands and pallette of toolbuttons.  Read the idraw man
-page for details on that part of the drawtool user interace.  This
+pulldown commands and palette of toolbuttons.  Read the idraw man
+page for details on that part of the drawtool user interface.  This
 page lists only the extensions to idraw embodied in drawtool.
 .PP
 drawtool saves and restores documents in a readable text format.  This
@@ -37,7 +37,7 @@ compress (.Z) and gzip (.gz) is recogniz
 files themselves and the PBM, PGM, and PPM image formats.
 .PP
 There is also support for opening (via command line or dialog box) and
-importing via the net (to the -import port) any arbitrary PostScript
+importing via the net (to the \-import port) any arbitrary PostScript
 file using the pstoedit filter, and any GIF, TIFF, or JPEG image,
 using respectively the giftopnm, tifftopnm, or djpeg filters.
 .PP
@@ -63,70 +63,70 @@ multilines if drawtool has been built wi
 
 .SH OPTIONS
 .TP
-"-import n" 
+"\-import n"
 specifies the port number to run the import service on.  The
 import service accepts connections over the net and reads drawtool
 or idraw documents and pbmplus image formats (PBM/PGM/PPM), plus JPEG, GIF,
 TIFF, and the non-raster portions of arbitrary PostScript if appropriate
 filters are available (djpeg, giftopnm, tifftopnm, pstoedit).
-"-color5" selects a colormap with 5 values per color or 125 entries (5
+"\-color5" selects a colormap with 5 values per color or 125 entries (5
 cubed).
 
 .PP
-"-nocolor6" overrides the selection of a colormap with 6 values per
+"\-nocolor6" overrides the selection of a colormap with 6 values per
 color or 216 entries (6 cubed).
 
 .PP
-"-gray5" selects a colormap with 5 bits of gray-level intensity (32
+"\-gray5" selects a colormap with 5 bits of gray-level intensity (32
 gray-levels) arranged to maximize rubberband visibility.
 
 .PP
-"-gray6" selects a colormap with 6 bits of gray-level intensity (64
+"\-gray6" selects a colormap with 6 bits of gray-level intensity (64
 gray-levels)  arranged to maximize rubberband visibility.
 
 .PP
-"-gray7" selects a colormap with 7 bits of gray-level intensity (128
+"\-gray7" selects a colormap with 7 bits of gray-level intensity (128
 gray-levels) arranged to maximize rubberband visibility.
 
 .PP
-"-dithermap" causes imported JPEG rasters to be mapped to the standard
-colormap (the default without -nocolor6) and dithered to avoid color
+"\-dithermap" causes imported JPEG rasters to be mapped to the standard
+colormap (the default without \-nocolor6) and dithered to avoid color
 banding.
 
 .PP
-"-opaque_off" (or "-opoff") disables the opaque (visible)
+"\-opaque_off" (or "\-opoff") disables the opaque (visible)
 interactive transformations of graphics.
 
 .PP
-"-pagecols" (or "-ncols") sets the horizontal page extent in pixels.
+"\-pagecols" (or "\-ncols") sets the horizontal page extent in pixels.
 
 .PP
-"-pagerows" (or "-nrows") sets the vertical page extent in pixels.
+"\-pagerows" (or "\-nrows") sets the vertical page extent in pixels.
 
 .PP
-"-panner_align tl|tc|tr|cl|c|cr|cl|bl|br|l|r|t|b|hc|vc" (or "-pal
-...") selects the alignment of the panner display.
+"\-panner_align tl|tc|tr|cl|c|cr|cl|bl|br|l|r|t|b|hc|vc" (or "\-pal ...")
+selects the alignment of the panner display.
 
 .PP
-"-panner_off" (or "-poff") disables the panner display.
+"\-panner_off" (or "\-poff") disables the panner display.
 
 .PP
-"-slider_off" (or "-soff") disables the slider display.
+"\-slider_off" (or "\-soff") disables the slider display.
 
 .PP
-"-zoomer_off" (or "-zoff") disables the zoomer display.
+"\-zoomer_off" (or "\-zoff") disables the zoomer display.
 
 .PP
-"-ptrloc" enables display of the current pointer location.
+"\-ptrloc" enables display of the current pointer location.
 
 .PP
-"-scribble_pointer (or "-scrpt") enables continuous line drawing.
+"\-scribble_pointer (or "\-scrpt") enables continuous line drawing.
 
 .PP
-"-toolbarloc r|l" (or "-tbl ...") selects the toolbar location.
+"\-toolbarloc r|l" (or "\-tbl ...") selects the toolbar location.
 
 .PP
-Also see "-help" and the idraw man page for more options.
+Also see "\-help" and the idraw man page for more options.
 
 .SH SEE ALSO  
 	idraw(1)
--- ivtools-1.2.11a1.orig/src/man/man1/flipbook.1
+++ ivtools-1.2.11a1/src/man/man1/flipbook.1
@@ -53,15 +53,15 @@ background.
 
 .SH OPTIONS
 
-"-bookgeom" brings up the flipbook in landscape mode, with a 906 by
+"\-bookgeom" brings up the flipbook in landscape mode, with a 906 by
 700 pixel page size.  Useful for viewing illustrated books prepared in
 this mode.
 
-"-slideshow sec" continuously plays the contents of a flipbook file
+"\-slideshow sec" continuously plays the contents of a flipbook file
 with "sec" delay between frames (currently only available when built
 with ACE).  
 
-Also see "-help" for more options, and the comdraw, drawtool, and
+Also see "\-help" for more options, and the comdraw, drawtool, and
 idraw man pages.
 
 .SH SEE ALSO
--- ivtools-1.2.11a1.orig/src/man/man3/BasicDialog.3
+++ ivtools-1.2.11a1/src/man/man3/BasicDialog.3
@@ -1,7 +1,7 @@
 .TH BasicDialog 3U "23 July 1990" "Unidraw" "InterViews Reference Manual"
 .SH NAME
 AcknowledgeDialog, BasicDialog, ConfirmDialog, GridDialog, \
-PrintDialog, UChooser - an assortment of useful dialog boxes
+PrintDialog, UChooser \- an assortment of useful dialog boxes
 .SH SYNOPSIS
 .B #include <Unidraw/dialogs.h>
 .SH DESCRIPTION
--- ivtools-1.2.11a1.orig/src/man/man3/Control.3
+++ ivtools-1.2.11a1/src/man/man3/Control.3
@@ -99,7 +99,7 @@ Grab reads input and only passes through
 is an active control.
 .TP
 .B "virtual void Skip()"
-Skip reads and discards input events until it reads an event targetted
+Skip reads and discards input events until it reads an event targeted
 for a control that is currently grabbing input, as indicated by
 IsGrabbing (see below).
 .TP
--- ivtools-1.2.11a1.orig/src/man/man3/Deck2_6.3
+++ ivtools-1.2.11a1/src/man/man3/Deck2_6.3
@@ -52,7 +52,7 @@ the deck (the components inserted last),
 component nearer to the ``top''.  FlipTo specifies a component by its
 absolute position in the deck.  A positive value of \fIposition\fP specifies
 a position from the top, starting at 1.  A negative value specifies a
-position from the bottom, starting at -1.  Top and Bottom are equivalent to
-FlipTo(1) and FlipTo(-1) respectively.
+position from the bottom, starting at \-1.  Top and Bottom are equivalent to
+FlipTo(1) and FlipTo(\-1) respectively.
 .SH SEE ALSO
 Interactor(3I), Scene(3I), Shape(3I)
--- ivtools-1.2.11a1.orig/src/man/man3/Graphic.3
+++ ivtools-1.2.11a1/src/man/man3/Graphic.3
@@ -104,7 +104,7 @@ transformers of the graphic's parents to
 transformation, which it then stores in \fIt\fP.
 .sp
 Unless otherwise noted, input and output coordinates are affected by
-the concatentation of \fIthis\fP's transformer, its parent's
+the concatenation of \fIthis\fP's transformer, its parent's
 transformer, its parent's parent's, and so on up to the root of the
 graphic instance hierarchy.  Prior to transformation, coordinates
 reflect the \fIgraphic's coordinate system\fP.  Following
--- ivtools-1.2.11a1.orig/src/man/man3/Painter.3
+++ ivtools-1.2.11a1/src/man/man3/Painter.3
@@ -189,7 +189,7 @@ Set a point or set of points to the curr
 .ns
 .TP
 .B "void ClearRect(Canvas*, Coord x1, y1, x2, y2)"
-Draw a rectangle with opposite corners specfied by (\fIx1\fP,\ \fIy1\fP) and
+Draw a rectangle with opposite corners specified by (\fIx1\fP,\ \fIy1\fP) and
 (\fIx2\fP,\ \fIy2\fP).
 FillRect fills the rectangle using the current pattern and colors;
 ClearRect fills the rectangle with the background color.
--- ivtools-1.2.11a1.orig/src/man/man3/Rubband.3
+++ ivtools-1.2.11a1/src/man/man3/Rubband.3
@@ -344,9 +344,9 @@ the tracking point.
 GrowingVertices is an abstract rubberband containing a list of
 vertices that grows or shrinks dynamically.  The \fIpt\fP parameter
 specifies the index of the vertex that will follow the tracking point;
-a value of -1 specifies a vertex after the last one in the list.  The
+a value of \-1 specifies a vertex after the last one in the list.  The
 \fIhandleSize\fP parameter specifies the size of the handle drawn at
-each vertex (as in RubberHandles above); a value of -1 specifies that
+each vertex (as in RubberHandles above); a value of \-1 specifies that
 no handles be drawn.
 
 The AddVertex operation adds a new vertex at the tracking point to the
--- ivtools-1.2.11a1.orig/src/man/man3/UArray.3
+++ ivtools-1.2.11a1/src/man/man3/UArray.3
@@ -31,7 +31,7 @@ Insert and remove an object at a particu
 succeeding objects up or down one position as required.
 .TP
 .B "int Index(void*)"
-Return the given object's index in the UArray, returning -1 if the
+Return the given object's index in the UArray, returning \-1 if the
 object does not appear in the UArray.
 .TP
 .B "int Count()"
--- ivtools-1.2.11a1.orig/src/man/man3/Unidraw.3
+++ ivtools-1.2.11a1/src/man/man3/Unidraw.3
@@ -78,7 +78,7 @@ constructor form.
 Run initiates the main loop of the program.  The call to Run returns
 when Quit is called.
 .TP
-.B "virtual void Update(boolean immedate = false)"
+.B "virtual void Update(boolean immediate = false)"
 Bring the screen up to date with the state of the application's
 objects.  By default, this involves moving connectors to their proper
 positions (by calling Solve on the global csolver object) and telling
--- ivtools-1.2.11a1.orig/src/man/man3/UnidrawIntro.3
+++ ivtools-1.2.11a1/src/man/man3/UnidrawIntro.3
@@ -1,6 +1,6 @@
 .TH UnidrawIntro 3U "11 June 1990" "Unidraw" "InterViews Reference Manual"
 .SH NAME
-Unidraw library for graphical object editor development
+Unidraw_Intro \- Unidraw library for graphical object editor development
 .SH SYNOPSIS
 .B #include <Unidraw/\fIclass\fP.h>
 .br
--- ivtools-1.2.11a1.orig/src/man/man3/Viewer.3
+++ ivtools-1.2.11a1/src/man/man3/Viewer.3
@@ -106,7 +106,7 @@ Set and get the viewer's orientation par
 whether the graphical view, page, and grid will appear in portrait or
 landscape mode.  No transformation will be applied in portrait mode,
 while landscape mode will rotate the page -90 degrees and translate it
-vertically by an amout equal to the width of the page's bounding box.
+vertically by an amount equal to the width of the page's bounding box.
 .TP
 .B "virtual Selection* GetSelection()"
 Return the enclosing editor's selection object; it is equivalent to
--- ivtools-1.2.11a1.orig/src/man/man3/World.3
+++ ivtools-1.2.11a1/src/man/man3/World.3
@@ -20,7 +20,7 @@ It is currently provided for backward co
 .B ")"
 .br
 Construct the world object for a display.
-The world's instance name comes from the -name option if
+The world's instance name comes from the \-name option if
 it was given; otherwise the instance name comes from the environment
 variable RESOURCE_NAME if it is nonnil.  If the name has still not
 been defined, then argv[0] with all leading directories stripped is
--- ivtools-1.2.11a1.orig/src/man/man3/statevars.3
+++ ivtools-1.2.11a1/src/man/man3/statevars.3
@@ -102,7 +102,7 @@ operation is performed on the component.
 .ns
 .TP
 .B "virtual void NameVar::SetName(const char*)"
-The NameVar constructor takes a string as an optional arguement, while
+The NameVar constructor takes a string as an optional argument, while
 GetName and SetName retrieve and assign the string.
 .TP
 .B "CompNameVar(Component* = nil)"
--- ivtools-1.2.11a1.orig/src/scripts/cntsrclines.bash
+++ ivtools-1.2.11a1/src/scripts/cntsrclines.bash
@@ -9,8 +9,8 @@ case "$#" in
     *)    cd $1
           ;;
 esac
-linecount1=`tmpnam`
-linecount2=`tmpnam`
+linecount1=`tempfile`
+linecount2=`tempfile`
 find . -name \*.c -exec wc -l {} \; >$linecount1
 find . -name \*.h -exec wc -l {} \; >>$linecount1
 find . -name \*.ci -exec wc -l {} \; >>$linecount1
--- ivtools-1.2.11a1.orig/src/scripts/ivgetjpg.bash
+++ ivtools-1.2.11a1/src/scripts/ivgetjpg.bash
@@ -11,8 +11,8 @@
 url=$1
 importport=$2
 echo import $url to port $importport
-tempfile=`tmpnam`
-cmapfile=`tmpnam`
+tempfile=`tempfile`
+cmapfile=`tempfile`
 stdcmapppm >$cmapfile
 w3c $url >$tempfile; djpeg -map $cmapfile -dither fs -pnm $tempfile | comterp telcat localhost $importport
 rm $tempfile $cmapfile
--- ivtools-1.2.11a1.orig/src/scripts/ivtiftopnm.bash
+++ ivtools-1.2.11a1/src/scripts/ivtiftopnm.bash
@@ -8,7 +8,7 @@
 #     $1 optional tiff image filename
 #
 case "$#" in 
-        0)      tempfile=`tmpnam`
+        0)      tempfile=`tempfile`
 		cat >$tempfile
 		tifftopnm $tempfile
 		rm $tempfile
--- ivtools-1.2.11a1.orig/src/scripts/pnmtopgm.sh
+++ ivtools-1.2.11a1/src/scripts/pnmtopgm.sh
@@ -14,14 +14,14 @@
 
 if [ ! $# = 1 ] ; then
     echo "usage: $0 <file>" 1>&2
-    exit 1
+    exit 64
 fi
 
 origfile="$1"
 file="$origfile"
 tmpfiles=""
 
-    filetype=`file "$file"`
+    filetype=$(file "$file")
 
     case "$filetype" in
 
@@ -42,4 +42,4 @@ tmpfiles=""
 
     esac
 
-exit -1
+exit 65
--- ivtools-1.2.11a1.orig/src/tests/y2k/y2ktest.cc
+++ ivtools-1.2.11a1/src/tests/y2k/y2ktest.cc
@@ -25,7 +25,7 @@
 using std::cin;
 using std::cout;
 
-main() {
+int main() {
   Date date(1, "Jan", 1999);
 
   cout << "Current date initialized to ";
--- ivtools-1.2.11a1.orig/src/utils/ivdl.cc
+++ ivtools-1.2.11a1/src/utils/ivdl.cc
@@ -32,8 +32,8 @@ int main(int argc, char** argv)
 {
   
   if(argc != 3){
-    cerr << "Wrong number of args.\n";
-    cerr << "Use:  a.out URL FilenameToSave\n";
+    std::cerr << "Wrong number of args.\n";
+    std::cerr << "Use:  a.out URL FilenameToSave\n";
     exit(0);
   }
 
--- ivtools-1.2.11a1.orig/src/utils/sockets.h
+++ ivtools-1.2.11a1/src/utils/sockets.h
@@ -72,7 +72,7 @@ class CSocket {
   void PConnect();  // Sets up a passive socket connection.
   int Listen(); // Blocks until incoming connection is made.
 
-  int ReadWrite(fstream&, String, char*); // Socket reading and file writing. 
+  int ReadWrite(std::fstream&, String, char*); // Socket reading and file writing. 
   
   // Closes a socket connection, given a file descriptor.
   void Shutdown(int);             
