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.
Ben Pfaff [Sun, 18 Jul 2021 21:21:24 +0000 (14:21 -0700)]
lexer: Change the pipeline to allow more flexible use of macros.
Frans Houweling reported that a use of macros in the following way:
DEFINE !dir() "/directory/to/my/work" !ENDDEFINE.
GET FILE=!dir + "/filename.sav".
did not work properly with the newly implemented PSPP macro facility.
Indeed, PSPP has until now implemented string concatenation early in the
lexical pipeline, before macro expansion, so that the above could
not work. This commit reworks it so that string concatenation happens
as the last stage in lexical analysis. It allows the above syntax
to work as expected.
Ben Pfaff [Mon, 5 Jul 2021 20:46:32 +0000 (13:46 -0700)]
configure: Enable GCC warnings to report use of C2x features.
One C2x feature in GCC 11 is the reason that the previous commit afda22462a88 ("Fix broken build due to missing braces") was needed by
some developers.
Ben Pfaff [Sun, 4 Jul 2021 05:00:47 +0000 (22:00 -0700)]
segment: Distinguish snippets from full files.
The comment on segmenter_init() explains what this means:
If IS_SNIPPET is false, then the segmenter will parse as if it's being
given a whole file. This means, for example, that it will interpret -
or + at the beginning of the syntax as a separator between commands
(since - or + at the beginning of a line has this meaning).
If IS_SNIPPET is true, then the segmenter will parse as if it's being
given an isolated piece of syntax. This means that, for example, that
it will interpret - or + at the beginning of the syntax as an operator
token or (if followed by a digit) as part of a number.
Ben Pfaff [Sun, 30 May 2021 20:31:39 +0000 (13:31 -0700)]
segment: Refine treatment of start of macro body.
Previously, if the first line of the macro body (the same line as the
closing parenthesis in the DEFINE) was blank, we reported it as a blank
line to the lexer. The parser for DEFINE could check for that (by seeing
whether the first line of macro body was empty or all-spaces) but it seems
more elegant to do it in the segmenter. This implements that.
Ben Pfaff [Sun, 30 May 2021 20:00:24 +0000 (13:00 -0700)]
segment: The body of DEFINE does not have to be on separate lines.
Some examples of one-line DEFINE can be seen at:
https://www.spsstools.net/en/macros/macros-index/utilities/quote-string-on-the-fly/
such as:
DEFINE !client() ABC Inc !ENDDEFINE.
Ben Pfaff [Sat, 1 May 2021 23:39:15 +0000 (16:39 -0700)]
psppire-output-view: Avoid doubling output when exporting or printing.
Outputting a group outputs its contents, but the code here was also
separately outputing the contents, which effectively doubled it. (PSPP
doesn't currently use nested groups but these would have led to additional
copies.)
This fixes the problem by only printing items that aren't nested inside
any group.
Bug #60464.
Thanks to John Darrington for reporting this bug.
Ben Pfaff [Sat, 1 May 2021 22:53:09 +0000 (15:53 -0700)]
format-parser: Fix inconsistent use of "char *" vs "char[NUMBER]".
These are equivalent according to the C standard in function prototypes,
but GCC 11 warns about using them inconsistently between a prototype and
a definition. This commit avoids the warning.
John Darrington [Sun, 18 Apr 2021 11:08:41 +0000 (13:08 +0200)]
Added rules to build nsis installers for w32
* Windows/AdvUninstLog.nsh: New file.
* Windows/MUI_EXTRAPAGES.nsh: New file.
* Windows/automake.mk: New file.
* Windows/pspp.nsi: New file.
* Makefile.am: include Windows/automake.mk.
* configure.ac: Add conditional for sizeof ptr.
Ben Pfaff [Tue, 13 Apr 2021 16:58:46 +0000 (09:58 -0700)]
segment: Improve segmentation when DEFINE command has early terminator.
The DEFINE command should not have a command terminator before the final
!ENDDEFINE. When it does, that ends the whole thing early. The segmenter
didn't handle this well, instead treating everything up to !ENDDEFINE as
part of the command. That's probably not the best way because it makes
for confusing error messages. This improves the behavior.