Continue reforming procedure execution. In this phase, get rid of
[pspp-builds.git] / src / data / dictionary.c
index ad5b50671fa6f2a9d138d064adb3ac2c40944ed8..e9a5a01450363bbdc8055abf7a760731de12facf 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
+
 #include "dictionary.h"
+
 #include <stdlib.h>
 #include <ctype.h>
-#include <libpspp/array.h>
-#include <libpspp/alloc.h>
+
 #include "case.h"
-#include "category.h"
 #include "cat-routines.h"
+#include "category.h"
+#include "settings.h"
+#include "value-labels.h"
+#include "variable.h"
+#include <libpspp/alloc.h>
+#include <libpspp/array.h>
 #include <libpspp/compiler.h>
-#include <libpspp/message.h>
 #include <libpspp/hash.h>
+#include <libpspp/message.h>
 #include <libpspp/misc.h>
-#include "settings.h"
 #include <libpspp/str.h>
-#include "value-labels.h"
-#include "variable.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -49,16 +52,13 @@ struct dictionary
     size_t split_cnt;           /* SPLIT FILE count. */
     struct variable *weight;    /* WEIGHT variable. */
     struct variable *filter;    /* FILTER variable. */
-    int case_limit;             /* Current case limit (N command). */
+    size_t case_limit;          /* Current case limit (N command). */
     char *label;               /* File label. */
     char *documents;           /* Documents, as a string. */
     struct vector **vector;     /* Vectors of variables. */
     size_t vector_cnt;          /* Number of vectors. */
   };
 
-/* Active file dictionary. */
-struct dictionary *default_dict;
-
 /* Creates and returns a new dictionary. */
 struct dictionary *
 dict_create (void) 
@@ -267,7 +267,7 @@ dict_create_var (struct dictionary *d, const char *name, int width)
   assert (d != NULL);
   assert (name != NULL);
 
-  assert (width >= 0 && width < 256);
+  assert (width >= 0 && width <= MAX_STRING);
 
   assert (var_is_plausible_name(name,0));
     
@@ -281,7 +281,7 @@ dict_create_var (struct dictionary *d, const char *name, int width)
   v->type = width == 0 ? NUMERIC : ALPHA;
   v->width = width;
   v->fv = d->next_value_idx;
-  v->nv = width == 0 ? 1 : DIV_RND_UP (width, 8);
+  v->nv = width_to_bytes(width) / MAX_SHORT_STRING ;
   v->leave = dict_class_from_id (v->name) == DC_SCRATCH;
   v->index = d->var_cnt;
   mv_init (&v->miss, width);
@@ -748,8 +748,8 @@ dict_set_filter (struct dictionary *d, struct variable *v)
 }
 
 /* Returns the case limit for dictionary D, or zero if the number
-   of cases is unlimited (see cmd_n()). */
-int
+   of cases is unlimited. */
+size_t
 dict_get_case_limit (const struct dictionary *d) 
 {
   assert (d != NULL);
@@ -757,13 +757,12 @@ dict_get_case_limit (const struct dictionary *d)
   return d->case_limit;
 }
 
-/* Sets CASE_LIMIT as the case limit for dictionary D.  Zero for
-   CASE_LIMIT indicates no limit. */
+/* Sets CASE_LIMIT as the case limit for dictionary D.  Use
+   0 for CASE_LIMIT to indicate no limit. */
 void
-dict_set_case_limit (struct dictionary *d, int case_limit) 
+dict_set_case_limit (struct dictionary *d, size_t case_limit) 
 {
   assert (d != NULL);
-  assert (case_limit >= 0);
 
   d->case_limit = case_limit;
 }