Ben Pfaff [Sat, 1 Jan 2022 19:01:00 +0000 (11:01 -0800)]
FREQUENCIES: Fix percentiles and median calculation for multiple variables.
The calculations here were using the same space each time for
calculating percentiles and median, but different areas are needed. This
commit fixes the problem.
Bug #60728.
Thanks to elias tsolis for reporting the problem.
Ben Pfaff [Fri, 31 Dec 2021 19:06:48 +0000 (11:06 -0800)]
Replace more uses of 'cnt' by 'n'.
This continues the work begun in commit 339f1956cc72 ("treewide: Replace
<name>_cnt by n_<name>s and <name>_cap by allocated_<name>.") by replacing
more uses of 'cnt' by 'n', which I think is a better choice these days.
Ben Pfaff [Thu, 30 Dec 2021 21:58:12 +0000 (13:58 -0800)]
Change how checking for missing values works.
It's more flexible to have the functions that check for missing values
return what kind of missing value was found (or 0 if none), than to have
to pass in the kind of missing values to check for.
Ben Pfaff [Sun, 19 Dec 2021 23:41:50 +0000 (15:41 -0800)]
expressions: Major work to improve error messages.
This makes the error messages related to expressions much better, by being
more precise about the location of the problem. It also fixes a number of
documentation and compatibility issues encountered along the way, as well
as redoing the testsuite for expressions to make it easier to understand
and to work on.
Ben Pfaff [Sat, 25 Dec 2021 22:12:39 +0000 (14:12 -0800)]
expressions: Fix built sources.
The dependencies were incomplete for the built sources, which meant that
build errors often came up if one built particular targets, e.g. for
"make src/ui/terminal/pspp". This fixes the problem.
Ben Pfaff [Thu, 16 Dec 2021 04:20:48 +0000 (20:20 -0800)]
MATRIX: Update EVAL test to avoid failure on i386.
The i386 buildbot produced different precision for the eigenvalues
(integers rather than almost-integers), which isn't a significant
difference. This commit should avoid the problem.
Ben Pfaff [Fri, 10 Dec 2021 06:23:59 +0000 (22:23 -0800)]
Clean up how transformations work.
Transformations had a messy system that included "finalizers" that needed
to be called before a chain could be executed and the need to keep track
of relative offsets for control flow. This commit reworks and simplifies
the whole thing.
Also adds some INPUT PROGRAM, LOOP, and DO IF tests.
Ben Pfaff [Thu, 9 Dec 2021 23:03:45 +0000 (15:03 -0800)]
treewide: Replace <name>_cnt by n_<name>s and <name>_cap by allocated_<name>.
I used to think that _cnt was a good suffix for a count representing the
number of items in an array, but I haven't used that convention in a long
time and it looks wrong now. This changes these to an n_ prefix instead.
Similarly, but in far fewer cases, replace <name>_cap for the allocated
capacity of an array by allocated_<name>.
This doesn't change the name of ref_cnt members used as reference counts.
Those are pure counts, not the length of anything.
This doesn't change the Perl library because that's an external API.
Ben Pfaff [Tue, 23 Nov 2021 03:16:48 +0000 (19:16 -0800)]
lexer: Allow for negative lookahead within a command.
This allows to getting the location of prior tokens within a command,
which makes it easier to find the end of a group of tokens that was just
parsed by referring to the token at offset -1.
Ben Pfaff [Mon, 22 Nov 2021 19:45:48 +0000 (11:45 -0800)]
lexer: Keep entire source file in memory.
Previously, the lexer tried to keep only part of each source file in
memory, the part that wasn't fully parsed yet. With this commit, the
lexer holds the entire file in memory, even parts that are no longer
needed. This should make it easier to produce better error messages.
Ben Pfaff [Mon, 6 Dec 2021 05:18:22 +0000 (21:18 -0800)]
distributions: New module for probability distribution functions.
These functions are currently just used in expressions, but in an upcoming
commit they will also be used in matrices, so this commit makes them more
widely available.
Ben Pfaff [Mon, 6 Dec 2021 17:02:30 +0000 (09:02 -0800)]
lexer: Be consistent across 32/64 bit in lex_force_int_range().
The exact error message that this function reported varied between 32-
and 64-bit platforms for invalid integers that require more than 32 bits
but no more than 64 bits, since "long int" has a different range between
those platforms. This commit fixes the problem.
This issue caused the test "testing lexer crash due to overflow" to fail
on 32-bit platforms.
Thanks to Friedrich Beckmann for reporting the problem.
Ben Pfaff [Wed, 6 Oct 2021 05:15:28 +0000 (22:15 -0700)]
expressions: Parse multiple sets of parentheses for grouping together.
Fuzzers are fond of driving expression parsers to failure by exhausting
the stack in trivial ways. This defeats the simplest attempts by
lining up thousands of left parentheses in a row.
I am a bit curious whether the fuzzer will now invent something more
sophisticated, such as nested function calls or non-empty expressions like
1+(1+(1+(1+(1+....
This fixes bug #61286.
Thanks to Irfan Ariq for reporting the bug.
Ben Pfaff [Tue, 5 Oct 2021 16:19:26 +0000 (09:19 -0700)]
dictionary: Allow dict_set_documents() argument to reference old documents.
merge_dictionary() in combine-file.c includes the old documents in the new
ones by just copying pointers. dict_set_documents() didn't handle this
properly. This fixes the problem.
Fixes bug #61258.
Thanks to Irfan Ariq for reporting the problem.
Ben Pfaff [Sun, 26 Sep 2021 18:06:45 +0000 (11:06 -0700)]
lexer: Fix use-after-free error in lex_source_get_lookahead().
This code used local variable 'out' as if its value stayed the same from
one iteration of the loop to the next, but in fact its scope meant that
it became indeterminate on each new iteration. This commit fixes the
problem by moving its declaration to an outer scope.
Thanks to John Darrington for reporting the problem.
Ben Pfaff [Wed, 1 Sep 2021 17:02:26 +0000 (10:02 -0700)]
macro: Fix crash for !QUOTE of a quoted string.
This revealed that the tests didn't include anything for !QUOTE and
!UNQUOTE, even though the manual had lots of examples. I added a test for
these and for !NULL, which had also been forgotten.
Ben Pfaff [Thu, 26 Aug 2021 16:32:31 +0000 (09:32 -0700)]
DEFINE: Only expand macro functions when the name is followed by '('.
Frans Houweling reported that PSPP was flagging an error for !EVAL(!len)
when !len was the name of a defined macro. This was because !len is short
for the !LENGTH macro function. This commit fixes the problem.