pspp
2 years agoFix possible divide by zero error
John Darrington [Sun, 4 Jun 2023 16:10:24 +0000 (18:10 +0200)]
Fix possible divide by zero error

2 years agoFix memory leak
John Darrington [Sun, 4 Jun 2023 15:30:15 +0000 (17:30 +0200)]
Fix memory leak

2 years agoFix minor English grammar errors, mostly "a" versus "an".
Ben Pfaff [Sun, 4 Jun 2023 14:57:24 +0000 (07:57 -0700)]
Fix minor English grammar errors, mostly "a" versus "an".

I spotted one of these and then found the rest via "grep".

2 years agolexer: New function for other kind of half-open range.
Ben Pfaff [Sun, 4 Jun 2023 14:52:11 +0000 (07:52 -0700)]
lexer: New function for other kind of half-open range.

The existing function lex_force_num_range_halfopen() handled ranges of the
form [low,high).  There is a new need for (low,high] ranges.  This commit
adds that new function and renames the existing one so that it's obvious
which kind it handles.

2 years agodictionary: Properly size string buffer in make_hinted_name().
Ben Pfaff [Sun, 4 Jun 2023 14:40:47 +0000 (07:40 -0700)]
dictionary: Properly size string buffer in make_hinted_name().

This causes a test failure on 32-bit platforms, where
INT_BUFSIZE_BOUND(unsigned long) is smaller than F26ADIC_STRLEN_MAX + 1.

Fixes: 2ba8dc2955f8 ("spreadsheet-reader: Merge duplicate code with libpspp/str.h.")
Thanks to Friedrich Beckmann for reporting the problem.

2 years agoMEANS: Allow string variables to be selected as the categorical variable.
John Darrington [Sat, 3 Jun 2023 20:01:12 +0000 (22:01 +0200)]
MEANS: Allow string variables to be selected as the categorical variable.

The gui did not allow string variables to be the subject of any MEANS command.
However it is entirely appropriate for them to be the independent (categorical)
variable.

2 years agospreadsheet-reader: Merge duplicate code with libpspp/str.h.
Ben Pfaff [Sat, 3 Jun 2023 17:02:28 +0000 (10:02 -0700)]
spreadsheet-reader: Merge duplicate code with libpspp/str.h.

The tree had two functions for 26-adic spreadsheet number formatting.  This
eliminates the duplication and moves the corresponding parsing function
into str.h as well.

2 years agotests: Fix PostgreSQL test.
Ben Pfaff [Wed, 31 May 2023 21:31:09 +0000 (14:31 -0700)]
tests: Fix PostgreSQL test.

2 years agoPortability/Regression: Check OS version to skip test first (1598)
Friedrich Beckmann [Tue, 30 May 2023 08:25:16 +0000 (10:25 +0200)]
Portability/Regression: Check OS version to skip test first (1598)

The test

1598: interactive output appears immediately

does not work on MacOS and the plan is to skip that test. I changed
the testcode to first test the OS and skip immediately instead of
first checking the python shell. Without that the test does not
stop on MacOS and runs forever.

2 years agoPortability: Variable initialization not at beginning of block
Friedrich Beckmann [Tue, 30 May 2023 08:21:08 +0000 (10:21 +0200)]
Portability: Variable initialization not at beginning of block

Recent changes in segment.c result in compilation errors on older
compilers like on debian buster or MacOS.

../pspp/src/language/lexer/segment.c:1255:7:
error: a label can only be part of a statement
and a declaration is not a statement
       int eol = at_end_of_line (input, n, eof, 1);

I changed the code such that it compiles on MacOS again to
a more traditional way to avoid the compile error.

2 years agoods-reader: Support more than a single piece of text in a cell.
Ben Pfaff [Tue, 30 May 2023 00:42:15 +0000 (17:42 -0700)]
ods-reader: Support more than a single piece of text in a cell.

This code read the first text content in the first <p> it found in a cell.
This meant that anything more sophisticated than just <p>text<p> broke,
including <p>text<span>some more</span></p>.  This commit fixes it.

The code here was really complicated and I didn't understand it.  I
simplified it a lot to use xmlTextReaderExpand(), which is a lot easier to
use than a state machine at the level we need it.  I also couldn't figure
out how to make the existing caching logic work quite right, so I replaced
it by something simpler which I think will be just fine.

This updates the test by adding some bold text to a cell.

Thanks to elias tsolis for reporting this bug.
Bug #63443.

2 years agospreadsheet-test: Fix usage message.
Ben Pfaff [Tue, 30 May 2023 00:37:52 +0000 (17:37 -0700)]
spreadsheet-test: Fix usage message.

2 years agoods-reader: Integrate xmlTextReaderRead() calls into process_node().
Ben Pfaff [Mon, 29 May 2023 23:36:20 +0000 (16:36 -0700)]
ods-reader: Integrate xmlTextReaderRead() calls into process_node().

This will allow using xmlTextReaderNext() instead of xmlTextReaderRead()
for some kinds of nodes.

2 years agotests: Add some keywords for ODS and gnumeric tests.
Ben Pfaff [Mon, 29 May 2023 23:33:17 +0000 (16:33 -0700)]
tests: Add some keywords for ODS and gnumeric tests.

2 years agogui: Update how the Run menu works in the syntax window.
Ben Pfaff [Mon, 29 May 2023 20:23:07 +0000 (13:23 -0700)]
gui: Update how the Run menu works in the syntax window.

Until now, the Run menu had both "Selection", which ran the current
selection, and "Current line", which ran the current line.  This commit
replaces that by a single menu item "Selection", which runs the current
command if there is no selection and all the selected or partially selected
commands if there is a selection.  This behavior matches SPSS.

Requested by Matthias Faeth.

2 years agocommand-segmenter: New library for dividing syntax into individual commands.
Ben Pfaff [Mon, 29 May 2023 20:09:09 +0000 (13:09 -0700)]
command-segmenter: New library for dividing syntax into individual commands.

This is a building block for allowing the GUI to run whole commands instead
of just lines.

2 years agodeque: Replace deque_init_null() by DEQUE_EMPTY_INITIALIZER.
Ben Pfaff [Mon, 29 May 2023 20:21:07 +0000 (13:21 -0700)]
deque: Replace deque_init_null() by DEQUE_EMPTY_INITIALIZER.

2 years agoidentifier: Fix typo in comment.
Ben Pfaff [Mon, 29 May 2023 20:06:41 +0000 (13:06 -0700)]
identifier: Fix typo in comment.

2 years agoCTABLES: Avoid causing nhtsa.sav to appear modified after running tests.
Ben Pfaff [Sun, 28 May 2023 16:31:00 +0000 (09:31 -0700)]
CTABLES: Avoid causing nhtsa.sav to appear modified after running tests.

Adding a hard link makes Git think that nhtsa.sav has been modified, before
it checks for real changes, which is sometimes annoying in the interface.
Using a symlink instead avoids the problem.

2 years agoCTABLES: Refine treatment for applying a summary to nested variables.
Ben Pfaff [Sun, 28 May 2023 16:27:33 +0000 (09:27 -0700)]
CTABLES: Refine treatment for applying a summary to nested variables.

In the previous commit, applying a summary to a nest operator caused an
error, which I assumed was the correct behvior.  This commit changes it
to apply the summary to the inner variable.

Thanks to Matthias Faeth for reporting the correct behavior.

2 years agoCTABLES: Don't crash for attempting to apply a summary to nested variables.
Ben Pfaff [Sun, 28 May 2023 06:18:31 +0000 (23:18 -0700)]
CTABLES: Don't crash for attempting to apply a summary to nested variables.

Thanks to Matthias Faeth for reporting this bug.

2 years agoCTABLES: Stop parsing after a summary spec error.
Ben Pfaff [Sun, 28 May 2023 06:17:32 +0000 (23:17 -0700)]
CTABLES: Stop parsing after a summary spec error.

2 years agogui: Support Ctrl+W to close windows and add File|Close to menus.
Ben Pfaff [Sun, 28 May 2023 03:18:07 +0000 (20:18 -0700)]
gui: Support Ctrl+W to close windows and add File|Close to menus.

Requested by Matthias Faeth.

2 years agohistogram: Improve coding style.
Ben Pfaff [Sun, 28 May 2023 02:52:01 +0000 (19:52 -0700)]
histogram: Improve coding style.

2 years agohistogram: Fix a couple of bugs.
Ben Pfaff [Sat, 27 May 2023 23:17:22 +0000 (16:17 -0700)]
histogram: Fix a couple of bugs.

The bug report wasn't specific enough to know that this fixes
the problem, which was an assertion failure for
  assert (*adjusted_min <= min);
in hist_find_pretty_no_of_bins().

Thanks to Stefan Huber for reporting these bugs.

2 years agoods-reader: Do basic validation of OpenDocument format on open.
Ben Pfaff [Sat, 27 May 2023 04:53:05 +0000 (21:53 -0700)]
ods-reader: Do basic validation of OpenDocument format on open.

Without this, ods-reader accepts any Zip file (including XLSX files) as
OpenDocument spreadsheets.

Thanks to Matthias Faeth for reporting the problem.

2 years agoods-reader: Don't return NULL from a boolean function.
Ben Pfaff [Sat, 27 May 2023 04:51:59 +0000 (21:51 -0700)]
ods-reader: Don't return NULL from a boolean function.

2 years agodoc: Fix typo in developer manual.
Ben Pfaff [Sat, 27 May 2023 04:20:47 +0000 (21:20 -0700)]
doc: Fix typo in developer manual.

2 years agotests: Skip pty-based test except on GNU/Linux.
Ben Pfaff [Thu, 18 May 2023 01:32:12 +0000 (18:32 -0700)]
tests: Skip pty-based test except on GNU/Linux.

It fails on Mac OS but there's no reason to believe the functionality is
really broken there.

Thanks to Friedrich Beckmann for reporting the failure.

2 years agoperl-module: Skip Pspp.t test if Test::More isn't installed.
Ben Pfaff [Tue, 16 May 2023 05:31:55 +0000 (22:31 -0700)]
perl-module: Skip Pspp.t test if Test::More isn't installed.

This was a requirement but it wasn't noticed until now.

Thanks to Marshall DeBerry for reporting this.

2 years agoT-TEST: Allow duplicate variable names in pairs list.
Ben Pfaff [Tue, 16 May 2023 02:06:56 +0000 (19:06 -0700)]
T-TEST: Allow duplicate variable names in pairs list.

"a a b WITH b c c (PAIRED)" makes sense and indicates pairs (a,b), (a,c),
and (b,c).

Thanks to the anonymous reporter.
Bug #64093.

2 years agotex: Ignore error output from tex.
Ben Pfaff [Tue, 16 May 2023 01:46:20 +0000 (18:46 -0700)]
tex: Ignore error output from tex.

tex writes non-error output to stderr sometimes, especially spew from
kpathsea about building formats and fonts.  This confused the tests.

Thanks to Marshall DeBerry for reporting the problem.

2 years agotests: Skip PSPP permissions test if permissions don't work as expected.
Ben Pfaff [Tue, 16 May 2023 01:36:53 +0000 (18:36 -0700)]
tests: Skip PSPP permissions test if permissions don't work as expected.

If permissions don't work from shell, then we can't expect them to work
from PSPP.

Thanks to Marshall DeBerry for reporting the problem.

2 years agogui: Ensure that libwidgets-essential uses our header fixes too.
Ben Pfaff [Mon, 15 May 2023 18:07:31 +0000 (11:07 -0700)]
gui: Ensure that libwidgets-essential uses our header fixes too.

This should fix compile and link errors with Glib before 2.76.

Thanks to Frans Houweling for reporting and debugging the problem with me.

2 years agocommand: Make command names available for translation.
Ben Pfaff [Mon, 15 May 2023 05:48:46 +0000 (22:48 -0700)]
command: Make command names available for translation.

PSPP command names should appear in translated form in labels in output,
but they didn't because their names weren't marked for translation.  This
fixes that problem.

The names still won't appear translated until translators add translations
for them.

Thanks to Ali Alhaidary for reporting the bug at
https://savannah.gnu.org/bugs/?62982

2 years agoImprove or fix some diagnostic messages.
Ben Pfaff [Mon, 15 May 2023 02:16:26 +0000 (19:16 -0700)]
Improve or fix some diagnostic messages.

Thanks to Jaap Verhage for reporting these bugs at
https://lists.gnu.org/archive/html/pspp-dev/2023-05/msg00004.html

2 years agoPERMISSIONS: Reword error messages to avoid "stat" jargon.
Ben Pfaff [Fri, 12 May 2023 05:28:31 +0000 (22:28 -0700)]
PERMISSIONS: Reword error messages to avoid "stat" jargon.

"Cannot stat" doesn't make sense to most people.

Reported by pspp.vertaler@gmail.com at
https://lists.gnu.org/archive/html/pspp-dev/2020-09/msg00058.html

2 years agoMATRIX DATA: Make N subcommand work properly without ROWTYPE_.
Ben Pfaff [Thu, 11 May 2023 02:29:56 +0000 (19:29 -0700)]
MATRIX DATA: Make N subcommand work properly without ROWTYPE_.

I found this bug myself while experimenting.

2 years agoAdd compatibility code for g_string_free_and_steal() in glib before 2.76.
Ben Pfaff [Thu, 11 May 2023 01:10:11 +0000 (18:10 -0700)]
Add compatibility code for g_string_free_and_steal() in glib before 2.76.

Thanks to Jeremy Lavergne for reporting this bug.
Bug #64178.

2 years agoMATRIX DATA: Allow slash before initial VARIABLES subcommand.
Ben Pfaff [Sun, 7 May 2023 15:05:17 +0000 (08:05 -0700)]
MATRIX DATA: Allow slash before initial VARIABLES subcommand.

2 years agopspp-output: Use page setup from command line by default.
Ben Pfaff [Sat, 6 May 2023 16:25:45 +0000 (09:25 -0700)]
pspp-output: Use page setup from command line by default.

pspp-output was ignoring the page setup specified on the command line in
favor of the one embedded in an SPV file.  This is usually wrong, and in
particular it screwed up the examples in the manual by causing them to be
broken across multiple PNG output files, only the first of which was
actually shown in the manual.

2 years agoRelease version 2.0.0-pre1.
Ben Pfaff [Sat, 6 May 2023 15:52:01 +0000 (08:52 -0700)]
Release version 2.0.0-pre1.

2 years agoMakefiles: Clean some more files created during the build.
Ben Pfaff [Sat, 6 May 2023 15:37:08 +0000 (08:37 -0700)]
Makefiles: Clean some more files created during the build.

2 years agocombine-files: Allow matching string variables to have different widths.
Ben Pfaff [Sat, 6 May 2023 01:01:06 +0000 (18:01 -0700)]
combine-files: Allow matching string variables to have different widths.

Requested by Frans Houweling and Alan Mead at
https://lists.gnu.org/archive/html/pspp-users/2015-03/msg00008.html

2 years agocombine-files: Remove write-only member 'var_sources'.
Ben Pfaff [Fri, 5 May 2023 14:49:08 +0000 (07:49 -0700)]
combine-files: Remove write-only member 'var_sources'.

2 years agogui: Fix warnings from g_string_free(..., FALSE).
Ben Pfaff [Thu, 4 May 2023 14:57:46 +0000 (07:57 -0700)]
gui: Fix warnings from g_string_free(..., FALSE).

This construct now causes a warning about an unused return value, so this
commit replaces it in each case with g_string_free_and_steal(), which also
leads to clearer code.

2 years agocombine-files: Adopt the encoding of the first input file.
Ben Pfaff [Sun, 30 Apr 2023 01:07:35 +0000 (18:07 -0700)]
combine-files: Adopt the encoding of the first input file.

Previously, there was no good way to control the output encoding, which was
simply the default encoding.  One could use SET LOCALE, but it seems more
reasonable to use the encoding from one of the input files, and the first
one is the most obvious choice.

Also, improve the warning about incompatible input encodings.

2 years agocombine-files: Only give an error for different types if they're kept.
Ben Pfaff [Sun, 30 Apr 2023 00:47:05 +0000 (17:47 -0700)]
combine-files: Only give an error for different types if they're kept.

Until now, ADD FILES, MATCH FILES, and UPDATE always gave an error if
variables in the input files had different types or widths and they weren't
renamed to avoid it.  This commit makes them only do that if the variables
in question aren't dropped.

2 years agocombine-files: Fix crash when no files are given.
Ben Pfaff [Sun, 30 Apr 2023 00:44:51 +0000 (17:44 -0700)]
combine-files: Fix crash when no files are given.

ADD FILES, MATCH FILES, and UPDATE would crash if no files were given.
This fixes the problem.

2 years agoCROSSTABS: Add significance of correlations in symmetric measures.
Ben Pfaff [Sat, 29 Apr 2023 23:04:19 +0000 (16:04 -0700)]
CROSSTABS: Add significance of correlations in symmetric measures.

Requested by Domingo J Rubira López at
https://lists.gnu.org/archive/html/pspp-users/2020-11/msg00000.html

2 years agoCROSSTABS: Make less bad data structures for symmetric stats and Somers D.
Ben Pfaff [Sat, 29 Apr 2023 22:07:28 +0000 (15:07 -0700)]
CROSSTABS: Make less bad data structures for symmetric stats and Somers D.

These still have nasty fixed index values in them that should be enums,
or named struct members.

2 years agoBe more careful about checking variable names.
Ben Pfaff [Sat, 29 Apr 2023 21:36:56 +0000 (14:36 -0700)]
Be more careful about checking variable names.

2 years agoMATRIX: Fix test failure on 32-bit platforms.
Ben Pfaff [Mon, 24 Apr 2023 16:04:09 +0000 (09:04 -0700)]
MATRIX: Fix test failure on 32-bit platforms.

Thanks to Friedrich Beckmann for reporting the problem.
Fixes: 505a04fe4cf5 ("Fix checks for valid integer range subset of 'double'.")
2 years agoSAVE TRANSLATE: Make first '/' optional in syntax.
Ben Pfaff [Sun, 23 Apr 2023 17:24:49 +0000 (10:24 -0700)]
SAVE TRANSLATE: Make first '/' optional in syntax.

This matches SPSS behavior.

Thanks to Matthias Faeth for reporting this bug.

2 years agoFix checks for valid integer range subset of 'double'.
Ben Pfaff [Sun, 23 Apr 2023 01:05:44 +0000 (18:05 -0700)]
Fix checks for valid integer range subset of 'double'.

Previously, I assumed that checking that a 'double' was between LONG_MIN
and LONG_MAX meant that it would convert to a sensible 'long'.  This is
wrong, because LONG_MAX rounds up to a higher 'double', because it has too
many bits for a 53-bit mantissa.  This could cause problems, like for
example LONG_MAX (as a double) turns out to convert back to LONG_MIN (as a
'long').  This commit fixes the problem.

Thanks to Youngseok Choi for reporting the problem.
Reported at https://lists.gnu.org/archive/html/bug-gnu-pspp/2023-04/msg00005.html.

2 years agoVECTOR: Check that multiple vectors don't create the same variable name.
Ben Pfaff [Sat, 22 Apr 2023 21:51:49 +0000 (14:51 -0700)]
VECTOR: Check that multiple vectors don't create the same variable name.

This is possible but I hadn't realized it before.

Thanks to Youngseok Choi for reporting this bug.
Reported at https://lists.gnu.org/archive/html/bug-gnu-pspp/2023-04/msg00004.html.

2 years agotreewide: Fix memory leaks from calls to relocate().
Ben Pfaff [Thu, 20 Apr 2023 02:54:12 +0000 (19:54 -0700)]
treewide: Fix memory leaks from calls to relocate().

These were all avoidable, and I got tired of seeing message from Address
Sanitizer about them.

2 years agoDATA LIST: Fix crash inside LOOP.
Ben Pfaff [Tue, 18 Apr 2023 15:45:48 +0000 (08:45 -0700)]
DATA LIST: Fix crash inside LOOP.

DATA LIST should be allowed inside LOOP if the LOOP is inside INPUT
PROGRAM, and disallowed otherwise.  The latter behavior was not correct
before this commit.

Reported-by: Youngseok Choi <youngseok.main@gmail.com>
Reported-at: https://lists.gnu.org/archive/html/bug-gnu-pspp/2023-04/msg00002.html.

2 years agoCTABLES: Fix treatment of string variables that differ past the first byte.
Ben Pfaff [Mon, 17 Apr 2023 23:08:56 +0000 (16:08 -0700)]
CTABLES: Fix treatment of string variables that differ past the first byte.

CTABLES display was treating string values with more than one byte as the
same if they had the same first byte, because var_get_type() was confused
with var_get_width().  (The former returns 0 for numeric and 1 for string
and the latter returns 0 for numeric and string width for string.)

Bug #64044.

2 years agoMATRIX: Check format specifier on PRINT command.
Ben Pfaff [Sat, 18 Mar 2023 21:41:40 +0000 (14:41 -0700)]
MATRIX: Check format specifier on PRINT command.

Thanks to Youngseok Choi for reporting the bug.

2 years agolexer: Avoid reentering the lexer upon error in special cases.
Ben Pfaff [Sat, 18 Mar 2023 21:09:38 +0000 (14:09 -0700)]
lexer: Avoid reentering the lexer upon error in special cases.

Thanks to Youngseok Choi for reporting the bug.

2 years agolexer: Simplify lex_get_error().
Ben Pfaff [Sat, 18 Mar 2023 21:25:08 +0000 (14:25 -0700)]
lexer: Simplify lex_get_error().

2 years agolexer: Get rid of useless code in lex_get_error().
Ben Pfaff [Sat, 18 Mar 2023 20:55:40 +0000 (13:55 -0700)]
lexer: Get rid of useless code in lex_get_error().

This function ellipsized the syntax and then didn't do anything with the
result.

2 years agodata-out: Make binary output buffer big enough for a null terminator.
Ben Pfaff [Sat, 18 Mar 2023 19:34:39 +0000 (12:34 -0700)]
data-out: Make binary output buffer big enough for a null terminator.

The max width for binary output is 16, for P or PK format, plus there
needs to be room for a null terminator, for a total width of 17 bytes.
The buffer here was undersized at only 16 bytes.  This commit fixes the
problem.

Thanks to Youngseok Choi for reporting the bug.

2 years agoMATRIX: Fix multiplication of empty matrices.
Ben Pfaff [Sat, 18 Mar 2023 19:22:42 +0000 (12:22 -0700)]
MATRIX: Fix multiplication of empty matrices.

This crashed due to an assertion failure in blas before.
Thanks to Youngseok Choi for reporting the bug.

2 years agodoc: Improve documentation for GET DATA/TYPE=PSQL.
Ben Pfaff [Sat, 18 Mar 2023 19:10:07 +0000 (12:10 -0700)]
doc: Improve documentation for GET DATA/TYPE=PSQL.

Reported by Kent Nassen.

2 years agoEnsure that interactive output appears without a one-command delay.
Ben Pfaff [Sat, 18 Mar 2023 18:43:16 +0000 (11:43 -0700)]
Ensure that interactive output appears without a one-command delay.

When pspp was run in the text-based mode interactively, output for a given
command only appeared after the next command was read.  This fixes the
problem and adds a test.

Thanks to the anonymous reporter.

Bug #63910.

2 years agoFix typo in manual.
Ben Pfaff [Wed, 8 Mar 2023 01:30:09 +0000 (17:30 -0800)]
Fix typo in manual.

Reported by knassen@chartermi.net.

2 years agoCLOSE FILE HANDLE: Fix bugs and add test.
Ben Pfaff [Tue, 7 Mar 2023 20:37:39 +0000 (12:37 -0800)]
CLOSE FILE HANDLE: Fix bugs and add test.

In addition to the particular bug that was reported, there was a memory
leak.  This commit fixes both.

Reported by knassen@chartermi.net.

2 years agoSHOW: Implement SHOW ENVIRONMENT.
Ben Pfaff [Tue, 7 Mar 2023 05:16:37 +0000 (21:16 -0800)]
SHOW: Implement SHOW ENVIRONMENT.

Requested by knassen@chartermi.net.

2 years agoDATA LIST: Fix crash with a bare / at the end of the command.
Ben Pfaff [Tue, 7 Mar 2023 01:00:13 +0000 (17:00 -0800)]
DATA LIST: Fix crash with a bare / at the end of the command.

Embarrassingly, this was in an example from the manual.

Reported by knassen@chartermi.net.

2 years agocase-map: Make creating a case_map destroy the stage.
Ben Pfaff [Sun, 5 Mar 2023 19:14:45 +0000 (11:14 -0800)]
case-map: Make creating a case_map destroy the stage.

This fit the usage model in every case in practice.

2 years agodataset: Replace 'compactor' by a translating casewriter.
Ben Pfaff [Sun, 5 Mar 2023 19:08:00 +0000 (11:08 -0800)]
dataset: Replace 'compactor' by a translating casewriter.

2 years agocase-map: Identity map is only when there are no changes at all.
Ben Pfaff [Sun, 5 Mar 2023 19:07:38 +0000 (11:07 -0800)]
case-map: Identity map is only when there are no changes at all.

case_map_stage_get_case_map() called a mapping an identity map when no
data was reordered, which left the possibility that data was removed from
the end would be called an identity map.  This seems like a bad idea, so
this commit tightens the criteria.

This is a bigger than necessary change that also avoids per-variable
malloc()s that weren't really needed.

This might be a bug fix.  I haven't identified a particular bug that
it fixes.

2 years agocase-map: Optimize case_map_create_output_translator() for no-op case.
Ben Pfaff [Sun, 5 Mar 2023 19:04:29 +0000 (11:04 -0800)]
case-map: Optimize case_map_create_output_translator() for no-op case.

2 years agodictionary: Get rid of case indexes.
Ben Pfaff [Sun, 5 Mar 2023 06:26:03 +0000 (22:26 -0800)]
dictionary: Get rid of case indexes.

Dictionary index (the index into the variables in the dictionary)
and case index (the index into struct ccase for a variable from
the dictionary) have always been independent, but they are
*usually* the same.  It is much cleaner to have an invariant
that they are *always* the same.  This commit makes that the case.

2 years agodictionary: Short-circuit no-op case in dict_reorder_var().
Ben Pfaff [Sun, 5 Mar 2023 17:23:53 +0000 (09:23 -0800)]
dictionary: Short-circuit no-op case in dict_reorder_var().

2 years agodictionary: Always compact immediately upon deletion of a variable.
Ben Pfaff [Sun, 5 Mar 2023 03:06:12 +0000 (19:06 -0800)]
dictionary: Always compact immediately upon deletion of a variable.

With this change, the dictionary has a new invariant that the case_indexes
are always a permutation of [0,N) where N is the number of variables in
the dictionary.  Most commonly, the case_indexes are the same as the
dict_indexes, but reordering the dictionary can permute them.

2 years agopc+-file-reader: Drop unneeded struct member.
Ben Pfaff [Sat, 4 Mar 2023 16:31:29 +0000 (08:31 -0800)]
pc+-file-reader: Drop unneeded struct member.

2 years agodictionary: Get rid of "internal var" concept.
Ben Pfaff [Sat, 4 Mar 2023 02:45:00 +0000 (18:45 -0800)]
dictionary: Get rid of "internal var" concept.

It's nasty and doesn't conform to the usual invariants.

2 years agocase-map: Simplify case_map_stage_get_case_map().
Ben Pfaff [Sat, 4 Mar 2023 01:56:15 +0000 (17:56 -0800)]
case-map: Simplify case_map_stage_get_case_map().

A caseproto can't contain -1s anymore, so don't look for them.

2 years agocase-map: Remove buggy and unused case_map_clone().
Ben Pfaff [Sat, 4 Mar 2023 01:55:12 +0000 (17:55 -0800)]
case-map: Remove buggy and unused case_map_clone().

The xmemdup() in the implementation copied 'old->proto' to 'new->map',
which can't possibly work.  We could fix it but it wasn't used anyway.

2 years agodictionary: Get rid of next_value_idx.
Ben Pfaff [Sat, 4 Mar 2023 01:31:36 +0000 (17:31 -0800)]
dictionary: Get rid of next_value_idx.

At this point, it was always the number of variables in the dictionary.

2 years agocaseproto: Disallow -1 elements in caseprotos.
Ben Pfaff [Sat, 4 Mar 2023 00:49:33 +0000 (16:49 -0800)]
caseproto: Disallow -1 elements in caseprotos.

This is a stronger invariant that should make PSPP code easier to
understand.

It required updating dict_get_proto() to avoid intermediate stages in
which a -1 appeared as a width.

2 years agocaseproto: Allocate base struct and widths separately.
Ben Pfaff [Sat, 4 Mar 2023 00:43:52 +0000 (16:43 -0800)]
caseproto: Allocate base struct and widths separately.

This will allow constructing a caseproto from a passed-in array
without copying it.

2 years agodataset: Before deleting variables, make sure new values are added.
Ben Pfaff [Sat, 4 Mar 2023 00:43:59 +0000 (16:43 -0800)]
dataset: Before deleting variables, make sure new values are added.

This fixes a crash reported privately by knassen(at)chartermi.net.

2 years agocaseinit: Introduce new caseinit_translate_casereader_to_init_vars().
Ben Pfaff [Thu, 2 Mar 2023 22:25:30 +0000 (14:25 -0800)]
caseinit: Introduce new caseinit_translate_casereader_to_init_vars().

2 years agoMakefiles: Make a couple of targets build more quietly.
Ben Pfaff [Sun, 5 Mar 2023 17:24:30 +0000 (09:24 -0800)]
Makefiles: Make a couple of targets build more quietly.

2 years agocaseproto: Fix calculation in caseproto_reserve().
Ben Pfaff [Sat, 4 Mar 2023 00:32:24 +0000 (16:32 -0800)]
caseproto: Fix calculation in caseproto_reserve().

This reserved way too much in a lot of cases.

2 years agoDO REPEAT: Order PRINT output correctly.
Ben Pfaff [Thu, 2 Mar 2023 22:16:25 +0000 (14:16 -0800)]
DO REPEAT: Order PRINT output correctly.

This was printed in reverse order, although the commands were executed in
the correct order.

2 years agoUpdate README.
Ben Pfaff [Mon, 27 Feb 2023 18:00:48 +0000 (10:00 -0800)]
Update README.

The PSPP output subsystem is now pretty good and I don't think that it's
necessary to include it as future work anymore.

I haven't heard anything about OpenBSD in a while, so I don't think it's
necessary to list its tests as an explicit caveat.

These days I tend to prefer hearing bug reports via email.

2 years agoAdd support for variable sets in the system file format.
Ben Pfaff [Sun, 26 Feb 2023 01:48:46 +0000 (17:48 -0800)]
Add support for variable sets in the system file format.

Variable sets are primarily a GUI feature, but this commit doesn't
implement them in the GUI.

2 years agodictionary: Avoid name shadowing in dict_clone().
Ben Pfaff [Mon, 27 Feb 2023 04:26:44 +0000 (20:26 -0800)]
dictionary: Avoid name shadowing in dict_clone().

In this case, it wasn't a bug, but it was confusing.

2 years agoAvoid another possible null pointer dereference
John Darrington [Sun, 26 Feb 2023 10:21:24 +0000 (11:21 +0100)]
Avoid another possible null pointer dereference

* modified:   tests/output/tex-strings.c

2 years agoAvoid possible null pointer dereference
John Darrington [Sun, 26 Feb 2023 09:59:50 +0000 (10:59 +0100)]
Avoid possible null pointer dereference

* modified:   src/ui/gui/psppire-encoding-selector.c

2 years agotreewide: Use struct fmt_spec by value instead of pointer in most cases.
Ben Pfaff [Sun, 26 Feb 2023 00:51:00 +0000 (16:51 -0800)]
treewide: Use struct fmt_spec by value instead of pointer in most cases.

struct fmt_spec is a small struct, only 4 bytes in size.  It doesn't make
sense to pass it by pointer in most cases.  This commit makes that change
treewide.

2 years agopivot-table: Force width of weight formats to 40.
Ben Pfaff [Sat, 25 Feb 2023 03:01:15 +0000 (19:01 -0800)]
pivot-table: Force width of weight formats to 40.

It was too confusing when output tables contained **** because of weight
variables with narrow widths.

Recently reported by Andreas Hammer.  I've also noticed the same thing
myself.

2 years agodictionary: Make dict_get_weight_format() return by value, not pointer.
Ben Pfaff [Sat, 25 Feb 2023 02:46:48 +0000 (18:46 -0800)]
dictionary: Make dict_get_weight_format() return by value, not pointer.

This seems like a better interface.

2 years agoDISPLAY MACROS: New command.
Ben Pfaff [Tue, 21 Feb 2023 19:05:16 +0000 (11:05 -0800)]
DISPLAY MACROS: New command.

2 years agoDELETE VARIABLES: Fix bugs related to details of case compaction.
Ben Pfaff [Mon, 20 Feb 2023 22:56:34 +0000 (14:56 -0800)]
DELETE VARIABLES: Fix bugs related to details of case compaction.

We have to change AUTORECODE and RANK so that they don't add a
transformation, since transformations prevent DELETE VARIABLES.

Thanks to Frans Houweling for reporting the problem.