LIST: Fix case numbering.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 10 Jan 2020 03:26:57 +0000 (03:26 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 10 Jan 2020 03:26:57 +0000 (03:26 +0000)
Case numbering was wrong when a starting case or a step was specified.

Bug #57534.

src/language/data-io/list.c
tests/language/data-io/list.at

index 920d66e322b4009c518cbc5ef1a4fbc9eca5a501..d9798852c1a815bb4aa4f390b39f4fbfbdb07171 100644 (file)
@@ -113,11 +113,12 @@ list_execute (const struct lst_cmd *lcmd, struct dataset *ds)
       else
         cases->hide_all_labels = true;
 
-      casenumber case_num = 1;
+      casenumber case_num = lcmd->first;
       for (; (c = casereader_read (group)) != NULL; case_unref (c))
         {
           int case_idx = pivot_category_create_leaf (
-            cases->root, pivot_value_new_integer (case_num++));
+            cases->root, pivot_value_new_integer (case_num));
+          case_num += lcmd->step;
 
           for (int i = 0; i < lcmd->n_variables; i++)
             pivot_table_put2 (table, i, case_idx,
index bc44cd592a86b76e9a95c75b9f0c8296107c476c..35acbbec771ef4b1dece9029d34ca25990d3e106 100644 (file)
@@ -76,6 +76,7 @@ AT_DATA([list.sps], [dnl
 DATA LIST FILE='data.txt'/avar 1-5 bvar 6-10.
 WEIGHT BY bvar.
 LIST/FORMAT NUMBERED.
+LIST/FORMAT NUMBERED/CASES FROM 2 TO 9 BY 2.
 ])
 AT_CHECK([pspp -o pspp.csv list.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
@@ -97,6 +98,13 @@ Case Number,avar,bvar
 9,26,30
 10,27,21
 11,28,23
+
+Table: Data List
+Case Number,avar,bvar
+2,19,7
+4,21,76
+6,23,58
+8,25,38
 ])
 AT_CLEANUP