changeset 2204:a24158362f9f

[project @ 1996-05-15 06:09:42 by jwe]
author jwe
date Wed, 15 May 1996 06:11:57 +0000
parents 88a4d3580427
children bd389b53befa
files src/Makefile.in src/defaults.h.in src/dirfns.cc src/dirfns.h src/pt-misc.cc src/toplev.cc src/toplev.h src/utils.cc src/utils.h src/variables.h
diffstat 10 files changed, 116 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.in	Wed May 15 06:09:30 1996 +0000
+++ b/src/Makefile.in	Wed May 15 06:11:57 1996 +0000
@@ -92,7 +92,7 @@
 	pt-fvc.h pt-mat.h pt-misc.h pt-mvr-base.h pt-mvr.h \
 	pt-plot.h pt-pr-code.h pt-walk.h sighandlers.h symtab.h \
 	syscalls.h sysdep.h systime.h syswait.h token.h toplev.h \
-	unwind-prot.h user-prefs.h utils.h variables.h version.h \
+	unwind-prot.h utils.h variables.h version.h \
 	xdiv.h xpow.h Map.h SLStack.h Stack.h
 
 TI_SRC := Array-os.cc Array-tc.cc Map-tc.cc \
@@ -108,8 +108,8 @@
   TI_PICOBJ := $(addprefix pic/, $(TI_OBJ))
 endif
 
-SOURCES := arith-ops.cc data.cc dirfns.cc dynamic-ld.cc error.cc \
-	file-io.cc gripes.cc help.cc input.cc lex.l \
+SOURCES := arith-ops.cc data.cc defaults.cc dirfns.cc dynamic-ld.cc \
+	error.cc file-io.cc gripes.cc help.cc input.cc lex.l \
 	load-save.cc mappers.cc oct-fstrm.cc oct-hist.cc oct-iostrm.cc \
 	oct-map.cc oct-obj.cc oct-prcstrm.cc oct-procbuf.cc \
 	oct-stdstrm.cc oct-stream.cc oct-strstrm.cc pager.cc \
@@ -119,7 +119,7 @@
 	pt-mvr-base.cc pt-mvr.cc pt-plot.cc pt-pr-code.cc resource.cc \
 	sighandlers.cc strcasecmp.c strncase.c strfns.cc strftime.c \
 	symtab.cc syscalls.cc sysdep.cc timefns.cc token.cc toplev.cc \
-	unwind-prot.cc user-prefs.cc utils.cc variables.cc xdiv.cc \
+	unwind-prot.cc utils.cc variables.cc xdiv.cc \
 	xpow.cc
 
 TEMPLATE_SRC = Map.cc SLStack.cc
@@ -329,10 +329,10 @@
 
 # Special rules -- these files need special things to be defined.
 
-defaults.h: ../Makeconf Makefile
+defaults.h: defaults.h.in ../Makeconf Makefile
 	@$(do-subst-default-vals)
 
-oct-conf.h: ../Makeconf Makefile
+oct-conf.h: oct-conf.h.in ../Makeconf Makefile
 	@$(do-subst-config-vals)
 
 oct-gperf.h: octave.gperf
--- a/src/defaults.h.in	Wed May 15 06:09:30 1996 +0000
+++ b/src/defaults.h.in	Wed May 15 06:11:57 1996 +0000
@@ -24,6 +24,8 @@
 #if !defined (octave_defaults_h)
 #define octave_defaults_h 1
 
+#include <string>
+
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER %DEFAULT_PAGER%
 #endif
@@ -112,8 +114,36 @@
 #define CXXLIB_PATH %CXXLIB_PATH%
 #endif
 
+extern string Voctave_home;
+
+extern string Vbin_dir;
+extern string Vlib_dir;
+extern string Vinfo_dir;
+extern string Varch_lib_dir;
+extern string Vfcn_file_dir;
+
+// The path that will be searched for programs that we execute.
+// (--exec-path path)
+extern string Vexec_path;
+
+// Load path specified on command line.
+// (--path path; -p path)
+extern string Vload_path;
+
+// Name of the editor to be invoked by the edit_history command.
+extern string Veditor;
+
+extern string Vimagepath;
+
+extern string Vlocal_site_defaults_file;
+extern string Vsite_defaults_file;
+
+extern string maybe_add_default_load_path (const string& pathstring);
+
 extern void install_defaults (void);
 
+extern void symbols_of_defaults (void);
+
 #endif
 
 /*
--- a/src/dirfns.cc	Wed May 15 06:09:30 1996 +0000
+++ b/src/dirfns.cc	Wed May 15 06:11:57 1996 +0000
@@ -73,7 +73,7 @@
 #include "variables.h"
 
 // The current working directory.
-static string Vcurrent_directory;
+string Vcurrent_directory;
 
 // Non-zero means follow symbolic links that point to directories just
 // as if they are real directories.
@@ -116,9 +116,9 @@
 {
   string retval;
 
-  size_t len = home_directory.length ();
+  size_t len = Vhome_directory.length ();
 
-  if (len > 1 && home_directory.compare (name, 0, len) == 0
+  if (len > 1 && Vhome_directory.compare (name, 0, len) == 0
       && (name.length () == len || name[len] == '/'))
     {
       retval = "~";
@@ -243,17 +243,17 @@
 get_working_directory (const string& for_whom)
 {
   if (! follow_symbolic_links)
-    the_current_working_directory = "";
+    Vcurrent_directory = "";
 
-  if (the_current_working_directory.empty ())
+  if (Vcurrent_directory.empty ())
     {
-      the_current_working_directory = octave_getcwd ();
+      Vcurrent_directory = octave_getcwd ();
 
-      if (the_current_working_directory.empty ())
+      if (Vcurrent_directory.empty ())
 	warning ("%s: can't find current directory!", for_whom.c_str ());
     }
 
-  return the_current_working_directory;
+  return Vcurrent_directory;
 }
 
 // Do the work of changing to the directory NEWDIR.  Handle symbolic
@@ -266,13 +266,13 @@
 
   if (follow_symbolic_links)
     {
-      if (the_current_working_directory.empty ())
+      if (Vcurrent_directory.empty ())
 	get_working_directory ("cd_links");
 
-      if (the_current_working_directory.empty ())
+      if (Vcurrent_directory.empty ())
 	tmp = newdir;
       else
-	tmp = make_absolute (newdir, the_current_working_directory);
+	tmp = make_absolute (newdir, Vcurrent_directory);
 
       // Get rid of trailing `/'.
 
@@ -288,7 +288,7 @@
 	return 0;
       else
 	{
-	  the_current_working_directory = tmp;
+	  Vcurrent_directory = tmp;
 	  return 1;
 	}
     }
@@ -337,8 +337,8 @@
     }
   else
     {
-      if (home_directory.empty ()
-	  || ! octave_change_to_directory (home_directory))
+      if (Vhome_directory.empty ()
+	  || ! octave_change_to_directory (Vhome_directory))
 	{
 	  return retval;
 	}
--- a/src/dirfns.h	Wed May 15 06:09:30 1996 +0000
+++ b/src/dirfns.h	Wed May 15 06:11:57 1996 +0000
@@ -32,6 +32,8 @@
 extern string make_absolute (const string&, const string&);
 extern string get_working_directory (const string&);
 
+extern string Vcurrent_directory;
+
 extern void symbols_of_dirfns (void);
 
 #endif
--- a/src/pt-misc.cc	Wed May 15 06:09:30 1996 +0000
+++ b/src/pt-misc.cc	Wed May 15 06:11:57 1996 +0000
@@ -48,7 +48,7 @@
 #include "pt-mvr.h"
 #include "pt-walk.h"
 #include "pt-pr-code.h"
-#include "user-prefs.h"
+#include "variables.h"
 
 // Nonzero means we're breaking out of a loop or function body.
 extern int breaking;
@@ -83,7 +83,7 @@
 tree_statement::maybe_echo_code (bool in_function_body)
 {
   if (in_function_body
-      && (user_pref.echo_executing_commands & ECHO_FUNCTIONS))
+      && (Vecho_executing_commands & ECHO_FUNCTIONS))
     {
       tree_print_code tpc (octave_stdout);
 
--- a/src/toplev.cc	Wed May 15 06:09:30 1996 +0000
+++ b/src/toplev.cc	Wed May 15 06:11:57 1996 +0000
@@ -68,47 +68,24 @@
 #include "sysdep.h"
 #include "toplev.h"
 #include "unwind-prot.h"
-#include "user-prefs.h"
 #include "utils.h"
 #include "variables.h"
 #include "version.h"
 
 // argv[0] for this program.
-string raw_prog_name;
+string Vprogram_invocation_name;
 
 // Cleaned-up name of this program, not including path information.
-string prog_name;
+string Vprogram_name;
 
 // Login name for user running this program.
-string user_name;
+string Vuser_name;
 
 // Name of the host we are running on.
-string host_name;
+string Vhost_name;
 
 // User's home directory.
-string home_directory;
-
-// Guess what?
-string the_current_working_directory;
-
-// The path that will be searched for programs that we execute.
-// (--exec-path path)
-string exec_path;
-
-// Load path specified on command line.
-// (--path path; -p path)
-string load_path;
-
-// Name of the info file specified on command line.
-// (--info-file file)
-string info_file;
-
-// Name of the info reader we'd like to use.
-// (--info-program program)
-string info_prog;
-
-// Name of the editor to be invoked by the edit_history command.
-string editor;
+string Vhome_directory;
 
 // Nonzero means we are using readline.
 // (--no-line-editing)
--- a/src/toplev.h	Wed May 15 06:09:30 1996 +0000
+++ b/src/toplev.h	Wed May 15 06:11:57 1996 +0000
@@ -48,37 +48,19 @@
 extern void do_octave_atexit (void);
 
 // argv[0] for this program.
-extern string raw_prog_name;
+extern string Vprogram_invocation_name;
 
 // Cleaned-up name of this program, not including path information.
-extern string prog_name;
+extern string Vprogram_name;
 
 // Login name for user running this program.
-extern string user_name;
+extern string Vuser_name;
 
 // Name of the host we are running on.
-extern string host_name;
-
-// User's home directory.
-extern string home_directory;
-
-// Guess what?
-extern string the_current_working_directory;
-
-// The path that will be searched for programs that we execute.
-extern string exec_path;
+extern string Vhost_name;
 
-// Load path specified on command line.
-extern string load_path;
-
-// Name of the info file specified on command line.
-extern string info_file;
-
-// Name of the info reader we'd like to use.
-extern string info_prog;
-
-// Name of the editor to be invoked by the edit_history command.
-extern string editor;
+// Home directory for the current user.
+extern string Vhome_directory;
 
 // Nonzero means we are using readline.
 extern int using_readline;
--- a/src/utils.cc	Wed May 15 06:09:30 1996 +0000
+++ b/src/utils.cc	Wed May 15 06:11:57 1996 +0000
@@ -58,6 +58,7 @@
 #include "oct-cmplx.h"
 #include "str-vec.h"
 
+#include "defaults.h"
 #include "defun.h"
 #include "dir-ops.h"
 #include "dirfns.h"
@@ -73,7 +74,6 @@
 #include "sysdep.h"
 #include "toplev.h"
 #include "unwind-prot.h"
-#include "user-prefs.h"
 #include "utils.h"
 #include "variables.h"
 
@@ -266,7 +266,7 @@
 
   string_vector retval (num_max);
 
-  dir_path p (user_pref.loadpath);
+  dir_path p (Vload_path);
 
   string_vector dirs = p.all_directories ();
 
@@ -331,7 +331,7 @@
 {
   dir_path p (path);
 
-  return make_absolute (p.find (name), the_current_working_directory);
+  return make_absolute (p.find (name), Vcurrent_directory);
 }
 
 DEFUN (file_in_path, args, ,
@@ -369,10 +369,10 @@
   if (! suffix.empty ())
     nm.append (suffix);
 
-  if (the_current_working_directory.empty ())
+  if (Vcurrent_directory.empty ())
     get_working_directory ("file_in_path");
 
-  return search_path_for_file (user_pref.loadpath, nm);
+  return search_path_for_file (Vload_path, nm);
 }
 
 // See if there is an function file in the path.  If so, return the
@@ -574,6 +574,40 @@
 #endif
 }
 
+// Check the value of a string variable to see if it it's ok to do
+// something.
+//
+//   return of  1 => always ok.
+//   return of  0 => never ok.
+//   return of -1 => ok, but give me warning (default).
+
+int
+check_preference (const string& var)
+{
+  int pref = -1;
+
+  string val = builtin_string_variable (var);
+
+  if (val.empty ())
+    {
+      double dval = 0;
+      if (builtin_real_scalar_variable (var, dval))
+	pref = NINT (dval);
+    }
+  else
+    {
+      if (val.compare ("yes", 0, 3) == 0
+	  || val.compare ("true", 0, 4) == 0)
+	pref = 1;
+      else if (val.compare ("never", 0, 5) == 0
+	       || val.compare ("no", 0, 2) == 0
+	       || val.compare ("false", 0, 5) == 0)
+	pref = 0;
+    }
+
+  return pref;
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
--- a/src/utils.h	Wed May 15 06:09:30 1996 +0000
+++ b/src/utils.h	Wed May 15 06:11:57 1996 +0000
@@ -62,6 +62,8 @@
 
 extern void oct_putenv (const char *, const char *);
 
+extern int check_preference (const string& var);
+
 #endif
 
 /*
--- a/src/variables.h	Wed May 15 06:09:30 1996 +0000
+++ b/src/variables.h	Wed May 15 06:11:57 1996 +0000
@@ -130,20 +130,6 @@
 
 extern void install_builtin_variables (void);
 
-extern string maybe_add_default_load_path (const string& p);
-
-extern string octave_lib_dir (void);
-extern string octave_arch_lib_dir (void);
-extern string octave_fcn_file_dir (void);
-extern string octave_bin_dir (void);
-extern string default_exec_path (void);
-extern string default_path (void);
-extern string default_info_file (void);
-extern string default_info_prog (void);
-extern string default_editor (void);
-extern string get_local_site_defaults (void);
-extern string get_site_defaults (void);
-
 // Symbol table for symbols at the top level.
 extern symbol_table *top_level_sym_tab;
 
@@ -153,6 +139,16 @@
 // Symbol table for global symbols.
 extern symbol_table *global_sym_tab;
 
+enum echo_state
+{
+  ECHO_OFF = 0,
+  ECHO_SCRIPTS = 1,
+  ECHO_FUNCTIONS = 2,
+  ECHO_CMD_LINE = 4
+};
+
+extern int Vecho_executing_commands;
+
 #endif
 
 /*