Mercurial > hg > octave-nkf
diff src/toplev.cc @ 3834:414e694c9e6a
[project @ 2001-05-17 13:45:41 by jwe]
author | jwe |
---|---|
date | Thu, 17 May 2001 13:45:42 +0000 |
parents | 1a809dae77db |
children | bbe74a066592 |
line wrap: on
line diff
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -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; }