Ben Pfaff [Tue, 25 Jun 2013 06:07:12 +0000 (23:07 -0700)]
datasheet: Avoid reading a given row more than necessary in source_read().
The datasheet casereader uses datasheet_get_row(), which calls rw_case(),
which until this commit called source_read() for every column. The latter
was expensive if casereader_peek() actually copied data for a whole large
row. For a datasheet with N columns, all from a single backing source,
the upshot was that datasheet_get_row() took O(N**2) time.
This commit fixes the problem in the common case by reading as many columns
as possible from a given source in a single call to source_read().
John Darrington [Sun, 23 Jun 2013 10:07:56 +0000 (12:07 +0200)]
variable.c: New function var_set_width_and_formats
Added a new function to set the width and formats of a variable as
an atomic operation. This is necessary to allow values to re-interpreted
without going through an intermediate format and thereby perhaps loosing
information.
John Darrington [Sat, 22 Jun 2013 10:09:56 +0000 (12:09 +0200)]
Fix and simplify the code for converting variables between types
Before this commit, changing a variable from string to numeric or
vici-versa would cause all values of that variable to become SYSMIS.
This commit fixes this problem at least partially.
John Darrington [Sat, 22 Jun 2013 05:23:16 +0000 (07:23 +0200)]
dictionary.c: Added a WHAT argument to dict_var_changed callback
Defined some bitwise constants to indicate which aspect of a variable has
changed. Added an argument to the dict_var_changed callback taking an
argument which contains a combination of these types.
This is used in later commits to avoid the callback implementation having
to guess what exactly changed.
John Darrington [Sat, 22 Jun 2013 04:52:10 +0000 (06:52 +0200)]
variable.c: Add _quiet versions of the var_set_ methods and use in var_clone
var_clone doesn't need to provoke callbacks, since the new variable does not
(yet) have a dictionary hence the callbacks can do nothing. Also the callbacks
cause problems for later commits, since they themselves could call var_clone.
This change therefore defines _quiet versions of all the var_set methods, which
do not generate any callbacks, and uses those versions in the implementation
of var_clone.
Ben Pfaff [Thu, 13 Jun 2013 07:03:51 +0000 (00:03 -0700)]
INPUT PROGRAM: Use a separate dataset for the input program.
Without this change, INPUT PROGRAM uses the same dataset as the following
syntax. This usually is fine, but there's at least one case where it
doesn't work: if the INPUT PROGRAM defines a vector, then a following
proc_execute() without any intervening transformations causes
proc_execute() to follow a "fast path" where it skips running the procedure
but instead just does a few things, like clearing the set of vectors.
Unfortunately, this means that later when the input program is really run,
it doesn't have the vectors and accesses freed memory.
This commit switches to a different tactic. INPUT PROGRAM creates a
special session and dataset that are used only for the input program. This
keeps the dataset and the transformations used for the input program
separate from those used after the input program.
Ben Pfaff [Sun, 26 May 2013 23:43:01 +0000 (16:43 -0700)]
Avoid letting data fields overflow in output and GUI.
When the output for data_out() is too big for the field width, it produces
output that consists of just asterisks: ******. This is OK when the
output is really going into a fixed-width space, such as the output for
PRINT and WRITE. But it is obnoxious if the output is going into PSPP
output or the GUI. This commit introduces a new function that typically
does not do this, and starts using it in output and the GUI.
Bug #35829.
Reported by John Darrington.
Bug #30731.
Reported by lavila <la@jump23.com>.
John Darrington [Sat, 25 May 2013 11:06:49 +0000 (13:06 +0200)]
Linear Regression Test: Provide more decimal places in test results.
This test previously had only 2 decimal places displayed, which
limited its ability to detect numerical errors. This change increases
the decimal places to 3.
The results for this test were checked against a pattern provided
by Olaf Nöhring.
Ben Pfaff [Tue, 21 May 2013 06:49:54 +0000 (23:49 -0700)]
DELETE VARIABLES: Fix crash with FILTER.
FILTER has the surprising property that it introduces a temporary
transformation, even if proc_make_temporary_transformations_permanent()
was previously called. This causes a crash if the procedure implementation
really relies on there being no temporary transformations.
This commit fixes the problem in the procedures I was able to identify as
having it, adds a comment to proc_make_temporary_transformations_permanent()
to make it a little less likely to happen again, and adds a test
specifically to check for regression on DELETE VARIABLES.
Ben Pfaff [Tue, 21 May 2013 05:54:31 +0000 (22:54 -0700)]
FLIP: Fix use-after-free and double frees with temporary transformations.
I originally thought this was a bug in FLIP, but it turned out that in
fact we just hadn't ever really tested
proc_make_temporary_transformations_permanent() properly with actual
transformations, and especially with adding a transformation after calling
proc_make_temporary_transformations_permanent().
The modified test should avoid regression for the bug.
John Darrington [Fri, 17 May 2013 14:24:31 +0000 (16:24 +0200)]
Sort items in datasheets dropdown box.
Before this change, the values in the data sheets dropdown
box appeared in a non-deterministic order (the order in
the underlying hash), which was inconvenient to users.
This change produces the values in sorted order.
John Darrington [Thu, 9 May 2013 09:28:12 +0000 (11:28 +0200)]
Fix stack corruption in ODS reader.
zip_reader_create takes a pointer to a struct string, which
is used to store error messages during zip operations. I had
been passing the address of a string declared as local variable
in ods_probe. However since the zip reader survives ods_probe,
this caused stack corruption in later read operations.
This change makes the string a member of the reader created (if any).
John Darrington [Thu, 9 May 2013 09:28:12 +0000 (11:28 +0200)]
Fix stack corruption in ODS reader.
zip_reader_create takes a pointer to a struct string, which
is used to store error messages during zip operations. I had
been passing the address of a string declared as local variable
in ods_probe. However since the zip reader survives ods_probe,
this caused stack corruption in later read operations.
This change makes the string a member of the reader created (if any).
John Darrington [Tue, 7 May 2013 13:52:44 +0000 (15:52 +0200)]
Spreadsheetreader: new function create_cell_ref and rename existing function with that name.
Rename convert_cell_ref to convert_cell_range which is a more accurate
description of the function, and add a new function, with the original
name of the function we've just renamed.
The new function (create_cell_ref) does just that.
Ben Pfaff [Thu, 9 May 2013 04:07:39 +0000 (21:07 -0700)]
psppire-cell-renderer-button: Do not update 'event->window'.
Commit 5b59146f8d0 (psppire-cell-renderer-button: Translate coords before
propagating event.) caused GDK and GTK+ warnings and criticals and a crash
if the scenario described in the bug report were repeated a number of
times. This change appears to fix the problem.
Ben Pfaff [Wed, 8 May 2013 05:29:50 +0000 (22:29 -0700)]
psppire-cell-renderer-button: Translate coords before propagating event.
When propagating a right-click upward, the x and y coordinates in the
event are those for the button, not for the parent window, but the parent
window's signal handlers will expect that they are relative to the parent
window. This commit makes that so.
Without this commit, the following scenario occurs:
1. Open a dataset with at least two cases.
2. Switch to the Data View
3. Place the pointer over (say) the tenth row header button.
4. Click the left mouse button.
5. Click the right mouse button.
6. The popup menu appears (as it should), but row 1 gets selected instead
of row 10.
With this commit, in step 6 the correct row is selected.
Ben Pfaff [Mon, 6 May 2013 04:48:06 +0000 (21:48 -0700)]
psppire-window: Disconnect signal handlers before unregistering.
Otherwise, the call to psppire_window_register_remove() calls back into
remove_menuitem() via the "remove" signal, but window->menu referenced in
that callback has already been freed.
Ben Pfaff [Mon, 6 May 2013 04:39:16 +0000 (21:39 -0700)]
psppire-data-sheet: Disconnect clipboard owner-change signal on dispose.
Otherwise, any clipboard change in ownership (e.g. clicking on some cells
and typing Control+C), even after a given PsppireDataSheet closes, still
calls into on_owner_change() and commits a use-after-free error.
Ben Pfaff [Mon, 6 May 2013 01:04:03 +0000 (18:04 -0700)]
psppire-data-sheet: Obtain data sheet targets via callback.
Calling gtk_clipboard_wait_is_target_available() within on_owner_change()
seems to cause Window|Split to act oddly (the right panes were empty),
perhaps because gtk_clipboard_wait_is_target_available() has a nested main
loop. Switching to gtk_clipboard_request_targets() fixes the problem.
John Darrington [Mon, 29 Apr 2013 11:40:06 +0000 (13:40 +0200)]
list.c Use "long" instead of "int" for command parameters.
Commit 4e5a6cc044c6c82e6c4d842bf056579b6bc47d48 used int instead of long for the
parameters of the LIST command. This caused compiler warnings and problems on
64 bit machines. This change fixes that.