changeset 643:cf16ec9a2428

[project @ 1994-08-24 04:38:14 by jwe]
author jwe
date Wed, 24 Aug 1994 04:41:03 +0000
parents 95c7e27b2df7
children 3a7c78b38ca3
files src/Makefile.in src/utils.cc
diffstat 2 files changed, 88 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.in	Wed Aug 24 02:27:30 1994 +0000
+++ b/src/Makefile.in	Wed Aug 24 04:41:03 1994 +0000
@@ -37,7 +37,7 @@
 	@echo making $@ from $<
 	@$(CXXCPP) -c $(CPPFLAGS) $(XALL_CXXFLAGS) -DMAKE_BUILTINS $< \
 	  | $(srcdir)/mkdefs > $@.tmp
-	@if test "`wc $@.tmp | awk '{print $3}'`" -ne 0 ; then \
+	@if test `wc $@.tmp | sed 's%[^0-9]*\([0-9]*\).*%\1%'` -ne 0 ; then \
 	  mv $@.tmp $@ ; \
 	else \
 	  echo "error: $@ is empty!" 1>&2 ; \
@@ -157,7 +157,7 @@
 	etags $(SOURCES)
 
 clean:
-	rm -f *.a *.o *.def builtins.cc
+	rm -f *.a *.o builtins.cc
 .PHONY: clean
 
 mostlyclean:
@@ -165,24 +165,24 @@
 .PHONY: mostlyclean
 
 distclean: clean
-	rm -f Makefile octave .fname *.d
+	rm -f Makefile octave .fname *.d *.def
 .PHONY: distclean
 
 realclean: distclean
 	rm -f tags TAGS y.tab.c y.tab.h y.output yy.lex.c \
-	lex.cc parse.cc defaults.h *.d
+	lex.cc parse.cc defaults.h *.d *.def
 .PHONY: realclean
 
 local-dist: parse.cc lex.cc
 	ln $(DISTFILES) ../`cat ../.fname`/src
-	rm -f parse.cc lex.cc y.tab.h y.output yy.lex.c \
-	lex.cc parse.cc defaults.h
+	rm -f parse.cc lex.cc y.tab.h y.output yy.lex.c
+	rm -f lex.cc parse.cc defaults.h *.d *.def
 .PHONY: local-dist
 
 dist: parse.cc lex.cc
 	ln $(DISTFILES) ../`cat ../.fname`/src
-	rm -f parse.cc lex.cc y.tab.h y.output yy.lex.c \
-	lex.cc parse.cc defaults.h
+	rm -f parse.cc lex.cc y.tab.h y.output yy.lex.c
+	rm -f lex.cc parse.cc defaults.h *.d *.def
 .PHONY: dist
 
 # Special rules -- these files need special things to be defined.
--- a/src/utils.cc	Wed Aug 24 02:27:30 1994 +0000
+++ b/src/utils.cc	Wed Aug 24 04:41:03 1994 +0000
@@ -34,6 +34,12 @@
   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
@@ -199,6 +205,80 @@
 }
 #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.
+
+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 **
 pathstring_to_vector (char *pathstring)
 {