compile without gnumeric and odf read support
authorpspp.freepost@ordinaryamerican.net <pspp.freepost@ordinaryamerican.net>
Mon, 7 Nov 2016 11:18:35 +0000 (12:18 +0100)
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>
Mon, 7 Nov 2016 12:14:01 +0000 (13:14 +0100)
This patch fixes the problem described in bug #49550. When libxml2 is
not installed, the gnumeric and odf read support is disabled. This was
not handled correctly. I changed the compilation requirements and the
error message handling if somebody tries to open a file.

Closes bug #49550.

src/data/gnumeric-reader.c
src/data/ods-reader.c
src/language/data-io/get-data.c

index ba4218ff77ef093999b73c24d62e2f19052f30ee..abbbceb72762a9cf8ba9965543f5656ac97ab988 100644 (file)
 
 #if !GNM_READ_SUPPORT
 
-struct casereader *
-gnumeric_open_reader (const struct spreadsheet_read_options *opts, struct dictionary **dict)
+struct spreadsheet *
+gnumeric_probe (const char *filename, bool report_errors)
 {
-  msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "Gnumeric");
+  if (report_errors)
+    msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "Gnumeric");
+
+  return NULL;
+}
 
+const char *
+gnumeric_get_sheet_name (struct spreadsheet *s, int n)
+{
+  return NULL;
+}
+
+char *
+gnumeric_get_sheet_range (struct spreadsheet *s, int n)
+{
   return NULL;
 }
 
index c2e7a0e354933309d4610574a73007342ec8d61b..eabdc8f5510b1928157df2815b0fd4fedb44badf 100644 (file)
 
 #if !ODF_READ_SUPPORT
 
-struct casereader *
-ods_open_reader (const struct spreadsheet_read_options *opts, 
-                struct dictionary **dict)
+struct spreadsheet *
+ods_probe (const char *filename, bool report_errors)
 {
-  msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "OpenDocument");
+  if (report_errors)
+    msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "OpenDocument");
+
+  return NULL;
+}
 
+const char *
+ods_get_sheet_name (struct spreadsheet *s, int n)
+{
+  return NULL;
+}
+
+char *
+ods_get_sheet_range (struct spreadsheet *s, int n)
+{
   return NULL;
 }
 
index 13eebe6c3aaabe840a155c4e405fa797e99af295..061fde1c03a0a4628873d58be10041a8c7cce38f 100644 (file)
 #define _(msgid) gettext (msgid)
 #define N_(msgid) (msgid)
 
-
-#ifdef ODF_READ_SUPPORT
-static const bool odf_read_support = true;
-#else
-static const bool odf_read_support = false;
-struct spreadsheet *ods_probe (const char *filename, bool report_errors){}
-#endif
-
-#ifdef GNM_READ_SUPPORT
-static const bool gnm_read_support = true;
-#else
-static const bool gnm_read_support = false;
-struct spreadsheet *gnumeric_probe (const char *filename, bool report_errors){}
-#endif
-
 static bool parse_spreadsheet (struct lexer *lexer, char **filename,
                               struct spreadsheet_read_options *opts);
 
@@ -113,14 +98,18 @@ cmd_get_data (struct lexer *lexer, struct dataset *ds)
        goto error;
 
       struct spreadsheet *spreadsheet = NULL;
-      if ( gnm_read_support && 0 == strncasecmp (tok, "GNM", 3))
+      if ( 0 == strncasecmp (tok, "GNM", 3))
         spreadsheet = gnumeric_probe (filename, true);
-      else if ( odf_read_support && 0 == strncasecmp (tok, "ODS", 3))
+      else if ( 0 == strncasecmp (tok, "ODS", 3))
         spreadsheet = ods_probe (filename, true);
 
-      free (filename);
       if (spreadsheet == NULL)
-        goto error;
+        {
+          msg (SE, _("error reading file `%s'"), filename);
+          free (filename);
+          goto error;
+        }
+      free (filename);
 
       struct casereader *reader = spreadsheet_make_reader (spreadsheet, &opts);
       if (reader)