From 2b015d094da720b9aa5fa1bcb2140c61458b0185 Mon Sep 17 00:00:00 2001
From: Miller Puckette <msp@ucsd.edu>
Date: Mon, 17 Dec 2007 09:47:17 -0800
Subject: [PATCH] several patches from sourceforge

---
 doc/1.manual/x2.htm                |   2 +-
 doc/2.control.examples/24.loops.pd |  49 +++++
 src/configure.in                   | 275 +++++++++++++++--------------
 src/d_misc.c                       |  17 +-
 src/s_path.c                       |  30 ++--
 src/u_main.tk                      |  78 +++++---
 src/x_connective.c                 |   2 +
 7 files changed, 271 insertions(+), 182 deletions(-)
 create mode 100644 doc/2.control.examples/24.loops.pd

diff --git a/doc/1.manual/x2.htm b/doc/1.manual/x2.htm
index dd33b1499..9879078eb 100644
--- a/doc/1.manual/x2.htm
+++ b/doc/1.manual/x2.htm
@@ -25,7 +25,7 @@ are described in the next chapter.  To learn digital audio processing basics
 such as how to generate time-varying sounds that don't click or fold over, try
 the on-line book,
 <A HREF="http://www.crca.ucsd.edu/~msp/techniques.htm"
-<I> Theory and Techniques of Electronic Music </I>.
+<I> Theory and Techniques of Electronic Music </I></A>.
 
 <H3> <A name=s1> 2.1 overview </A> </H3>
 
diff --git a/doc/2.control.examples/24.loops.pd b/doc/2.control.examples/24.loops.pd
new file mode 100644
index 000000000..a0f78bb51
--- /dev/null
+++ b/doc/2.control.examples/24.loops.pd
@@ -0,0 +1,49 @@
+#N canvas 258 107 701 742 12;
+#X obj 195 318 until;
+#X obj 221 284 max 0;
+#X floatatom 221 263 5 0 0 1 times - -;
+#X text 229 234 times;
+#X obj 195 342 print repetition;
+#X msg 195 234 5;
+#X obj 175 571 + 1;
+#X obj 118 572 float;
+#X obj 118 546 until;
+#X obj 118 606 moses 10;
+#X obj 233 558 bang;
+#X obj 118 639 print number;
+#X msg 118 524 bang;
+#X msg 196 529 0;
+#X text 241 529 reset;
+#X text 277 560 stop "until" when counter reaches 10;
+#X text 479 711 updated for Pd 0.41;
+#X text 31 16 Looping with the "until" object;
+#X text 52 47 It is sometimes desirable to make a loop without an embedded
+delay (as in 06.more.counters.pd") but rather to make the entire loop
+take place in the context of a single incoming message. The "until"
+object is provided to make this possible.;
+#X text 273 285 make nonnegative;
+#X text 56 445 Conditional loops get started with a "bang" to until's
+left inlet. Make sure you stop the loop with a "bang" to until's right
+inlet \, otherwise it will try to run forever and Pd will freeze!;
+#X text 48 131 "until" has two modes: It can either run automatically
+for a certain number of times (a "counting" loop) or it can run forever
+until stopped through its right inlet (a "conditional" loop).;
+#X text 47 196 You can perform a counting loop by sending a positive
+number to until:;
+#X text 55 398 (As of version 0.41 \, "until" silently interprets negative
+numbers to be equivalent to zero.);
+#X text 62 667 In pseudo-code: "x=0 \; do print x++ until x>=10";
+#X text 57 368 In pseudo-code: "for i = 1 to 5 do print end";
+#X connect 0 0 4 0;
+#X connect 1 0 0 0;
+#X connect 2 0 1 0;
+#X connect 5 0 0 0;
+#X connect 6 0 7 1;
+#X connect 7 0 6 0;
+#X connect 7 0 9 0;
+#X connect 8 0 7 0;
+#X connect 9 0 11 0;
+#X connect 9 1 10 0;
+#X connect 10 0 8 1;
+#X connect 12 0 8 0;
+#X connect 13 0 7 1;
diff --git a/src/configure.in b/src/configure.in
index b13379c79..66940f6ef 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -42,6 +42,8 @@ AC_ARG_ENABLE(setuid,   [  --enable-setuid         install as setuid (linux)],
     setuid=$enableval)
 AC_ARG_ENABLE(fftw,     [  --enable-fftw           use FFTW package],
     fftw=$enableval)
+AC_ARG_ENABLE(fat,              [  --disable-fat    build fat binary on Mac OS X], 
+    fat=$enableval, fat="yes")
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -77,7 +79,7 @@ AC_CHECK_LIB(ffm, sin,PDLIB="$PDLIB -lffm")
 
 dnl Checking for `sin' function in -lm:
 AC_CHECK_LIB(m, sin,PDLIB="$PDLIB -lm",
-	         echo "math library required" || exit 1)
+                 echo "math library required" || exit 1)
 
 dnl Checking for `pthread_create' function in -pthread
 AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread",
@@ -87,7 +89,7 @@ AC_CHECK_LIB(pthread, pthread_create,PDLIB="$PDLIB -lpthread",
          echo "pthreads required"; exit 1))))
 
 dnl Check for fftw package
-if test x$fftw == "xyes";
+if test x$fftw = "xyes";
 then
 AC_CHECK_LIB(fftw, fftw_one,PDLIB="$PDLIB -lfftw",
     echo "fftw package not found - using built-in FFT"; fftw=no)
@@ -96,83 +98,83 @@ fi
 dnl look for tcl 8.x... do I really have to go through all this!?
 
 foundit=no
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl.h,foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.7/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.6/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.5/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.4/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.4/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/local/include/tcl8.4";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/local/include/tcl8.4";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.3/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     AC_CHECK_HEADER(tcl8.2/tcl.h,
-    	GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2";foundit=yes,)
+        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2";foundit=yes,)
 fi
-if test $foundit == "no";
+if test $foundit = "no";
 then
     echo no tcl header found
-	 echo bolding trying without...
+         echo bolding trying without...
 #    exit -1
 fi
 
 AC_CHECK_LIB(tcl85, main,,
-	AC_CHECK_LIB(tcl8.5, main,,
+        AC_CHECK_LIB(tcl8.5, main,,
         AC_CHECK_LIB(tcl84, main,,
-	    AC_CHECK_LIB(tcl8.4, main,,
-		AC_CHECK_LIB(tcl8.3, main,,
-		    AC_CHECK_LIB(tcl8.2, main,,
-        		            AC_CHECK_LIB(tcl8.0, main,,
+            AC_CHECK_LIB(tcl8.4, main,,
+                AC_CHECK_LIB(tcl8.3, main,,
+                    AC_CHECK_LIB(tcl8.2, main,,
+                                    AC_CHECK_LIB(tcl8.0, main,,
                             echo no tcl library found; exit 1)))))))
 
 AC_CHECK_LIB(tk85, main,,
-	AC_CHECK_LIB(tk8.5, main,,
+        AC_CHECK_LIB(tk8.5, main,,
        AC_CHECK_LIB(tk84, main,,
-	    AC_CHECK_LIB(tk8.4, main,,
-		AC_CHECK_LIB(tk8.3, main,,
-		    AC_CHECK_LIB(tk8.2, main,,
-        		            AC_CHECK_LIB(tk8.0, main,,
+            AC_CHECK_LIB(tk8.4, main,,
+                AC_CHECK_LIB(tk8.3, main,,
+                    AC_CHECK_LIB(tk8.2, main,,
+                                    AC_CHECK_LIB(tk8.0, main,,
                             echo no tk library found; exit 1)))))))
 
 
-if test `uname -s` == Linux;
+if test `uname -s` = Linux;
 then
     dnl Ckecking for ALSA
     echo .................... alsa= $alsa
 dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
-    if test x$alsa == xyes; then
-	AC_CHECK_LIB(asound,snd_pcm_info,PDLIB="$PDLIB -lasound" ; alsa="yes",alsa="no")
+    if test x$alsa = xyes; then
+        AC_CHECK_LIB(asound,snd_pcm_info,PDLIB="$PDLIB -lasound" ; alsa="yes",alsa="no")
     fi
 
     dnl Checking for JACK
 
-    if test x$jack == xyes; then
+    if test x$jack = xyes; then
         AC_CHECK_LIB(rt,shm_open,LIBS="$LIBS -lrt")
         AC_CHECK_LIB(jack,jack_set_xrun_callback,LIBS="$LIBS -ljack";jack=xrun,jack=no)
         AC_CHECK_LIB(jack,jack_set_error_function,LIBS="$LIBS -ljack";jack=yes,jack=no)
@@ -184,69 +186,69 @@ dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
     fi 
     EXT=pd_linux
     CPPFLAGS="-DDL_OPEN -DPA_USE_OSS -DUNIX -DUNISTD\
-    	-DUSEAPI_OSS \
-	-fno-strict-aliasing"
+        -DUSEAPI_OSS \
+        -fno-strict-aliasing"
     SYSSRC="s_midi_oss.c s_audio_oss.c"
-    if test x$alsa == "xyes";
+    if test x$alsa = "xyes";
     then
-    	SYSSRC=$SYSSRC" s_audio_alsa.c s_audio_alsamm.c s_midi_alsa.c"
-	CPPFLAGS=$CPPFLAGS" -DPA_USE_ALSA -DUSEAPI_ALSA"
-	LDFLAGS=$LDFLAGS" -lasound"
+        SYSSRC=$SYSSRC" s_audio_alsa.c s_audio_alsamm.c s_midi_alsa.c"
+        CPPFLAGS=$CPPFLAGS" -DPA_USE_ALSA -DUSEAPI_ALSA"
+        LDFLAGS=$LDFLAGS" -lasound"
     fi
 
-    if test x$portaudio == "xyes";
+    if test x$portaudio = "xyes";
     then
-    	CPPFLAGS=$CPPFLAGS" -DUSEAPI_PORTAUDIO -DHAVE_SYS_SOUNDCARD_H \
-	-Wno-error \
+        CPPFLAGS=$CPPFLAGS" -DUSEAPI_PORTAUDIO -DHAVE_SYS_SOUNDCARD_H \
+        -Wno-error \
         -I../portaudio/include -I../portaudio/src/common \
-	-I../portaudio/src/os/unix/ \
+        -I../portaudio/src/os/unix/ \
         -I../portmidi/pm_common \
         -I../portmidi/pm_linux"
-	SYSSRC="s_audio_pa.c \
-    	s_audio_pablio.c     \
-	s_audio_paring.c     \
-	../portaudio/src/common/pa_allocation.c  \
-	../portaudio/src/common/pa_converters.c  \
-	../portaudio/src/common/pa_cpuload.c     \
-	../portaudio/src/common/pa_dither.c      \
-	../portaudio/src/common/pa_front.c       \
-	../portaudio/src/common/pa_process.c     \
-	../portaudio/src/common/pa_skeleton.c    \
-	../portaudio/src/common/pa_stream.c      \
-	../portaudio/src/common/pa_trace.c       \
-	../portaudio/src/common/pa_debugprint.c  \
-	../portaudio/src/common/pa_ringbuffer.c  \
-	../portaudio/src/os/unix/pa_unix_hostapis.c \
-	../portaudio/src/os/unix/pa_unix_util.c     \
-	../portaudio/src/hostapi/oss/pa_unix_oss.c "$SYSSRC
-	if test x$alsa == "xyes";
-	then
-    	    SYSSRC="../portaudio/src/hostapi/alsa/pa_linux_alsa.c "$SYSSRC
-	    CPPFLAGS=$CPPFLAGS" -DPA_USE_ALSA"
-	fi
-	if test x$jack == "xyes";
-	then
-    	    SYSSRC="../portaudio/src/hostapi/jack/pa_jack.c "$SYSSRC
-	    CPPFLAGS=$CPPFLAGS" -DPA_USE_JACK"
-	fi
+        SYSSRC="s_audio_pa.c \
+        s_audio_pablio.c     \
+        s_audio_paring.c     \
+        ../portaudio/src/common/pa_allocation.c  \
+        ../portaudio/src/common/pa_converters.c  \
+        ../portaudio/src/common/pa_cpuload.c     \
+        ../portaudio/src/common/pa_dither.c      \
+        ../portaudio/src/common/pa_front.c       \
+        ../portaudio/src/common/pa_process.c     \
+        ../portaudio/src/common/pa_skeleton.c    \
+        ../portaudio/src/common/pa_stream.c      \
+        ../portaudio/src/common/pa_trace.c       \
+        ../portaudio/src/common/pa_debugprint.c  \
+        ../portaudio/src/common/pa_ringbuffer.c  \
+        ../portaudio/src/os/unix/pa_unix_hostapis.c \
+        ../portaudio/src/os/unix/pa_unix_util.c     \
+        ../portaudio/src/hostapi/oss/pa_unix_oss.c "$SYSSRC
+        if test x$alsa = "xyes";
+        then
+            SYSSRC="../portaudio/src/hostapi/alsa/pa_linux_alsa.c "$SYSSRC
+            CPPFLAGS=$CPPFLAGS" -DPA_USE_ALSA"
+        fi
+        if test x$jack = "xyes";
+        then
+            SYSSRC="../portaudio/src/hostapi/jack/pa_jack.c "$SYSSRC
+            CPPFLAGS=$CPPFLAGS" -DPA_USE_JACK"
+        fi
     fi
-    if test x$setuid == "xyes";
+    if test x$setuid = "xyes";
     then
-    	binarymode="-m4755"
+        binarymode="-m4755"
     fi
     STRIPFLAG=-s
     GUINAME="pd-gui"
-    if test x$USE_DEBUG_CFLAGS == "xyes";
+    if test x$USE_DEBUG_CFLAGS = "xyes";
     then
-	MORECFLAGS=$MORECFLAGS" -g"
+        MORECFLAGS=$MORECFLAGS" -g"
     else
-	MORECFLAGS=$MORECFLAGS" -O6 -funroll-loops -fomit-frame-pointer"
+        MORECFLAGS=$MORECFLAGS" -O6 -funroll-loops -fomit-frame-pointer"
     fi
-    if test x$jack == "xyes";
+    if test x$jack = "xyes";
     then
         LDFLAGS=$LDFLAGS" -lrt -ljack"
     fi
-    if test x$jack == "xrun";
+    if test x$jack = "xrun";
     then
         LDFLAGS=$LDFLAGS" -lrt -ljack"
     fi
@@ -255,47 +257,52 @@ dnl This should be fixed so Pd can use ALSA shared libraries where appropriate.
 
 fi
 
-if test `uname -s` == Darwin;
+if test `uname -s` = Darwin;
 then
     LDFLAGS="-Wl -framework CoreAudio \
         -framework AudioUnit -framework AudioToolbox \
         -framework Carbon -framework CoreMIDI"
     EXT=pd_darwin
     CPPFLAGS="-DDL_OPEN -DMACOSX -DUNISTD -I/usr/X11R6/include \
-	-I../portaudio/include -I../portaudio/src/common \
-	-I../portaudio/src/os/mac_osx/ \
-	-I../portmidi/pm_common -I../portmidi/pm_mac \
-	-I../portmidi/porttime \
-	-DUSEAPI_PORTAUDIO -DPA19 -DPA_USE_COREAUDIO -DNEWBUFFER"
+        -I../portaudio/include -I../portaudio/src/common \
+        -I../portaudio/src/os/mac_osx/ \
+        -I../portmidi/pm_common -I../portmidi/pm_mac \
+        -I../portmidi/porttime \
+        -DUSEAPI_PORTAUDIO -DPA19 -DPA_USE_COREAUDIO -DNEWBUFFER"
+    dnl for Mac OS X 10.3 (i.e. < 10.4)
     if test `uname -r` = 7.9.0;
     then
-        MORECFLAGS="-DMACOSX3 -DPA_BIG_ENDIAN -Wno-error"
-    	EXTERNTARGET=d_ppc
-    else
+        fat="no"
+    fi
+    if test "x$fat" == "xyes";
+    then
         MORECFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
             -arch i386 -arch ppc -Wno-error"
-    	EXTERNTARGET=d_fat
+        EXTERNTARGET=d_fat
         LDFLAGS=$LDFLAGS" -arch i386 -arch ppc"
+    else
+        MORECFLAGS="-DMACOSX3 -DPA_BIG_ENDIAN -Wno-error"
+        EXTERNTARGET=d_ppc
     fi
     SYSSRC="s_midi_pm.c s_audio_pa.c \
-    	s_audio_pablio.c     \
-	s_audio_paring.c     \
-	../portaudio/src/common/pa_allocation.c  \
-	../portaudio/src/common/pa_converters.c  \
-	../portaudio/src/common/pa_cpuload.c     \
-	../portaudio/src/common/pa_dither.c      \
-	../portaudio/src/common/pa_front.c       \
-	../portaudio/src/common/pa_process.c     \
-	../portaudio/src/common/pa_skeleton.c    \
-	../portaudio/src/common/pa_stream.c      \
-	../portaudio/src/common/pa_trace.c       \
-	../portaudio/src/common/pa_debugprint.c       \
-	../portaudio/src/common/pa_ringbuffer.c  \
-	../portaudio/src/os/unix/pa_unix_util.c     \
-	../portaudio/src/os/mac_osx/pa_mac_hostapis.c   \
-	../portaudio/src/hostapi/coreaudio/pa_mac_core.c  \
-	../portaudio/src/hostapi/coreaudio/pa_mac_core_blocking.c  \
-	../portaudio/src/hostapi/coreaudio/pa_mac_core_utilities.c  \
+        s_audio_pablio.c     \
+        s_audio_paring.c     \
+        ../portaudio/src/common/pa_allocation.c  \
+        ../portaudio/src/common/pa_converters.c  \
+        ../portaudio/src/common/pa_cpuload.c     \
+        ../portaudio/src/common/pa_dither.c      \
+        ../portaudio/src/common/pa_front.c       \
+        ../portaudio/src/common/pa_process.c     \
+        ../portaudio/src/common/pa_skeleton.c    \
+        ../portaudio/src/common/pa_stream.c      \
+        ../portaudio/src/common/pa_trace.c       \
+        ../portaudio/src/common/pa_debugprint.c       \
+        ../portaudio/src/common/pa_ringbuffer.c  \
+        ../portaudio/src/os/unix/pa_unix_util.c     \
+        ../portaudio/src/os/mac_osx/pa_mac_hostapis.c   \
+        ../portaudio/src/hostapi/coreaudio/pa_mac_core.c  \
+        ../portaudio/src/hostapi/coreaudio/pa_mac_core_blocking.c  \
+        ../portaudio/src/hostapi/coreaudio/pa_mac_core_utilities.c  \
         ../portmidi/pm_mac/pmmac.c \
         ../portmidi/pm_mac/pmmacosxcm.c \
         ../portmidi/pm_common/pmutil.c \
@@ -305,34 +312,34 @@ then
     GUINAME="libPdTcl.dylib"
 
 # find the Tcl/Tk Frameworks
- 	 if test -d "../../Frameworks";
+         if test -d "../../Frameworks";
     then
         # Miller's location
         TCLTK_FRAMEWORKS_PATH="../../Frameworks"
- 	 elif test -d "/Library/Frameworks";
-	 then
+         elif test -d "/Library/Frameworks";
+         then
         # get it from the default install location
         TCLTK_FRAMEWORKS_PATH="/Library/Frameworks"
     else
         # Panther has Tcl here; Tiger has Tcl and Tk here
         TCLTK_FRAMEWORKS_PATH="/System/Library/Frameworks"
-    fi		 
+    fi           
     GUIFLAGS="-F$TCLTK_FRAMEWORKS_PATH -framework Tcl -framework Tk \
         -I$TCLTK_FRAMEWORKS_PATH/Tk.framework/Versions/Current/Headers \
         -I$TCLTK_FRAMEWORKS_PATH/Tcl.framework/Versions/Current/Headers \
         -I$TCLTK_FRAMEWORKS_PATH/Tcl.framework/Versions/8.4/PrivateHeaders"
-    if test x$USE_DEBUG_CFLAGS == "xyes";
+    if test x$USE_DEBUG_CFLAGS = "xyes";
     then
-	MORECFLAGS=$MORECFLAGS" -g"
+        MORECFLAGS=$MORECFLAGS" -g"
     else
-	MORECFLAGS=$MORECFLAGS" -O2"
+        MORECFLAGS=$MORECFLAGS" -O2"
     fi
     OSNUMBER=2
-    if test x$jack == "xyes";
+    if test x$jack = "xyes";
     then
-    	LDFLAGS=$LDFLAGS" -weak_framework Jack"
+        LDFLAGS=$LDFLAGS" -weak_framework Jack"
     fi
-    if test x$jack == "xrun";
+    if test x$jack = "xrun";
     then
         LDFLAGS=$LDFLAGS" -weak_framework Jack"
     fi
@@ -341,35 +348,35 @@ fi
 # only Windows uses ASIO, for the rest, set to blank
 ASIOSRC=
 
-if test `uname -s` == MINGW32_NT-5.0;
+if test `uname -s` = MINGW32_NT-5.0;
 then
     EXT=dll
     MORECFLAGS="-DUSEAPI_PORTAUDIO -DPA19 -DMSW -DPA_NO_DS -DPD_INTERNAL \
         -I../portaudio/include -I../portaudio/src/common \
-	-I../portaudio/src/os/win/ \
+        -I../portaudio/src/os/win/ \
         -mwindows -mms-bitfields "$MORECFLAGS
     PDLIB=$PDLIB" -lwsock32 -lwinmm -lole32 -lstdc++"
 
     SYSSRC="s_audio_pa.c s_audio_pablio.c s_audio_paring.c \
         s_audio_mmio.c s_midi_mmio.c \
-	../portaudio/src/common/pa_allocation.c  \
-	../portaudio/src/common/pa_converters.c  \
-	../portaudio/src/common/pa_cpuload.c     \
-	../portaudio/src/common/pa_dither.c      \
-	../portaudio/src/common/pa_front.c       \
-	../portaudio/src/common/pa_process.c     \
-	../portaudio/src/common/pa_skeleton.c    \
-	../portaudio/src/common/pa_stream.c      \
-	../portaudio/src/common/pa_trace.c       \
-	../portaudio/src/common/pa_debugprint.c       \
-	../portaudio/src/common/pa_ringbuffer.c  \
+        ../portaudio/src/common/pa_allocation.c  \
+        ../portaudio/src/common/pa_converters.c  \
+        ../portaudio/src/common/pa_cpuload.c     \
+        ../portaudio/src/common/pa_dither.c      \
+        ../portaudio/src/common/pa_front.c       \
+        ../portaudio/src/common/pa_process.c     \
+        ../portaudio/src/common/pa_skeleton.c    \
+        ../portaudio/src/common/pa_stream.c      \
+        ../portaudio/src/common/pa_trace.c       \
+        ../portaudio/src/common/pa_debugprint.c       \
+        ../portaudio/src/common/pa_ringbuffer.c  \
         ../portaudio/src/os/win/pa_win_util.c       \
         ../portaudio/src/os/win/pa_win_hostapis.c   \
         ../portaudio/src/os/win/pa_x86_plain_converters.c   \
         ../portaudio/src/hostapi/wmme/pa_win_wmme.c"
-	 ASIOSRC="../portaudio/src/hostapi/asio/iasiothiscallresolver.cpp \
-	 ../portaudio/src/hostapi/pa_asio/asio.cpp ../asio/asio.cpp \
-	 ../asio/asiodrivers.cpp ../asio/asiolist.cpp"
+         ASIOSRC="../portaudio/src/hostapi/asio/iasiothiscallresolver.cpp \
+         ../portaudio/src/hostapi/pa_asio/asio.cpp ../asio/asio.cpp \
+         ../asio/asiodrivers.cpp ../asio/asiolist.cpp"
     STRIPFLAG="--strip-unneeded"
     GUINAME="pdtcl.dll"
     GUIFLAGS=
@@ -377,18 +384,18 @@ fi
 
 # support for jack, on either linux or darwin:
 
-if test x$jack == "xyes";
+if test x$jack = "xyes";
 then
     MORECFLAGS=$MORECFLAGS" -DUSEAPI_JACK"
     SYSSRC=$SYSSRC" s_audio_jack.c"
 fi
-if test x$jack == "xrun";
+if test x$jack = "xrun";
 then
     MORECFLAGS=$MORECFLAGS" -DUSEAPI_JACK -DJACK_XRUN"
     SYSSRC=$SYSSRC" s_audio_jack.c"
 fi
 
-if test x$fftw == "xyes";
+if test x$fftw = "xyes";
 then
     SYSSRC=$SYSSRC" d_fft_fftw.c d_fftroutine.c"
     LDFLAGS=$LDFLAGS" -lfftw"
diff --git a/src/d_misc.c b/src/d_misc.c
index 3a327dc55..cdb99bb8b 100644
--- a/src/d_misc.c
+++ b/src/d_misc.c
@@ -27,18 +27,13 @@ static t_int *print_perform(t_int *w)
     int n = (int)(w[3]);
     if (x->x_count)
     {
-        post("%s:", x->x_sym->s_name);
-        if (n == 1) post("%8g", in[0]);
-        else if (n == 2) post("%8g %8g", in[0], in[1]);
-        else if (n == 4) post("%8g %8g %8g %8g",
-            in[0], in[1], in[2], in[3]);
-        else while (n > 0)
-        {
-            post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g",
-                in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7]);
-            n -= 8;
-            in += 8;
+        int i=0;
+        startpost("%s:", x->x_sym->s_name);
+        for(i=0; i<n; i++) {
+          if(i%8==0)endpost();
+          startpost("%-8.5g", in[i]);
         }
+        endpost();
         x->x_count--;
     }
     return (w+4);
diff --git a/src/s_path.c b/src/s_path.c
index 97591d4ce..6abe7d0c2 100644
--- a/src/s_path.c
+++ b/src/s_path.c
@@ -522,11 +522,16 @@ void glob_start_path_dialog(t_pd *dummy)
     char buf[MAXPDSTRING];
     int i;
     t_namelist *nl;
-    
-    for (nl = sys_searchpath, i = 0; nl && i < 10; nl = nl->nl_next, i++)
-        sys_vgui("pd_set pd_path%d \"%s\"\n", i, nl->nl_string);
-    for (; i < 10; i++)
-        sys_vgui("pd_set pd_path%d \"\"\n", i);
+
+    sprintf(buf, "list");
+    for (nl = sys_searchpath, i = 0; nl; nl = nl->nl_next, i++) {
+      if(nl->nl_string){
+        strcat(buf, " \"");
+        strcat(buf, nl->nl_string);
+        strcat(buf, "\"");
+      }
+    }
+    sys_vgui("pd_set pd_path [%s]\n", buf);
 
     sprintf(buf, "pdtk_path_dialog %%s %d %d\n", sys_usestdpath, sys_verbose);
     gfxstub_new(&glob_pdobject, (void *)glob_start_path_dialog, buf);
@@ -554,11 +559,16 @@ void glob_start_startup_dialog(t_pd *dummy)
     char buf[MAXPDSTRING];
     int i;
     t_namelist *nl;
-    
-    for (nl = sys_externlist, i = 0; nl && i < 10; nl = nl->nl_next, i++)
-        sys_vgui("pd_set pd_startup%d \"%s\"\n", i, nl->nl_string);
-    for (; i < 10; i++)
-        sys_vgui("pd_set pd_startup%d \"\"\n", i);
+
+    sprintf(buf, "list");
+    for (nl = sys_externlist, i = 0; nl; nl = nl->nl_next, i++) {
+      if(nl->nl_string){
+        strcat(buf, " \"");
+        strcat(buf, nl->nl_string);
+        strcat(buf, "\"");
+      }
+    }
+    sys_vgui("pd_set pd_startup [%s]\n", buf);
 
     sprintf(buf, "pdtk_startup_dialog %%s %d \"%s\"\n", sys_defeatrt,
         sys_flags->s_name);
diff --git a/src/u_main.tk b/src/u_main.tk
index cabec4c08..dc3cc8013 100644
--- a/src/u_main.tk
+++ b/src/u_main.tk
@@ -415,9 +415,16 @@ proc menu_openhtml {filename} {
     global pd_nt         
 
     if {$pd_nt == 0} {
-        exec sh -c \
-            [format "firefox file:%s || mozilla file:%s " \
-                $filename $filename] &
+        foreach candidate \
+            { gnome-open xdg-open sensible-browser iceweasel firefox mozilla \
+              galeon konqueror netscape lynx } {
+                  set browser [lindex [auto_execok $candidate] 0]
+                  if {[string length $browser]} {
+                         puts stderr [format "%s %s" $browser $filename]
+                         exec -- sh -c [format "%s %s" $browser $filename] &
+                         break
+                     }
+                 }
     } elseif {$pd_nt == 2} {
         puts stderr [format "open %s" $filename]
             exec sh -c [format "open %s" $filename]
@@ -4209,15 +4216,16 @@ proc pdtk_alsa_midi_dialog {id indev1 indev2 indev3 indev4 \
 
 proc path_apply {id} {
     global pd_extrapath pd_verbose
-    global pd_path0 pd_path1 pd_path2 pd_path3 pd_path4 
-    global pd_path5 pd_path6 pd_path7 pd_path8 pd_path9 
+    global pd_path_count
+    set pd_path {}
 
-    pd [concat pd path-dialog $pd_extrapath $pd_verbose \
-    [pdtk_encodedialog $pd_path0] [pdtk_encodedialog $pd_path1] \
-    [pdtk_encodedialog $pd_path2] [pdtk_encodedialog $pd_path3] \
-    [pdtk_encodedialog $pd_path4] [pdtk_encodedialog $pd_path5] \
-    [pdtk_encodedialog $pd_path6] [pdtk_encodedialog $pd_path7] \
-    [pdtk_encodedialog $pd_path8] [pdtk_encodedialog $pd_path9] \;]
+    for {set x 0} {$x < $pd_path_count} {incr x} {
+        global pd_path$x
+        set this_path [set pd_path$x]
+        if {0==[string match "" $this_path]} {lappend pd_path [pdtk_encodedialog $this_path]}
+    }
+
+    pd [concat pd path-dialog $pd_extrapath $pd_verbose $pd_path \;]
 }
 
 proc path_cancel {id} {
@@ -4231,8 +4239,16 @@ proc path_ok {id} {
 
 proc pdtk_path_dialog {id extrapath verbose} {
     global pd_extrapath pd_verbose
-    global pd_path0 pd_path1 pd_path2 pd_path3 pd_path4 
-    global pd_path5 pd_path6 pd_path7 pd_path8 pd_path9 
+    global pd_path
+    global pd_path_count
+
+    set pd_path_count [expr [llength $pd_path] + 2]
+    if { $pd_path_count < 10 } { set pd_path_count 10 }
+
+    for {set x 0} {$x < $pd_path_count} {incr x} {
+        global pd_path$x
+        set pd_path$x [lindex $pd_path $x]
+    }
 
     set pd_extrapath $extrapath
     set pd_verbose $verbose
@@ -4262,8 +4278,8 @@ proc pdtk_path_dialog {id extrapath verbose} {
         -command "path_apply $id \; pd pd save-preferences \\;"
     pack $id.extraframe.extra $id.extraframe.verbose $id.extraframe.save \
         -side left -expand 1
-    
-    for {set x 0} {$x < 10} {incr x} {
+
+    for {set x 0} {$x < $pd_path_count} {incr x} {
         entry $id.f$x -textvariable pd_path$x -width 80
         bind $id.f$x <KeyPress-Return> [concat path_ok $id]
         pdtk_standardkeybindings $id.f$x
@@ -4282,16 +4298,16 @@ proc pd_set {var value} {
 
 proc startup_apply {id} {
     global pd_nort pd_flags
-    global pd_startup0 pd_startup1 pd_startup2 pd_startup3 pd_startup4 
-    global pd_startup5 pd_startup6 pd_startup7 pd_startup8 pd_startup9 
+    global pd_startup_count
 
-    pd [concat pd startup-dialog $pd_nort [pdtk_encodedialog $pd_flags] \
-    [pdtk_encodedialog $pd_startup0] [pdtk_encodedialog $pd_startup1] \
-    [pdtk_encodedialog $pd_startup2] [pdtk_encodedialog $pd_startup3] \
-    [pdtk_encodedialog $pd_startup4] [pdtk_encodedialog $pd_startup5] \
-    [pdtk_encodedialog $pd_startup6] [pdtk_encodedialog $pd_startup7] \
-    [pdtk_encodedialog $pd_startup8] [pdtk_encodedialog $pd_startup9] \;]
+    set pd_startup {}
+    for {set x 0} {$x < $pd_startup_count} {incr x} {
+        global pd_startup$x
+        set this_startup [set pd_startup$x]
+        if {0==[string match "" $this_startup]} {lappend pd_startup [pdtk_encodedialog $this_startup]}
+    }
 
+    pd [concat pd startup-dialog $pd_nort [pdtk_encodedialog $pd_flags] $pd_startup \;]
 }
 
 proc startup_cancel {id} {
@@ -4305,8 +4321,16 @@ proc startup_ok {id} {
 
 proc pdtk_startup_dialog {id nort flags} {
     global pd_nort pd_nt pd_flags
-    global pd_startup0 pd_startup1 pd_startup2 pd_startup3 pd_startup4 
-    global pd_startup5 pd_startup6 pd_startup7 pd_startup8 pd_startup9 
+    global pd_startup
+    global pd_startup_count
+
+    set pd_startup_count [expr [llength $pd_startup] + 2]
+    if { $pd_startup_count < 10 } { set pd_startup_count 10 }
+
+    for {set x 0} {$x < $pd_startup_count} {incr x} {
+        global pd_startup$x
+        set pd_startup$x [lindex $pd_startup $x]
+    }
 
     set pd_nort $nort
     set pd_flags $flags
@@ -4348,7 +4372,9 @@ proc pdtk_startup_dialog {id nort flags} {
         pack $id.nortframe.save -side left -expand 1
     }
 
-    for {set x 0} {$x < 10} {incr x} {
+
+
+    for {set x 0} {$x < $pd_startup_count} {incr x} {
         entry $id.f$x -textvariable pd_startup$x -width 80
         bind $id.f$x <KeyPress-Return> [concat startup_ok $id]
         pdtk_standardkeybindings $id.f$x
diff --git a/src/x_connective.c b/src/x_connective.c
index 3b2bbba5a..c26877791 100644
--- a/src/x_connective.c
+++ b/src/x_connective.c
@@ -1174,6 +1174,8 @@ static void until_bang(t_until *x)
 
 static void until_float(t_until *x, t_float f)
 {
+    if (f < 0)
+        f = 0;
     x->x_run = 1;
     x->x_count = f;
     while (x->x_run && x->x_count)
-- 
GitLab