Rename procedure.[ch] to dataset.[ch].
[pspp-builds.git] / src / language / dictionary / sys-file-info.c
index 24130cbc30abfa4830aff59ff96f7023cd2284d1..8db1b68150fa81c6ae984e9fce9680a5672e898c 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <ctype.h>
 #include <stdlib.h>
 
-#include <data/attributes.h>
-#include <data/casereader.h>
-#include <data/dictionary.h>
-#include <data/file-handle-def.h>
-#include <data/format.h>
-#include <data/missing-values.h>
-#include <data/procedure.h>
-#include <data/sys-file-reader.h>
-#include <data/value-labels.h>
-#include <data/variable.h>
-#include <data/vector.h>
-#include <language/command.h>
-#include <language/data-io/file-handle.h>
-#include <language/lexer/lexer.h>
-#include <language/lexer/variable-parser.h>
-#include <libpspp/array.h>
-#include <libpspp/message.h>
-#include <libpspp/message.h>
-#include <libpspp/misc.h>
-#include <output/tab.h>
-
-#include "minmax.h"
-#include "xalloc.h"
+#include "data/attributes.h"
+#include "data/casereader.h"
+#include "data/dataset.h"
+#include "data/dictionary.h"
+#include "data/file-handle-def.h"
+#include "data/format.h"
+#include "data/missing-values.h"
+#include "data/sys-file-reader.h"
+#include "data/value-labels.h"
+#include "data/variable.h"
+#include "data/vector.h"
+#include "language/command.h"
+#include "language/data-io/file-handle.h"
+#include "language/lexer/lexer.h"
+#include "language/lexer/variable-parser.h"
+#include "libpspp/array.h"
+#include "libpspp/message.h"
+#include "libpspp/misc.h"
+#include "libpspp/string-array.h"
+#include "output/tab.h"
+
+#include "gl/minmax.h"
+#include "gl/xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -75,7 +75,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED)
   int r, i;
 
   lex_match_id (lexer, "FILE");
-  lex_match (lexer, '=');
+  lex_match (lexer, T_EQUALS);
 
   h = fh_parse (lexer, FH_REF_FILE);
   if (!h)
@@ -164,7 +164,7 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED)
   dict_destroy (d);
 
   fh_unref (h);
-  return lex_end_of_command (lexer);
+  return CMD_SUCCESS;
 }
 \f
 /* DISPLAY utility. */
@@ -211,7 +211,7 @@ cmd_display (struct lexer *lexer, struct dataset *ds)
       if (lex_match_id (lexer, "VECTORS"))
        {
          display_vectors (dataset_dict(ds), sorted);
-         return lex_end_of_command (lexer);
+         return CMD_SUCCESS;
        }
       else if (lex_match_id (lexer, "SCRATCH")) 
         {
@@ -247,11 +247,11 @@ cmd_display (struct lexer *lexer, struct dataset *ds)
                 break;
               }
 
-          lex_match (lexer, '/');
+          lex_match (lexer, T_SLASH);
           lex_match_id (lexer, "VARIABLES");
-          lex_match (lexer, '=');
+          lex_match (lexer, T_EQUALS);
 
-          if (lex_token (lexer) != '.')
+          if (lex_token (lexer) != T_ENDCMD)
             {
               if (!parse_variables_const (lexer, dataset_dict (ds), &vl, &n,
                                           PV_NONE))
@@ -281,7 +281,7 @@ cmd_display (struct lexer *lexer, struct dataset *ds)
                                       flags);
     }
 
-  return lex_end_of_command (lexer);
+  return CMD_SUCCESS;
 }
 
 static void
@@ -293,24 +293,19 @@ display_macros (void)
 static void
 display_documents (const struct dictionary *dict)
 {
-  const char *documents = dict_get_documents (dict);
+  const struct string_array *documents = dict_get_documents (dict);
 
-  if (documents == NULL)
+  if (string_array_is_empty (documents))
     tab_output_text (TAB_LEFT, _("The active file dictionary does not "
                                  "contain any documents."));
   else
     {
-      struct string line = DS_EMPTY_INITIALIZER;
       size_t i;
 
       tab_output_text (TAB_LEFT | TAT_TITLE,
                       _("Documents in the active file:"));
       for (i = 0; i < dict_get_document_line_cnt (dict); i++)
-        {
-          dict_get_document_line (dict, i, &line);
-          tab_output_text (TAB_LEFT | TAB_FIX, ds_cstr (&line));
-        }
-      ds_destroy (&line);
+        tab_output_text (TAB_LEFT | TAB_FIX, dict_get_document_line (dict, i));
     }
 }