Merge remote branch 'origin/master' into import-gui
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 27 Mar 2013 19:07:58 +0000 (20:07 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 27 Mar 2013 19:07:58 +0000 (20:07 +0100)
NEWS
src/language/data-io/combine-files.c
src/ui/gui/page-file.c
tests/language/data-io/match-files.at

diff --git a/NEWS b/NEWS
index bf043140e13df834f407c9caffd5ca2648a52a19..3685d9e2a4dae9e6c0f705316d72cb11f2b26371 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ See the end for copying conditions.
 
 Please send PSPP bug reports to bug-gnu-pspp@gnu.org.
 
-Changes from 0.6.2 to 0.7.9:
+Changes from 0.6.2 to 0.7.10:
 
  * New commands:
 
index b7ba87ab7ccd39fd445121deea9d63eb1b4b4473..d803ccdc869d40d2fe49cb295e0d50ad23c01533 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -264,7 +264,8 @@ combine_files (enum comb_command_type command,
             saw_sort = true;
           }
 
-      merge_dictionary (proc.dict, file);
+      if (!merge_dictionary (proc.dict, file))
+        goto error;
     }
 
   while (lex_token (lexer) != T_ENDCMD)
@@ -554,8 +555,10 @@ merge_dictionary (struct dictionary *const m, struct comb_file *f)
           if (var_get_width (mv) != var_get_width (dv))
             {
               const char *var_name = var_get_name (dv);
-              const char *file_name = fh_get_name (f->handle);
               struct string s = DS_EMPTY_INITIALIZER;
+              const char *file_name;
+
+              file_name = f->handle ? fh_get_name (f->handle) : "*";
               ds_put_format (&s,
                              _("Variable %s in file %s has different "
                                "type or width from the same variable in "
index 3947c7901233f558ef52ab1bd4940e28a9fa4c29..84b7928a27645689afc37a04a6268edbb1de33ff 100644 (file)
@@ -81,21 +81,12 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window)
 {
   enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */
   struct file *file = &ia->file;
-  struct spreadsheet_read_options opts;
 
   file->lines = NULL;
   file->file_name = choose_file (parent_window, &file->encoding);
   if (file->file_name == NULL)
     return false;
 
-  opts.sheet_name = NULL;
-  opts.cell_range = NULL;
-  opts.sheet_index = 1;
-
-  opts.read_names = true;
-  opts.asw = -1;
-
-
   if (ia->spreadsheet == NULL)
     ia->spreadsheet = gnumeric_probe (file->file_name, false);
 
index ce429a81e8f9b696cf78eec0bb626012c52c1597..d83eec8e48d759c21549cb169dbf1cc776b2f04f 100644 (file)
@@ -198,3 +198,33 @@ x,y,j
 2.00,3.00,55.00
 ])
 AT_CLEANUP
+
+dnl Tests for a bug that caused MATCH FILES to crash
+dnl with incompatible variables, especially but not
+dnl exclusively when one variable came from the active
+dnl file.
+AT_SETUP([MATCH FILES with incompatible variable types])
+AT_DATA([match-files.sps], [dnl
+DATA LIST LIST NOTABLE/name (A6) x.
+BEGIN DATA.
+al,7
+brad,8
+carl,9
+END DATA.
+SAVE OUTFILE='x.sav'.
+
+DATA LIST LIST NOTABLE/name (A7) y.
+BEGIN DATA.
+al,1
+carl,2
+dan,3
+END DATA.
+MATCH FILES/FILE='x.sav'/FILE=*/BY name.
+LIST.
+])
+AT_CHECK([pspp -O format=csv match-files.sps], [1], [dnl
+"match-files.sps:15: error: MATCH FILES: Variable name in file * has different type or width from the same variable in earlier file.  In file *, name is a string variable with width 7.  In an earlier file, name was a string variable with width 6."
+
+match-files.sps:16: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+AT_CLEANUP