projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5f90c3d
)
dictionary: Limit split file variables to 8, for compatibility.
author
Ben Pfaff
<blp@cs.stanford.edu>
Sat, 6 Aug 2022 19:31:40 +0000
(12:31 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 28 Aug 2022 21:22:19 +0000
(14:22 -0700)
src/data/dictionary.c
patch
|
blob
|
history
src/data/dictionary.h
patch
|
blob
|
history
src/language/dictionary/split-file.c
patch
|
blob
|
history
tests/language/dictionary/split-file.at
patch
|
blob
|
history
diff --git
a/src/data/dictionary.c
b/src/data/dictionary.c
index 66cb956f1dc6d1dfa6284fe5bcc9d601e110d2b3..a2e3fb8fc1ee2a6e42d6d287eb6bd3047cee9277 100644
(file)
--- a/
src/data/dictionary.c
+++ b/
src/data/dictionary.c
@@
-384,12
+384,15
@@
dict_unset_split_var (struct dictionary *d, struct variable *v, bool skip_callba
}
}
-/* Sets N split vars SPLIT in dictionary D. */
+/* Sets N split vars SPLIT in dictionary D. N is silently capped to a maximum
+ of MAX_SPLITS. */
static void
dict_set_split_vars__ (struct dictionary *d,
struct variable *const *split, size_t n,
enum split_type type, bool skip_callbacks)
{
static void
dict_set_split_vars__ (struct dictionary *d,
struct variable *const *split, size_t n,
enum split_type type, bool skip_callbacks)
{
+ if (n > MAX_SPLITS)
+ n = MAX_SPLITS;
assert (n == 0 || split != NULL);
d->n_splits = n;
assert (n == 0 || split != NULL);
d->n_splits = n;
diff --git
a/src/data/dictionary.h
b/src/data/dictionary.h
index e9e203add068f1971cbd745fbd35f0c7ac1a8a8c..3e874d87071349bad38e253aaeb65b9b7a81f966 100644
(file)
--- a/
src/data/dictionary.h
+++ b/
src/data/dictionary.h
@@
-134,6
+134,7
@@
enum split_type
SPLIT_SEPARATE, /* Produce separate output for each split. */
SPLIT_LAYERED, /* Output splits in same table. */
};
SPLIT_SEPARATE, /* Produce separate output for each split. */
SPLIT_LAYERED, /* Output splits in same table. */
};
+#define MAX_SPLITS 8
const struct variable *const *dict_get_split_vars (const struct dictionary *);
size_t dict_get_n_splits (const struct dictionary *);
enum split_type dict_get_split_type (const struct dictionary *);
const struct variable *const *dict_get_split_vars (const struct dictionary *);
size_t dict_get_n_splits (const struct dictionary *);
enum split_type dict_get_split_type (const struct dictionary *);
diff --git
a/src/language/dictionary/split-file.c
b/src/language/dictionary/split-file.c
index 8b4c8783371a8d165a1243c2896a9618f542f557..8a134e1e769eca5562e57e31febb49b9c29b03d0 100644
(file)
--- a/
src/language/dictionary/split-file.c
+++ b/
src/language/dictionary/split-file.c
@@
-58,6
+58,14
@@
cmd_split_file (struct lexer *lexer, struct dataset *ds)
if (!parse_variables (lexer, dataset_dict (ds), &v, &n, PV_NO_DUPLICATE))
return CMD_CASCADING_FAILURE;
if (!parse_variables (lexer, dataset_dict (ds), &v, &n, PV_NO_DUPLICATE))
return CMD_CASCADING_FAILURE;
+ if (n > MAX_SPLITS)
+ {
+ verify (MAX_SPLITS == 8);
+ msg (SE, _("At most 8 split variables may be specified."));
+ free (v);
+ return CMD_CASCADING_FAILURE;
+ }
+
dict_set_split_vars (dataset_dict (ds), v, n, type);
free (v);
}
dict_set_split_vars (dataset_dict (ds), v, n, type);
free (v);
}
diff --git
a/tests/language/dictionary/split-file.at
b/tests/language/dictionary/split-file.at
index 674bd6ff05eb339ac2032f1b52fa60d6aeb52735..aec4b7449f02fb350d1d8c288d8eb0b833607ef7 100644
(file)
--- a/
tests/language/dictionary/split-file.at
+++ b/
tests/language/dictionary/split-file.at
@@
-70,10
+70,6
@@
X,Y
])
AT_CLEANUP
])
AT_CLEANUP
-
-
-
-
AT_SETUP([SPLIT FILE - vs procedures])
AT_DATA([split-file.sps], [dnl
AT_SETUP([SPLIT FILE - vs procedures])
AT_DATA([split-file.sps], [dnl
@@
-136,3
+132,14
@@
finish.
AT_CHECK([pspp -O format=csv split-file.sps], [0],[ignore])
AT_CLEANUP
AT_CHECK([pspp -O format=csv split-file.sps], [0],[ignore])
AT_CLEANUP
+
+AT_SETUP([SPLIT FILE - split variable limit])
+AT_DATA([split-file.sps], [dnl
+DATA LIST LIST NOTABLE /V1 TO V9.
+SPLIT FILE BY V1 TO V9.
+])
+AT_CHECK([pspp split-file.sps], [1], [dnl
+split-file.sps:2: error: SPLIT FILE: At most 8 split variables may be
+specified.
+])
+AT_CLEANUP