Index: Singular/ChangeLog
===================================================================
--- Singular/ChangeLog	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/ChangeLog	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -1,2 +1,14 @@
+1998-04-06  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
+
+	* spSpolyLoop.h: neww calling interface for spGetSpolyLoop
+
+	* kstd1.cc (kNF): moved strat->ak field initailization out of
+	initBuchMora into single routines
+
+	* febase.cc (feGetSearchPath): added feGetSearchPath; changed
+	algorithm for searching files: $SINGULARPATH -> relative to
+	executable -> burnt-in locations
+	* added find_exec.c to get absolute pathname of executable
+
 Mon Apr  6 14:23:52 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
 
Index: Singular/LIB/poly.lib
===================================================================
--- Singular/LIB/poly.lib	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/LIB/poly.lib	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -1,3 +1,3 @@
-// $Id: poly.lib,v 1.10 1998-04-03 22:47:09 krueger Exp $
+// $Id: poly.lib,v 1.11 1998-04-06 17:59:38 obachman Exp $
 //system("random",787422842);
 //(GMG, last modified 22.06.96)
@@ -5,5 +5,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 
-version="$Id: poly.lib,v 1.10 1998-04-03 22:47:09 krueger Exp $";
+version="$Id: poly.lib,v 1.11 1998-04-06 17:59:38 obachman Exp $";
 info="
 LIBRARY:  poly.lib      PROCEDURES FOR MANIPULATING POLYS, IDEALS, MODULES
@@ -22,5 +22,6 @@
  normalize(poly/...);   normalize poly/... such that leading coefficient is 1
  rad_con(p,I);          check radical containment of poly p in ideal I
-           (parameters in square brackets [] are optional)
+ content(f);            content of polynomial/vector f
+          (parameters in square brackets [] are optional)
 ";
 
Index: Singular/Makefile.in
===================================================================
--- Singular/Makefile.in	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/Makefile.in	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -99,5 +99,5 @@
     ndbm.cc spSpolyLoop.cc libparse.cc
 
-CSOURCES=mmalloc.c mmallocb.c mmallocs.c mmblock.c mmheap.c mmspec.c mmutil.c weight0.c
+CSOURCES=mmalloc.c mmallocb.c mmallocs.c mmblock.c mmheap.c mmspec.c mmutil.c weight0.c find_exec.c
 
 SOURCES=${CSOURCES} ${CXXSOURCES} grammar.y scanner.l libparse.l spSpolyLoop.pl
@@ -143,5 +143,6 @@
      algmap.o clapconv.o  clapmem.o clapsing.o claptmpl.o\
      mpsr_Error.o mpsr_Put.o mpsr_PutPoly.o mpsr_GetPoly.o \
-     mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o libparse.o
+     mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o libparse.o \
+     find_exec.o
 
 ##
@@ -394,8 +395,9 @@
      mpsr_Error.og mpsr_Put.og mpsr_PutPoly.og mpsr_GetPoly.og \
      mpsr_Get.og mpsr_GetMisc.og \
-     ndbm.og spSpolyLoop.og libparse.og
+     ndbm.og spSpolyLoop.og libparse.og \
 
 OBJG2= mmalloc.og mmallocb.og mmallocs.og mmblock.og mmheap.og \
-     mmspec.og mmutil.og weight0.og
+     mmspec.og mmutil.og weight0.og find_exec.og
+
 
 OBJG=$(OBJG1) $(OBJG2) claptmpl.og
@@ -470,5 +472,5 @@
 
 OBJP2= mmalloc.op mmallocb.op mmallocs.op mmblock.op mmheap.op \
-     mmspec.op mmutil.op weight0.op
+     mmspec.op mmutil.op weight0.op find_exec.op
 
 OBJP=$(OBJP1) $(OBJP2) claptmpl.op
@@ -492,8 +494,8 @@
      mpsr_Error.ob mpsr_Put.ob mpsr_PutPoly.ob mpsr_GetPoly.ob \
      mpsr_Get.ob mpsr_GetMisc.ob \
-     ndbm.ob spSpolyLoop.ob libparse.ob
+     ndbm.ob spSpolyLoop.ob libparse.ob 
 
 OBJB2= mmalloc.ob mmallocb.ob mmallocs.ob mmblock.ob mmheap.ob \
-     mmspec.ob mmutil.ob weight0.ob
+     mmspec.ob mmutil.ob weight0.ob find_exec.ob
 
 OBJB=$(OBJB1) $(OBJB2) claptmpl.ob
Index: Singular/configure
===================================================================
--- Singular/configure	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/configure	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2415,4 +2415,59 @@
 fi
 
+echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
+echo "configure:2419: checking whether stat file-mode macros are broken" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2424 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(S_ISBLK) && defined(S_IFDIR)
+# if S_ISBLK (S_IFDIR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISBLK) && defined(S_IFCHR)
+# if S_ISBLK (S_IFCHR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISLNK) && defined(S_IFREG)
+# if S_ISLNK (S_IFREG)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISSOCK) && defined(S_IFREG)
+# if S_ISSOCK (S_IFREG)
+You lose.
+# endif
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "You lose" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_header_stat_broken=yes
+else
+  rm -rf conftest*
+  ac_cv_header_stat_broken=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_header_stat_broken" 1>&6
+if test $ac_cv_header_stat_broken = yes; then
+  cat >> confdefs.h <<\EOF
+#define STAT_MACROS_BROKEN 1
+EOF
+
+fi
 
 for ac_hdr in limits.h unistd.h
@@ -2420,15 +2475,15 @@
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2423: checking for $ac_hdr" >&5
+echo "configure:2478: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2428 "configure"
+#line 2483 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2433: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2488: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
@@ -2458,19 +2513,19 @@
 
 
-for ac_hdr in sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h sys/stat.h fcntl.h
+for ac_hdr in sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h sys/stat.h fcntl.h sys/param.h pwd.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2465: checking for $ac_hdr" >&5
+echo "configure:2520: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2470 "configure"
+#line 2525 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2475: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2530: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
@@ -2501,5 +2556,5 @@
 WITH_DBM=no
 echo $ac_n "checking whether to build with dbm links""... $ac_c" 1>&6
-echo "configure:2504: checking whether to build with dbm links" >&5
+echo "configure:2559: checking whether to build with dbm links" >&5
 if test "$with_dbm" != no; then
   cat >> confdefs.h <<\EOF
@@ -2515,10 +2570,10 @@
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:2518: checking for working const" >&5
+echo "configure:2573: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2523 "configure"
+#line 2578 "configure"
 #include "confdefs.h"
 
@@ -2569,5 +2624,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2572: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2627: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
@@ -2590,5 +2645,5 @@
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:2593: checking for inline" >&5
+echo "configure:2648: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2597,5 +2652,5 @@
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 2600 "configure"
+#line 2655 "configure"
 #include "confdefs.h"
 
@@ -2604,5 +2659,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2607: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2662: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
@@ -2630,10 +2685,10 @@
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:2633: checking for size_t" >&5
+echo "configure:2688: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2638 "configure"
+#line 2693 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -2663,10 +2718,10 @@
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:2666: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:2721: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2671 "configure"
+#line 2726 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -2677,5 +2732,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2680: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2735: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
@@ -2698,10 +2753,10 @@
 
 echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:2701: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:2756: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2706 "configure"
+#line 2761 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -2711,5 +2766,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2714: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2769: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
@@ -2735,10 +2790,10 @@
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:2738: checking for working alloca.h" >&5
+echo "configure:2793: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2743 "configure"
+#line 2798 "configure"
 #include "confdefs.h"
 #include <alloca.h>
@@ -2747,5 +2802,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
@@ -2768,10 +2823,10 @@
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:2771: checking for alloca" >&5
+echo "configure:2826: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2776 "configure"
+#line 2831 "configure"
 #include "confdefs.h"
 
@@ -2796,5 +2851,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
@@ -2828,10 +2883,10 @@
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:2831: checking whether alloca needs Cray hooks" >&5
+echo "configure:2886: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2836 "configure"
+#line 2891 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
@@ -2858,10 +2913,10 @@
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2861: checking for $ac_func" >&5
+echo "configure:2916: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2866 "configure"
+#line 2921 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
@@ -2886,5 +2941,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:2889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
@@ -2913,5 +2968,5 @@
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:2916: checking stack direction for C alloca" >&5
+echo "configure:2971: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2921,5 +2976,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 2924 "configure"
+#line 2979 "configure"
 #include "confdefs.h"
 find_stack_direction ()
@@ -2940,5 +2995,5 @@
 }
 EOF
-if { (eval echo configure:2943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
@@ -2963,5 +3018,5 @@
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:2966: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:3021: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2969,5 +3024,5 @@
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 2972 "configure"
+#line 3027 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
@@ -2987,5 +3042,5 @@
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 2990 "configure"
+#line 3045 "configure"
 #include "confdefs.h"
 #include <termio.h>
@@ -3012,15 +3067,15 @@
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3015: checking for $ac_hdr" >&5
+echo "configure:3070: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3020 "configure"
+#line 3075 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3080: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
@@ -3051,10 +3106,10 @@
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3054: checking for $ac_func" >&5
+echo "configure:3109: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3059 "configure"
+#line 3114 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
@@ -3079,5 +3134,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
@@ -3104,5 +3159,5 @@
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:3107: checking for working mmap" >&5
+echo "configure:3162: checking for working mmap" >&5
 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3112,5 +3167,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3115 "configure"
+#line 3170 "configure"
 #include "confdefs.h"
 
@@ -3252,5 +3307,5 @@
 
 EOF
-if { (eval echo configure:3255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
@@ -3275,10 +3330,10 @@
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3278: checking return type of signal handlers" >&5
+echo "configure:3333: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3283 "configure"
+#line 3338 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -3297,5 +3352,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3355: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
@@ -3316,10 +3371,10 @@
 
 echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:3319: checking for vprintf" >&5
+echo "configure:3374: checking for vprintf" >&5
 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3324 "configure"
+#line 3379 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
@@ -3344,5 +3399,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_vprintf=yes"
@@ -3368,10 +3423,10 @@
 if test "$ac_cv_func_vprintf" != yes; then
 echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:3371: checking for _doprnt" >&5
+echo "configure:3426: checking for _doprnt" >&5
 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3376 "configure"
+#line 3431 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
@@ -3396,5 +3451,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func__doprnt=yes"
@@ -3420,13 +3475,13 @@
 fi
 
-for ac_func in gettimeofday strstr strtod strtol atexit bcopy
+for ac_func in gettimeofday strstr strtod strtol atexit bcopy getcwd getwd
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3426: checking for $ac_func" >&5
+echo "configure:3481: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3431 "configure"
+#line 3486 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
@@ -3451,5 +3506,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
@@ -3478,5 +3533,5 @@
 
 echo $ac_n "checking whether your machine has correct arithmetic shifts""... $ac_c" 1>&6
-echo "configure:3481: checking whether your machine has correct arithmetic shifts" >&5
+echo "configure:3536: checking whether your machine has correct arithmetic shifts" >&5
 if eval "test \"`echo '$''{'ac_cv_shift'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3491,9 +3546,9 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3494 "configure"
+#line 3549 "configure"
 #include "confdefs.h"
  int main() { if (-2 >> 1 == -1) exit(0); else exit(1); } 
 EOF
-if { (eval echo configure:3498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_shift=yes
@@ -3518,5 +3573,5 @@
 
 echo $ac_n "checking whether vsprintf returns number of printed chars""... $ac_c" 1>&6
-echo "configure:3521: checking whether vsprintf returns number of printed chars" >&5
+echo "configure:3576: checking whether vsprintf returns number of printed chars" >&5
 if eval "test \"`echo '$''{'ac_cv_returns_n_of_chars'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3526,10 +3581,10 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3529 "configure"
+#line 3584 "configure"
 #include "confdefs.h"
 #include <stdio.h> 
  main() { char *str=(char*)malloc(20); if (((int) sprintf(str,"123456789")) == 9) exit(0); else exit(1); }
 EOF
-if { (eval echo configure:3534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_returns_n_of_chars=yes
@@ -3557,5 +3612,5 @@
 
 echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:3560: checking size of char" >&5
+echo "configure:3615: checking size of char" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3565,5 +3620,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3568 "configure"
+#line 3623 "configure"
 #include "confdefs.h"
 #include <stdio.h>
@@ -3576,5 +3631,5 @@
 }
 EOF
-if { (eval echo configure:3579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3634: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_char=`cat conftestval`
@@ -3596,5 +3651,5 @@
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:3599: checking size of short" >&5
+echo "configure:3654: checking size of short" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3604,5 +3659,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3607 "configure"
+#line 3662 "configure"
 #include "confdefs.h"
 #include <stdio.h>
@@ -3615,5 +3670,5 @@
 }
 EOF
-if { (eval echo configure:3618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
@@ -3635,5 +3690,5 @@
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3638: checking size of int" >&5
+echo "configure:3693: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3643,5 +3698,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3646 "configure"
+#line 3701 "configure"
 #include "confdefs.h"
 #include <stdio.h>
@@ -3654,5 +3709,5 @@
 }
 EOF
-if { (eval echo configure:3657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
@@ -3674,5 +3729,5 @@
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3677: checking size of long" >&5
+echo "configure:3732: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3682,5 +3737,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3685 "configure"
+#line 3740 "configure"
 #include "confdefs.h"
 #include <stdio.h>
@@ -3693,5 +3748,5 @@
 }
 EOF
-if { (eval echo configure:3696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
@@ -3713,5 +3768,5 @@
 
 echo $ac_n "checking size of void*""... $ac_c" 1>&6
-echo "configure:3716: checking size of void*" >&5
+echo "configure:3771: checking size of void*" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3721,5 +3776,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3724 "configure"
+#line 3779 "configure"
 #include "confdefs.h"
 #include <stdio.h>
@@ -3732,5 +3787,5 @@
 }
 EOF
-if { (eval echo configure:3735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_voidp=`cat conftestval`
@@ -3752,5 +3807,5 @@
 
 echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:3755: checking whether byte ordering is bigendian" >&5
+echo "configure:3810: checking whether byte ordering is bigendian" >&5
 if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3759,5 +3814,5 @@
 # See if sys/param.h defines the BYTE_ORDER macro.
 cat > conftest.$ac_ext <<EOF
-#line 3762 "configure"
+#line 3817 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -3770,9 +3825,9 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3773: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   # It does; now see whether it defined to BIG_ENDIAN or not.
 cat > conftest.$ac_ext <<EOF
-#line 3777 "configure"
+#line 3832 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -3785,5 +3840,5 @@
 ; return 0; }
 EOF
-if { (eval echo configure:3788: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_bigendian=yes
@@ -3805,5 +3860,5 @@
 else
   cat > conftest.$ac_ext <<EOF
-#line 3808 "configure"
+#line 3863 "configure"
 #include "confdefs.h"
 main () {
@@ -3818,5 +3873,5 @@
 }
 EOF
-if { (eval echo configure:3821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_bigendian=no
@@ -3851,5 +3906,5 @@
 
 echo $ac_n "checking which exponent types to use""... $ac_c" 1>&6
-echo "configure:3854: checking which exponent types to use" >&5
+echo "configure:3909: checking which exponent types to use" >&5
 if test "$with_exp_type" = "char"; then
   echo "$ac_t""char" 1>&6
@@ -3885,10 +3940,10 @@
 
 echo $ac_n "checking whether _AIX is defined""... $ac_c" 1>&6
-echo "configure:3888: checking whether _AIX is defined" >&5
+echo "configure:3943: checking whether _AIX is defined" >&5
 if eval "test \"`echo '$''{'ac_cv_is_aix'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3893 "configure"
+#line 3948 "configure"
 #include "confdefs.h"
 #ifdef _AIX
Index: Singular/configure.in
===================================================================
--- Singular/configure.in	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/configure.in	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -395,9 +395,9 @@
 
 AC_HEADER_STDC
-
+AC_HEADER_STAT
 AC_CHECK_HEADERS(limits.h unistd.h,,
   AC_MSG_ERROR(Can not compile without limits.h unistd.h))
 
-AC_CHECK_HEADERS(sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h sys/stat.h fcntl.h)
+AC_CHECK_HEADERS(sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h sys/stat.h fcntl.h sys/param.h pwd.h)
 
 dnl Check dbm
@@ -430,5 +430,5 @@
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(gettimeofday strstr strtod strtol atexit bcopy)
+AC_CHECK_FUNCS(gettimeofday strstr strtod strtol atexit bcopy getcwd getwd)
 
 dnl
Index: Singular/extra.cc
===================================================================
--- Singular/extra.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/extra.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR      *
 *****************************************/
-/* $Id: extra.cc,v 1.32 1998-04-03 17:38:35 Singular Exp $ */
+/* $Id: extra.cc,v 1.33 1998-04-06 17:59:27 obachman Exp $ */
 /*
 * ABSTRACT: general interface to internals of Singular ("system" command)
@@ -245,4 +245,11 @@
     #endif
     #endif
+#if 0
+/*==================== whoami ==================================*/
+    if (strcmp((char*)(h->data), "whoami") == 0)
+    {
+      res->rtype=STRING_CMD;
+    }
+#endif
 /*==================== HC ==================================*/
     if (strcmp((char*)(h->data),"HC")==0)
Index: Singular/febase.cc
===================================================================
--- Singular/febase.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/febase.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: febase.cc,v 1.26 1998-03-31 07:41:21 Singular Exp $ */
+/* $Id: febase.cc,v 1.27 1998-04-06 17:59:27 obachman Exp $ */
 /*
 * ABSTRACT: i/o system
@@ -103,4 +103,72 @@
 #endif  /* macintosh */
 
+extern "C" char* find_executable_path(const char* argv0);
+
+#define SINGULAR_RELATIVE_DATA_DIR "LIB"
+
+static char* SearchPath = NULL;
+
+// Return the file search path for singular w.r.t. the following priorities:
+// Env-variables + Relative Data Dir + Burned-in data dir
+char* feGetSearchPath(const char* argv0)
+{   
+  if (SearchPath == NULL) 
+  {
+    char *env = NULL, *sibbling = NULL, *path;
+    int plength = 0, tmp;
+  
+#ifdef MSDOS
+    env=getenv("SPATH");
+#else
+    env=getenv("SINGULARPATH");
+#endif
+  
+    if (argv0 != NULL)
+      sibbling = find_executable_path(argv0);
+  
+    if (env != NULL)
+      plength = strlen(env) + 1;
+
+    if (sibbling != NULL)
+      plength += strlen(sibbling) + strlen(SINGULAR_RELATIVE_DATA_DIR) + 2;
+  
+    plength += strlen(SINGULAR_DATADIR) + 2;
+  
+    path = (char*) AllocL(plength*sizeof(char));
+    SearchPath = path;
+  
+    if (env != NULL)
+    {
+      tmp = strlen(env);
+      memcpy(path, env, tmp);
+      path = &(path[tmp]);
+      *path = FS_SEP;
+      path++;
+    }
+  
+    if (sibbling != NULL)
+    {
+      tmp = strlen(sibbling);
+      memcpy(path, sibbling, tmp);
+      path = &(path[tmp]);
+      *path = DIR_SEP;
+      path++;
+      tmp = strlen(SINGULAR_RELATIVE_DATA_DIR);
+      memcpy(path, SINGULAR_RELATIVE_DATA_DIR, tmp);
+      path = &(path[tmp]);
+      *path = FS_SEP;
+      path++;
+      FreeL(sibbling);
+    }
+  
+    tmp = strlen(SINGULAR_DATADIR);
+    memcpy(path,SINGULAR_DATADIR, tmp);
+    path = &(path[tmp]);
+    *path = '\0';
+  }
+  return SearchPath;
+}
+
+
 FILE * feFopen(char *path, char *mode, char *where,int useWerror)
 {
@@ -157,30 +225,14 @@
   {
     char found = 0;
-    #ifdef MSDOS
-      char *env=getenv("SPATH");
-    #else
-      char *env=getenv("SINGULARPATH");
-    #endif
+    char* spath = feGetSearchPath();
     char *s;
-    #ifndef macintosh
-    // extend path by SINGULAR_DATADIR
-    s = (char*) AllocL((env != NULL ? strlen(env) : 0)
-                       +strlen(SINGULAR_DATADIR)+2);
-    if (env != NULL)
-    {
-      strcpy(s, env);
-      s[strlen(env)] = FS_SEP;
-      s[strlen(env)+1] = '\0';
-      strcat(s, SINGULAR_DATADIR);
-    }
-    else strcpy(s, SINGULAR_DATADIR);
-    env = s;
-    #endif
+
     if (where==NULL) s=(char *)AllocL(250);
     else             s=where;
-    if (env!=NULL)
+
+    if (spath!=NULL)
     {
       char *p,*q;
-      p = env;
+      p = spath;
       while( (q=strchr(p, FS_SEP)) != NULL)
       {
@@ -216,7 +268,4 @@
       f=fopen(path,mode);
     }
-    #ifndef macintosh
-    FreeL(env);
-    #endif
     if (where==NULL) FreeL((ADDRESS)s);
   }
Index: Singular/febase.h
===================================================================
--- Singular/febase.h	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/febase.h	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: febase.h,v 1.9 1998-03-31 09:00:43 Singular Exp $ */
+/* $Id: febase.h,v 1.10 1998-04-06 17:59:28 obachman Exp $ */
 /*
 * ABSTRACT
@@ -65,4 +65,5 @@
 };
 
+char*   feGetSearchPath(const char* argv0 = NULL);
 FILE *  feFopen(char *path, char *mode, char *where=NULL, int useWerror=FALSE);
 void    fePause(void);
Index: Singular/find_exec.c
===================================================================
--- Singular/find_exec.c	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
+++ Singular/find_exec.c	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -0,0 +1,210 @@
+/****************************************
+*  Computer Algebra System SINGULAR     *
+****************************************/
+/* $id:$ */
+
+/* find_exec.c -- Find a program, given an argv[0]
+   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1990 by W. Wilson Ho.
+   This file is part of the GNU Dld Library. */
+
+/* Adapted for use with Singular by obachman */
+
+#include "mod2.h"
+
+#if ! defined(MSDOS) && ! defined(macintosh) && \
+    defined(HAVE_SYS_TYPES_H) && defined(HAVE_PWD_H)&&defined(HAVE_SYS_PARAM_H)
+
+#include <sys/types.h>
+#include <unistd.h> /* always defiend */
+#include <pwd.h>
+
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h> /* can live without it */
+#endif
+#include <sys/param.h>
+#include <strings.h>
+
+#include "mmemory.h"
+
+
+
+/* Do not return copies of sth, but simply the strings 
+   -- we make copies later */
+#define copy_of(string) mstrdup(string)
+
+/* ABSOLUTE_FILENAME_P (fname): True if fname is an absolute filename */
+#ifdef atarist
+#define ABSOLUTE_FILENAME_P(fname)	((fname[0] == '/') || \
+	(fname[0] && (fname[1] == ':')))
+#else
+#define ABSOLUTE_FILENAME_P(fname)	(fname[0] == '/')
+#endif /* atarist */
+
+/* Return the absolute name of the program named NAME.  This function
+   searches the directories in the PATH environment variable if PROG
+   has no directory components. */
+char *
+find_executable (const char *name)
+{
+  char *search;
+  char *p;
+  char tbuf[MAXPATHLEN];
+
+  if (ABSOLUTE_FILENAME_P(name)) {
+      /* If we can execute the named file, and it is normal, then return it. */
+      if (! access (name, X_OK)) {
+	struct stat stat_temp;
+
+	if (stat (name, &stat_temp))
+	  return 0;
+
+#ifndef STAT_MACROS_BROKEN
+	if (! S_ISREG(stat_temp.st_mode))
+	  return 0;
+#endif
+	return copy_of (name);
+      }
+    }
+  else {
+    if ((name[0] == '.') && (name[1] == '/')) {
+      strcpy (tbuf, ".");
+
+#ifdef HAVE_GETCWD
+      getcwd (tbuf, MAXPATHLEN);
+#else
+# ifdef HAVE_GETWD
+      getwd (tbuf);
+# endif
+#endif
+      strcat (tbuf, name + 1);
+      return copy_of (tbuf);
+    }
+
+    search = getenv ("PATH");
+    p = search;
+
+    while (*p) {
+      char *next;
+      next = tbuf;
+
+      /* Perform tilde-expansion. Stolen from GNU readline/tilde.c. */
+      if (p[0] == '~') {
+	if (! p[1] || p[1] == '/') {
+	  /* Prepend $HOME to the rest of the string. */
+	  char *temp_home = (char *) getenv ("HOME");
+
+	  /* If there is no HOME variable, look up the directory in the
+	     password database. */
+	  if (! temp_home) {
+	    struct passwd *entry;
+
+	    entry = getpwuid (getuid ());
+	    if (entry)
+	      temp_home = entry->pw_dir;
+	  }
+
+	  strcpy (tbuf, temp_home);
+	  next = tbuf + strlen (tbuf);
+	  p ++;
+	}
+	else {
+	  char username[MAXPATHLEN];
+	  struct passwd *user_entry;
+	  int i;
+
+	  p ++;			/* Skip the tilde. */
+	  for (i = 0; *p && *p != '/' && *p != ':'; i++)
+	    username[i] = *p ++;
+	  username[i] = '\0';
+
+	  user_entry = getpwnam (username);
+	  if (user_entry) {
+	    strcpy (tbuf, user_entry->pw_dir);
+	    next = tbuf + strlen (tbuf);
+	  }
+	}
+
+	endpwent ();
+      }
+
+      /* Copy directory name into [tbuf]. */
+      while (*p && *p != ':')
+	*next ++ = *p ++;
+      *next = '\0';
+      if (*p != '\0')
+	p ++;
+
+      if (tbuf[0] == '.' && tbuf[1] == '\0') {
+#ifdef HAVE_GETCWD
+	getcwd (tbuf, MAXPATHLEN);
+#else
+# ifdef HAVE_GETWD
+	getwd (tbuf);
+# endif
+#endif
+      }
+
+      strcat (tbuf, "/");
+      strcat (tbuf, name);
+
+      /* If we can execute the named file, and it is normal, then return it. */
+      if (! access (tbuf, X_OK)) {
+	struct stat stat_temp;
+
+	if (stat (tbuf, &stat_temp))
+	  continue;
+
+#ifndef STAT_MACROS_BROKEN
+	if (! S_ISREG(stat_temp.st_mode))
+	  continue;
+#endif
+	return copy_of (tbuf);
+      }
+    }
+  }
+
+  return NULL;
+}
+
+char* find_executable_path(const char *name)
+{
+  char *ef = find_executable(name);
+  char *temp, *temp2;
+  
+  temp2 = ef;
+  if (ef != NULL)
+  {
+    temp = NULL;
+    while (*ef != '\0')
+    {
+      if (*ef == '/') temp = ef;
+      ef++;
+    }
+    if (temp != NULL)
+    {
+      *temp = '\0';
+    }
+  }
+  return temp2;
+}
+
+  
+#else
+
+char* find_executable (const char *name)
+{
+  return NULL;
+}
+
+char* find_executable_path(const char *name)
+{
+  return NULL;
+}
+
+#endif /* #if ! defined(MSDOS) && ! defined(macintosh) && defined(HAVE_SYS_TYPES_H) && defined(HAVE_PWD_H)&&defined(HAVE_SYS_PARAM_H) */
+
+
Index: Singular/kstd1.cc
===================================================================
--- Singular/kstd1.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/kstd1.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstd1.cc,v 1.17 1998-03-23 22:50:58 obachman Exp $ */
+/* $Id: kstd1.cc,v 1.18 1998-04-06 17:59:29 obachman Exp $ */
 /*
 * ABSTRACT:
@@ -1642,5 +1642,5 @@
   initMora(F,strat);
   strat->spSpolyLoop = spGetSpolyLoop(currRing, 
-                                      MAX(strat->ak,pMaxComp(q)),
+                                      max(strat->ak,pMaxComp(q)),
                                       strat->syzComp, FALSE);
   strat->enterS = enterSMoraNF;
@@ -1737,5 +1737,5 @@
   /*- set T -*/
   strat->spSpolyLoop = spGetSpolyLoop(currRing, 
-                                      MAX(strat->ak,idRankFreeModule(q)),
+                                      max(strat->ak,idRankFreeModule(q)),
                                       strat->syzComp, FALSE);
   strat->tl = -1;
@@ -1836,4 +1836,5 @@
   else                 strat->LazyPass=20;
   strat->LazyDegree = 1;
+  strat->ak = idRankFreeModule(F);
   if ((h==testHomog)
 #ifdef DRING
@@ -1842,5 +1843,4 @@
   )
   {
-    strat->ak = idRankFreeModule(F);
     if (strat->ak == 0)       
     {
@@ -1876,5 +1876,5 @@
   strat->homog=h;
   spSet(currRing);
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat, syzComp);
   if (pOrdSgn==-1)
   {
@@ -1942,4 +1942,5 @@
   strat->LazyPass=32000;
   strat->LazyDegree = 10;
+  strat->ak = idRankFreeModule(F);
 //   if(stdTrace!=NULL)
 //     stdTrace->GetPrimes(F,primes);  // Array mit Primzahlen muß geordnet sein !
@@ -1951,5 +1952,4 @@
   )
   {
-    strat->ak = idRankFreeModule(F);
     if (strat->ak == 0)
     {
@@ -1978,5 +1978,5 @@
   strat->homog=h;
   spSet(currRing);
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat syzComp);
 //   if (pOrdSgn==-1)
 //   {
@@ -2035,4 +2035,5 @@
   strat->LazyDegree = 1;
   strat->minim=(reduced % 2)+1;
+  strat->ak = idRankFreeModule(F);
   if ((h==testHomog)
 #ifdef DRING
@@ -2041,5 +2042,4 @@
   )
   {
-    strat->ak = idRankFreeModule(F);
     if (strat->ak == 0)
     {
@@ -2080,5 +2080,5 @@
   strat->homog=h;
   spSet(currRing);
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat, syzComp);
   if (pOrdSgn==-1)
   {
Index: Singular/kstd2.cc
===================================================================
--- Singular/kstd2.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/kstd2.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstd2.cc,v 1.14 1998-03-23 22:50:59 obachman Exp $ */
+/* $Id: kstd2.cc,v 1.15 1998-04-06 17:59:30 obachman Exp $ */
 /*
 *  ABSTRACT -  Kernel: alg. of Buchberger
@@ -1545,5 +1545,5 @@
   /*- set S -*/
   strat->sl = -1;
-  strat->spSpolyLoop = spGetSpolyLoop(currRing, MAX(strat->ak, pMaxComp(q)),
+  strat->spSpolyLoop = spGetSpolyLoop(currRing, max(strat->ak, pMaxComp(q)),
                                       strat->syzComp, FALSE);
   /*- init local data struct.---------------------------------------- -*/
@@ -1590,5 +1590,5 @@
   strat->sl = -1;
   strat->spSpolyLoop =  spGetSpolyLoop(currRing, 
-                                       MAX(strat->ak, idRankFreeModule(q)),
+                                       max(strat->ak, idRankFreeModule(q)),
                                        strat->syzComp, FALSE);
   /*- init local data struct.---------------------------------------- -*/
@@ -1657,7 +1657,7 @@
   else                 strat->LazyPass=20;
   strat->LazyDegree = 1;
+  strat->ak = idRankFreeModule(F);
   if ((h==testHomog))
   {
-    strat->ak = idRankFreeModule(F);
     if (strat->ak==0)
     {
Index: Singular/kstdfac.cc
===================================================================
--- Singular/kstdfac.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/kstdfac.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kstdfac.cc,v 1.13 1998-03-23 14:07:54 obachman Exp $ */
+/* $Id: kstdfac.cc,v 1.14 1998-04-06 17:59:31 obachman Exp $ */
 /*
 *  ABSTRACT -  Kernel: factorizing alg. of Buchberger
@@ -726,7 +726,7 @@
   else                 strat->LazyPass=20;
   strat->LazyDegree = 1;
+  strat->ak = idRankFreeModule(F);
   if ((h==testHomog))
   {
-    strat->ak = idRankFreeModule(F);
     if (strat->ak==0)
     {
Index: Singular/kutil.cc
===================================================================
--- Singular/kutil.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/kutil.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kutil.cc,v 1.14 1998-03-23 22:51:00 obachman Exp $ */
+/* $Id: kutil.cc,v 1.15 1998-04-06 17:59:32 obachman Exp $ */
 /*
 * ABSTRACT: kernel: utils for std
@@ -3575,5 +3575,4 @@
 {
   strat->interpt = BTEST1(OPT_INTERRUPT);
-  strat->ak = idRankFreeModule(F);
   strat->kHEdge=NULL;
   if (pOrdSgn==1) strat->kHEdgeFound=FALSE;
Index: Singular/kutil.h
===================================================================
--- Singular/kutil.h	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/kutil.h	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: kutil.h,v 1.6 1998-03-19 16:05:48 obachman Exp $ */
+/* $Id: kutil.h,v 1.7 1998-04-06 17:59:33 obachman Exp $ */
 /*
 * ABSTRACT: kernel: utils for std
@@ -175,15 +175,4 @@
 
 rOrderType_t spGetOrderType(ring r, int modrank, int syzcomp);
-inline rOrderType_t spGetOrderType(ring r, kStrategy strat)
-{
-  return spGetOrderType(r, strat->ak, strat->syzComp);
-}
-
-inline int MAX(int a, int b)
-{
-  if (a > b) return a;
-  else return b;
-}
-
 
 inline TSet initT () { return (TSet)Alloc0(setmax*sizeof(TObject)); }
Index: Singular/misc.cc
===================================================================
--- Singular/misc.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/misc.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -726,12 +726,4 @@
 #endif
               StringAppend("random=%d\n",siRandomStart);
-#ifdef MSDOS
-              char *p=getenv("SPATH");
-#else
-              char *p=getenv("SINGULARPATH");
-#endif
-              if (p!=NULL)
-                return StringAppend("search path:%s:%s",p,SINGULAR_DATADIR);
-              else
-                return StringAppend("search path:%s", SINGULAR_DATADIR);
-}
+              return StringAppend("search path %s", feGetSearchPath());
+}
Index: Singular/mod2.h.in
===================================================================
--- Singular/mod2.h.in	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/mod2.h.in	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -36,4 +36,8 @@
 /* Define if you have sys/file.h */
 #undef HAVE_SYS_FILE_H
+/* Define if you have sys/param.h */
+#undef HAVE_SYS_PARAM_H
+/* Define if you have sys/file.h */
+#undef HAVE_SYS_TYPES_H
 /* Define if you have sys/ioctl.h */
 #undef HAVE_SYS_IOCTL_H
@@ -46,4 +50,6 @@
 /* Define if you have alloca.h */
 #undef HAVE_ALLOCA_H
+/* Define if you have pwd.h */
+#undef HAVE_PWD_H
 /* Define if you have alloca */
 #undef HAVE_ALLOCA
@@ -67,4 +73,10 @@
 /* Define if sprintf does not return number of printed chars */
 #undef BSD_SPRINTF
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
+#undef STAT_MACROS_BROKEN
+/* Define if you have the getcwd function.  */
+#undef HAVE_GETCWD
+/* Define if you have the getwd function.  */
+#undef HAVE_GETWD
 /* Define sizeof(char) */
 #define SIZEOF_CHAR 1
Index: Singular/spSpolyLoop.h
===================================================================
--- Singular/spSpolyLoop.h	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/spSpolyLoop.h	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -25,8 +25,16 @@
 inline spSpolyLoopProc spGetSpolyLoop(ring r, kStrategy strat)
 {
-  return spGetSpolyLoop(r, spGetOrderType(r, strat), 
+  return spGetSpolyLoop(r, spGetOrderType(r, strat->ak, strat->syzComp), 
                         ((strat->homog && strat->kModW==NULL && 
                           ! rHasSimpleLexOrder(r))));
 }
+
+inline spSpolyLoopProc spGetSpolyLoop(ring r, kStrategy strat, int syzComp)
+{
+  return spGetSpolyLoop(r, spGetOrderType(r, strat->ak, syzComp), 
+                        ((strat->homog && strat->kModW==NULL && 
+                          ! rHasSimpleLexOrder(r))));
+}
+
 
 inline spSpolyLoopProc spGetSpolyLoop(ring r)
Index: Singular/spSpolyLoop.inc
===================================================================
--- Singular/spSpolyLoop.inc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/spSpolyLoop.inc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -1525,4 +1525,5 @@
     {
       assume(pComp0(b, a2) == 1);
+      assume(pComp0(b,a2) == 1);
       pSetCoeff0(b,npMultM(pGetCoeff(a1), tneg));
       a = pNext(a) = b;       // append b to result and advance a1
Index: Singular/spSpolyLoop.pl
===================================================================
--- Singular/spSpolyLoop.pl	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/spSpolyLoop.pl	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -1,5 +1,5 @@
 #!/usr/local/bin/perl
 ###########################################################################
-# $Id: spSpolyLoop.pl,v 1.5 1998-03-31 12:20:23 obachman Exp $
+# $Id: spSpolyLoop.pl,v 1.6 1998-04-06 17:59:36 obachman Exp $
 
 ###########################################################################
@@ -11,4 +11,17 @@
 ##
 
+###########################################################################
+##
+## How to add/modify generation of spSpolyLoops
+##
+
+# 1.) Add property/characterisitc to property specification and make
+# sure that property is checked for in spGetSpolyLoop(...) in
+# spSpolyLoop.cc
+# 
+# 2.) Modify macros of spSpolyLoops so that approriate actions are taken
+# for new properties
+# 
+# 3.) Add properties to check for in @input
 
 
@@ -639,5 +652,4 @@
 }
 
-
 ###########################################################################
 ##
@@ -651,4 +663,9 @@
 
 
+###########################################################################
+##
+## Main program
+##
+
 #flatten out input
 @finput = &FlattenInput(@input);
@@ -670,14 +687,2 @@
 print $getspolyloop;
 
-
-
-
-  
-
-
-
-
-
-
-
-
Index: Singular/tesths.cc
===================================================================
--- Singular/tesths.cc	(revision d336d53da70515a0ed2ed294fdce5f4768ee4d95)
+++ Singular/tesths.cc	(revision 1caa724ecc92dd76617c98c9946796d008178c53)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: tesths.cc,v 1.31 1998-02-27 16:28:01 Singular Exp $ */
+/* $Id: tesths.cc,v 1.32 1998-04-06 17:59:37 obachman Exp $ */
 
 /*
@@ -58,4 +58,6 @@
   thisfile = argv[0];
   BOOLEAN load_std_lib=TRUE;
+  feGetSearchPath(thisfile);
+  
   /*. process parameters */
   for (;(argc > 1) && (!feBatch); --argc, ++argv)
