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.
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.
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.
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.
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.
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.
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.)
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.
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.
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.
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.
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.
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.
Ben Pfaff [Sun, 22 Jan 2023 20:32:59 +0000 (12:32 -0800)]
render: Fix spanned width distribution for cells not at top or left.
This code always used the widths of rules at the left or top side of the
table, even in cases where the spanned cells were not at the top of left
side of the table. This obviously made the calculations wrong sometimes.
Ben Pfaff [Mon, 6 Feb 2023 16:17:28 +0000 (08:17 -0800)]
output: Correctly define and properly implement column width ranges.
I previously had the idea that SPV files had ranges for both column
widths and row heights, which didn't really make sense, since if
you fix the range of one of those you have to be flexible about the
other. However, these settings actually control just column widths,
in two sets of columns: the columns for row headings and the columns
for column headings. This implements those properly.
Ben Pfaff [Fri, 10 Feb 2023 18:54:25 +0000 (10:54 -0800)]
spv-driver: Add page_setup to output files and allow user to configure them.
This seems better than what I see happening otherwise, which can be that
the default page_setup that SPSS Viewer picks is a ridiculous one, like a
postcard page size.
Ben Pfaff [Fri, 10 Feb 2023 17:25:43 +0000 (09:25 -0800)]
cairo: Fix crashes and bugs in 'setup' call.
Changing the page_setup was not properly supported for PNG and SVG output,
because it assert-failed in xr_set_surface_size(). In addition, for all
kinds of output, it didn't account for margins properly in the page size.
This fixes the problem and unifies page setup between initial driver
creation and update.
This wasn't noticed before because output_set_page_setup() wasn't used
much, but it could be triggered with the pspp-output utility, converting
from an SPV file that contained a page_setup. It will become more
important because an upcoming commit will cause the SPV driver to output
a page_setup every time.
Ben Pfaff [Sat, 28 Jan 2023 18:16:25 +0000 (10:16 -0800)]
ascii: Improve look of dashed line ends.
Until now, partial ends of horizontal dashed lines were rendered as
U+2574 BOX DRAWINGS LIGHT LEFT and U+2576 BOX DRAWINGS LIGHT RIGHT,
which are solid lines. This looks funny at the end of a dashed line,
especially in some fonts. This commit changes these ends to
U+254C BOX DRAWINGS LIGHT DOUBLE DASH HORIZONTAL, which does extend all the
way across the character cell but looks much better.
Ben Pfaff [Sun, 22 Jan 2023 18:41:03 +0000 (10:41 -0800)]
table: Make debug code unconditional.
The debugging code in table_vline() and table_hline() was in practice
always enabled, but because of the way it was written each of the tests
was being re-tested in an assertion. It seems better to just enable it
all the time and avoid duplication.
Ben Pfaff [Fri, 27 Jan 2023 19:43:00 +0000 (11:43 -0800)]
pivot-table: Fix buffer overflow in corner case in pivot_table_dump().
Dumping a table with a layer dimension that has no leaves read from an
invalid pointer. This fixes the problem. This functionality isn't used
in PSPP, only by "pspp-output dump".
Ben Pfaff [Fri, 27 Jan 2023 02:35:38 +0000 (18:35 -0800)]
pivot-table: Fix buffer overflow in pivot_table_dump() in corner case.
This occurred when categories were more deeply nested into groups than
there were leaf categories. This functionality isn't used in PSPP, only
by "pspp-output dump".