diff src/parse.y @ 3162:7c96e85c76db

[project @ 1998-04-08 18:19:35 by jwe]
author jwe
date Wed, 08 Apr 1998 18:21:04 +0000
parents a494f93e60ff
children e4bbfc196e53
line wrap: on
line diff
--- a/src/parse.y
+++ b/src/parse.y
@@ -82,6 +82,9 @@
 // the name of the file in which it is defined.
 static bool Vwarn_function_name_clash;
 
+// TRUE means warn about function files that have time stamps in the future.
+bool Vwarn_future_time_stamp;
+
 // If TRUE, generate warning if a statement in a function is not
 // terminated with a semicolon.  Useful for checking functions that
 // should only produce output using explicit printing statements.
@@ -2201,10 +2204,22 @@
 	  id_name = id->name ();
 	}
 
+      time_t now = time (0);
+
       fcn->stash_function_name (id_name);
       fcn->stash_fcn_file_name ();
-      fcn->stash_fcn_file_time (time (0));
+      fcn->stash_fcn_file_time (now);
       fcn->mark_as_system_fcn_file ();
+
+      if (Vwarn_future_time_stamp)
+	{
+	  string nm = fcn->fcn_file_name ();
+
+	  file_stat fs (nm);
+
+	  if (fs && fs.is_newer (now))
+	    warning ("time stamp for `%s' is in the future", nm.c_str ());
+	}
     }
   else if (! (input_from_tmp_history_file || input_from_startup_file)
 	   && reading_script_file
@@ -3128,6 +3143,14 @@
 }
 
 static int
+warn_future_time_stamp (void)
+{
+  Vwarn_future_time_stamp = check_preference ("warn_future_time_stamp");
+
+  return 0;
+}
+
+static int
 warn_missing_semicolon (void)
 {
   Vwarn_missing_semicolon = check_preference ("warn_missing_semicolon");
@@ -3157,6 +3180,9 @@
   DEFVAR (warn_function_name_clash, 1.0, 0, warn_function_name_clash,
     "produce warning if function name conflicts with file name");
 
+  DEFVAR (warn_future_time_stamp, 1.0, 0, warn_future_time_stamp,
+    "warn if a function file has a time stamp that is in the future");
+
   DEFVAR (warn_missing_semicolon, 0.0, 0, warn_missing_semicolon,
     "produce a warning if a statement in a function file is not\n\
 terminated with a semicolon");