aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/tclmidi/Makefile40
-rw-r--r--audio/tclmidi/files/BSDmakefile30
-rw-r--r--audio/tclmidi/files/patch-aa96
-rw-r--r--audio/tclmidi/files/patch-modern2139
-rw-r--r--audio/tclmidi/files/patch-rb456
-rw-r--r--audio/tclmidi/files/patch-smf__Makefile.in24
-rw-r--r--audio/tclmidi/files/patch-song__Makefile.in25
-rw-r--r--audio/tclmidi/files/strstream.h1
8 files changed, 2779 insertions, 32 deletions
diff --git a/audio/tclmidi/Makefile b/audio/tclmidi/Makefile
index 637732d2f9f7..77c25fe44195 100644
--- a/audio/tclmidi/Makefile
+++ b/audio/tclmidi/Makefile
@@ -7,22 +7,20 @@
PORTNAME= tclmidi
PORTVERSION= 3.1
+PORTREVISION= 1
CATEGORIES= audio
-MASTER_SITES= ftp://ftp.cs.ruu.nl/pub/MIDI/PROGRAMS/ \
- http://ringtail.its.monash.edu.au/pub/midi/PROGRAMS/
-# despite references on the homepage to ftp.xor.com, that server
-# doesn't work - edwin 20021227
+MASTER_SITES= http://ringtail.its.monash.edu.au/pub/midi/PROGRAMS/
MAINTAINER= ports@FreeBSD.org
COMMENT= A language designed for creating and editing standard MIDI files
-LIB_DEPENDS= tcl82.1:${PORTSDIR}/lang/tcl82
-
-MAKE_ENV= TCL_GENERIC_DIR=${LOCALBASE}/include/tcl8.2
-GNU_CONFIGURE= yes
-CONFIGURE_ARGS= --with-tclsh=${LOCALBASE}/bin/tclsh8.2
+USE_TCL= 84+
+MAKE_ENV= TCL_INCLUDEDIR="${TCL_INCLUDEDIR}" TCL_LIBDIR="${TCL_LIBDIR}"
+MAKE_ENV+= TCLSH=${TCLSH} FILESDIR="${FILESDIR}" MAN="${MAN1} ${MANN}"
PKGMESSAGE= ${WRKDIR}/pkg-message
SUB_FILES= pkg-message
+MAKE_JOBS_SAFE= yes
+MAKEFILE= ${FILESDIR}/BSDmakefile
MAN1= mplay.1 mrec.1 tclmidi.1 minfo.1 midtotcl.1
MANN= midiconf.n midievnt.n midifree.n midiget.n midigrep.n \
@@ -30,19 +28,19 @@ MANN= midiconf.n midievnt.n midifree.n midiget.n midigrep.n \
midirec.n midirew.n midisplt.n midistop.n midiwait.n \
midiwrit.n midivers.n midimove.n midicopy.n mididel.n \
miditrck.n mididev.n miditime.n midifeat.n
+MANCOMPRESSED= maybe
-.include <bsd.port.pre.mk>
-
-.if ${ARCH} == "ia64" || ${ARCH} == "sparc64"
-IGNORE= ignored due to cast from pointer to integer of different size
-.elif ${OSVERSION} >= 900000
-BROKEN= does not build
-.endif
-
-post-patch:
- @${CP} -f ${FILESDIR}/strstream.h ${WRKSRC}
+post-build:
+ cd ${WRKSRC} && echo pkg_mkIndex . tclmidi31.so | ${TCLSH}
-post-install:
+pre-su-install:
+.for s in mplay mrec minfo midtotcl
+ ${SED} 's|/usr/local/bin/tclsh|${TCLSH}|' \
+ < ${WRKSRC}/$s.dist > ${PREFIX}/bin/$s
+ ${CHMOD} 755 ${PREFIX}/bin/$s
+.endfor
@${CAT} ${PKGMESSAGE}
+ ${MKDIR} ${PREFIX}/lib/tclmidi
+ ${INSTALL_DATA} ${WRKSRC}/pkgIndex.tcl ${PREFIX}/lib/tclmidi/
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff --git a/audio/tclmidi/files/BSDmakefile b/audio/tclmidi/files/BSDmakefile
new file mode 100644
index 000000000000..6aa693220bfe
--- /dev/null
+++ b/audio/tclmidi/files/BSDmakefile
@@ -0,0 +1,30 @@
+SRCS= MidiDev.cxx TclmDr75.cxx ChanPres.cxx Event.cxx MChanPrf.cxx \
+ MCopy.cxx MCue.cxx MEOT.cxx MEvent.cxx MInstNam.cxx MKey.cxx \
+ MLyric.cxx MMarker.cxx MPortNum.cxx MSMPTE.cxx MSeqNam.cxx \
+ MSeqNum.cxx MSeqSpec.cxx MTempo.cxx MText.cxx MTime.cxx \
+ NormEvnt.cxx NoteOff.cxx NoteOn.cxx KeyPres.cxx Param.cxx \
+ PitchWhl.cxx Program.cxx SysEx.cxx MUnknown.cxx EvntUtil.cxx \
+ Note.cxx GusPatch.cxx SMFUtils.cxx SMFHead.cxx SMFTrack.cxx \
+ EvntTree.cxx Song.cxx
+
+SRCS+= TclmIntp.cxx tclmCmd.cxx tclmEvnt.cxx tclmPlay.cxx \
+ tclmPtch.cxx tclmUtil.cxx
+
+
+SRCS+= rb.c list.c
+SHLIB_NAME= tclmidi31.so
+MANDIR= ${PREFIX}/man/man
+LIBDIR= ${PREFIX}/lib/tclmidi
+LDADD= -lstdc++
+
+SUBDIRS=events device patch smf song rb
+INCLUDES= -I${TCL_INCLUDEDIR} ${SUBDIRS:S/^/-I/}
+CFLAGS+= ${INCLUDES} -Werror
+CXXFLAGS+= -Wall -Wno-deprecated ${INCLUDES} -I${FILESDIR}
+CXXFLAGS+= -DHAVE_UNISTD_H -DHAVE_SYS_FILIO_H -DHAVE_SYS_TIME_H -Werror
+CXXFLAGS+= -DUSE_INTERP_RESULT
+
+.PATH: ${SUBDIRS} man
+WARNS= 5
+
+.include <bsd.lib.mk>
diff --git a/audio/tclmidi/files/patch-aa b/audio/tclmidi/files/patch-aa
index 9a53e78ef542..037b99198ab6 100644
--- a/audio/tclmidi/files/patch-aa
+++ b/audio/tclmidi/files/patch-aa
@@ -1,24 +1,35 @@
---- Makefile.in.orig Mon Nov 9 18:00:54 1998
-+++ Makefile.in Mon Nov 9 17:47:11 1998
+--- Makefile.in 1996-10-09 23:32:36.000000000 -0400
++++ Makefile.in 2012-04-07 12:07:34.000000000 -0400
@@ -11,7 +11,7 @@
# The directory containing the Tcl library archive file appropriate
# for this version of Tk:
-TCL_BIN_DIR = @TCL_BIN_DIR@
-+TCL_BIN_DIR = ${LOCALBASE}/lib/tcl8.2
++TCL_BIN_DIR = ${TCL_LIBDIR}
#----------------------------------------------------------------
# The information below is modified by the configure script when
-@@ -35,7 +35,7 @@
+@@ -35,8 +35,9 @@
VPATH = @srcdir@
CFLAGS = @CFLAGS@ @DEFS@
-CC_SWITCHES = @CFLAGS@ @DEFS@ ${SHLIB_CFLAGS} \
+CC_SWITCHES = @CFLAGS@ @DEFS@ ${SHLIB_CFLAGS} -I${TCL_GENERIC_DIR} \
-Idevice -Ievents -Irb -Ipatch -Ismf -Isong -I.
++CXX_SWITCHES= ${CC_SWITCHES} ${CXXFLAGS}
TCLMFILES = tclmCmd.o tclmUtil.o tclmEvnt.o tclmPlay.o tclmPtch.o TclmIntp.o
-@@ -101,7 +101,7 @@
+ TCLMFILES_SRC = tclmCmd.cxx tclmUtil.cxx tclmEvnt.cxx tclmPlay.cxx \
+@@ -61,7 +62,7 @@
+ @echo 'pkg_mkIndex . $(PROJ_LIB_NAME)' | @TCLSH_PATH@
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ $(PROJ_LIB_NAME): events/objs smf/objs \
+ song/objs device/objs patch/objs rb/objs $(TCLMFILES)
+@@ -101,7 +102,7 @@
install: $(PROJ_LIB_NAME) $(SCRIPTS)
-mkdir -p $(prefix)$(libdir)/tclmidi
@@ -27,3 +38,78 @@
echo 'pkg_mkIndex $(prefix)$(libdir)/tclmidi \
$(PROJECT)*${SHLIB_SUFFIX}' | @TCLSH_PATH@
cd man; $(MAKE) install
+@@ -128,7 +129,7 @@
+ sed "/[#]# Dependancies/,$$$$d" < Makefile > Makefile.tmp
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(TCLMFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(TCLMFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
+
+--- device/Makefile.in 1996-10-09 23:32:40.000000000 -0400
++++ device/Makefile.in 2012-04-07 12:13:09.000000000 -0400
+@@ -18,4 +18,5 @@
+ -I$(srcdir)/../events -I$(srcdir)/../rb -I$(srcdir)/../patch \
+ -I$(srcdir)/../smf -I$(srcdir)/../song -I$(srcdir)/.. -I$(srcdir)
++CXX_SWITCHES= ${CC_SWITCHES} ${CXXFLAGS}
+
+ DEVICEFILES = MidiDev.o TclmDr75.o
+@@ -25,5 +26,5 @@
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ objs: $(DEVICEFILES)
+@@ -34,5 +35,5 @@
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(DEVICEFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(DEVICEFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
+--- events/Makefile.in 1996-10-09 23:32:42.000000000 -0400
++++ events/Makefile.in 2012-04-07 12:15:41.000000000 -0400
+@@ -17,4 +17,5 @@
+ CC_SWITCHES = @CFLAGS@ @DEFS@ -I${TCL_GENERIC_DIR} ${SHLIB_CFLAGS} \
+ -I$(srcdir)/../smf -I$(srcdir)/../song -I$(srcdir)/.. -I$(srcdir)
++CXX_SWITCHES = ${CC_SWITCHES} ${CXXFLAGS}
+
+ EVENTFILES = ChanPres.o Event.o MChanPrf.o MCopy.o MCue.o \
+@@ -36,5 +37,5 @@
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ objs: $(EVENTFILES)
+@@ -45,5 +46,5 @@
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(EVENTFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(EVENTFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
+--- patch/Makefile.in 1996-10-09 23:32:43.000000000 -0400
++++ patch/Makefile.in 2012-04-07 12:23:29.000000000 -0400
+@@ -17,4 +17,5 @@
+ CC_SWITCHES = @CFLAGS@ @DEFS@ -I${TCL_GENERIC_DIR} ${SHLIB_CFLAGS} \
+ -I. -I..
++CXX_SWITCHES = ${CC_SWITCHES} ${CXXFLAGS}
+
+ PATCHFILES = GusPatch.o
+@@ -24,5 +25,5 @@
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ objs: $(PATCHFILES)
+@@ -33,5 +34,5 @@
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(PATCHFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(PATCHFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
diff --git a/audio/tclmidi/files/patch-modern b/audio/tclmidi/files/patch-modern
new file mode 100644
index 000000000000..3f4a55f229d2
--- /dev/null
+++ b/audio/tclmidi/files/patch-modern
@@ -0,0 +1,2139 @@
+--- events/ChanPres.h 1996-02-18 19:57:20.000000000 -0500
++++ events/ChanPres.h 2012-04-07 14:08:43.000000000 -0400
+@@ -44,7 +44,7 @@
+ {return (new ChannelPressureEvent(*this));}
+
+ virtual EventType GetType(void) const {return (CHANNELPRESSURE);}
+- virtual char *GetTypeStr(void) const {return ("ChannelPressureEvent");}
++ virtual const char *GetTypeStr(void) const {return ("ChannelPressureEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetPressure(void) const {
+ if (GetWildcard(wc_pressure))
+--- events/Event.h 1996-07-28 14:51:08.000000000 -0400
++++ events/Event.h 2012-04-11 01:04:43.000000000 -0400
+@@ -81,12 +81,13 @@
+ else
+ return (time);
+ }
++ virtual ~Event() {};
+ virtual EventType GetType(void) const {return (NOTYPE);}
+- virtual char *GetTypeStr(void) const {return ("NoType");}
++ virtual const char *GetTypeStr(void) const {return ("NoType");}
+ virtual char *GetEventStr(void) const;
+ Event *GetNextEvent(void) const {return (next_event);}
+ Event *GetPrevEvent(void) const {return (prev_event);}
+- const EventTreeNode *GetEventTreeNode(void) const {return (node);}
++ EventTreeNode *GetEventTreeNode(void) const {return (node);}
+
+ void SetTime(unsigned long t) {
+ if (t == WC_TIME)
+@@ -96,7 +97,7 @@
+ }
+ void SetNextEvent(Event *n) {next_event = n;}
+ void SetPrevEvent(Event *p) {prev_event = p;}
+- void SetEventTreeNode(const EventTreeNode *n) {node = n;}
++ void SetEventTreeNode(EventTreeNode *n) {node = n;}
+
+ Event &operator=(const Event &e);
+ int operator==(const Event &e) const;
+@@ -120,6 +121,6 @@
+ static const unsigned long wc_time;
+ Event *next_event;
+ Event *prev_event;
+- const EventTreeNode *node;
++ EventTreeNode *node;
+ };
+ #endif
+--- events/KeyPres.h 1996-02-18 19:57:26.000000000 -0500
++++ events/KeyPres.h 2012-04-07 14:08:43.000000000 -0400
+@@ -45,7 +45,7 @@
+ virtual Event *Dup(void) const {return (new KeyPressureEvent(*this));}
+
+ virtual EventType GetType(void) const {return (KEYPRESSURE);}
+- virtual char *GetTypeStr(void) const {return ("KeyPressureEvent");}
++ virtual const char *GetTypeStr(void) const {return ("KeyPressureEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetPitch(void) const {
+ if (GetWildcard(wc_pitch))
+--- events/MChanPrf.cxx 1996-07-28 15:09:16.000000000 -0400
++++ events/MChanPrf.cxx 2012-04-07 15:41:59.000000000 -0400
+@@ -74,7 +74,7 @@
+ MetaChannelPrefixEvent::~MetaChannelPrefixEvent()
+ {
+
+- delete data;
++ delete[] data;
+ }
+
+ void
+@@ -82,7 +82,7 @@
+ {
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if (dat == WC_DATA || len == WC_LENGTH) {
+ SetWildcard(wc_data);
+ data = 0;
+@@ -101,7 +101,7 @@
+
+ (MetaEvent)*this = (MetaEvent)e;
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if (e.GetWildcard(wc_data)) {
+ data = 0;
+ length = -1;
+@@ -129,7 +129,7 @@
+ buf.setf(ios::showbase | ios::internal);
+ for (i = 0; i < length; i++)
+ buf << " " << hex << setw(4) << setfill('0') <<
+- (int)data[i];
++ (intptr_t)data[i];
+ }
+ buf << ends;
+ delete tbuf;
+@@ -142,7 +142,7 @@
+ const unsigned char *ptr;
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if ((length = t.GetVarValue()) == -1)
+ return ("Incomplete MetaChannelPrefixEvent - bad length");
+ data = new unsigned char[length];
+--- events/MChanPrf.h 1996-02-18 19:57:29.000000000 -0500
++++ events/MChanPrf.h 2012-04-07 14:36:23.000000000 -0400
+@@ -46,7 +46,7 @@
+ {return (new MetaChannelPrefixEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METACHANNELPREFIX);}
+- virtual char *GetTypeStr(void) const
++ virtual const char *GetTypeStr(void) const
+ {return ("MetaChannelPrefixEvent");}
+ virtual char *GetEventStr(void) const;
+ const unsigned char *GetData(void) const {
+--- events/MCopy.h 1996-02-12 19:25:36.000000000 -0500
++++ events/MCopy.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaCopyrightEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METACOPYRIGHT);}
+- virtual char *GetTypeStr(void) const {return ("MetaCopyrightEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaCopyrightEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaCopyrightEvent &operator=(const MetaCopyrightEvent &e);
+--- events/MCue.h 1996-02-12 19:25:37.000000000 -0500
++++ events/MCue.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaCueEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METACUE);}
+- virtual char *GetTypeStr(void) const {return ("MetaCueEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaCueEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaCueEvent &operator=(const MetaCueEvent &e);
+--- events/MEOT.h 1996-02-12 19:25:38.000000000 -0500
++++ events/MEOT.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ {return (new MetaEndOfTrackEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAENDOFTRACK);}
+- virtual char *GetTypeStr(void) const {return ("MetaEndOfTrackEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaEndOfTrackEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaEndOfTrackEvent &operator=(const MetaEndOfTrackEvent &e);
+--- events/MEvent.h 1996-02-12 19:25:39.000000000 -0500
++++ events/MEvent.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new MetaEvent(*this));}
+
+ virtual EventType GetType(void) const {return (META);}
+- virtual char *GetTypeStr(void) const {return ("MetaEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaEvent &operator=(const MetaEvent &e);
+--- events/MInstNam.h 1996-02-12 19:25:39.000000000 -0500
++++ events/MInstNam.h 2012-04-07 14:08:43.000000000 -0400
+@@ -45,7 +45,7 @@
+ {return (new MetaInstrumentNameEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAINSTRUMENTNAME);}
+- virtual char *GetTypeStr(void) const {return ("MetaInstrumentName");}
++ virtual const char *GetTypeStr(void) const {return ("MetaInstrumentName");}
+ virtual char *GetEventStr(void) const;
+
+ MetaInstrumentNameEvent &operator=(const MetaInstrumentNameEvent &e);
+--- events/MKey.cxx 1996-07-28 15:09:19.000000000 -0400
++++ events/MKey.cxx 2012-04-07 15:51:06.000000000 -0400
+@@ -396,7 +396,7 @@
+ badkey = 1;
+ }
+
+- delete keystr;
++ delete[] keystr;
+ if (badkey)
+ *match = 0;
+ else
+@@ -409,21 +409,13 @@
+ StrToMode(const char *str, int *match)
+ {
+ Mode mode;
+- char *modestr;
+- int i, modelen;
+-
+- modelen = strlen(str);
+- modestr = new char[modelen + 1];
+- for (i = 0; i < modelen; i++)
+- modestr[i] = tolower(str[i]);
+- modestr[i] = '\0';
+
+ *match = 1;
+- if (strcmp(modestr, "minor") == 0)
++ if (strcasecmp(str, "minor") == 0)
+ mode = MODE_MINOR;
+- else if (strcmp(modestr, "major") == 0)
++ else if (strcasecmp(str, "major") == 0)
+ mode = MODE_MAJOR;
+- else if (strcmp(modestr, "*") == 0)
++ else if (strcasecmp(str, "*") == 0)
+ mode = MODE_WC;
+ else {
+ mode = MODE_MAJOR;
+--- events/MKey.h 1996-02-18 19:57:33.000000000 -0500
++++ events/MKey.h 2012-04-07 14:08:43.000000000 -0400
+@@ -57,7 +57,7 @@
+ virtual Event *Dup(void) const {return (new MetaKeyEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAKEY);}
+- virtual char *GetTypeStr(void) const {return ("MetaKeyEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaKeyEvent");}
+ virtual char *GetEventStr(void) const;
+ Key GetKey(void) const {
+ if (GetWildcard(wc_key))
+--- events/MLyric.h 1996-02-12 19:25:41.000000000 -0500
++++ events/MLyric.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaLyricEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METALYRIC);}
+- virtual char *GetTypeStr(void) const {return ("MetaLyricEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaLyricEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaLyricEvent &operator=(const MetaLyricEvent &e);
+--- events/MMarker.h 1996-02-12 19:25:42.000000000 -0500
++++ events/MMarker.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaMarkerEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAMARKER);}
+- virtual char *GetTypeStr(void) const {return ("MetaMarkerEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaMarkerEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaMarkerEvent &operator=(const MetaMarkerEvent &e);
+--- events/MPortNum.h 1996-02-18 19:57:36.000000000 -0500
++++ events/MPortNum.h 2012-04-07 14:08:43.000000000 -0400
+@@ -44,7 +44,7 @@
+ {return (new MetaPortNumberEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAPORTNUMBER);}
+- virtual char *GetTypeStr(void) const
++ virtual const char *GetTypeStr(void) const
+ {return ("MetaPortNumberEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetPort(void) const {
+--- events/MSMPTE.h 1996-02-18 19:57:40.000000000 -0500
++++ events/MSMPTE.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new MetaSMPTEEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METASMPTE);}
+- virtual char *GetTypeStr(void) const {return ("MetaSMPTEEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaSMPTEEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetHour(void) const {
+ if (GetWildcard(wc_hour))
+--- events/MSeqNam.h 1996-02-12 19:25:44.000000000 -0500
++++ events/MSeqNam.h 2012-04-07 14:08:43.000000000 -0400
+@@ -44,7 +44,7 @@
+ {return (new MetaSequenceNameEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METASEQUENCENAME);}
+- virtual char *GetTypeStr(void) const {return ("MetaSequenceNameEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaSequenceNameEvent");}
+ virtual char *GetEventStr(void) const;
+
+ MetaSequenceNameEvent &operator=(const MetaSequenceNameEvent &e);
+--- events/MSeqNum.h 1996-02-18 19:57:43.000000000 -0500
++++ events/MSeqNum.h 2012-04-07 14:08:43.000000000 -0400
+@@ -44,7 +44,7 @@
+ {return (new MetaSequenceNumberEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METASEQUENCENUMBER);}
+- virtual char *GetTypeStr(void) const
++ virtual const char *GetTypeStr(void) const
+ {return ("MetaSequenceNumberEvent");}
+ virtual char *GetEventStr(void) const;
+ long GetNumber(void) const {
+--- events/MSeqSpec.cxx 1996-07-28 15:09:24.000000000 -0400
++++ events/MSeqSpec.cxx 2012-04-07 15:47:09.000000000 -0400
+@@ -74,7 +74,7 @@
+ MetaSequencerSpecificEvent::~MetaSequencerSpecificEvent()
+ {
+
+- delete data;
++ delete[] data;
+ }
+
+ void
+@@ -82,7 +82,7 @@
+ {
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if (dat == WC_DATA || len == WC_LENGTH) {
+ SetWildcard(wc_data);
+ data = 0;
+@@ -102,7 +102,7 @@
+
+ (MetaEvent)*this = (MetaEvent)e;
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if (e.GetWildcard(wc_data)) {
+ data = 0;
+ length = -1;
+@@ -144,7 +144,7 @@
+ const unsigned char *ptr;
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if ((length = t.GetVarValue()) == -1)
+ return ("Incomplete MetaSequenceSpecificEvent - bad length");
+ data = new unsigned char[length];
+--- events/MSeqSpec.h 1996-02-18 19:57:45.000000000 -0500
++++ events/MSeqSpec.h 2012-04-07 14:08:43.000000000 -0400
+@@ -46,7 +46,7 @@
+ {return (new MetaSequencerSpecificEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METASEQUENCERSPECIFIC);}
+- virtual char *GetTypeStr(void) const
++ virtual const char *GetTypeStr(void) const
+ {return ("MetaSequencerSpecificEvent");}
+ virtual char *GetEventStr(void) const;
+ const unsigned char *GetData(void) const {
+--- events/MTempo.h 1996-02-18 19:57:49.000000000 -0500
++++ events/MTempo.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new MetaTempoEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METATEMPO);}
+- virtual char *GetTypeStr(void) const {return ("MetaTempoEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaTempoEvent");}
+ virtual char *GetEventStr(void) const;
+ short GetTempo(void) const {
+ if (GetWildcard(wc_tempo))
+--- events/MText.cxx 1996-07-28 15:09:25.000000000 -0400
++++ events/MText.cxx 2012-04-07 15:46:17.000000000 -0400
+@@ -83,14 +83,14 @@
+ MetaTextEvent::~MetaTextEvent()
+ {
+
+- delete string;
++ delete[] string;
+ }
+
+ void
+ MetaTextEvent::SetString(const char *str)
+ {
+
+- delete string;
++ delete[] string;
+ if (str == WC_STRING) {
+ string = 0;
+ length = -1;
+@@ -110,7 +110,7 @@
+
+ (MetaEvent)*this = (MetaEvent)e;
+ length = e.length;
+- delete string;
++ delete[] string;
+ if (e.GetWildcard(wc_string)) {
+ string = 0;
+ return (*this);
+@@ -144,7 +144,7 @@
+ const unsigned char *ptr;
+
+ if (string != 0)
+- delete string;
++ delete[] string;
+ if ((length = t.GetVarValue()) == -1)
+ return ("Incomplete MetaTextEvent - bad length");
+ string = new char[length + 1];
+--- events/MText.h 1996-02-18 19:57:52.000000000 -0500
++++ events/MText.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaTextEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METATEXT);}
+- virtual char *GetTypeStr(void) const {return ("MetaTextEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaTextEvent");}
+ virtual char *GetEventStr(void) const;
+ const char *GetString(void) const {
+ if (GetWildcard(wc_string))
+--- events/MTime.h 1996-02-18 19:57:55.000000000 -0500
++++ events/MTime.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new MetaTimeEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METATIME);}
+- virtual char *GetTypeStr(void) const {return ("MetaTimeEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaTimeEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetNumerator(void) const {
+ if (GetWildcard(wc_numerator))
+--- events/MUnknown.cxx 1996-07-28 15:09:26.000000000 -0400
++++ events/MUnknown.cxx 2012-04-07 15:48:00.000000000 -0400
+@@ -86,14 +86,14 @@
+ MetaUnknownEvent::~MetaUnknownEvent()
+ {
+
+- delete data;
++ delete[] data;
+ }
+
+ void
+ MetaUnknownEvent::SetData(const unsigned char *dat, long len)
+ {
+
+- delete data;
++ delete[] data;
+ if (dat == WC_DATA || len == WC_LENGTH) {
+ SetWildcard(wc_data);
+ data = 0;
+@@ -111,7 +111,7 @@
+ {
+
+ (MetaEvent)*this = (MetaEvent)e;
+- delete data;
++ delete[] data;
+ type = e.type;
+ if (e.GetWildcard(wc_data)) {
+ data = 0;
+@@ -158,7 +158,7 @@
+ const unsigned char *ptr;
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if ((length = t.GetVarValue()) == -1)
+ return ("Incomplete MetaUnknownEvent - bad length");
+ data = new unsigned char[length];
+--- events/MUnknown.h 1996-02-25 18:09:15.000000000 -0500
++++ events/MUnknown.h 2012-04-07 14:08:43.000000000 -0400
+@@ -45,7 +45,7 @@
+ virtual Event *Dup(void) const {return (new MetaUnknownEvent(*this));}
+
+ virtual EventType GetType(void) const {return (METAUNKNOWN);}
+- virtual char *GetTypeStr(void) const {return ("MetaUnknownEvent");}
++ virtual const char *GetTypeStr(void) const {return ("MetaUnknownEvent");}
+ virtual char *GetEventStr(void) const;
+ const unsigned char *GetData(void) const {
+ if (GetWildcard(wc_data))
+--- events/NormEvnt.h 1996-02-18 19:58:01.000000000 -0500
++++ events/NormEvnt.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new NormalEvent(*this));}
+
+ virtual EventType GetType(void) const {return (NORMAL);}
+- virtual char *GetTypeStr(void) const {return ("NormalEvent");}
++ virtual const char *GetTypeStr(void) const {return ("NormalEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetChannel(void) const {
+ if (GetWildcard(wc_channel))
+--- events/Note.h 1996-02-25 18:09:19.000000000 -0500
++++ events/Note.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new NoteEvent(*this));}
+
+ virtual EventType GetType(void) const {return (NOTE);}
+- virtual char *GetTypeStr(void) const {return ("NoteEvent");}
++ virtual const char *GetTypeStr(void) const {return ("NoteEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetPitch(void) const {
+ if (GetWildcard(wc_pitch))
+--- events/NoteOff.h 1996-02-18 19:58:07.000000000 -0500
++++ events/NoteOff.h 2012-04-07 14:08:43.000000000 -0400
+@@ -43,7 +43,7 @@
+ virtual Event *Dup(void) const {return (new NoteOffEvent(*this));}
+
+ virtual EventType GetType(void) const {return (NOTEOFF);}
+- virtual char *GetTypeStr(void) const {return ("NoteOffEvent");}
++ virtual const char *GetTypeStr(void) const {return ("NoteOffEvent");}
+ virtual char *GetEventStr(void) const;
+
+ NoteOffEvent &operator=(const NoteOffEvent &e);
+--- events/NoteOn.h 1996-02-25 18:09:22.000000000 -0500
++++ events/NoteOn.h 2012-04-07 14:08:43.000000000 -0400
+@@ -45,7 +45,7 @@
+ virtual Event *Dup(void) const {return (new NoteOnEvent(*this));}
+
+ virtual EventType GetType(void) const {return (NOTEON);}
+- virtual char *GetTypeStr(void) const {return ("NoteOnEvent");}
++ virtual const char *GetTypeStr(void) const {return ("NoteOnEvent");}
+ virtual char *GetEventStr(void) const;
+
+ unsigned long GetDuration(void) const {
+--- events/Param.h 1996-02-18 19:58:13.000000000 -0500
++++ events/Param.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new ParameterEvent(*this));}
+
+ virtual EventType GetType(void) const {return (PARAMETER);}
+- virtual char *GetTypeStr(void) const {return ("ParameterEvent");}
++ virtual const char *GetTypeStr(void) const {return ("ParameterEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetParameter(void) const {
+ if (GetWildcard(wc_parameter))
+--- events/PitchWhl.h 1996-02-18 19:58:16.000000000 -0500
++++ events/PitchWhl.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new PitchWheelEvent(*this));}
+
+ virtual EventType GetType(void) const {return (PITCHWHEEL);}
+- virtual char *GetTypeStr(void) const {return ("PitchWheelEvent");}
++ virtual const char *GetTypeStr(void) const {return ("PitchWheelEvent");}
+ virtual char *GetEventStr(void) const;
+ long GetValue(void) const {
+ if (GetWildcard(wc_value))
+--- events/Program.h 1996-02-18 19:58:19.000000000 -0500
++++ events/Program.h 2012-04-07 14:08:43.000000000 -0400
+@@ -42,7 +42,7 @@
+ virtual Event *Dup(void) const {return (new ProgramEvent(*this));}
+
+ virtual EventType GetType(void) const {return (PROGRAM);}
+- virtual char *GetTypeStr(void) const {return ("ProgramEvent");}
++ virtual const char *GetTypeStr(void) const {return ("ProgramEvent");}
+ virtual char *GetEventStr(void) const;
+ int GetValue(void) const {
+ if (GetWildcard(wc_value))
+--- events/SysEx.cxx 1996-07-28 15:09:30.000000000 -0400
++++ events/SysEx.cxx 2012-04-07 15:44:56.000000000 -0400
+@@ -81,7 +81,7 @@
+ SystemExclusiveEvent::~SystemExclusiveEvent()
+ {
+
+- delete data;
++ delete[] data;
+ }
+
+ void
+@@ -89,7 +89,7 @@
+ {
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if (len == WC_LENGTH || dat == WC_DATA) {
+ SetWildcard(wc_data);
+ data = 0;
+@@ -107,7 +107,7 @@
+
+ (Event)*this = (Event)e;
+ if (data != 0)
+- delete data;
++ delete[] data;
+ continued = e.continued;
+ length = e.length;
+ if (e.GetWildcard(wc_data)) {
+@@ -148,7 +148,7 @@
+ const unsigned char *ptr;
+
+ if (data != 0)
+- delete data;
++ delete[] data;
+ if ((length = t.GetVarValue()) == -1)
+ return ("Incomplete SystemExclusiveEvent - bad length");
+ data = new unsigned char[length];
+--- events/SysEx.h 1996-02-18 19:58:22.000000000 -0500
++++ events/SysEx.h 2012-04-07 14:08:43.000000000 -0400
+@@ -46,7 +46,7 @@
+ {return (new SystemExclusiveEvent(*this));}
+
+ virtual EventType GetType(void) const {return (SYSTEMEXCLUSIVE);}
+- virtual char *GetTypeStr(void) const {return ("SystemExclusiveEvent");}
++ virtual const char *GetTypeStr(void) const {return ("SystemExclusiveEvent");}
+ virtual char *GetEventStr(void) const;
+ const unsigned char *GetData(void) const {
+ if (GetWildcard(wc_data))
+--- smf/SMFUtils.cxx 1996-08-04 23:47:36.000000000 -0400
++++ smf/SMFUtils.cxx 2012-04-07 14:08:43.000000000 -0400
+@@ -59,7 +59,7 @@
+ }
+
+ long
+-MWrite(int fd, char *data, long len)
++MWrite(int fd, const char *data, long len)
+ {
+ int num_written;
+ int total_written;
+@@ -96,7 +96,7 @@
+ }
+
+ long
+-MWrite(Tcl_Channel channel, char *data, long len)
++MWrite(Tcl_Channel channel, const char *data, long len)
+ {
+ int num_written;
+ int total_written;
+@@ -116,7 +116,7 @@
+
+
+ long
+-VarToFix(unsigned char *var, int *len)
++VarToFix(const unsigned char *var, int *len)
+ {
+ long fix;
+
+--- smf/SMFUtils.h 1996-08-04 23:47:36.000000000 -0400
++++ smf/SMFUtils.h 2012-04-07 14:08:43.000000000 -0400
+@@ -147,9 +147,9 @@
+
+
+ extern long MRead(int fd, char *data, long len);
+-extern long MWrite(int fd, char *data, long len);
++extern long MWrite(int fd, const char *data, long len);
+ extern long MRead(Tcl_Channel channel, char *data, long len);
+-extern long MWrite(Tcl_Channel channel, char *data, long len);
+-extern long VarToFix(unsigned char *var, int *len);
++extern long MWrite(Tcl_Channel channel, const char *data, long len);
++extern long VarToFix(const unsigned char *var, int *len);
+ extern int FixToVar(long fix, unsigned char *var);
+ #endif
+--- song/EvntTree.cxx 1996-08-04 23:47:38.000000000 -0400
++++ song/EvntTree.cxx 2012-04-11 01:45:51.000000000 -0400
+@@ -611,7 +611,7 @@
+ for (j = 0; j < num_found; j++)
+ new_found[j] = found[j];
+ new_found[j] = e;
+- delete found;
++ delete[] found;
+ found = new_found;
+ num_found++;
+ }
+@@ -631,7 +631,7 @@
+ for (j = 0; j < num_found; j++)
+ new_found[j] = found[j];
+ new_found[j] = e;
+- delete found;
++ delete[] found;
+ found = new_found;
+ num_found++;
+ }
+@@ -735,6 +735,7 @@
+ assert(new_event != 0);
+ place = rb_insert_b(place, (char *)time, (char *)new_event);
+ }
++
+ curr_event = new_event;
+ new_event->SetEventTreeNode(place);
+ return (new_event);
+@@ -746,7 +747,7 @@
+ Event *e, *events, *prev;
+ EventTreeNode *n, *next_n;
+
+- n = (EventTreeNode *)event.GetEventTreeNode();
++ n = event.GetEventTreeNode();
+ if (n != 0) {
+ e = &event;
+ prev = e->GetPrevEvent();
+@@ -785,6 +786,9 @@
+ }
+
+ }
++ if (e->GetNextEvent() == 0 ||
++ prev && prev->GetEventTreeNode() != n)
++ rb_delete_node(n);
+ } else {
+ // This is the only event in the node
+ if (curr_event == e) {
+@@ -818,7 +822,7 @@
+ /* get each event in order and delete it */
+ while ((e = NextEvent()) != 0)
+ DeleteEvent(*e);
+-
++
+ /* then free head */
+ free(head);
+ head = 0;
+--- song/Song.cxx 1996-08-04 23:47:39.000000000 -0400
++++ song/Song.cxx 2012-04-11 01:02:09.000000000 -0400
+@@ -51,7 +51,7 @@
+ }
+ for (i = 0; i < s.num_tracks; i++) {
+ tracks[i] = new EventTree(*s.tracks[i]);
+- assert(tracks[1] != 0);
++ assert(tracks[i] != 0);
+ }
+ }
+
+@@ -102,7 +102,7 @@
+
+ for (i = 0; i < num_tracks; i++)
+ delete tracks[i];
+- delete tracks;
++ delete[] tracks;
+ }
+
+ Event *
+--- tclmCmd.cxx 1996-08-04 23:47:12.000000000 -0400
++++ tclmCmd.cxx 2012-04-11 01:14:10.000000000 -0400
+@@ -41,39 +41,27 @@
+ #include "tclmEvnt.h"
+ #include "patchlvl.h"
+
+-static int Tclm_MidiMake(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiFree(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiRead(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiWrite(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiConfig(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiRewind(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiGet(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiPut(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiDelete(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiMerge(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiSplit(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiCopy(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiVersion(ClientData client_data, Tcl_Interp *interp,
+- int argc, char **argv);
+-static int Tclm_MidiTrack(ClientData client_data, Tcl_Interp *interp,
+- int argc, char **argv);
+-static int Tclm_MidiGrep(ClientData client_data, Tcl_Interp *interp,
+- int argc, char **argv);
++static Tcl_CmdProc Tclm_MidiMake;
++static Tcl_CmdProc Tclm_MidiFree;
++static Tcl_CmdProc Tclm_MidiRead;
++static Tcl_CmdProc Tclm_MidiWrite;
++static Tcl_CmdProc Tclm_MidiConfig;
++static Tcl_CmdProc Tclm_MidiRewind;
++static Tcl_CmdProc Tclm_MidiGet;
++static Tcl_CmdProc Tclm_MidiPut;
++static Tcl_CmdProc Tclm_MidiDelete;
++static Tcl_CmdProc Tclm_MidiMerge;
++static Tcl_CmdProc Tclm_MidiSplit;
++static Tcl_CmdProc Tclm_MidiCopy;
++static Tcl_CmdProc Tclm_MidiVersion;
++static Tcl_CmdProc Tclm_MidiTrack;
++static Tcl_CmdProc Tclm_MidiGrep;
+ static int Tclm_GetTrack(TclmInterp *tclm_interp, Tcl_Interp *interp,
+ const char *str, Song **song, int *track);
+
++#define SET_CONST_RESULT(string) \
++ Tcl_SetResult(interp, (char *)(void *)string, TCL_STATIC)
++
+
+ /*
+ * DllEntryPoint --
+@@ -98,8 +86,7 @@
+
+ ti = new TclmInterp;
+ if (ti == 0) {
+- Tcl_SetResult(interp, "Out of memory in Tclmidi_Init",
+- TCL_STATIC);
++ SET_CONST_RESULT("Out of memory in Tclmidi_Init");
+ return (TCL_ERROR);
+ }
+ Tcl_CreateCommand(interp, "midimake", Tclm_MidiMake, ti, 0);
+@@ -129,7 +116,7 @@
+
+ int
+ Tclm_MidiMake(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *s;
+@@ -145,13 +132,13 @@
+ s = new Song;
+ key = tclm_interp->AddSong(s);
+ Tcl_SetResult(interp, key, TCL_VOLATILE);
+- delete key;
++ delete[] key;
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiFree(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+
+@@ -171,7 +158,7 @@
+
+ int
+ Tclm_MidiRead(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ Tcl_Channel channel;
+ int mode;
+@@ -211,7 +198,7 @@
+
+ int
+ Tclm_MidiWrite(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -250,12 +237,13 @@
+
+ int
+ Tclm_MidiConfig(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ ostrstream *buf;
+ TclmInterp *tclm_interp;
+ Song *song;
+- char *str, **sub_argv;
++ char *str;
++ const char **sub_argv;
+ int i, sub_argc, value;
+
+ if (argc < 2) {
+@@ -338,8 +326,8 @@
+ }
+ break;
+ default:
+- Tcl_SetResult(interp, "wrong # args: should be "
+- "{format|division|tracks ?value?}", TCL_STATIC);
++ SET_CONST_RESULT("wrong # args: should be "
++ "{format|division|tracks ?value?}");
+ return (TCL_ERROR);
+ break;
+ }
+@@ -350,7 +338,7 @@
+
+ int
+ Tclm_MidiRewind(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -380,7 +368,7 @@
+
+ int
+ Tclm_MidiGet(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ ostrstream *buf;
+ long time;
+@@ -421,7 +409,7 @@
+ printable = 0;
+ while (!printable) {
+ if ((e = song->NextEvent(track)) == 0) {
+- Tcl_SetResult(interp, "EOT", TCL_STATIC);
++ SET_CONST_RESULT("EOT");
+ printable = 1;
+ } else {
+ buf = new ostrstream;
+@@ -432,7 +420,7 @@
+ TCL_VOLATILE);
+ printable = 1;
+ }
+- delete str;
++ delete[] str;
+ delete buf;
+ }
+ }
+@@ -440,7 +428,7 @@
+ printable = 0;
+ while (!printable) {
+ if ((e = song->PrevEvent(track)) == 0) {
+- Tcl_SetResult(interp, "EOT", TCL_STATIC);
++ SET_CONST_RESULT("EOT");
+ printable = 1;
+ } else {
+ buf = new ostrstream;
+@@ -459,7 +447,7 @@
+ if (Tcl_GetLong(interp, argv[3], &time) != TCL_OK)
+ return (TCL_ERROR);
+ if ((events = song->GetEvents((short)track, time)) == 0)
+- Tcl_SetResult(interp, "EOT", TCL_STATIC);
++ SET_CONST_RESULT("EOT");
+ else {
+ for (e = events; e != 0; e = e->GetNextEvent()) {
+ buf = new ostrstream;
+@@ -477,7 +465,7 @@
+
+ int
+ Tclm_MidiPut(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -514,17 +502,16 @@
+
+ if ((event = Tclm_ParseEvent(interp, argv[3])) == 0) {
+ if (strlen(interp->result) == 0)
+- Tcl_SetResult(interp, "No more memory", TCL_STATIC);
++ SET_CONST_RESULT("No more memory");
+ return (TCL_ERROR);
+ }
+ if (event->IsWildcard()) {
+- Tcl_SetResult(interp, "Can't put wildcard events in a song",
+- TCL_STATIC);
++ SET_CONST_RESULT("Can't put wildcard events in a song");
+ return (TCL_ERROR);
+ }
+ new_e1 = song->PutEvent(track, *event);
+ if (new_e1 == 0) {
+- Tcl_SetResult(interp, "Couldn't put event", TCL_STATIC);
++ SET_CONST_RESULT("Couldn't put event");
+ return (TCL_ERROR);
+ }
+ // check to see if it has a note off too
+@@ -534,8 +521,7 @@
+ if (np != 0) {
+ new_e2 = (NoteEvent *)song->PutEvent(track, *np);
+ if (new_e2 == 0) {
+- Tcl_SetResult(interp, "Couldn't put event",
+- TCL_STATIC);
++ SET_CONST_RESULT("Couldn't put event");
+ return (TCL_ERROR);
+ }
+ ((NoteEvent *)new_e1)->SetNotePair(new_e2);
+@@ -549,7 +535,7 @@
+
+ int
+ Tclm_MidiDelete(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -592,17 +578,16 @@
+ if (Tcl_GetLong(interp, argv[5], (long *)&end) != TCL_OK)
+ return (TCL_ERROR);
+ if (!song->DeleteRange(track, start, end)) {
+- Tcl_SetResult(interp, "couldn't delete range",
+- TCL_STATIC);
++ SET_CONST_RESULT("couldn't delete range");
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ if ((event = Tclm_ParseEvent(interp, argv[3])) == 0) {
+ if (strlen(interp->result) == 0)
+- Tcl_SetResult(interp, "No more memory", TCL_STATIC);
++ SET_CONST_RESULT("No more memory");
+ return (TCL_ERROR);
+ }
+ // If this is a NoteOn/NoteOff pair, get real NoteOff from tree
+@@ -616,7 +601,7 @@
+ for (e = events; e != 0 && !(*event == *e);
+ e = e->GetNextEvent());
+ if (e == 0) {
+- Tcl_SetResult(interp, "0", TCL_STATIC);
++ SET_CONST_RESULT("0");
+ delete ((NoteEvent *)event)->GetNotePair();
+ delete event;
+ return (TCL_OK);
+@@ -625,7 +610,7 @@
+ // find real NoteOff pair and delete it
+ note_off = ((NoteEvent *)e)->GetNotePair();
+ if (!song->DeleteEvent(track, *note_off)) {
+- Tcl_SetResult(interp, "0", TCL_STATIC);
++ SET_CONST_RESULT("0");
+ delete ((NoteEvent *)event)->GetNotePair();
+ delete event;
+ return (TCL_OK);
+@@ -633,7 +618,7 @@
+ delete ((NoteEvent *)event)->GetNotePair();
+ }
+ if (!song->DeleteEvent(track, *event)) {
+- Tcl_SetResult(interp, "0", TCL_STATIC);
++ SET_CONST_RESULT("0");
+ if (event->GetType() == NOTEON &&
+ ((NoteEvent *)event)->GetNotePair() != 0)
+ delete ((NoteEvent *)event)->GetNotePair();
+@@ -641,13 +626,13 @@
+ return (TCL_OK);
+ }
+ delete event;
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiMerge(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *dest_song, *src_song;
+@@ -680,7 +665,7 @@
+
+ int
+ Tclm_MidiSplit(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *src_song, *meta_song, *normal_song;
+@@ -715,7 +700,7 @@
+
+ int
+ Tclm_MidiCopy(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ EventTree *tmp_track;
+@@ -748,6 +733,7 @@
+ scalar = (double)dest_song->GetDivision() / src_song->GetDivision();
+
+ tmp_track = src_song->GetRange(src_track, sstart, send);
++fprintf(stderr, "Got tmp_track as %p\n", tmp_track);
+ if (tmp_track == 0) {
+ Tcl_AppendResult(interp, "Couldn't get range from: ", argv[3],
+ " to ", argv[4], 0);
+@@ -757,20 +743,23 @@
+ if (!src_song->DeleteRange(src_track, sstart, send)) {
+ Tcl_AppendResult(interp, "Couldn't remove events "
+ "from source track", 0);
++ delete tmp_track;
+ return (TCL_ERROR);
+ }
+ }
+ if (!dest_song->Add(dest_track, *tmp_track, dstart, scalar)) {
+ Tcl_AppendResult(interp, "Couldn't add range", 0);
++ delete tmp_track;
+ return (TCL_ERROR);
+ }
++fprintf(stderr, "Deleting tmp_track %p\n", tmp_track);
+ delete tmp_track;
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiVersion(ClientData client_data, Tcl_Interp *interp, int argc,
+- char *argv[])
++ const char *argv[])
+ {
+ ClientData *dummy;
+
+@@ -782,13 +771,13 @@
+ argv[0], "\"", 0);
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, (char *)TCLMIDI_VERSION, TCL_STATIC);
++ SET_CONST_RESULT(TCLMIDI_VERSION);
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiTrack(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -848,7 +837,7 @@
+
+ int
+ Tclm_MidiGrep(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -857,6 +846,7 @@
+ NoteEvent *np;
+ ostrstream *buf;
+ char *str;
++ int result;
+
+ if (argc < 4) {
+ Tcl_AppendResult(interp, "wrong # args: should be \"",
+@@ -888,7 +878,7 @@
+ num_events = argc - 3;
+ events = new Event *[num_events];
+ if (events == 0) {
+- Tcl_SetResult(interp, "No more memory", TCL_STATIC);
++ SET_CONST_RESULT("No more memory");
+ return (TCL_ERROR);
+ }
+ for (i = 0; i < num_events; i++) {
+@@ -896,8 +886,7 @@
+ events[i] = Tclm_ParseEvent(interp, argv[i + 3]);
+ if (events[i] == 0) {
+ if (strlen(interp->result) == 0)
+- Tcl_SetResult(interp, "No more memory",
+- TCL_STATIC);
++ SET_CONST_RESULT("No more memory");
+ i--;
+ for (; i >= 0; i--) {
+ if (events[i]->GetType() == NOTEON) {
+@@ -913,9 +902,11 @@
+ }
+ }
+ if (!song->Grep(track, events, num_events, &matched, &num_matched)) {
+- Tcl_SetResult(interp, "midigrep failed", TCL_STATIC);
+- return (TCL_ERROR);
+- }
++ SET_CONST_RESULT("midigrep failed");
++ result = TCL_ERROR;
++ } else
++ result = TCL_OK;
++
+ for (i = 0; i < num_events; i++) {
+ if (events[i]->GetType() == NOTEON) {
+ np = ((NoteEvent *)events[i])->GetNotePair();
+@@ -924,33 +915,33 @@
+ }
+ delete events[i];
+ }
+- delete events;
++ delete[] events;
+ for (i = 0; i < num_matched; i++) {
+ buf = new ostrstream;
+ Tclm_PrintEvent(*buf, matched[i]);
+ str = buf->str();
+ if (str != 0 && str[0] != '\0')
+ Tcl_AppendElement(interp, str);
+- delete str;
++ delete[] str;
+ delete buf;
+ }
+- delete matched;
++ delete[] matched;
++ return (result);
+ return (TCL_OK);
+ }
+
+-
+ int
+ Tclm_GetTrack(TclmInterp *tclm_interp, Tcl_Interp *interp, const char *str,
+ Song **song, int *track)
+ {
+- char **sub_argv;
++ const char **sub_argv;
+ int sub_argc;
+
+- if (Tcl_SplitList(interp, (char *)str, &sub_argc, &sub_argv) != TCL_OK)
++ if (Tcl_SplitList(interp, str, &sub_argc, &sub_argv) != TCL_OK)
+ return (TCL_ERROR);
+ if (sub_argc != 2) {
+- Tcl_SetResult(interp, "bad track designation: "
+- "should be \"{MidiID Track}\"", TCL_STATIC);
++ SET_CONST_RESULT("bad track designation: "
++ "should be \"{MidiID Track}\"");
+ Tcl_Ckfree((char *)sub_argv);
+ return (TCL_ERROR);
+ }
+--- tclmEvnt.cxx 1996-07-29 20:14:11.000000000 -0400
++++ tclmEvnt.cxx 2012-04-07 15:42:14.000000000 -0400
+@@ -44,6 +44,9 @@
+ #include "tclmidi.h"
+ #include "tclmEvnt.h"
+
++#define SET_CONST_RESULT(string) \
++ Tcl_SetResult(interp, (char *)(void *)string, TCL_STATIC)
++
+ void
+ Tclm_PrintEvent(ostream &buf, Event *e)
+ {
+@@ -148,7 +151,7 @@
+ buf << "* " << str << ends;
+ else
+ buf << e->GetTime() << " " << str << ends;
+- delete str;
++ delete[] str;
+ }
+
+ char *
+@@ -552,13 +555,9 @@
+ }
+
+ char *
+-Tclm_PrintMetaEndOfTrack(MetaEndOfTrackEvent *e)
++Tclm_PrintMetaEndOfTrack(MetaEndOfTrackEvent *)
+ {
+ ostrstream buf;
+- MetaEndOfTrackEvent *dummy;
+-
+- // shut up a warning
+- dummy = e;
+
+ buf << "MetaEndOfTrack" << ends;
+ return (buf.str());
+@@ -722,11 +721,11 @@
+ }
+
+ Event *
+-Tclm_ParseEvent(Tcl_Interp *interp, char *str)
++Tclm_ParseEvent(Tcl_Interp *interp, const char *str)
+ {
+ Event *event;
+- Event *(*pfunc)(Tcl_Interp *, long, int, char **);
+- char **argv, **aptr;;
++ Event *(*pfunc)(Tcl_Interp *, long, int, const char **);
++ const char **argv, **aptr;
+ char *name;
+ long time;
+ int argc, i, length;
+@@ -852,18 +851,19 @@
+ }
+ event = pfunc(interp, time, argc, argv);
+ Tcl_Ckfree((char *)aptr);
+- delete name;
++ delete[] name;
+ return (event);
+ }
+
+ Event *
+-Tclm_ParseNoteOff(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseNoteOff(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, pitch, velocity;
+
+ if (argc != 3 && argc != 4) {
+- Tcl_SetResult(interp, "bad event: should be \"time NoteOff "
+- "channel pitch ?velocity?\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time NoteOff "
++ "channel pitch ?velocity?\"");
+ return (0);
+ }
+
+@@ -886,13 +886,14 @@
+ }
+
+ Event *
+-Tclm_ParseNoteOn(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseNoteOn(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, pitch, velocity;
+
+ if (argc != 4) {
+- Tcl_SetResult(interp, "bad event: should be \"time NoteOn "
+- "channel pitch velocity\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time NoteOn "
++ "channel pitch velocity\"");
+ return (0);
+ }
+
+@@ -913,7 +914,8 @@
+ }
+
+ Event *
+-Tclm_ParseNote(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseNote(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ NoteOnEvent *event;
+ NoteOffEvent *off;
+@@ -921,8 +923,8 @@
+ int channel, pitch, velocity;
+
+ if (argc != 5) {
+- Tcl_SetResult(interp, "bad event: should be \"time Note "
+- "channel pitch velocity duration\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time Note "
++ "channel pitch velocity duration\"");
+ return (0);
+ }
+
+@@ -964,13 +966,14 @@
+ }
+
+ Event *
+-Tclm_ParseKeyPressure(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseKeyPressure(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, pitch, pressure;
+
+ if (argc != 4) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time KeyPressure channel pitch pressure\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time KeyPressure channel pitch pressure\"");
+ return (0);
+ }
+
+@@ -991,13 +994,14 @@
+ }
+
+ Event *
+-Tclm_ParseParameter(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseParameter(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, parameter, value;
+
+ if (argc != 4) {
+- Tcl_SetResult(interp, "bad event: should be \"time Parameter "
+- "channel parameter value\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time Parameter "
++ "channel parameter value\"");
+ return (0);
+ }
+
+@@ -1018,13 +1022,14 @@
+ }
+
+ Event *
+-Tclm_ParseProgram(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseProgram(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, value;
+
+ if (argc != 3) {
+- Tcl_SetResult(interp, "bad event: should be \"time Program "
+- "channel value\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time Program "
++ "channel value\"");
+ return (0);
+ }
+
+@@ -1041,13 +1046,14 @@
+ }
+
+ Event *
+-Tclm_ParseChannelPressure(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseChannelPressure(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel, pressure;
+
+ if (argc != 3) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time ChannelPressure channel pressure\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time ChannelPressure channel pressure\"");
+ return (0);
+ }
+
+@@ -1064,14 +1070,15 @@
+ }
+
+ Event *
+-Tclm_ParsePitchWheel(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParsePitchWheel(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int channel;
+ long value;
+
+ if (argc != 3) {
+- Tcl_SetResult(interp, "bad event: should be \"time PitchWheel "
+- "channel value\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time PitchWheel "
++ "channel value\"");
+ return (0);
+ }
+
+@@ -1088,19 +1095,19 @@
+ }
+
+ Event *
+-Tclm_ParseSystemExclusive(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseSystemExclusive(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+- char **str;
++ const char **str;
+ SystemExclusiveEvent *event;
+ unsigned char *data;
+- long len;
++ int len;
+ int i, val;
+
+ if ((argc != 2 && argc != 3) || (argc == 3 && strncmp(argv[1], "cont",
+ 4) != 0)) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time SystemExclusive ?continued? {data ?data ...?}\"",
+- TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time SystemExclusive ?continued? {data ?data ...?}\"");
+ return (0);
+ }
+
+@@ -1111,7 +1118,7 @@
+ event = new SystemExclusiveEvent(time, data, len);
+ return (event);
+ }
+- if (Tcl_SplitList(interp, argv[1], (int *)&len, &str) != TCL_OK)
++ if (Tcl_SplitList(interp, argv[1], &len, &str) != TCL_OK)
+ return (0);
+ } else {
+ if (strcmp(argv[2], "*") == 0) {
+@@ -1121,7 +1128,7 @@
+ event->SetContinued(1);
+ return (event);
+ }
+- if (Tcl_SplitList(interp, argv[2], (int *)&len, &str) != TCL_OK)
++ if (Tcl_SplitList(interp, argv[2], &len, &str) != TCL_OK)
+ return (0);
+ }
+
+@@ -1139,20 +1146,20 @@
+ event = new SystemExclusiveEvent(time, data, len);
+ if (argc == 3)
+ event->SetContinued(1);
+- delete data;
++ delete[] data;
+
+ return (event);
+ }
+
+ Event *
+ Tclm_ParseMetaSequenceNumber(Tcl_Interp *interp, long time, int argc,
+- char **argv)
++ const char **argv)
+ {
+ long num;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaSequenceNumber number\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaSequenceNumber number\"");
+ return (0);
+ }
+
+@@ -1165,13 +1172,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaText(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaText(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaText "
+- "string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaText "
++ "string\"");
+ return (0);
+ }
+ if (strcmp(argv[1], "*") == 0)
+@@ -1183,13 +1191,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaCopyright(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaCopyright(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaCopyright string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaCopyright string\"");
+ return (0);
+ }
+
+@@ -1203,13 +1212,13 @@
+
+ Event *
+ Tclm_ParseMetaSequenceName(Tcl_Interp *interp, long time, int argc,
+- char **argv)
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaSequenceName string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaSequenceName string\"");
+ return (0);
+ }
+
+@@ -1223,13 +1232,13 @@
+
+ Event *
+ Tclm_ParseMetaInstrumentName(Tcl_Interp *interp, long time, int argc,
+- char **argv)
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaInstrumentName string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaInstrumentName string\"");
+ return (0);
+ }
+
+@@ -1242,13 +1251,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaLyric(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaLyric(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaLyric "
+- "string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaLyric "
++ "string\"");
+ return (0);
+ }
+
+@@ -1261,13 +1271,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaMarker(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaMarker(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaMarker "
+- "string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaMarker "
++ "string\"");
+ return (0);
+ }
+
+@@ -1280,13 +1291,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaCue(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaCue(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ const char *t;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaCue "
+- "string\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaCue "
++ "string\"");
+ return (0);
+ }
+
+@@ -1300,17 +1312,17 @@
+
+ Event *
+ Tclm_ParseMetaChannelPrefix(Tcl_Interp *interp, long time, int argc,
+- char **argv)
++ const char **argv)
+ {
+- char **str;
++ const char **str;
+ MetaChannelPrefixEvent *event;
+ unsigned char *data;
+- long len;
++ int len;
+ int i, val;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaChannelPrefix {data ?data ...?}\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaChannelPrefix {data ?data ...?}\"");
+ return (0);
+ }
+
+@@ -1319,7 +1331,7 @@
+ len = MetaChannelPrefixEvent::WC_LENGTH;
+ return (new MetaChannelPrefixEvent(time, data, len));
+ }
+- if (Tcl_SplitList(interp, argv[1], (int *)&len, &str) != TCL_OK)
++ if (Tcl_SplitList(interp, argv[1], &len, &str) != TCL_OK)
+ return (0);
+
+ data = new unsigned char[len];
+@@ -1334,19 +1346,20 @@
+
+ Tcl_Ckfree((char *)str);
+ event = new MetaChannelPrefixEvent(time, data, len);
+- delete data;
++ delete[] data;
+
+ return (event);
+ }
+
+ Event *
+-Tclm_ParseMetaPortNumber(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaPortNumber(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int port;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaPortNumber port\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaPortNumber port\"");
+ return (0);
+ }
+
+@@ -1359,16 +1372,13 @@
+ }
+
+ Event *
+-Tclm_ParseMetaEndOfTrack(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaEndOfTrack(Tcl_Interp *interp, long time, int argc,
++ const char **)
+ {
+- char *dummy;
+-
+- // shut up a warning
+- dummy = argv[0];
+
+ if (argc != 1) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaEndOfTrack\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaEndOfTrack\"");
+ return (0);
+ }
+
+@@ -1376,13 +1386,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaTempo(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaTempo(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int tempo;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaTempo "
+- "tempo\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaTempo "
++ "tempo\"");
+ return (0);
+ }
+
+@@ -1395,13 +1406,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaSMPTE(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaSMPTE(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int hour, minute, second, frame, fractional_frame;
+
+ if (argc != 6) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaSMPTE "
+- "hour minute second frame fractional_frame\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaSMPTE "
++ "hour minute second frame fractional_frame\"");
+ return (0);
+ }
+
+@@ -1431,14 +1443,14 @@
+ }
+
+ Event *
+-Tclm_ParseMetaTime(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaTime(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ int numerator, denominator, clocks, thirty_seconds;
+
+ if (argc != 5) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaTime "
+- "numerator denominator clocks/beat 32nds/quarter\"",
+- TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaTime "
++ "numerator denominator clocks/beat 32nds/quarter\"");
+ return (0);
+ }
+
+@@ -1464,15 +1476,16 @@
+ }
+
+ Event *
+-Tclm_ParseMetaKey(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaKey(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+ Key key;
+ Mode mode;
+ int match;
+
+ if (argc != 3) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaKey "
+- "key mode\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaKey "
++ "key mode\"");
+ return (0);
+ }
+
+@@ -1500,18 +1513,17 @@
+
+ Event *
+ Tclm_ParseMetaSequencerSpecific(Tcl_Interp *interp, long time, int argc,
+- char **argv)
++ const char **argv)
+ {
+- char **str;
++ const char **str;
+ MetaSequencerSpecificEvent *event;
+ unsigned char *data;
+- long len;
++ int len;
+ int i, val;
+
+ if (argc != 2) {
+- Tcl_SetResult(interp, "bad event: should be "
+- "\"time MetaSequencerSpecific {data ?data ...?}\"",
+- TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be "
++ "\"time MetaSequencerSpecific {data ?data ...?}\"");
+ return (0);
+ }
+
+@@ -1520,7 +1532,7 @@
+ len = MetaSequencerSpecificEvent::WC_LENGTH;
+ return (new MetaSequencerSpecificEvent(time, data, len));
+ }
+- if (Tcl_SplitList(interp, argv[1], (int *)&len, &str) != TCL_OK)
++ if (Tcl_SplitList(interp, argv[1], &len, &str) != TCL_OK)
+ return (0);
+
+ data = new unsigned char[len];
+@@ -1535,23 +1547,24 @@
+
+ Tcl_Ckfree((char *)str);
+ event = new MetaSequencerSpecificEvent(time, data, len);
+- delete data;
++ delete[] data;
+
+ return (event);
+ }
+
+ Event *
+-Tclm_ParseMetaUnknown(Tcl_Interp *interp, long time, int argc, char **argv)
++Tclm_ParseMetaUnknown(Tcl_Interp *interp, long time, int argc,
++ const char **argv)
+ {
+- char **str;
++ const char **str;
+ MetaUnknownEvent *event;
+ unsigned char *data;
+- long len;
++ int len;
+ int i, type, val;
+
+ if (argc != 3) {
+- Tcl_SetResult(interp, "bad event: should be \"time MetaUnknown "
+- "type {data ?data ...?}\"", TCL_STATIC);
++ SET_CONST_RESULT("bad event: should be \"time MetaUnknown "
++ "type {data ?data ...?}\"");
+ return (0);
+ }
+
+@@ -1565,7 +1578,7 @@
+ len = MetaUnknownEvent::WC_LENGTH;
+ return (new MetaUnknownEvent(time, data, len, type));
+ }
+- if (Tcl_SplitList(interp, argv[2], (int *)&len, &str) != TCL_OK)
++ if (Tcl_SplitList(interp, argv[2], &len, &str) != TCL_OK)
+ return (0);
+
+ data = new unsigned char[len];
+@@ -1580,7 +1593,7 @@
+
+ Tcl_Ckfree((char *)str);
+ event = new MetaUnknownEvent(time, data, len, type);
+- delete data;
++ delete[] data;
+
+ return (event);
+ }
+--- tclmEvnt.h 1996-02-12 19:25:00.000000000 -0500
++++ tclmEvnt.h 2012-04-07 14:08:43.000000000 -0400
+@@ -61,57 +61,57 @@
+ extern char *Tclm_PrintMetaKey(MetaKeyEvent *e);
+ extern char *Tclm_PrintMetaSequencerSpecific(MetaSequencerSpecificEvent *e);
+ extern char *Tclm_PrintMetaUnknown(MetaUnknownEvent *e);
+-extern Event *Tclm_ParseEvent(Tcl_Interp *interp, char *str);
++extern Event *Tclm_ParseEvent(Tcl_Interp *interp, const char *str);
+ extern Event *Tclm_ParseNoteOff(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseNoteOn(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseNote(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseKeyPressure(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseParameter(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseProgram(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseChannelPressure(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParsePitchWheel(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseSystemExclusive(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaSequenceNumber(Tcl_Interp *interp, long time,
+- int argc, char **argv);
++ int argc, const char **argv);
+ extern Event *Tclm_ParseMetaText(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaCopyright(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaSequenceName(Tcl_Interp *interp, long time,
+- int argc, char **argv);
++ int argc, const char **argv);
+ extern Event *Tclm_ParseMetaInstrumentName(Tcl_Interp *interp, long time,
+- int argc, char **argv);
++ int argc, const char **argv);
+ extern Event *Tclm_ParseMetaLyric(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaMarker(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaCue(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaChannelPrefix(Tcl_Interp *interp, long time,
+- int argc, char **argv);
++ int argc, const char **argv);
+ extern Event *Tclm_ParseMetaPortNumber(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaEndOfTrack(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaTempo(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaSMPTE(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaTime(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaKey(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ extern Event *Tclm_ParseMetaSequencerSpecific(Tcl_Interp *interp, long time,
+- int argc, char **argv);
++ int argc, const char **argv);
+ extern Event *Tclm_ParseMetaUnknown(Tcl_Interp *interp, long time, int argc,
+- char **argv);
++ const char **argv);
+ #endif
+--- tclmPlay.cxx 1996-08-04 23:47:12.000000000 -0400
++++ tclmPlay.cxx 2012-04-07 14:08:43.000000000 -0400
+@@ -43,30 +43,24 @@
+ #include "TclmDr75.h"
+ #endif
+
++#define SET_CONST_RESULT(string) \
++ Tcl_SetResult(interp, (char *)(void *)string, TCL_STATIC)
++
+ #if defined(HAVE_SYS_MIDIIOCTL_H)
+ static const int DeviceConfigured = 1;
+ #else
+ static const int DeviceConfigured = 0;
+ #endif
+
+-static int Tclm_MidiPlay(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiRecord(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiStop(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiWait(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiDevice(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiTime(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiFeature(ClientData client_data, Tcl_Interp *interp,
+- int argc, char **argv);
+-static int Tclm_MidiSend(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_MidiRecv(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
++static Tcl_CmdProc Tclm_MidiPlay;
++static Tcl_CmdProc Tclm_MidiRecord;
++static Tcl_CmdProc Tclm_MidiStop;
++static Tcl_CmdProc Tclm_MidiWait;
++static Tcl_CmdProc Tclm_MidiDevice;
++static Tcl_CmdProc Tclm_MidiTime;
++static Tcl_CmdProc Tclm_MidiFeature;
++static Tcl_CmdProc Tclm_MidiSend;
++static Tcl_CmdProc Tclm_MidiRecv;
+
+ int
+ Tclm_PlayInit(Tcl_Interp *interp, TclmInterp *tclm_interp)
+@@ -89,7 +83,7 @@
+
+ int
+ Tclm_MidiPlay(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *song;
+@@ -130,13 +124,13 @@
+ dev->GetError(), 0);
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiRecord(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ Song *rsong, *psong;
+@@ -185,13 +179,13 @@
+ dev->GetError(), 0);
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiStop(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ MidiDevice *dev;
+@@ -214,13 +208,13 @@
+ dev->GetError(), 0);
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiWait(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ MidiDevice *dev;
+@@ -241,19 +235,20 @@
+ "to stop\n", dev->GetError(), 0);
+ return (TCL_ERROR);
+ }
+- Tcl_SetResult(interp, "1", TCL_STATIC);
++ SET_CONST_RESULT("1");
+ return (TCL_OK);
+ }
+
+ int
+ Tclm_MidiDevice(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ MidiDevice *dev;
+ ostrstream *buf;
+ unsigned short mask;
+- char *dev_key, *str, **sub_argv;
++ const char *dev_key, **sub_argv;
++ char *str;
+ int con, i, imask, j, mt, sub_argc, value;
+
+ tclm_interp = (TclmInterp *)client_data;
+@@ -293,7 +288,7 @@
+ dev = 0;
+ #endif
+ if (dev == 0) {
+- Tcl_SetResult(interp, "Out of memory", TCL_STATIC);
++ SET_CONST_RESULT("Out of memory");
+ return (TCL_ERROR);
+ }
+ if (!dev->Open(argv[1])) {
+@@ -303,8 +298,7 @@
+ }
+ dev_key = tclm_interp->AddDevice(dev);
+ if (dev_key == 0) {
+- Tcl_SetResult(interp, "Couldn't add device",
+- TCL_STATIC);
++ SET_CONST_RESULT("Couldn't add device");
+ return (TCL_ERROR);
+ }
+ Tcl_AppendResult(interp, dev_key, 0);
+@@ -317,13 +311,13 @@
+ return (TCL_ERROR);
+ if (strcmp(sub_argv[0], "close") == 0) {
+ if (i != argc - 1) {
+- Tcl_SetResult(interp, "Can't perform ops after "
+- "closing device", TCL_STATIC);
++ SET_CONST_RESULT("Can't perform ops after "
++ "closing device");
+ return (TCL_ERROR);
+ }
+ if (dev_key == 0) {
+- Tcl_SetResult(interp, "Can't close until after "
+- "device has been opened", TCL_STATIC);
++ SET_CONST_RESULT("Can't close until after "
++ "device has been opened");
+ return (TCL_ERROR);
+ }
+ tclm_interp->DeleteDevice(dev_key);
+@@ -465,7 +459,7 @@
+
+ int
+ Tclm_MidiTime(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ ostrstream tbuf;
+ unsigned long t;
+@@ -498,11 +492,11 @@
+
+ int
+ Tclm_MidiFeature(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ MidiDevice *dev;
+- char **sub_argv;
++ const char **sub_argv;
+ int i, sub_argc;
+
+ if (argc < 3) {
+@@ -542,7 +536,7 @@
+
+ int
+ Tclm_MidiSend(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+ MidiDevice *dev;
+@@ -564,7 +558,7 @@
+
+ events = new Event *[argc - 2];
+ if (events == 0) {
+- Tcl_SetResult(interp, "Out of memory", TCL_STATIC);
++ SET_CONST_RESULT("Out of memory");
+ return (TCL_ERROR);
+ }
+ num_events = 0;
+@@ -585,8 +579,7 @@
+ }
+ } else {
+ if (strlen(interp->result) == 0) {
+- Tcl_SetResult(interp, "Out of memory",
+- TCL_STATIC);
++ SET_CONST_RESULT("Out of memory");
+ return (TCL_ERROR);
+ }
+ }
+@@ -603,7 +596,7 @@
+
+ int
+ Tclm_MidiRecv(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ ostrstream *buf;
+ TclmInterp *tclm_interp;
+--- tclmPtch.cxx 1996-08-04 23:47:13.000000000 -0400
++++ tclmPtch.cxx 2012-04-07 14:08:43.000000000 -0400
+@@ -37,10 +37,8 @@
+ #include "tclmidi.h"
+ #include "TclmIntp.h"
+
+-static int Tclm_PatchRead(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
+-static int Tclm_PatchFree(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv);
++static Tcl_CmdProc Tclm_PatchRead;
++static Tcl_CmdProc Tclm_PatchFree;
+
+ int
+ Tclm_PatchInit(Tcl_Interp *interp, TclmInterp *tclm_interp)
+@@ -53,7 +51,7 @@
+
+ int
+ Tclm_PatchRead(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ Tcl_Channel channel;
+ int mode;
+@@ -96,7 +94,7 @@
+
+ int
+ Tclm_PatchFree(ClientData client_data, Tcl_Interp *interp, int argc,
+- char **argv)
++ const char **argv)
+ {
+ TclmInterp *tclm_interp;
+
diff --git a/audio/tclmidi/files/patch-rb b/audio/tclmidi/files/patch-rb
new file mode 100644
index 000000000000..1d9107628373
--- /dev/null
+++ b/audio/tclmidi/files/patch-rb
@@ -0,0 +1,456 @@
+--- rb/rb.h 1994-12-05 16:57:58.000000000 -0500
++++ rb/rb.h 2012-04-07 13:21:08.000000000 -0400
+@@ -34,38 +34,38 @@
+ } v;
+ } *Rb_node;
+
+-#ifndef __P
+-#if defined(__STDC__) || defined(__cplusplus)
+-#define __P(protos) protos
+-#else
+-#define __P(protos) ()
+-#endif
+-#endif
+-
++#ifndef EXTERN
+ #ifdef __cplusplus
+ #define EXTERN extern "C"
+ #else
+ #define EXTERN extern
+ #endif
++#endif
+
+-EXTERN Rb_node make_rb __P(());
+-EXTERN Rb_node rb_insert_b __P((Rb_node node, char *key, char *value));
+-
+-EXTERN Rb_node rb_find_key __P((Rb_node tree, char *key));
+-EXTERN Rb_node rb_find_ikey __P((Rb_node tree, int ikey));
+-EXTERN Rb_node rb_find_ukey __P((Rb_node tree, unsigned long ukey));
+-EXTERN Rb_node rb_find_gkey __P((Rb_node tree, char *key, int (*fxn)()));
+-
+-EXTERN Rb_node rb_find_key_n __P((Rb_node tree, char *key, int *found));
+-EXTERN Rb_node rb_find_ikey_n __P((Rb_node tree, int ikey, int *found));
+-EXTERN Rb_node rb_find_ukey_n __P((Rb_node tree, unsigned long ukey,
+- int *found));
+-EXTERN Rb_node rb_find_gkey_n __P((Rb_node tree, char *key, int (*fxn)(),
+- int *found));
+-EXTERN void rb_delete_node __P((Rb_node node));
+-EXTERN void rb_free_tree __P((Rb_node node)); /* Deletes and frees an entire tree */
+-EXTERN char *rb_val __P((Rb_node node)); /* Returns node->v.val
++typedef int (*Rb_cmp)(const char *key1, const char *key2);
++EXTERN Rb_node make_rb(void);
++EXTERN Rb_node rb_insert_b(Rb_node node, char *key, char *value);
++
++EXTERN Rb_node rb_find_key(Rb_node tree, const char *key);
++EXTERN Rb_node rb_find_ikey(Rb_node tree, int ikey);
++EXTERN Rb_node rb_find_ukey(Rb_node tree, unsigned long ukey);
++EXTERN Rb_node rb_find_gkey(Rb_node tree, const char *key, Rb_cmp);
++
++EXTERN Rb_node rb_find_key_n(Rb_node tree, const char *key, int *found);
++EXTERN Rb_node rb_find_ikey_n(Rb_node tree, int ikey, int *found);
++EXTERN Rb_node rb_find_ukey_n(Rb_node tree, unsigned long ukey,
++ int *found);
++EXTERN Rb_node rb_find_gkey_n(Rb_node tree, const char *key, Rb_cmp,
++ int *found);
++EXTERN void rb_delete_node(Rb_node node);
++EXTERN void rb_free_tree(Rb_node node); /* Deletes and frees an entire tree */
++EXTERN char *rb_val(Rb_node node); /* Returns node->v.val
+ (this is to shut lint up */
++EXTERN void rb_print_tree(const struct rb_node * const t, int level);
++EXTERN void rb_iprint_tree(const struct rb_node * const t, int level);
++EXTERN void rb_uprint_tree(const struct rb_node * const t, int level);
++EXTERN int rb_nblack(const struct rb_node *t);
++EXTERN int rb_plength(const struct rb_node *t);
+
+ #define rb_insert_a(n, k, v) rb_insert_b(n->c.list.flink, k, v)
+ #define rb_insert(t, k, v) rb_insert_b(rb_find_key(t, k), k, v)
+@@ -84,5 +84,5 @@
+ #define rb_traverse(ptr, lst) \
+ for(ptr = rb_first(lst); ptr != nil(lst); ptr = rb_next(ptr))
+
+-EXTERN void recolor __P(());
+-EXTERN void single_rotate __P(());
++EXTERN void recolor(Rb_node);
++EXTERN void single_rotate(Rb_node, int);
+--- rb/rb.c 1994-12-05 16:57:57.000000000 -0500
++++ rb/rb.c 2012-04-07 13:22:05.000000000 -0400
+@@ -37,10 +37,8 @@
+ setnormal(new);\
+ }
+
+-void
+-mk_new_int(l, r, p, il)
+- Rb_node l, r, p;
+- int il;
++static void
++mk_new_int(Rb_node l, Rb_node r, Rb_node p, int il)
+ {
+ Rb_node new;
+
+@@ -71,9 +69,8 @@
+ }
+
+
+-Rb_node
+-lprev(n)
+- Rb_node n;
++static Rb_node
++lprev(Rb_node n)
+ {
+ if (ishead(n))
+ return (n);
+@@ -85,9 +82,8 @@
+ return (n->p.parent);
+ }
+
+-Rb_node
+-rprev(n)
+- Rb_node n;
++static Rb_node
++rprev(Rb_node n)
+ {
+ if (ishead(n))
+ return (n);
+@@ -109,24 +105,20 @@
+ head->c.list.flink = head;
+ head->c.list.blink = head;
+ head->p.root = head;
+- head->k.key = "";
++ /* head->k.key = ""; */
+ head->v.val = NULL;
+ sethead(head);
+ return (head);
+ }
+
+ Rb_node
+-rb_find_key_n(n, key, fnd)
+- Rb_node n;
+- char *key;
+- int *fnd;
++rb_find_key_n(Rb_node n, const char *key, int *fnd)
+ {
+ int cmp;
+
+ *fnd = 0;
+ if (!ishead(n)) {
+- fprintf(stderr, "rb_find_key_n called on non-head 0x%x\n",
+- (int)n);
++ fprintf(stderr, "%s called on non-head %p\n", __func__, n);
+ exit(1);
+ }
+ if (n->p.root == n)
+@@ -156,9 +148,7 @@
+ }
+
+ Rb_node
+-rb_find_key(n, key)
+- Rb_node n;
+- char *key;
++rb_find_key(Rb_node n, const char *key)
+ {
+ int fnd;
+
+@@ -173,8 +163,7 @@
+ {
+ *fnd = 0;
+ if (!ishead(n)) {
+- fprintf(stderr, "rb_find_ikey_n called on non-head 0x%x\n",
+- (int)n);
++ fprintf(stderr, "%s called on non-head %p\n", __func__, n);
+ exit(1);
+ }
+ if (n->p.root == n)
+@@ -208,8 +197,7 @@
+
+ *fnd = 0;
+ if (!ishead(n)) {
+- fprintf(stderr, "rb_find_ukey_n called on non-head 0x%x\n",
+- (int)n);
++ fprintf(stderr, "%s called on non-head %p\n", __func__, n);
+ exit(1);
+ }
+ if (n->p.root == n)
+@@ -255,18 +243,13 @@
+ }
+
+ Rb_node
+-rb_find_gkey_n(n, key, fxn, fnd)
+- Rb_node n;
+- char *key;
+- int (*fxn)();
+- int *fnd;
++rb_find_gkey_n(Rb_node n, const char *key, Rb_cmp fxn, int *fnd)
+ {
+ int cmp;
+
+ *fnd = 0;
+ if (!ishead(n)) {
+- fprintf(stderr, "rb_find_key_n called on non-head 0x%x\n",
+- (int)n);
++ fprintf(stderr, "%s called on non-head %p\n", __func__, n);
+ exit(1);
+ }
+ if (n->p.root == n)
+@@ -296,20 +279,15 @@
+ }
+
+ Rb_node
+-rb_find_gkey(n, key, fxn)
+- Rb_node n;
+- char *key;
+- int (*fxn)();
++rb_find_gkey(Rb_node n, const char *key, Rb_cmp fxn)
+ {
+ int fnd;
+
+ return (rb_find_gkey_n(n, key, fxn, &fnd));
+ }
++
+ Rb_node
+-rb_insert_b(n, key, val)
+- Rb_node n;
+- char *key;
+- char *val;
++rb_insert_b(Rb_node n, char *key, char *val)
+ {
+ Rb_node newleft, newright, newnode, p;
+
+@@ -346,8 +324,7 @@
+ }
+
+ void
+-recolor(n)
+- Rb_node n;
++recolor(Rb_node n)
+ {
+ Rb_node p, gp, s;
+ int done = 0;
+@@ -392,9 +369,7 @@
+ }
+
+ void
+-single_rotate(y, l)
+- Rb_node y;
+- int l;
++single_rotate(Rb_node y, int l)
+ {
+ int rl, ir;
+ Rb_node x, yp;
+@@ -440,20 +415,17 @@
+ }
+
+ void
+-rb_delete_node(n)
+- Rb_node n;
++rb_delete_node(Rb_node n)
+ {
+ Rb_node s, p, gp;
+ char ir;
+
+ if (isint(n)) {
+- fprintf(stderr, "Cannot delete an internal node: 0x%x\n",
+- (int)n);
++ fprintf(stderr, "Cannot delete an internal node: %p\n", n);
+ exit(1);
+ }
+ if (ishead(n)) {
+- fprintf(stderr, "Cannot delete the head of an rb_tree: 0x%x\n",
+- (int)n);
++ fprintf(stderr, "Cannot delete the head of an rb_tree: %p\n", n);
+ exit(1);
+ }
+ delete_item((List)n); /* Delete it from the list */
+@@ -579,120 +551,112 @@
+ }
+
+ void
+-rb_print_tree(t, level)
+- Rb_node t;
+- int level;
++rb_print_tree(const struct rb_node * const t, int level)
+ {
+ int i;
+
+ if (ishead(t) && t->p.parent == t) {
+- printf("tree 0x%x is empty\n",
+- (int)t);
++ printf("tree %p is empty\n", t);
+ } else if (ishead(t)) {
+- printf("Head: 0x%x. Root = 0x%x\n", (int)t, (int)t->p.root);
++ printf("Head: %p. Root = %p\n", t, t->p.root);
+ rb_print_tree(t->p.root, 0);
+ } else {
+ if (isext(t)) {
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Ext node 0x%x: %c,%c: p=0x%x, k=%s\n", (int)t,
++ printf("Ext node %p: %c,%c: p=%p, k=%s\n", t,
+ isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->p.parent, t->k.key);
++ t->p.parent, t->k.key);
+ } else {
+ rb_print_tree(t->c.child.left, level + 2);
+ rb_print_tree(t->c.child.right, level + 2);
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Int node 0x%x: %c,%c: l=0x%x, r=0x%x, p=0x%x, lr=(%s,%s)\n",
+- (int)t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->c.child.left, (int)t->c.child.right,
+- (int)t->p.parent, t->k.lext->k.key,
++ printf("Int node %p: %c,%c: l=%p, r=%p, p=%p, lr=(%s,%s)\n",
++ t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
++ t->c.child.left, t->c.child.right,
++ t->p.parent, t->k.lext->k.key,
+ t->v.rext->k.key);
+ }
+ }
+ }
+
+ void
+-rb_iprint_tree(t, level)
+- Rb_node t;
+- int level;
++rb_iprint_tree(const struct rb_node * const t, int level)
+ {
+ int i;
+
+ if (ishead(t) && t->p.parent == t) {
+- printf("tree 0x%x is empty\n", (int)t);
++ printf("tree %p is empty\n", t);
+ } else if (ishead(t)) {
+- printf("Head: 0x%x. Root = 0x%x, < = 0x%x, > = 0x%x\n",
+- (int)t, (int)t->p.root, (int)t->c.list.blink,
+- (int)t->c.list.flink);
++ printf("Head: %p. Root = %p, < = %p, > = %p\n",
++ t, t->p.root, t->c.list.blink,
++ t->c.list.flink);
+ rb_iprint_tree(t->p.root, 0);
+ } else {
+ if (isext(t)) {
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Ext node 0x%x: %c,%c: p=0x%x, <=0x%x, >=0x%x k=%d\n",
+- (int)t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->p.parent, (int)t->c.list.blink,
+- (int)t->c.list.flink, t->k.ikey);
++ printf("Ext node %p: %c,%c: p=%p, <=%p, >=%p k=%d\n",
++ t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
++ t->p.parent, t->c.list.blink,
++ t->c.list.flink, t->k.ikey);
+ } else {
+ rb_iprint_tree(t->c.child.left, level + 2);
+ rb_iprint_tree(t->c.child.right, level + 2);
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Int node 0x%x: %c,%c: l=0x%x, r=0x%x, p=0x%x, lr=(%d,%d)\n",
+- (int)t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->c.child.left, (int)t->c.child.right,
+- (int)t->p.parent, t->k.lext->k.ikey,
++ printf("Int node %p: %c,%c: l=%p, r=%p, p=%p, lr=(%d,%d)\n",
++ t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
++ t->c.child.left, t->c.child.right,
++ t->p.parent, t->k.lext->k.ikey,
+ t->v.rext->k.ikey);
+ }
+ }
+ }
+
+ void
+-rb_uprint_tree(t, level)
+- Rb_node t;
+- int level;
++rb_uprint_tree(const struct rb_node * const t, int level)
+ {
+ int i;
+ if (ishead(t) && t->p.parent == t) {
+- printf("tree 0x%x is empty\n", (int)t);
++ printf("tree %p is empty\n", t);
+ } else if (ishead(t)) {
+- printf("Head: 0x%x. Root = 0x%x, < = 0x%x, > = 0x%x\n",
+- (int)t, (int)t->p.root, (int)t->c.list.blink,
+- (int)t->c.list.flink);
++ printf("Head: %p. Root = %p, < = %p, > = %p\n",
++ t, t->p.root, t->c.list.blink,
++ t->c.list.flink);
+ rb_uprint_tree(t->p.root, 0);
+ } else {
+ if (isext(t)) {
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Ext node 0x%x: %c,%c: p=0x%x, <=0x%x, >=0x%x k=%lu\n",
+- (int)t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->p.parent, (int)t->c.list.blink,
+- (int)t->c.list.flink, t->k.ukey);
++ printf("Ext node %p: %c,%c: p=%p, <=%p, >=%p k=%lu\n",
++ t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
++ t->p.parent, t->c.list.blink,
++ t->c.list.flink, t->k.ukey);
+ } else {
+ rb_uprint_tree(t->c.child.left, level + 2);
+ rb_uprint_tree(t->c.child.right, level + 2);
+ for (i = 0; i < level; i++)
+ putchar(' ');
+- printf("Int node 0x%x: %c,%c: l=0x%x, r=0x%x, p=0x%x, lr=(%lu,%lu)\n",
+- (int)t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
+- (int)t->c.child.left, (int)t->c.child.right,
+- (int)t->p.parent, t->k.lext->k.ukey,
++ printf("Int node %p: %c,%c: l=%p, r=%p, p=%p, lr=(%lu,%lu)\n",
++ t, isred(t) ? 'R' : 'B', isleft(t) ? 'l' : 'r',
++ t->c.child.left, t->c.child.right,
++ t->p.parent, t->k.lext->k.ukey,
+ t->v.rext->k.ukey);
+ }
+ }
+ }
+
+ int
+-rb_nblack(n)
+- Rb_node(n);
++rb_nblack(const struct rb_node *n)
+ {
+ int nb;
+
+ if (ishead(n) || isint(n)) {
+ fprintf(stderr,
+- "ERROR: rb_nblack called on a non-external node 0x%x\n",
+- (int)n);
++ "ERROR: %s called on a non-external node %p\n",
++ __func__, n);
+ exit(1);
+ }
+ nb = 0;
+@@ -705,15 +669,14 @@
+ }
+
+ int
+-rb_plength(n)
+- Rb_node(n);
++rb_plength(const struct rb_node *n)
+ {
+ int pl;
+
+ if (ishead(n) || isint(n)) {
+ fprintf(stderr,
+- "ERROR: rb_plength called on a non-external node 0x%x\n",
+- (int)n);
++ "ERROR: %s called on a non-external node %p\n",
++ __func__, n);
+ exit(1);
+ }
+ pl = 0;
+@@ -725,13 +688,11 @@
+ }
+
+ void
+-rb_free_tree(n)
+- Rb_node(n);
++rb_free_tree(Rb_node n)
+ {
+
+ if (!ishead(n)) {
+- fprintf(stderr,
+- "ERROR: Rb_free_tree called on a non-head node\n");
++ fprintf(stderr, "%s called on non-head %p\n", __func__, n);
+ exit(1);
+ }
+ while (rb_first(n) != nil(n)) {
diff --git a/audio/tclmidi/files/patch-smf__Makefile.in b/audio/tclmidi/files/patch-smf__Makefile.in
index af1a63d8f89c..83cd73c753c9 100644
--- a/audio/tclmidi/files/patch-smf__Makefile.in
+++ b/audio/tclmidi/files/patch-smf__Makefile.in
@@ -1,12 +1,30 @@
---- smf/Makefile.in.orig Thu Oct 10 05:32:53 1996
-+++ smf/Makefile.in Mon Mar 15 16:30:42 2004
-@@ -14,7 +14,8 @@
+--- smf/Makefile.in Thu Oct 10 05:32:53 1996
++++ smf/Makefile.in 2012-04-07 12:16:41.000000000 -0400
+@@ -14,7 +14,9 @@
VPATH = @srcdir@
CFLAGS = @CFLAGS@ @DEFS@
-CC_SWITCHES = @CFLAGS@ @DEFS@ -I${TCL_GENERIC_DIR} ${SHLIB_CFLAGS}
+CC_SWITCHES = @CFLAGS@ @DEFS@ -I${TCL_GENERIC_DIR} ${SHLIB_CFLAGS} \
+ -I$(srcdir)/../smf -I$(srcdir)/../song -I$(srcdir)/.. -I$(srcdir)
++CXX_SWITCHES= ${CC_SWITCHES} ${CXXFLAGS}
SMFFILES = SMFUtils.o SMFHead.o SMFTrack.o
SMFFILES_SRC = SMFUtils.cxx SMFHead.cxx SMFTrack.cxx
+@@ -22,7 +24,7 @@
+ .SUFFIXES: .cxx $(SUFFIXES)
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ objs: $(SMFFILES)
+ for f in $(SMFFILES) ; do echo smf/$$f ; done > objs
+@@ -31,6 +33,6 @@
+ sed "/[#]# Dependancies/,$$$$d" < Makefile > Makefile.tmp
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(SMFFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(SMFFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
diff --git a/audio/tclmidi/files/patch-song__Makefile.in b/audio/tclmidi/files/patch-song__Makefile.in
index f4cb59a86ebd..594790d70b68 100644
--- a/audio/tclmidi/files/patch-song__Makefile.in
+++ b/audio/tclmidi/files/patch-song__Makefile.in
@@ -1,11 +1,30 @@
---- song/Makefile.in.orig Thu Oct 10 05:32:55 1996
-+++ song/Makefile.in Mon Mar 15 16:39:34 2004
-@@ -15,7 +15,7 @@
+--- song/Makefile.in Thu Oct 10 05:32:55 1996
++++ song/Makefile.in 2012-04-07 12:25:09.000000000 -0400
+@@ -15,7 +15,8 @@
CFLAGS = @CFLAGS@ @DEFS@
CC_SWITCHES = @CFLAGS@ @DEFS@ -I${TCL_GENERIC_DIR} ${SHLIB_CFLAGS} \
- -I$(srcdir)/../events -I$(srcdir)/../rb -I$(srcdir)/../smf -I$(srcdir)
+ -I$(srcdir)/../events -I$(srcdir)/../rb -I$(srcdir)/../smf -I$(srcdir)/.. -I$(srcdir)
++CXX_SWITCHES = ${CC_SWITCHES} ${CXXFLAGS}
SONGFILES = EvntTree.o Song.o
SONGFILES_SRC = EvntTree.cxx Song.cxx
+@@ -23,7 +24,7 @@
+ .SUFFIXES: .cxx $(SUFFIXES)
+
+ .cxx.o:
+- @CXX@ -c $(CC_SWITCHES) $<
++ @CXX@ -c $(CXX_SWITCHES) $<
+
+ objs: $(SONGFILES)
+ for f in $(SONGFILES) ; do echo song/$$f ; done > objs
+@@ -32,7 +33,7 @@
+ sed "/[#]# Dependancies/,$$$$d" < Makefile > Makefile.tmp
+ echo >> Makefile.tmp
+ echo "##" "Dependancies" >> Makefile.tmp
+- @CXX@ -M $(CC_SWITCHES) $(SONGFILES_SRC) >> Makefile.tmp
++ @CXX@ -M $(CXX_SWITCHES) $(SONGFILES_SRC) >> Makefile.tmp
+ cp Makefile.tmp Makefile
+ rm Makefile.tmp
+
diff --git a/audio/tclmidi/files/strstream.h b/audio/tclmidi/files/strstream.h
index 8897edb70330..75480ede00a8 100644
--- a/audio/tclmidi/files/strstream.h
+++ b/audio/tclmidi/files/strstream.h
@@ -36,6 +36,7 @@ using std::strstreambuf;
using std::istrstream;
using std::ostrstream;
using std::strstream;
+using namespace std;
#endif