changeset 3834:414e694c9e6a

[project @ 2001-05-17 13:45:41 by jwe]
author jwe
date Thu, 17 May 2001 13:45:42 +0000
parents f3278ec3ccb7
children 47ee5e57a350
files liboctave/pathsearch.cc src/ChangeLog src/octave.cc src/toplev.cc src/toplev.h
diffstat 5 files changed, 60 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/pathsearch.cc	Thu May 17 12:31:52 2001 +0000
+++ b/liboctave/pathsearch.cc	Thu May 17 13:45:42 2001 +0000
@@ -136,20 +136,29 @@
 void
 dir_path::set_program_name (const std::string& nm)
 {
+  std::string selfautodir = octave_env::getenv ("SELFAUTODIR");
+  std::string selfautoloc = octave_env::getenv ("SELFAUTOLOC");
+  std::string selfautoparent = octave_env::getenv ("SELFAUTOPARENT");
+
   ::octave_kpse_set_progname (nm.c_str ());
 
   // Calling kpse_set_progname has the unfortunate side-effect of
-  // exporting the following variables.  We make them empty here so
-  // that they will not interfere with TeX, if it is run as a
-  // subprocess of Octave.
+  // exporting the following variables.  If they were empty when we
+  // started, we make them empty again so that they will not interfere
+  // with TeX if it is run as a subprocess of Octave (if they were set
+  // before, we want to preserve their values).
   //
   // XXX FIXME XXX -- is there a reasonable way to actually remove
   // them from the environment?
 
-  octave_env::putenv ("SELFAUTOLOC", "");
-  octave_env::putenv ("SELFAUTODIR", "");
-  octave_env::putenv ("SELFAUTOPARENT", "");
-  octave_env::putenv ("TEXMFDBS", "");
+  if (selfautodir.empty ())
+    octave_env::putenv ("SELFAUTODIR", "");
+
+  if (selfautoloc.empty ())
+    octave_env::putenv ("SELFAUTOLOC", "");
+
+  if (selfautoparent.empty ())
+    octave_env::putenv ("SELFAUTOPARENT", "");
 }
 
 void
--- a/src/ChangeLog	Thu May 17 12:31:52 2001 +0000
+++ b/src/ChangeLog	Thu May 17 13:45:42 2001 +0000
@@ -1,3 +1,11 @@
+2001-05-17  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* octave.cc (initialize_pathsearch): Save initial value of the
+	TEXMFDBS environment variable here.
+	* toplev.cc (restore_texmfdbs_envvar): New function.
+	(Fsystem): Set TEXMFDBS back to original value before running
+	subprocesses.
+
 2001-05-02  Mumit Khan  <khan@nanotech.wisc.edu>
 
 	* Makefile.in (octave): Add $(FFTW_LIBS).
--- a/src/octave.cc	Thu May 17 12:31:52 2001 +0000
+++ b/src/octave.cc	Thu May 17 13:45:42 2001 +0000
@@ -189,6 +189,8 @@
   if (odb.empty ())
     odb = Vdata_dir + std::string ("/octave:") + Vlibexec_dir + std::string ("/octave");
 
+  octave_original_texmfdbs = octave_env::getenv ("TEXMFDBS");
+
   octave_env::putenv ("TEXMFDBS", odb);
 }
 
--- a/src/toplev.cc	Thu May 17 12:31:52 2001 +0000
+++ b/src/toplev.cc	Thu May 17 13:45:42 2001 +0000
@@ -88,6 +88,9 @@
 // Pointer to function that is currently being evaluated.
 octave_user_function *curr_function = 0;
 
+// Original value of TEXMFDBS environment variable.
+std::string octave_original_texmfdbs;
+
 // Top level context (?)
 jmp_buf toplevel;
 
@@ -381,6 +384,14 @@
   return retval;
 }
 
+static void
+restore_texmfdbs_envvar (void *ptr)
+{
+  std::string *s = static_cast<std::string *> (ptr);
+
+  octave_env::putenv ("TEXMFDBS", *s);
+}
+
 DEFUN (system, args, nargout,
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} system (@var{string}, @var{return_output}, @var{type})\n\
@@ -425,6 +436,8 @@
 {
   octave_value_list retval;
 
+  unwind_protect::begin_frame ("Fsystem");
+
   int nargin = args.length ();
 
   if (nargin > 0 && nargin < 4)
@@ -461,6 +474,22 @@
 
       if (! error_state)
 	{
+	  // The value of TEXMFDBS that Octave puts in the environment
+	  // will cause trouble if we are asked to run TeX, so we
+	  // should reset it to whatever it was before Octave started.
+	  //
+	  // XXX FIXME XXX -- it would be better to fix the
+	  // kpathsearch library to not always do TeX-specific
+	  // things...
+
+	  static string odb;
+
+	  odb = octave_env::getenv ("TEXMFDBS");
+
+	  unwind_protect::add (restore_texmfdbs_envvar, &odb);
+
+	  octave_env::putenv ("TEXMFDBS", octave_original_texmfdbs);
+
 	  if (type == async)
 	    {
 	      pid_t pid = fork ();
@@ -500,6 +529,8 @@
   else
     print_usage ("system");
 
+  unwind_protect::run_frame ("Fsystem");
+
   return retval;
 }
 
--- a/src/toplev.h	Thu May 17 12:31:52 2001 +0000
+++ b/src/toplev.h	Thu May 17 13:45:42 2001 +0000
@@ -48,6 +48,9 @@
 // Pointer to function that is currently being evaluated.
 extern octave_user_function *curr_function;
 
+// Original value of TEXMFDBS environment variable.
+extern std::string octave_original_texmfdbs;
+
 #endif
 
 /*