Merge remote branch 'origin/master' into import-gui
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 5 Apr 2013 18:27:21 +0000 (20:27 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 5 Apr 2013 18:27:21 +0000 (20:27 +0200)
src/data/gnumeric-reader.c
src/language/stats/reliability.c
src/output/ascii.c
tests/language/stats/reliability.at
tests/output/ascii.at

index 197c1d1a59f208981cbb9c75a008b995bde24e89..27ba9d4cd21811c76bb0c2340d269dea018063bd 100644 (file)
@@ -473,7 +473,7 @@ gnumeric_error_handler (void *ctx, const char *mesg,
 static struct gnumeric_reader *
 gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_errors)
 {  
-  int ret;
+  int ret = -1;
   struct state_data *sd;
 
   xmlTextReaderPtr xtr;
index 695beabb5706d863dd716e5d24e1612afb9c777e..a4c4b862fdb344f98a3cf2a49cce3f2ee39265ba 100644 (file)
@@ -118,9 +118,10 @@ reliability_destroy (struct reliability *rel)
       {
        int x;
        free (rel->sc[j].items);
-       moments1_destroy (rel->sc[j].total);
-       for (x = 0; x < rel->sc[j].n_items; ++x)
-         free (rel->sc[j].m[x]);
+        moments1_destroy (rel->sc[j].total);
+        if (rel->sc[j].m)
+          for (x = 0; x < rel->sc[j].n_items; ++x)
+            free (rel->sc[j].m[x]);
        free (rel->sc[j].m);
       }
 
@@ -374,6 +375,20 @@ run_reliability (struct dataset *ds, const struct reliability *reliability)
   struct casereader *group;
 
   struct casegrouper *grouper = casegrouper_create_splits (proc_open (ds), dict);
+  int si;
+
+  for (si = 0 ; si < reliability->n_sc; ++si)
+    {
+      struct cronbach *s = &reliability->sc[si];
+      int i;
+
+      s->m = xzalloc (sizeof *s->m * s->n_items);
+      s->total = moments1_create (MOMENT_VARIANCE);
+
+      for (i = 0 ; i < s->n_items ; ++i )
+       s->m[i] = moments1_create (MOMENT_VARIANCE);
+    }
+
 
   while (casegrouper_get_next_group (grouper, &group))
     {
@@ -437,11 +452,10 @@ do_reliability (struct casereader *input, struct dataset *ds,
     {
       struct cronbach *s = &rel->sc[si];
 
-      s->m = xzalloc (sizeof (s->m) * s->n_items);
-      s->total = moments1_create (MOMENT_VARIANCE);
+      moments1_clear (s->total);
 
       for (i = 0 ; i < s->n_items ; ++i )
-       s->m[i] = moments1_create (MOMENT_VARIANCE);
+        moments1_clear (s->m[i]);
     }
 
   input = casereader_create_filter_missing (input,
index 756235c5cbf6cae7183e19d4a287ff6566840c7a..00806b4e64bd73a1e9b7e23391049c549981b078 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2007, 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
@@ -120,13 +120,14 @@ static const ucs4_t unicode_box_chars[N_BOX] =
     0x2564, 0x256a, 0x256c,
     0x2564, 0x256a, 0x256c,
     0x2554, 0x2560, 0x2560,
+    0x2560, 0x256c, 0x256c,
     0x2566, 0x256c, 0x256c,
   };
 
 static inline int
 make_box_index (int left, int right, int top, int bottom)
 {
-  return ((right * 3 + bottom) * 3 + left) * 3 + top;
+  return ((right * RENDER_N_LINES + bottom) * RENDER_N_LINES + left) * RENDER_N_LINES + top;
 }
 
 /* How to emphasize text. */
index f320d3e6f38246772e474e4e43c3173b541f2d8d..dcae7d517ad5e44e367e70f01a425e293327d846 100644 (file)
@@ -268,3 +268,32 @@ reliability x y.
 AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
 
 AT_CLEANUP
+
+dnl Checks for a crash when bad syntax followed scale specification.
+AT_SETUP([RELIABILITY bad syntax 2])
+AT_DATA([bad-syntax.sps], [dnl
+new file.
+data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
+begin data.
+end data.
+
+* This syntax is incorrect
+reliability variables=f01 to f10/asdfj.
+])
+AT_CHECK([pspp -O format=csv bad-syntax.sps], [1], [ignore])
+AT_CLEANUP
+
+
+dnl Checks for a crash when the active file was empty.  Bug #38660.
+AT_SETUP([RELIABILITY crash with no data])
+AT_DATA([reliability.sps], [dnl
+new file.
+data list notable list /f01 f02 f03 f04 f05 f06 f07 f08 f09 f10 *.
+begin data.
+end data.
+
+reliability variables=f01 to f10.
+])
+AT_CHECK([pspp -O format=csv reliability.sps], [0], [])
+AT_CLEANUP
+
index a3f66b933be8bb5afdaa570d7799b3282db5dfc6..b4de68808ee8d2f9f985be211e93e5aab0087058 100644 (file)
@@ -627,3 +627,29 @@ included in the variable list.
 ])
 
 AT_CLEANUP
+
+AT_SETUP([ASCII unicode box chars])
+
+AT_DATA([uc.sps], [dnl
+SET FORMAT=F8.4.
+DATA LIST NOTABLE LIST /x * .
+BEGIN DATA.
+1
+2
+3
+END DATA.
+
+DESCRIPTIVES X.
+])
+
+
+AT_CHECK([pspp -O box=unicode uc.sps], [0], [dnl
+Valid cases = 3; cases with missing value(s) = 0.
+╭────────╥─┬──────┬───────┬───────┬───────╮
+│Variable║N│ Mean │Std Dev│Minimum│Maximum│
+╞════════╬═╪══════╪═══════╪═══════╪═══════╡
+│x       ║3│2.0000│ 1.0000│ 1.0000│ 3.0000│
+╰────────╨─┴──────┴───────┴───────┴───────╯
+])
+
+AT_CLEANUP