projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge 'master' into 'gtk3'.
[pspp]
/
src
/
language
/
data-io
/
get-data.c
diff --git
a/src/language/data-io/get-data.c
b/src/language/data-io/get-data.c
index cfa33d115239010244e082705d45e2bd1b885df1..2738cb29f1a277bd73cacdeb427b303c27eb41b3 100644
(file)
--- a/
src/language/data-io/get-data.c
+++ b/
src/language/data-io/get-data.c
@@
-1,5
+1,6
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 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
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
@@
-45,10
+46,23
@@
#define _(msgid) gettext (msgid)
#define N_(msgid) (msgid)
#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;
+#endif
+
+#ifdef GNM_READ_SUPPORT
+static const bool gnm_read_support = true;
+#else
+static const bool gnm_read_support = false;
+#endif
+
static bool parse_spreadsheet (struct lexer *lexer, char **filename,
struct spreadsheet_read_options *opts);
static bool parse_spreadsheet (struct lexer *lexer, char **filename,
struct spreadsheet_read_options *opts);
-static void destroy_spreadsheet_read_info (struct spreadsheet_read_
info *, struct spreadsheet_read_
options *);
+static void destroy_spreadsheet_read_info (struct spreadsheet_read_options *);
static int parse_get_txt (struct lexer *lexer, struct dataset *);
static int parse_get_psql (struct lexer *lexer, struct dataset *);
static int parse_get_txt (struct lexer *lexer, struct dataset *);
static int parse_get_psql (struct lexer *lexer, struct dataset *);
@@
-57,10
+71,18
@@
int
cmd_get_data (struct lexer *lexer, struct dataset *ds)
{
char *tok = NULL;
cmd_get_data (struct lexer *lexer, struct dataset *ds)
{
char *tok = NULL;
+ struct spreadsheet_read_options opts;
+
+ opts.sheet_name = NULL;
+ opts.sheet_index = -1;
+ opts.cell_range = NULL;
+ opts.read_names = false;
+ opts.asw = -1;
+
lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "TYPE"))
lex_force_match (lexer, T_SLASH);
if (!lex_force_match_id (lexer, "TYPE"))
-
return CMD_FAILURE
;
+
goto error
;
lex_force_match (lexer, T_EQUALS);
lex_force_match (lexer, T_EQUALS);
@@
-81,35
+103,46
@@
cmd_get_data (struct lexer *lexer, struct dataset *ds)
char *filename = NULL;
struct casereader *reader = NULL;
struct dictionary *dict = NULL;
char *filename = NULL;
struct casereader *reader = NULL;
struct dictionary *dict = NULL;
- struct spreadsheet_read_options opts;
+
if (!parse_spreadsheet (lexer, &filename, &opts))
goto error;
if (!parse_spreadsheet (lexer, &filename, &opts))
goto error;
- if ( 0 == strncasecmp (tok, "GNM", 3))
+ if (
gnm_read_support &&
0 == strncasecmp (tok, "GNM", 3))
{
struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
{
struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
+ if (spreadsheet == NULL)
+ goto error;
reader = gnumeric_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
reader = gnumeric_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
+ gnumeric_destroy (spreadsheet);
}
}
- else if (0 == strncasecmp (tok, "ODS", 3))
+ else if (
odf_read_support &&
0 == strncasecmp (tok, "ODS", 3))
{
struct spreadsheet *spreadsheet = ods_probe (filename, true);
{
struct spreadsheet *spreadsheet = ods_probe (filename, true);
+ if (spreadsheet == NULL)
+ goto error;
reader = ods_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
reader = ods_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
+ ods_destroy (spreadsheet);
}
}
+ free (filename);
+
if (reader)
{
dataset_set_dict (ds, dict);
dataset_set_source (ds, reader);
free (tok);
if (reader)
{
dataset_set_dict (ds, dict);
dataset_set_source (ds, reader);
free (tok);
+ destroy_spreadsheet_read_info (&opts);
return CMD_SUCCESS;
}
}
else
msg (SE, _("Unsupported TYPE %s."), tok);
return CMD_SUCCESS;
}
}
else
msg (SE, _("Unsupported TYPE %s."), tok);
+
error:
error:
+ destroy_spreadsheet_read_info (&opts);
free (tok);
return CMD_FAILURE;
}
free (tok);
return CMD_FAILURE;
}
@@
-667,7
+700,8
@@
parse_get_txt (struct lexer *lexer, struct dataset *ds)
static void
static void
-destroy_spreadsheet_read_info (UNUSED struct spreadsheet_read_info *sri,
- UNUSED struct spreadsheet_read_options *opts)
+destroy_spreadsheet_read_info (struct spreadsheet_read_options *opts)
{
{
+ free (opts->cell_range);
+ free (opts->sheet_name);
}
}