We've had a mix of min, max from libpspp/misc.h and MIN, MAX from
[pspp-builds.git] / src / language / dictionary / sys-file-info.c
index 5425e68827bfd53ee9f49076096fff4858512b93..44278060d391d5161b58f06da64018fc932c6ccb 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
    Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
@@ -43,6 +43,8 @@
 #include <output/output.h>
 #include <output/table.h>
 
+#include "minmax.h"
+
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
@@ -70,7 +72,7 @@ sysfile_info_dim (struct tab_table *t, struct outp_driver *d)
   int i;
 
   for (p = max; *p; p++)
-    t->w[p - max] = min (tab_natural_width (t, d, p - max),
+    t->w[p - max] = MIN (tab_natural_width (t, d, p - max),
                         *p * d->prop_em_width);
   for (i = 0; i < t->nr; i++)
     t->h[i] = tab_natural_height (t, d, i);
@@ -78,7 +80,7 @@ sysfile_info_dim (struct tab_table *t, struct outp_driver *d)
 
 /* SYSFILE INFO utility. */
 int
-cmd_sysfile_info (struct dataset *ds UNUSED)
+cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED)
 {
   struct file_handle *h;
   struct dictionary *d;
@@ -88,10 +90,10 @@ cmd_sysfile_info (struct dataset *ds UNUSED)
   int r, nr;
   int i;
 
-  lex_match_id ("FILE");
-  lex_match ('=');
+  lex_match_id (lexer, "FILE");
+  lex_match (lexer, '=');
 
-  h = fh_parse (FH_REF_FILE);
+  h = fh_parse (lexer, FH_REF_FILE);
   if (!h)
     return CMD_FAILURE;
 
@@ -152,7 +154,7 @@ cmd_sysfile_info (struct dataset *ds UNUSED)
       
       if (r + 10 + nvl > nr)
        {
-         nr = max (nr * dict_get_var_cnt (d) / (i + 1), nr);
+         nr = MAX (nr * dict_get_var_cnt (d) / (i + 1), nr);
          nr += 10 + nvl;
          tab_realloc (t, 4, nr);
        }
@@ -170,7 +172,7 @@ cmd_sysfile_info (struct dataset *ds UNUSED)
 
   dict_destroy (d);
   
-  return lex_end_of_command ();
+  return lex_end_of_command (lexer);
 }
 \f
 /* DISPLAY utility. */
@@ -181,7 +183,7 @@ static void display_variables (struct variable **, size_t, int);
 static void display_vectors (const struct dictionary *dict, int sorted);
 
 int
-cmd_display (struct dataset *ds)
+cmd_display (struct lexer *lexer, struct dataset *ds)
 {
   /* Whether to sort the list of variables alphabetically. */
   int sorted;
@@ -190,14 +192,14 @@ cmd_display (struct dataset *ds)
   size_t n;
   struct variable **vl;
 
-  if (lex_match_id ("MACROS"))
+  if (lex_match_id (lexer, "MACROS"))
     display_macros ();
-  else if (lex_match_id ("DOCUMENTS"))
+  else if (lex_match_id (lexer, "DOCUMENTS"))
     display_documents (dataset_dict (ds));
-  else if (lex_match_id ("FILE"))
+  else if (lex_match_id (lexer, "FILE"))
     {
       som_blank_line ();
-      if (!lex_force_match_id ("LABEL"))
+      if (!lex_force_match_id (lexer, "LABEL"))
        return CMD_FAILURE;
       if (dict_get_label (dataset_dict (ds)) == NULL)
        tab_output_text (TAB_LEFT,
@@ -216,12 +218,12 @@ cmd_display (struct dataset *ds)
       const char **cp;
       int as;
 
-      sorted = lex_match_id ("SORTED");
+      sorted = lex_match_id (lexer, "SORTED");
 
       for (cp = sbc; *cp; cp++)
-       if (token == T_ID && lex_id_match (*cp, tokid))
+       if (lex_token (lexer) == T_ID && lex_id_match (*cp, lex_tokid (lexer)))
          {
-           lex_get ();
+           lex_get (lexer);
            break;
          }
       as = cp - sbc;
@@ -235,13 +237,13 @@ cmd_display (struct dataset *ds)
          return CMD_SUCCESS;
        }
 
-      lex_match ('/');
-      lex_match_id ("VARIABLES");
-      lex_match ('=');
+      lex_match (lexer, '/');
+      lex_match_id (lexer, "VARIABLES");
+      lex_match (lexer, '=');
 
-      if (token != '.')
+      if (lex_token (lexer) != '.')
        {
-         if (!parse_variables (dataset_dict (ds), &vl, &n, PV_NONE))
+         if (!parse_variables (lexer, dataset_dict (ds), &vl, &n, PV_NONE))
            {
              free (vl);
              return CMD_FAILURE;
@@ -278,7 +280,7 @@ cmd_display (struct dataset *ds)
       free (vl);
     }
 
-  return lex_end_of_command ();
+  return lex_end_of_command (lexer);
 }
 
 static void
@@ -334,8 +336,8 @@ variables_dim (struct tab_table *t, struct outp_driver *d)
   t->w[0] = tab_natural_width (t, d, 0);
   if (_as == AS_DICTIONARY || _as == AS_VARIABLES || _as == AS_LABELS)
     {
-      t->w[1] = max (tab_natural_width (t, d, 1), d->prop_em_width * 5);
-      t->w[2] = max (tab_natural_width (t, d, 2), d->prop_em_width * 35);
+      t->w[1] = MAX (tab_natural_width (t, d, 1), d->prop_em_width * 5);
+      t->w[2] = MAX (tab_natural_width (t, d, 2), d->prop_em_width * 35);
       pc = 3;
     }
   else pc = 1;
@@ -399,7 +401,7 @@ display_variables (struct variable **vl, size_t n, int as)
       
          if (r + 10 + nvl > nr)
            {
-             nr = max (nr * n / (i + 1), nr);
+             nr = MAX (nr * n / (i + 1), nr);
              nr += 10 + nvl;
              tab_realloc (t, nc, nr);
            }
@@ -454,17 +456,19 @@ describe_variable (struct variable *v, struct tab_table *t, int r, int as)
       && v->print.w == v->write.w
       && v->print.d == v->write.d)
     {
+      char str[FMT_STRING_LEN_MAX + 1];
       tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF, _("Format: %s"),
-                     fmt_to_string (&v->print));
+                     fmt_to_string (&v->print, str));
       r++;
     }
   else
     {
+      char str[FMT_STRING_LEN_MAX + 1];
       tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF,
-                     _("Print Format: %s"), fmt_to_string (&v->print));
+                     _("Print Format: %s"), fmt_to_string (&v->print, str));
       r++;
       tab_joint_text (t, 1, r, 2, r, TAB_LEFT | TAT_PRINTF,
-                     _("Write Format: %s"), fmt_to_string (&v->write));
+                     _("Write Format: %s"), fmt_to_string (&v->write, str));
       r++;
     }