Avoid compiler warnings
[pspp] / src / data / ods-reader.c
index a5ece5c504b394bde637060d603771e8bf7d7145..ab8b84a44484449e4eefe813c25be9c51c3da8c2 100644 (file)
@@ -268,7 +268,7 @@ process_node (struct ods_reader *r)
              r->sheets[r->n_allocated_sheets - 1].stop_col = -1;
              r->sheets[r->n_allocated_sheets - 1].start_row = -1;
              r->sheets[r->n_allocated_sheets - 1].stop_row = -1;
-             r->sheets[r->n_allocated_sheets - 1].name = xmlStrdup (r->current_sheet_name);
+             r->sheets[r->n_allocated_sheets - 1].name = CHAR_CAST (char *, xmlStrdup (r->current_sheet_name));
            }
 
          r->col = 0;
@@ -441,7 +441,7 @@ convert_xml_to_value (struct ccase *c, const struct variable *var,
 
       if ( 0 == xmlStrcmp (xmv->type, _xml("float")))
        {
-         v->f = c_strtod (xmv->value, NULL);
+         v->f = c_strtod (CHAR_CAST (const char *, xmv->value), NULL);
        }
       else
        {
@@ -637,7 +637,8 @@ ods_make_reader (struct spreadsheet *spreadsheet,
 
 
   /* Advance to the start of the cells for the target sheet */
-  while ( ! reading_target_sheet (r)  || r->state != STATE_ROW || r->row < r->start_row )
+  while ( ! reading_target_sheet (r)  
+         || r->state != STATE_ROW || r->row <= r->start_row )
     {
       if (1 != (ret = xmlTextReaderRead (r->xtr)))
           break;
@@ -645,7 +646,6 @@ ods_make_reader (struct spreadsheet *spreadsheet,
       process_node (r);
     }
 
-
   if (ret < 1)
     {
       msg (MW, _("Selected sheet or range of spreadsheet `%s' is empty."),
@@ -696,6 +696,9 @@ ods_make_reader (struct spreadsheet *spreadsheet,
              var_spec[idx].firstval.type = 0;
 
              var_spec [idx].name = strdup (CHAR_CAST (const char *, value));
+
+             //              printf ("%s:%d Name %s\n", __FILE__, __LINE__, var_spec [idx].name);
+
              xmlFree (value);
            }
        }
@@ -707,6 +710,9 @@ ods_make_reader (struct spreadsheet *spreadsheet,
       int idx;
       process_node (r);
 
+      if ( ! reading_target_sheet (r) )
+       break;
+
       /* If the row is finished then stop for now */
       if (r->state == STATE_TABLE &&
          r->row > r->start_row + (opts->read_names ? 1 : 0))
@@ -752,6 +758,8 @@ ods_make_reader (struct spreadsheet *spreadsheet,
          var_spec [idx].firstval.text = xmlTextReaderValue (r->xtr);
          var_spec [idx].firstval.value = val_string;
 
+         //      printf ("%s:%d Text %s\n", __FILE__, __LINE__, var_spec [idx].firstval.text);
+
          val_string = NULL;
          type = NULL;
        }
@@ -921,13 +929,14 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_)
 
          for (col = 0; col < r->col_span; ++col)
            {
+             const struct variable *var;
              const int idx = r->col + col - r->start_col - 1;
              if (idx < 0)
                continue;
              if (r->stop_col != -1 && idx > r->stop_col - r->start_col )
                break;
 
-             const struct variable *var = dict_get_var (r->dict, idx);
+              var = dict_get_var (r->dict, idx);
              convert_xml_to_value (c, var, xmv);
            }