Beginning of VFM cleanup.
[pspp-builds.git] / src / glob.c
index d879546c68d966f6fe811deb978506116385d9cb..5bf5600f25189eb2be5d7c5b9c5e62e4ad06d02b 100644 (file)
@@ -18,7 +18,7 @@
    02111-1307, USA. */
 
 #include <config.h>
-
+#include "glob.h"
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -62,7 +62,7 @@ extern void stifle_history ();
 
 #if __DJGPP__
 #include <conio.h>
-#elif __WIN32__ && __BORLANDC__
+#elif defined (__WIN32__) && defined (__BORLANDC__)
 #undef gettext
 #include <conio.h>
 #define gettext(STRING)                                \
@@ -82,6 +82,7 @@ extern void stifle_history ();
 #include "do-ifP.h"
 #include "error.h"
 #include "expr.h"
+#include "file-handle.h"
 #include "filename.h"
 #include "getline.h"
 #include "hash.h"
@@ -96,7 +97,7 @@ extern void stifle_history ();
 #include "vfm.h"
 
 /* var.h */
-struct dictionary default_dict;
+struct dictionary *default_dict;
 struct expression *process_if_expr;
 
 struct ccase *temp_case;
@@ -110,9 +111,6 @@ int FILTER_before_TEMPORARY;
 
 struct file_handle *default_handle;
 
-void (*read_active_file) (void);
-void (*cancel_input_pgm) (void);
-
 struct ctl_stmt *ctl_stack;
 
 /* log.h */
@@ -129,11 +127,11 @@ static char term_buffer[16384];
 #endif
 
 void
-init_glob (int argc unused, char **argv)
+init_glob (int argc UNUSED, char **argv)
 {
   /* FIXME: Allow i18n of other locale items (besides LC_MESSAGES). */
 #if ENABLE_NLS
-#if LC_MESSAGE
+#if HAVE_LC_MESSAGES
   setlocale (LC_MESSAGES, "");
 #endif
   setlocale (LC_MONETARY, "");
@@ -166,13 +164,7 @@ init_glob (int argc unused, char **argv)
 #endif
 
   /* var.h */
-  default_dict.name_tab = hsh_create (8, compare_variables, hash_variable,
-                                      NULL, NULL);
-
-  vec_init (&reinit_sysmis);
-  vec_init (&reinit_blanks);
-  vec_init (&init_zero);
-  vec_init (&init_blanks);
+  default_dict = dict_create ();
 
   last_vfm_invocation = time (NULL);
 
@@ -258,7 +250,7 @@ init_glob (int argc unused, char **argv)
   set_nullline = 1;
   set_more = 1;
   set_prompt = xstrdup ("PSPP> ");
-  set_seed = 2000000;
+  set_seed = NOT_LONG;
 
 #if __DJGPP__ || __BORLANDC__
   {
@@ -306,54 +298,26 @@ init_glob (int argc unused, char **argv)
   logfile = NULL;
 
   /* file-handle.h */
-  {
-    extern void fh_init_files (void);
-    
-    fh_init_files ();
-  }
+  fh_init_files ();
   
   get_date ();
 }
 
 static void
-get_date ()
+get_date (void)
 {
-  static const char *months[12] =
-    {
-      N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
-      N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
-    };
 
   time_t t;
-  int mn, dy, yr;
   struct tm *tmp;
 
   if ((time_t) -1 == time (&t))
     {
-      strcpy (curdate, "1 Jan 1970");
+      strcpy (curdate, "?? ??? 2???");
       return;
     }
   tmp = localtime (&t);
 
-  mn = tmp->tm_mon;
-  if (mn < 0)
-    mn = 0;
-  if (mn > 11)
-    mn = 11;
-
-  dy = tmp->tm_mday;
-  if (dy < 0)
-    dy = 0;
-  if (dy > 99)
-    dy = 99;
-
-  yr = tmp->tm_year + 1900;
-  if (yr < 0)
-    yr = 0;
-  if (yr > 9999)
-    yr = 9999;
-
-  sprintf (curdate, "%2d %s %04d", dy, gettext (months[mn]), yr);
+  strftime (curdate, 12, "%d %b %Y",tmp);
 }
 
 #if __BORLANDC__