changeset 661:9ccf86647203

[project @ 1994-08-30 04:41:56 by jwe]
author jwe
date Tue, 30 Aug 1994 04:46:17 +0000
parents 1787dc40c811
children fdf4ce2d855e
files src/dirfns.cc src/input.cc src/lex.l src/pt-plot.cc src/sysdep.cc src/user-prefs.cc src/user-prefs.h src/utils.cc src/utils.h src/variables.cc
diffstat 10 files changed, 450 insertions(+), 291 deletions(-) [+]
line wrap: on
line diff
--- a/src/dirfns.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/dirfns.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -21,6 +21,25 @@
 
 */
 
+/*
+
+The functions listed below were adapted from similar functions from
+the GNU C library, copyright (C) 1991, 1992, 1993, Free Software
+Foundation, Inc.
+
+  dir_access    exists    gen_tempname    tempnam
+
+The functions listed below were adapted from a similar functions
+from GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991
+Free Software Foundation, Inc.
+
+  polite_directory_format  absolute_pathname
+  absolute_program         base_pathname
+  make_absolute            pathname_backup
+  change_to_directory      get_working_directory
+
+*/ 
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -29,9 +48,14 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <strstream.h>
 #include <sys/param.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <errno.h>
 
 // This mess suggested by the autoconf manual.
@@ -85,10 +109,195 @@
 // of symbolic link following.
 static int verbatim_pwd = 1;
 
-/*
- * Remove the last N directories from PATH.  Do not PATH blank.
- * PATH must contain enough space for MAXPATHLEN characters.
- */
+#ifndef HAVE_TEMPNAM
+
+#ifndef P_tmpdir
+#define P_tmpdir "/usr/tmp/"
+#endif
+
+// Return nonzero if DIR is an existent directory.
+
+static int
+diraccess (const char *dir)
+{
+  struct stat buf;
+  return stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+}
+
+// Return nonzero if FILE exists.
+
+static int
+exists (const char *file)
+{
+// We can stat the file even if we can't read its data.
+  struct stat st;
+  int save = errno;
+  if (stat (file, &st) == 0)
+    return 1;
+  else
+    {
+// We report that the file exists if stat failed for a reason other
+// than nonexistence.  In this case, it may or may not exist, and we
+// don't know; but reporting that it does exist will never cause any
+// trouble, while reporting that it doesn't exist when it does would
+// violate the interface of gen_tempname.
+      int exists = errno != ENOENT;
+      errno = save;
+      return exists;
+    }
+}
+
+// These are the characters used in temporary filenames.
+
+static const char letters[] =
+  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+// Generate a temporary filename and return it (in a static buffer).
+// If DIR_SEARCH is nonzero, DIR and PFX are used as described for
+// tempnam.  If not, a temporary filename in P_tmpdir with no special
+// prefix is generated.  This goes through a cyclic pattern of all
+// possible filenames consisting of five decimal digits of the current
+// pid and three of the characters in `letters'.  Data for tempnam and
+// tmpnam is kept separate, but when tempnam is using P_tmpdir and no
+// prefix (i.e, it is identical to tmpnam), the same data is used.
+// Each potential filename is tested for an already-existing file of
+// the same name, and no name of an existing file will be returned.
+// When the cycle reaches its end (12345ZZZ), NULL is returned.
+
+static char *
+gen_tempname (const char *dir, const char *pfx, int dir_search,
+	      size_t *lenptr)
+{
+  int saverrno = errno;
+  static const char tmpdir[] = P_tmpdir;
+  static size_t indices[2];
+  size_t *idx;
+  static char buf[MAXPATHLEN];
+  static pid_t oldpid = (pid_t) 0;
+  pid_t pid = getpid ();
+  register size_t len, plen, dlen;
+
+  if (dir_search)
+    {
+      register const char *d = getenv ("TMPDIR");
+      if (d != NULL && !diraccess (d))
+	d = NULL;
+      if (d == NULL && dir != NULL && diraccess (dir))
+	d = dir;
+      if (d == NULL && diraccess (tmpdir))
+	d = tmpdir;
+      if (d == NULL && diraccess ("/tmp"))
+	d = "/tmp";
+      if (d == NULL)
+	{
+	  errno = ENOENT;
+	  return NULL;
+	}
+      dir = d;
+    }
+  else
+    dir = tmpdir;
+
+  dlen = strlen (dir);
+
+// Remove trailing slashes from the directory name.
+  while (dlen > 1 && dir[dlen - 1] == '/')
+    --dlen;
+
+  if (pfx != NULL && *pfx != '\0')
+    {
+      plen = strlen (pfx);
+      if (plen > 5)
+	plen = 5;
+    }
+  else
+    plen = 0;
+
+  if (dir != tmpdir && !strcmp (dir, tmpdir))
+    dir = tmpdir;
+  idx = &indices[(plen == 0 && dir == tmpdir) ? 1 : 0];
+
+  if (pid != oldpid)
+    {
+      oldpid = pid;
+      indices[0] = indices[1] = 0;
+    }
+
+  len = dlen + 1 + plen + 5 + 3;
+  for (; *idx < ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
+		 (sizeof (letters) - 1));
+       ++*idx)
+    {
+// Construct a file name and see if it already exists.
+//
+// We use a single counter in *IDX to cycle each of three character
+// positions through each of 62 possible letters.
+
+      if (sizeof (buf) < len)
+	return NULL;
+
+      sprintf (buf, "%.*s/%.*s%.5d%c%c%c",
+	       (int) dlen, dir, (int) plen, pfx, pid % 100000,
+	       letters[*idx % (sizeof (letters) - 1)],
+	       letters[(*idx / (sizeof (letters) - 1))
+		       % (sizeof (letters) - 1)], 
+	       letters[(*idx / ((sizeof (letters) - 1)
+				* (sizeof (letters) - 1)))
+		       % (sizeof (letters) - 1)]);
+
+      if (strlen (buf) != (int) len)
+	return NULL;
+
+      if (exists (buf))
+	continue;
+
+// If the file already existed we have continued the loop above, so we
+// only get here when we have a winning name to return.
+
+      errno = saverrno;
+
+      if (lenptr != NULL)
+	*lenptr = len + 1;
+
+      return buf;
+    }
+
+// We got out of the loop because we ran out of combinations to try.
+  errno = EEXIST;		// ???
+  return NULL;
+}
+
+// Generate a unique temporary filename using up to five characters of
+// PFX if it is not NULL.  The directory to put this file in is
+// searched for as follows: First the environment variable "TMPDIR" is
+// checked.  If it contains the name of a writable directory, that
+// directory is used.  If not and if DIR is not NULL, that value is
+// checked.  If that fails, P_tmpdir is tried and finally "/tmp".  The
+// storage for the filename is allocated by `malloc'.
+
+char *
+tempnam (const char *dir, const char *pfx)
+{
+  size_t len;
+  register char *s;
+  register char *t = gen_tempname (dir, pfx, 1, &len);
+
+  if (t == NULL)
+    return NULL;
+
+  s = (char *) malloc (len);
+  if (s == NULL)
+    return NULL;
+
+  (void) memcpy (s, t, len);
+  return s;
+}
+
+#endif
+
+// Remove the last N directories from PATH.  Do not PATH blank.
+// PATH must contain enough space for MAXPATHLEN characters.
+
 void
 pathname_backup (char *path, int n)
 {
@@ -111,10 +320,9 @@
     }
 }
 
-/*
- * Return a pretty pathname.  If the first part of the pathname is the
- * same as $HOME, then replace that with `~'.
- */
+// Return a pretty pathname.  If the first part of the pathname is the
+// same as $HOME, then replace that with `~'.
+
 char *
 polite_directory_format (char *name)
 {
@@ -131,9 +339,8 @@
     return name;
 }
 
-/*
- * Return 1 if STRING contains an absolute pathname, else 0.
- */
+// Return 1 if STRING contains an absolute pathname, else 0.
+
 int
 absolute_pathname (const char *string)
 {
@@ -155,21 +362,19 @@
   return 0;
 }
 
-/*
- * Return 1 if STRING is an absolute program name; it is absolute if
- * it contains any slashes.  This is used to decide whether or not to
- * look up through $PATH.
- */
+// Return 1 if STRING is an absolute program name; it is absolute if
+// it contains any slashes.  This is used to decide whether or not to
+// look up through $PATH.
+
 int
 absolute_program (const char *string)
 {
   return (strchr (string, '/') != 0);
 }
 
-/*
- * Return the `basename' of the pathname in STRING (the stuff after
- * the last '/').  If STRING is not a full pathname, simply return it.
- */
+// Return the `basename' of the pathname in STRING (the stuff after
+// the last '/').  If STRING is not a full pathname, simply return it.
+
 char *
 base_pathname (char *string)
 {
@@ -184,12 +389,11 @@
     return (string);
 }
 
-/*
- * Turn STRING (a pathname) into an absolute pathname, assuming that
- * DOT_PATH contains the symbolic location of '.'.  This always
- * returns a new string, even if STRING was an absolute pathname to
- * begin with.
- */
+// Turn STRING (a pathname) into an absolute pathname, assuming that
+// DOT_PATH contains the symbolic location of '.'.  This always
+// returns a new string, even if STRING was an absolute pathname to
+// begin with.
+
 char *
 make_absolute (const char *string, const char *dot_path)
 {
@@ -248,15 +452,14 @@
   return strsave (current_path);
 }
 
-/*
- * Has file `A' been modified after time `T'?
- *
- * case:
- *
- *   a newer than t         returns    1
- *   a older than t         returns    0
- *   stat on a fails        returns   -1
- */
+// Has file `A' been modified after time `T'?
+//
+// case:
+//
+//   a newer than t         returns    1
+//   a older than t         returns    0
+//   stat on a fails        returns   -1
+
 int
 is_newer (const char *fa, time_t t)
 {
@@ -274,10 +477,9 @@
   return (fa_sb.st_mtime > t);
 }
 
-/*
- * Return a consed string which is the current working directory.
- * FOR_WHOM is the name of the caller for error printing.
- */ 
+// Return a consed string which is the current working directory.
+// FOR_WHOM is the name of the caller for error printing.
+
 char *
 get_working_directory (const char *for_whom)
 {
@@ -307,10 +509,9 @@
   return the_current_working_directory;
 }
 
-/*
- * Do the work of changing to the directory NEWDIR.  Handle symbolic
- * link following, etc.
- */ 
+// Do the work of changing to the directory NEWDIR.  Handle symbolic
+// link following, etc.
+
 static int
 change_to_directory (const char *newdir)
 {
@@ -326,7 +527,7 @@
       else
 	t = strsave (newdir);
 
-      /* Get rid of trailing `/'. */
+// Get rid of trailing `/'.
       {
 	register int len_t = strlen (t);
 	if (len_t > 1)
@@ -413,9 +614,8 @@
 
 DEFALIAS (chdir, cd);
 
-/*
- * Get a directory listing.
- */
+// Get a directory listing.
+
 DEFUN_TEXT ("ls", Fls, Sls, -1, 1,
   "ls [options]\n\
 \n\
--- a/src/input.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/input.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -21,6 +21,16 @@
 
 */
 
+/*
+
+The 3 functions listed below were adapted from similar functions
+from GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991
+Free Software Foundation, Inc.
+
+  read_octal    sub_append_string    decode_prompt_string
+
+*/
+
 // Use the GNU readline library for command line editing and hisory.
 
 #ifdef HAVE_CONFIG_H
--- a/src/lex.l	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/lex.l	Tue Aug 30 04:46:17 1994 +0000
@@ -540,18 +540,18 @@
 		}
 
 \"		{ BEGIN DQSTRING; }
-".**"		{ BIN_OP_RETURN (EPOW, 0); }
 ".*"		{ BIN_OP_RETURN (EMUL, 0); }
 "./"		{ BIN_OP_RETURN (EDIV, 0); }
 ".\\"		{ BIN_OP_RETURN (ELEFTDIV, 0); }
+".**"		|
 ".^"		{ BIN_OP_RETURN (EPOW, 0); }
 ".'"		{ do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, 1); }
 "++"		{ do_comma_insert_check (); BIN_OP_RETURN (PLUS_PLUS, 1); }
 "--"		{ do_comma_insert_check (); BIN_OP_RETURN (MINUS_MINUS, 1); }
 "<="		{ BIN_OP_RETURN (EXPR_LE, 0); }
 "=="		{ BIN_OP_RETURN (EXPR_EQ, 0); }
-"~="		{ BIN_OP_RETURN (EXPR_NE, 0); }
-"!="		{ BIN_OP_RETURN (EXPR_NE, 0); }
+"~="		|
+"!="		|
 "<>"		{ BIN_OP_RETURN (EXPR_NE, 0); }
 ">="		{ BIN_OP_RETURN (EXPR_GE, 0); }
 "||"		{
@@ -570,11 +570,7 @@
 		}
 "|"		{ BIN_OP_RETURN (EXPR_OR, 0); }
 "&"		{ BIN_OP_RETURN (EXPR_AND, 0); }
-"!"		{
-		  if (plotting && ! in_plot_range)
-		    past_plot_range = 1;
-		  BIN_OP_RETURN (EXPR_NOT, 1);
-		}
+"!"		|
 "~"		{
 		  if (plotting && ! in_plot_range)
 		    past_plot_range = 1;
@@ -582,22 +578,24 @@
 		}
 "<"		{ BIN_OP_RETURN (EXPR_LT, 0); }
 ">"		{ BIN_OP_RETURN (EXPR_GT, 0); }
-"+"		{ 
+"+"		|
+".+"		{ 
 		  if (plotting && ! in_plot_range)
 		    past_plot_range = 1;
 		  BIN_OP_RETURN ('+', 0);
 		}
-"-"		{
+"-"		|
+".-"		{ 
 		  if (plotting && ! in_plot_range)
 		    past_plot_range = 1;
 		  BIN_OP_RETURN ('-', 0);
 		}
-"**"		{ BIN_OP_RETURN (POW, 0); }
 "*"		{ BIN_OP_RETURN ('*', 0); }
 "/"		{ BIN_OP_RETURN ('/', 0); }
 "\\"		{ BIN_OP_RETURN (LEFTDIV, 0); }
 ";"		{ BIN_OP_RETURN (';', 1); }
 ","		{ BIN_OP_RETURN (',', 1); }
+"**"		|
 "^"		{ BIN_OP_RETURN (POW, 0); }
 "="		{ BIN_OP_RETURN ('=', 1); }
 "("		{
--- a/src/pt-plot.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/pt-plot.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -131,11 +131,19 @@
 	return -1;
     }
 
-  if (plot_line_count == 0 && strncmp (cmd, "replot", 6) == 0)
+  int is_replot = (strncmp (cmd, "replot", 6) == 0);
+  int is_splot = (strncmp (cmd, "splot", 5) == 0);
+  int is_plot = (strncmp (cmd, "plot", 4) == 0);
+
+  if (plot_line_count == 0 && is_replot)
     error ("replot: no previous plot");
   else
     {
       plot_stream << cmd;
+      if (! (is_replot || is_splot || is_plot)
+	  && plot_line_count > 0
+	  && user_pref.automatic_replot)
+	plot_stream << "replot\n";
       plot_stream.flush ();
       pipe_handler_error_count = 0;
     }
--- a/src/sysdep.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/sysdep.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -21,6 +21,14 @@
 
 */
 
+/*
+
+The function gethostname was adapted from a similar function from GNU
+Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
+Software Foundation, Inc.
+
+*/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
--- a/src/user-prefs.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/user-prefs.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -37,14 +37,14 @@
 // need to check a preference.
 user_preferences user_pref;
 
-/*
- * Check the value of a string variable to see if it it\'s ok to do
- * something.
- *
- *   return of -1 => ok, but give me warning (default).
- *   return of  0 => always ok.
- *   return of  1 => never ok.
- */
+
+// Check the value of a string variable to see if it it's ok to do
+// something.
+//
+//   return of -1 => ok, but give me warning (default).
+//   return of  0 => always ok.
+//   return of  1 => never ok.
+
 static int
 check_str_pref (char *var)
 {
@@ -63,41 +63,52 @@
   return pref;
 }
 
-/*
- * Should commas be required to separate elements in a literal matrix
- * list?
- *
- *   user specifies   value of pref
- *   --------------   -------------
- *   "required"             2
- *   "traditional"          1
- *   anything else          0
- *
- * Octave will never insert a comma in a literal matrix list if the
- * user specifies "required".  For example, the statement [1 2] will
- * result in an error instead of being treated the same as [1, 2].
- *
- * Traditional behavior makes Octave convert spaces to a comma between
- * identifiers and `('.  For example, the statement
- *
- *   [eye (2)]
- *
- * will be parsed as
- *
- *   [eye, (2)]
- *
- * and will result in an error since the `eye' function will be
- * called with no arguments.  To get around this, you would have to
- * omit the space between `eye' and the `('.
- *
- * The default value is 0, which results in behavior that is the same
- * as traditional, except that Octave does not convert spaces to a
- * comma between identifiers and `('.  For example, the statement
- *
- *   [eye (2)]
- *
- * will result in a call to `eye' with the argument `2'. 
- */
+// Should a replot command be generated automatically each time a plot
+// changes in some way?
+
+int
+automatic_replot (void)
+{
+  user_pref.automatic_replot = check_str_pref ("automatic_replot");
+
+  return 0;
+}
+
+
+// Should commas be required to separate elements in a literal matrix
+// list?
+//
+//   user specifies   value of pref
+//   --------------   -------------
+//   "required"             2
+//   "traditional"          1
+//   anything else          0
+//
+// Octave will never insert a comma in a literal matrix list if the
+// user specifies "required".  For example, the statement [1 2] will
+// result in an error instead of being treated the same as [1, 2].
+//
+// Traditional behavior makes Octave convert spaces to a comma between
+// identifiers and `('.  For example, the statement
+//
+//   [eye (2)]
+//
+// will be parsed as
+//
+//   [eye, (2)]
+//
+// and will result in an error since the `eye' function will be
+// called with no arguments.  To get around this, you would have to
+// omit the space between `eye' and the `('.
+//
+// The default value is 0, which results in behavior that is the same
+// as traditional, except that Octave does not convert spaces to a
+// comma between identifiers and `('.  For example, the statement
+//
+//   [eye (2)]
+//
+// will result in a call to `eye' with the argument `2'. 
+
 int
 commas_in_literal_matrix (void)
 {
@@ -114,13 +125,13 @@
   return 0;
 }
 
-/*
- * Should we allow assignments like:
- *
- *   octave> A(1) = 3; A(2) = 5
- *
- * for A already defined and a matrix type?
- */
+
+// Should we allow assignments like:
+//
+//   octave> A(1) = 3; A(2) = 5
+//
+// for A already defined and a matrix type?
+
 int
 do_fortran_indexing (void)
 {
@@ -130,10 +141,10 @@
   return 0;
 }
 
-/*
- * Should ignore empty elements in a matrix list (i.e., is an
- *  expression like `[[], 1]' ok?
- */
+
+// Should ignore empty elements in a matrix list (i.e., is an
+//  expression like `[[], 1]' ok?
+
 int
 empty_list_elements_ok (void)
 {
@@ -143,10 +154,10 @@
   return 0;
 }
 
-/*
- * Should Octave always check to see if function files have changed
- * since they were last compiled?
- */
+
+// Should Octave always check to see if function files have changed
+// since they were last compiled?
+
 int
 ignore_function_time_stamp (void)
 {
@@ -167,14 +178,14 @@
   return 0;
 }
 
-/*
- * Should we allow things like:
- *
- *   octave> 'abc' + 0
- *   97 98 99
- *
- * to happen?
- */
+
+// Should we allow things like:
+//
+//   octave> 'abc' + 0
+//   97 98 99
+//
+// to happen?
+
 int
 implicit_str_to_num_ok (void)
 {
@@ -184,10 +195,10 @@
   return 0;
 }
 
-/*
- * Should we allow silent conversion of complex to real when a real
- * type is what we\'re really looking for?
- */
+
+// Should we allow silent conversion of complex to real when a real
+// type is what we\'re really looking for?
+
 int
 ok_to_lose_imaginary_part (void)
 {
@@ -197,10 +208,10 @@
   return 0;
 }
 
-/*
- * If possible, send all output intended for the screen through the
- * pager. 
- */
+
+// If possible, send all output intended for the screen through the
+// pager. 
+
 int
 page_screen_output (void)
 {
@@ -209,14 +220,14 @@
   return 0;
 }
 
-/*
- * When doing assignments like:
- *
- *   octave> A(1) = 3; A(2) = 5
- *
- * (for A undefined) should we build column vectors?  Returning true
- * only matters when resize_on_range_error is also true.
- */
+
+// When doing assignments like:
+//
+//   octave> A(1) = 3; A(2) = 5
+//
+// (for A undefined) should we build column vectors?  Returning true
+// only matters when resize_on_range_error is also true.
+
 int
 prefer_column_vectors (void)
 {
@@ -226,13 +237,13 @@
   return 0;
 }
 
-/*
- * For things like
- *
- *   a = [2,3]; a([1,1])
- *
- * return [2 3] instead of [2 2].
- */
+
+// For things like
+//
+//   a = [2,3]; a([1,1])
+//
+// return [2 3] instead of [2 2].
+
 int
 prefer_zero_one_indexing (void)
 {
@@ -242,15 +253,15 @@
   return 0;
 }
 
-/*
- * Should we print things like
- *
- *   octave> a = [1,2;3,4]
- *   a = 
- *
- *      1  2
- *      3  4
- */
+
+// Should we print things like
+//
+//   octave> a = [1,2;3,4]
+//   a = 
+//
+//      1  2
+//      3  4
+
 int
 print_answer_id_name (void)
 {
@@ -260,9 +271,9 @@
   return 0;
 }
 
-/*
- * Should we also print the dimensions of empty matrices?
- */
+
+// Should we also print the dimensions of empty matrices?
+
 int
 print_empty_dimensions (void)
 {
@@ -272,10 +283,10 @@
   return 0;
 }
 
-/*
- * Should operations on empty matrices return empty matrices or an
- * error?
- */
+
+// Should operations on empty matrices return empty matrices or an
+// error?
+
 int
 propagate_empty_matrices (void)
 {
@@ -285,10 +296,10 @@
   return 0;
 }
 
-/*
- * When doing assignments, should we resize matrices if the indices
- * are outside the current bounds?
- */
+
+// When doing assignments, should we resize matrices if the indices
+// are outside the current bounds?
+
 int
 resize_on_range_error (void)
 {
@@ -298,10 +309,10 @@
   return 0;
 }
 
-/*
- * If a function does not return any values explicitly, return the
- * last computed value.
- */
+
+// If a function does not return any values explicitly, return the
+// last computed value.
+
 int
 return_last_computed_value (void)
 {
@@ -311,9 +322,9 @@
   return 0;
 }
 
-/*
- * Suppress printing results in called functions.
- */
+
+// Suppress printing results in called functions.
+
 int
 silent_functions (void)
 {
@@ -323,9 +334,9 @@
   return 0;
 }
 
-/*
- * Should should big matrices be split into smaller slices for output?
- */
+
+// Should should big matrices be split into smaller slices for output?
+
 int
 split_long_rows (void)
 {
@@ -334,13 +345,13 @@
   return 0;
 }
 
-/*
- * Should things like:
- *
- *   octave> ones (-1, 5)
- *
- * result in an empty matrix or an error?
- */
+
+// Should things like:
+//
+//   octave> ones (-1, 5)
+//
+// result in an empty matrix or an error?
+
 int
 treat_neg_dim_as_zero (void)
 {
@@ -350,15 +361,15 @@
   return 0;
 }
 
-/*
- * Generate a warning for the assignment in things like
- *
- *   octave> if (a = 2 < n)
- *
- * but not
- *
- *   octave> if ((a = 2) < n)
- */
+
+// Generate a warning for the assignment in things like
+//
+//   octave> if (a = 2 < n)
+//
+// but not
+//
+//   octave> if ((a = 2) < n)
+
 int
 warn_assign_as_truth_value (void)
 {
@@ -368,11 +379,11 @@
   return 0;
 }
 
-/*
- * Generate a warning for the comma in things like
- *
- *   octave> global a, b = 2
- */
+
+// Generate a warning for the comma in things like
+//
+//   octave> global a, b = 2
+
 int
 warn_comma_in_global_decl (void)
 {
@@ -382,9 +393,9 @@
   return 0;
 }
 
-/*
- * On IEEE machines, allow divide by zero errors to be suppressed.
- */
+
+// On IEEE machines, allow divide by zero errors to be suppressed.
+
 int
 warn_divide_by_zero (void)
 {
--- a/src/user-prefs.h	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/user-prefs.h	Tue Aug 30 04:46:17 1994 +0000
@@ -26,6 +26,7 @@
 
 struct user_preferences
 {
+  int automatic_replot;
   int commas_in_literal_matrix;
   int do_fortran_indexing;
   int empty_list_elements_ok;
@@ -63,6 +64,7 @@
 
 extern user_preferences user_pref;
 
+extern int automatic_replot (void);
 extern int commas_in_literal_matrix (void);
 extern int do_fortran_indexing (void);
 extern int empty_list_elements_ok (void);
--- a/src/utils.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/utils.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -21,27 +21,6 @@
 
 */
 
-/*
-
-The 12 functions listed below were adapted from a similar functions
-from GNU Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991
-Free Software Foundation, Inc.
-
-  polite_directory_format  absolute_pathname
-  absolute_program         base_pathname
-  read_octal               sub_append_string
-  decode_prompt_string     pathname_backup
-  make_absolute            get_working_directory
-  change_to_directory      gethostname
-
-The 2 functions listed below were adapted from a similar functions
-from GCC, the GNU C compiler, copyright (C) 1987, 1989, 1992, 1993,
-1994 Free Software Foundation, Inc.
-
-  choose_temp_base_try     octave_tmp_file_name
-
-*/
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -205,78 +184,15 @@
 }
 #endif
 
-// Compute a string to use as the base of all temporary file names.
-
-static char *
-choose_temp_base_try (char *try_me, char *base)
-{
-  char *retval;
-
-  if (base)
-    retval = base;
-  else if (! try_me)
-    retval = 0;
-  else if (access (try_me, R_OK | W_OK) != 0)
-    retval = 0;
-  else
-    retval = try_me;
-
-  return retval;
-}
-
-// Get a temporary file name.  The prefix comes from the envvar
-// TMPDIR, or TMP, or TEMP if defined; otherwise, from the P_tmpdir
-// macro if that is defined; otherwise, it is /usr/tmp or /tmp, or ./.
-//
-// If nothing works, panic.
+// Get a temporary file name.
 
 char *
 octave_tmp_file_name (void)
 {
-#if defined (HAVE_MKTEMP)
-  static char *temp_file_name = 0;
-
-  char *base = 0;
-  int len;
-
-  base = choose_temp_base_try (getenv ("TMPDIR"), base);
-  base = choose_temp_base_try (getenv ("TMP"), base);
-  base = choose_temp_base_try (getenv ("TEMP"), base);
-
-#ifdef P_tmpdir
-  base = choose_temp_base_try (P_tmpdir, base);
-#endif
-
-  base = choose_temp_base_try ("/usr/tmp", base);
-  base = choose_temp_base_try ("/tmp", base);
-
-// If all else fails, use the current directory!
-
-  if (base == (char *)0)
-    base = "./";
-
-  len = strlen (base);
-
-  delete [] temp_file_name;
-
-  temp_file_name = new char [len + sizeof("/oct-XXXXXX") + 1];
-
-  strcpy (temp_file_name, base);
-
-  if (len > 0 && temp_file_name[len-1] != '/')
-    temp_file_name[len++] = '/';
-
-  strcpy (temp_file_name + len, "oct-XXXXXX");
-
-  mktemp (temp_file_name);
-
-  if (! strlen (temp_file_name))
-    panic ("unable to find directory for temporary files!");
-
-  return temp_file_name;
-#else
-  return tmpnam (0);
-#endif
+  char *retval = tempnam (0, "oct-");
+  if (! retval)
+    error ("can't open temporary file!");
+  return retval;
 }
 
 char **
--- a/src/utils.h	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/utils.h	Tue Aug 30 04:46:17 1994 +0000
@@ -49,6 +49,8 @@
 extern char *fcn_file_in_path (const char *);
 extern char *oct_file_in_path (const char *);
 
+extern char *octave_tmp_file_name (void);
+
 extern char **pathstring_to_vector (char *pathstring);
 
 extern void jump_to_top_level (void);
--- a/src/variables.cc	Mon Aug 29 23:32:17 1994 +0000
+++ b/src/variables.cc	Tue Aug 30 04:46:17 1994 +0000
@@ -1333,6 +1333,10 @@
   DEFVAR ("ans", SBV_ans, , 0, 0, 1, 0,
     "");
 
+  DEFVAR ("automatic_replot", SBV_automatic_replot, "false",
+	  0, 0, 1, automatic_replot,
+    "if true, auto-insert a replot command when a plot changes");
+
   DEFVAR ("commas_in_literal_matrix", SBV_commas_in_literal_matrix, "",
 	  0, 0, 1, commas_in_literal_matrix,
     "control auto-insertion of commas in literal matrices");