changeset 3308:7ae1928ca623

[project @ 1999-10-21 08:57:11 by jwe]
author jwe
date Thu, 21 Oct 1999 08:57:14 +0000
parents b6c74a0772b5
children caebc01df081
files ChangeLog configure.in src/ChangeLog src/Makefile.in src/dirfns.cc src/oct-procbuf.cc src/symtab.cc src/sysdep.cc src/toplev.cc src/utils.h src/variables.h
diffstat 11 files changed, 96 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-10-21  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* configure.in: Check for select and poll.  Also check for poll.h
+	and sys/poll.h.
+
 1999-10-19  Geoff Jacobsen <geoffj@casquet.inet.net.nz>
 
 	* autogen.sh: New file.
--- a/configure.in
+++ b/configure.in
@@ -21,7 +21,7 @@
 ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 ### 02111-1307, USA. 
 
-AC_REVISION($Revision: 1.317 $)
+AC_REVISION($Revision: 1.318 $)
 AC_PREREQ(2.9)
 AC_INIT(src/octave.cc)
 AC_CONFIG_HEADER(config.h)
@@ -706,11 +706,12 @@
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 
-AC_CHECK_HEADERS(assert.h curses.h dlfcn.h fcntl.h float.h floatingpoint.h \
-  fnmatch.h glob.h grp.h ieeefp.h limits.h memory.h nan.h ncurses.h \
-  pwd.h sgtty.h stdlib.h string.h sys/ioctl.h sys/param.h sys/resource.h \
-  sys/select.h sys/stat.h sys/time.h sys/times.h sys/types.h \
-  sys/utsname.h termcap.h termio.h $TERMIOS_H unistd.h varargs.h)
+AC_CHECK_HEADERS(assert.h curses.h dlfcn.h fcntl.h float.h \
+  floatingpoint.h fnmatch.h glob.h grp.h ieeefp.h limits.h memory.h \
+  nan.h ncurses.h poll.h pwd.h sgtty.h stdlib.h string.h sys/ioctl.h \
+  sys/param.h sys/poll.h sys/resource.h sys/select.h sys/stat.h \
+  sys/time.h sys/times.h sys/types.h sys/utsname.h termcap.h \
+  termio.h $TERMIOS_H unistd.h varargs.h)
 
 ### I'm told that termios.h is broken on NeXT systems.
 
@@ -776,11 +777,11 @@
 AC_CHECK_FUNCS(atexit bcopy bzero dup2 endgrent endpwent execvp fcntl \
   fork getcwd getegid geteuid getgid getgrent getgrgid getgrnam \
   gethostname getpgrp getpid getppid getpwent getpwnam getpwuid \
-  gettimeofday getuid getwd lstat memmove mkdir mkfifo on_exit pipe \
-  putenv rename rindex rmdir setgrent setpwent setvbuf sigaction \
-  sigpending sigprocmask sigsuspend stat strcasecmp strdup strerror \
-  strftime stricmp strncasecmp strnicmp tempnam umask unlink usleep \
-  vfprintf vsprintf waitpid)
+  gettimeofday getuid getwd lstat memmove mkdir mkfifo on_exit pipe
+  poll putenv rename rindex rmdir select setgrent setpwent setvbuf \
+  sigaction sigpending sigprocmask sigsuspend stat strcasecmp strdup \
+  strerror strftime stricmp strncasecmp strnicmp tempnam umask unlink \
+  usleep vfprintf vsprintf waitpid)
 
 OCTAVE_SMART_PUTENV
 
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
+1999-10-21  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* variables.h (is_valid_function): Provide default values for the
+	string argument.
+
+	* symtab.cc (variable_reference): Maybe print warning (or error)
+	about variables that hide functions of the same name.
+	(symbol_record::define (const octave_value&, unsigned int)): Ditto.
+	(Vvariables_can_hide_functions): New static variable.
+	(variables_can_hide_functions, symbols_of_symtab): New functions.
+
+	* cutils.c: New file.
+	* Makefile.in (SOURCES): Add it to the list.
+	* utils.h: Declare octave_usleep here.
+	* dirfns.cc (Fls): Simply all octave_usleep.
+	* oct-procbuf.cc (octave_procbuf::open): Ditto.
+	* sysdep.cc (Fusleep): Ditto.
+	* toplev.cc (run_command_and_return_output): Ditto.
+
 1999-10-20  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* data.cc (make_diag (const octave_value&, const octave_value&)):
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -123,7 +123,7 @@
 	pt-select.cc pt-stmt.cc pt-unop.cc
 
 DIST_SRC := BaseSLList.cc Map.cc SLList.cc SLStack.cc Stack.cc \
-	data.cc defaults.cc defun.cc dirfns.cc dynamic-ld.cc \
+	cutils.c data.cc defaults.cc defun.cc dirfns.cc dynamic-ld.cc \
 	error.cc file-io.cc fn-cache.cc gripes.cc help.cc input.cc \
 	lex.l load-save.cc mappers.cc matherr.c oct-fstrm.cc \
 	oct-hist.cc oct-iostrm.cc oct-map.cc oct-obj.cc oct-prcstrm.cc \
--- a/src/dirfns.cc
+++ b/src/dirfns.cc
@@ -197,11 +197,7 @@
         {
           cmd->clear ();
 
-#if defined (HAVE_USLEEP)
-          usleep (100);
-#else
-          sleep (1);
-#endif
+          octave_usleep (100);
         }
 
       while (cmd->get (ch))
--- a/src/oct-procbuf.cc
+++ b/src/oct-procbuf.cc
@@ -43,6 +43,7 @@
 
 #include "defun.h"
 #include "gripes.h"
+#include "utils.h"
 
 // Number of microseconds to delay in the parent after forking.
 #if defined (__CYGWIN32__)
@@ -112,13 +113,8 @@
       exit (127);
     }
 
-#if defined (HAVE_USLEEP)
   if (Vkluge_procbuf_delay > 0)
-    usleep (Vkluge_procbuf_delay);
-#else
-  if (Vkluge_procbuf_delay > 499999)
-    sleep ((Vkluge_procbuf_delay + 500000) / 1000000);
-#endif
+    octave_usleep (Vkluge_procbuf_delay);
 
   ::close (child_end);
 
--- a/src/symtab.cc
+++ b/src/symtab.cc
@@ -37,6 +37,7 @@
 #include "glob-match.h"
 #include "str-vec.h"
 
+#include "defun.h"
 #include "error.h"
 #include "oct-lvalue.h"
 #include "ov.h"
@@ -45,6 +46,11 @@
 #include "utils.h"
 #include "variables.h"
 
+// Should variables be allowed to hide functions of the same name?  A
+// positive value means yes.  A negative value means yes, but print a
+// warning message.  Zero means it should be considered an error.
+static int Vvariables_can_hide_functions;
+
 octave_allocator
 symbol_record::symbol_def::allocator (sizeof (symbol_record::symbol_def));
 
@@ -74,7 +80,17 @@
   if (! (is_variable () && read_only_error ("redefine")))
     {
       if (is_function () || is_constant ())
-	push_def (new symbol_def ());
+	{
+	  if (Vvariables_can_hide_functions)
+	    {
+	      push_def (new symbol_def ());
+
+	      if (Vvariables_can_hide_functions < 0)
+		warning ("variable `%s' hides function", nm.c_str ());
+	    }
+	  else
+	    error ("variable `%s' hides function", nm.c_str ());
+	}
 
       if (definition->type () == symbol_record::BUILTIN_VARIABLE)
 	sym_type = symbol_record::BUILTIN_VARIABLE;
@@ -243,6 +259,19 @@
 octave_lvalue
 symbol_record::variable_reference (void)
 {
+  if (Vvariables_can_hide_functions <= 0
+      && (is_function ()
+	  || (! is_defined () && is_valid_function (nm))))
+    {
+      if (Vvariables_can_hide_functions < 0)
+	warning ("variable `%s' hides function", nm.c_str ());
+      else
+	{
+	  error ("variable `%s' hides function", nm.c_str ());
+	  return octave_lvalue ();
+	}
+    }
+
   if (is_function () || is_constant ())
     clear ();
 
@@ -778,6 +807,24 @@
   return h & (table_size - 1);
 }
 
+
+static int
+variables_can_hide_functions (void)
+{
+  Vvariables_can_hide_functions
+    = check_preference ("variables_can_hide_functions");
+
+  return 0;
+}
+
+void
+symbols_of_symtab (void)
+{
+  DEFVAR (variables_can_hide_functions, 1.0, variables_can_hide_functions,
+    "Should variables be allowed to hide functions of the same name?");
+}
+
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/sysdep.cc
+++ b/src/sysdep.cc
@@ -519,17 +519,10 @@
 	    warning ("usleep: NaN is an invalid delay");
 	  else
 	    {
-#if defined (HAVE_USLEEP)
 	      int delay = NINT (dval);
 
 	      if (delay > 0)
-		usleep (delay);
-#else
-	      int delay = NINT (dval / 1e6);
-
-	      if (delay > 0)
-		sleep (delay);
-#endif
+		octave_usleep (delay);
 	    }
 	}
     }
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -335,11 +335,7 @@
 	    {
 	      cmd->clear ();
 
-#if defined (HAVE_USLEEP)
-	      usleep (100);
-#else
-	      sleep (1);
-#endif
+	      octave_usleep (100);
 	    }
 
 	  while (cmd->get (ch))
--- a/src/utils.h
+++ b/src/utils.h
@@ -58,6 +58,8 @@
 
 extern int check_preference (const string& var);
 
+extern "C" void octave_usleep (unsigned int useconds);
+
 #endif
 
 /*
--- a/src/variables.h
+++ b/src/variables.h
@@ -50,10 +50,12 @@
 extern bool is_globally_visible (const string&);
 
 extern octave_function *
-is_valid_function (const octave_value&, const string&, bool warn = false); 
+is_valid_function (const octave_value&, const string& = string (),
+		   bool warn = false); 
 
 extern octave_function *
-is_valid_function (const string&, const string&, bool warn = false); 
+is_valid_function (const string&, const string& = string (),
+		   bool warn = false); 
 
 extern octave_function *
 extract_function (const octave_value& arg, const string& warn_for,