Fixed some issues with internationalisation
[pspp-builds.git] / src / glob.c
index f9d443b5cfdf37c37f9708f856f1ae3a8d256ec0..958edc5f221f34ab36e3a8b7a64a7b2f5e985db6 100644 (file)
    02111-1307, USA. */
 
 #include <config.h>
-
+#include "glob.h"
 #include <assert.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #if TIME_WITH_SYS_TIME
 #include <sys/time.h>
@@ -77,15 +78,17 @@ extern void stifle_history ();
 #endif
 
 #include "alloc.h"
-#include "avl.h"
 #include "command.h"
 #include "do-ifP.h"
 #include "error.h"
 #include "expr.h"
+#include "file-handle.h"
 #include "filename.h"
 #include "getline.h"
+#include "hash.h"
 #include "julcal/julcal.h"
 #include "lexer.h"
+#include "magic.h"
 #include "main.h"
 #include "settings.h"
 #include "str.h"
@@ -94,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;
@@ -122,8 +125,8 @@ int logging;
 
 static void get_date (void);
 
-#if HAVE_LIBTERMCAP && !__CHECKER__
-static char *term_buffer;
+#if HAVE_LIBTERMCAP
+static char term_buffer[16384];
 #endif
 
 void
@@ -163,56 +166,8 @@ init_glob (int argc unused, char **argv)
   _control87 (0xffff, 0x137f);
 #endif
 
-#if ENDIAN==UNKNOWN
-  {
-    /* Test for endianness borrowed from acspecific.m4, which was in
-     turn borrowed from Harbison&Steele. */
-    union
-      {
-       long l;
-       char c[sizeof (long)];
-      }
-    u;
-
-    u.l = 1;
-    if (u.c[sizeof u.l - 1] == 1)
-      endian = BIG;
-    else if (u.c[0] == 1)
-      endian = LITTLE;
-    else
-      msg (FE, _("Your machine does not appear to be either big- or little-"
-                "endian.  At the moment, PSPP only supports machines of "
-                "these standard endiannesses.  If you want to hack in "
-                "others, contact the author."));
-  }
-#endif
-
-  /* PORTME: Set the value for second_lowest_value, which is the
-     "second lowest" possible value for a double.  This is the value
-     for LOWEST on MISSING VALUES, etc. */
-#ifndef SECOND_LOWEST_VALUE
-#if FPREP == FPREP_IEEE754
-  {
-    union
-      {
-       unsigned char c[8];
-       double d;
-      }
-    second_lowest_little = {{0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff}},
-    second_lowest_big = {{0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}};
-
-    if (endian == LITTLE)
-      second_lowest_value = second_lowest_little.d;
-    else if (endian == BIG)
-      second_lowest_value = second_lowest_big.d;
-  }
-#else /* FPREP != FPREP_IEEE754 */
-#error Unknown floating-point representation.
-#endif /* FPREP != FPREP_IEEE754 */
-#endif /* !SECOND_LOWEST_VALUE */
-
   /* var.h */
-  default_dict.var_by_name = avl_create (NULL, cmp_variable, NULL);
+  default_dict = dict_create ();
 
   vec_init (&reinit_sysmis);
   vec_init (&reinit_blanks);
@@ -319,20 +274,11 @@ init_glob (int argc unused, char **argv)
     int success;
 
     /* This code stolen from termcap.info, though modified. */
-#if !__CHECKER__
-    term_buffer = xmalloc (2048);
-#endif
-
     termtype = getenv ("TERM");
     if (!termtype)
       msg (FE, _("Specify a terminal type with `setenv TERM <yourtype>'."));
 
-#if __CHECKER__
-    success = tgetent (NULL, termtype);
-#else
     success = tgetent (term_buffer, termtype);
-#endif
-
     if (success <= 0)
       {
        if (success < 0)
@@ -360,60 +306,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);
-}
-
-int
-cmp_variable (const void *a, const void *b, void *foo unused)
-{
-  return strcmp (((struct variable *) a)->name, ((struct variable *) b)->name);
+  strftime (curdate, 12, "%d %b %Y",tmp);
 }
 
 #if __BORLANDC__