From ddf35b11f8525281dd9e524a5d322a80bf56a24f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Fri, 15 Feb 2013 12:08:21 +0100 Subject: [PATCH] Fixed many warnings --- src/data/gnumeric-reader.c | 4 +--- src/data/spreadsheet-reader.c | 12 +++++++---- src/data/spreadsheet-reader.h | 2 +- src/language/data-io/get-data.c | 2 +- src/ui/gui/automake.mk | 5 +++++ src/ui/gui/page-assistant.c | 3 --- src/ui/gui/page-file.c | 1 - src/ui/gui/page-first-line.c | 2 ++ src/ui/gui/page-first-line.h | 26 ++++++++++++++++++++++++ src/ui/gui/page-formats.c | 1 - src/ui/gui/page-formats.h | 26 ++++++++++++++++++++++++ src/ui/gui/page-intro.c | 2 ++ src/ui/gui/page-intro.h | 26 ++++++++++++++++++++++++ src/ui/gui/page-separators.c | 2 ++ src/ui/gui/page-separators.h | 26 ++++++++++++++++++++++++ src/ui/gui/page-sheet-spec.c | 7 ++++--- src/ui/gui/page-sheet-spec.h | 30 ++++++++++++++++++++++++++++ src/ui/gui/sheet-test.c | 3 ++- src/ui/gui/text-data-import-dialog.c | 12 +++++++---- 19 files changed, 170 insertions(+), 22 deletions(-) create mode 100644 src/ui/gui/page-first-line.h create mode 100644 src/ui/gui/page-formats.h create mode 100644 src/ui/gui/page-intro.h create mode 100644 src/ui/gui/page-separators.h create mode 100644 src/ui/gui/page-sheet-spec.h diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index edb4b4291d..7bec97a9e0 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -140,7 +140,7 @@ gnumeric_get_sheet_name (struct spreadsheet *s, int n) struct gnumeric_reader *gr = (struct gnumeric_reader *) s; assert (n < s->n_sheets); - return gr->sheets[n].name; + return gr->sheets[n].name; // Kludge: Assumes the encoding is utf8 } @@ -175,7 +175,6 @@ gnumeric_get_sheet_range (struct spreadsheet *s, int n) static void gnm_file_casereader_destroy (struct casereader *reader UNUSED, void *r_) { - int i; struct gnumeric_reader *r = r_; if ( r == NULL) return ; @@ -430,7 +429,6 @@ struct var_spec void gnumeric_destroy (struct spreadsheet *s) { - struct gnumeric_reader *r = (struct gnumeric *) s; gnm_file_casereader_destroy (NULL, s); } diff --git a/src/data/spreadsheet-reader.c b/src/data/spreadsheet-reader.c index 2b4178835a..b010999c1f 100644 --- a/src/data/spreadsheet-reader.c +++ b/src/data/spreadsheet-reader.c @@ -18,10 +18,14 @@ #include "spreadsheet-reader.h" +#include "gnumeric-reader.h" + #include #include #include - +#include +#include +#include struct spreadsheet * spreadsheet_open (const char *filename) @@ -34,7 +38,7 @@ spreadsheet_open (const char *filename) } void -spreadsheet_close (struct spreadsheet *spreadsheet) +spreadsheet_close (UNUSED struct spreadsheet *spreadsheet) { } @@ -107,7 +111,7 @@ int_to_ps26 (int i) i -= lower; i += base; - ret = malloc (exp); + ret = xmalloc (exp); exp = 0; do @@ -137,7 +141,7 @@ create_cell_ref (int col0, int row0, int coli, int rowi) cs0 = int_to_ps26 (col0); csi = int_to_ps26 (coli); - s = c_xasprintf ("%s%d:%s%ld", + s = c_xasprintf ("%s%d:%s%d", cs0, row0 + 1, csi, rowi + 1); free (cs0); diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index 765f3ca953..f6380e31c1 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -61,7 +61,7 @@ enum spreadsheet_type struct spreadsheet { - char *file_name; + const char *file_name; enum spreadsheet_type type; diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 26de745464..7b1d2882a2 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -671,7 +671,7 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds) static void -destroy_spreadsheet_read_info (struct spreadsheet_read_info *sri, +destroy_spreadsheet_read_info (UNUSED struct spreadsheet_read_info *sri, struct spreadsheet_read_options *opts) { free (opts->sheet_name); diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 38a22b6e69..e47996ea62 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -320,11 +320,16 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/split-file-dialog.h \ src/ui/gui/page-assistant.c \ src/ui/gui/page-intro.c \ + src/ui/gui/page-intro.h \ src/ui/gui/page-file.c \ src/ui/gui/page-first-line.c \ + src/ui/gui/page-first-line.h \ src/ui/gui/page-formats.c \ + src/ui/gui/page-formats.h \ src/ui/gui/page-separators.c \ + src/ui/gui/page-separators.h \ src/ui/gui/page-sheet-spec.c \ + src/ui/gui/page-sheet-spec.h \ src/ui/gui/text-data-import-dialog.c \ src/ui/gui/text-data-import-dialog.h \ src/ui/gui/transpose-dialog.c \ diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index 7c54f40f80..43f6a36287 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -153,10 +153,7 @@ static void on_prepare (GtkAssistant *assistant, GtkWidget *page, struct import_assistant *ia) { - struct sheet_spec_page *ssp = ia->sheet_spec; - int pn = gtk_assistant_get_current_page (assistant); - g_print ("%s:%d Page %d %p\n", __FILE__, __LINE__, pn, page); if ( ia->spreadsheet) { diff --git a/src/ui/gui/page-file.c b/src/ui/gui/page-file.c index fdf6d6c912..48db5a2a16 100644 --- a/src/ui/gui/page-file.c +++ b/src/ui/gui/page-file.c @@ -81,7 +81,6 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) { enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */ struct file *file = &ia->file; - struct sheet_spec_page *ssp = ia->sheet_spec; struct spreadsheet_read_info sri; struct spreadsheet_read_options opts; diff --git a/src/ui/gui/page-first-line.c b/src/ui/gui/page-first-line.c index 8a0e103227..d1cec2cb4e 100644 --- a/src/ui/gui/page-first-line.c +++ b/src/ui/gui/page-first-line.c @@ -16,6 +16,8 @@ #include +#include "page-first-line.h" + #include "ui/gui/text-data-import-dialog.h" #include diff --git a/src/ui/gui/page-first-line.h b/src/ui/gui/page-first-line.h new file mode 100644 index 0000000000..291ffd21db --- /dev/null +++ b/src/ui/gui/page-first-line.h @@ -0,0 +1,26 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#ifndef PAGE_FIRST_LINE_H +#define PAGE_FIRST_LINE_H + +struct first_line_page ; +struct import_assistant; + +struct first_line_page *first_line_page_create (struct import_assistant *ia); + +#endif diff --git a/src/ui/gui/page-formats.c b/src/ui/gui/page-formats.c index b80699887f..16438eeaee 100644 --- a/src/ui/gui/page-formats.c +++ b/src/ui/gui/page-formats.c @@ -117,7 +117,6 @@ prepare_formats_page (struct import_assistant *ia) GtkBin *vars_scroller; GtkWidget *old_var_sheet; PsppireVarSheet *var_sheet; - struct separators_page *seps = ia->separators; struct formats_page *p = ia->formats; struct fmt_guesser *fg; unsigned long int number = 0; diff --git a/src/ui/gui/page-formats.h b/src/ui/gui/page-formats.h new file mode 100644 index 0000000000..2e532068bf --- /dev/null +++ b/src/ui/gui/page-formats.h @@ -0,0 +1,26 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef PAGE_FORMATS_H +#define PAGE_FORMATS_H + +struct formats_page; +struct import_assistant; + +struct formats_page *formats_page_create (struct import_assistant *ia); + + +#endif diff --git a/src/ui/gui/page-intro.c b/src/ui/gui/page-intro.c index f580310c1f..6ef991c314 100644 --- a/src/ui/gui/page-intro.c +++ b/src/ui/gui/page-intro.c @@ -16,6 +16,8 @@ #include +#include "page-intro.h" + #include "ui/gui/text-data-import-dialog.h" #include diff --git a/src/ui/gui/page-intro.h b/src/ui/gui/page-intro.h new file mode 100644 index 0000000000..d0de8bfad4 --- /dev/null +++ b/src/ui/gui/page-intro.h @@ -0,0 +1,26 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef PAGE_INTRO_H +#define PAGE_INTRO_H + +struct intro_page; +struct import_assistant; + +struct intro_page *intro_page_create (struct import_assistant *ia); + + +#endif diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index e153a231f5..780742bf5b 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -16,6 +16,8 @@ #include +#include "page-separators.h" + #include "ui/gui/text-data-import-dialog.h" #include diff --git a/src/ui/gui/page-separators.h b/src/ui/gui/page-separators.h new file mode 100644 index 0000000000..273bcaab72 --- /dev/null +++ b/src/ui/gui/page-separators.h @@ -0,0 +1,26 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef PAGE_SEPARATORS +#define PAGE_SEPARATORS + +struct separators_page; +struct import_assistant; + +struct separators_page *separators_page_create (struct import_assistant *ia); + +#endif diff --git a/src/ui/gui/page-sheet-spec.c b/src/ui/gui/page-sheet-spec.c index b68180bf04..59c9c76636 100644 --- a/src/ui/gui/page-sheet-spec.c +++ b/src/ui/gui/page-sheet-spec.c @@ -16,6 +16,8 @@ #include +#include "page-sheet-spec.h" + #include "ui/gui/text-data-import-dialog.h" #include @@ -163,11 +165,11 @@ prepare_sheet_spec_page (struct import_assistant *ia) { GtkBuilder *builder = ia->asst.builder; GtkWidget *sheet_entry = get_widget_assert (builder, "sheet-entry"); - printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet); + gtk_combo_box_set_model (GTK_COMBO_BOX (sheet_entry), psppire_spreadsheet_model_new (ia->spreadsheet)); - gtk_combo_box_set_active (sheet_entry, 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (sheet_entry), 0); } @@ -195,7 +197,6 @@ post_sheet_spec_page (struct import_assistant *ia) struct casereader *creader = NULL; struct dictionary *dict = NULL; - GtkWidget *sheet_entry = get_widget_assert (builder, "sheet-entry"); GtkWidget *range_entry = get_widget_assert (builder, "cell-range-entry"); GtkWidget *readnames_checkbox = get_widget_assert (builder, "readnames-checkbox"); diff --git a/src/ui/gui/page-sheet-spec.h b/src/ui/gui/page-sheet-spec.h new file mode 100644 index 0000000000..7a4e8012b2 --- /dev/null +++ b/src/ui/gui/page-sheet-spec.h @@ -0,0 +1,30 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2013 Free Software Foundation + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef PAGE_SHEET_SPEC +#define PAGE_SHEET_SPEC 1 + + +struct sheet_spec_page ; +struct import_assistant; + +/* Initializes IA's sheet_spec substructure. */ +struct sheet_spec_page *sheet_spec_page_create (struct import_assistant *ia); + +char *sheet_spec_gen_syntax (const struct import_assistant *ia); + + +#endif diff --git a/src/ui/gui/sheet-test.c b/src/ui/gui/sheet-test.c index bc7fd04e51..8f38e90f06 100644 --- a/src/ui/gui/sheet-test.c +++ b/src/ui/gui/sheet-test.c @@ -13,6 +13,7 @@ #define N 10 +#if 0 static GtkListStore * make_store () { @@ -31,7 +32,7 @@ make_store () } return list_store; } - +#endif struct spreadsheet *sp = NULL; GtkWidget *combo_box; diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 94fc9300d7..412af5b8f4 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -18,6 +18,12 @@ #include "ui/gui/text-data-import-dialog.h" +#include "page-intro.h" +#include "page-sheet-spec.h" +#include "page-first-line.h" +#include "page-separators.h" +#include "page-formats.h" + #include #include #include @@ -72,7 +78,6 @@ text_data_import_assistant (PsppireDataWindow *dw) { GtkWindow *parent_window = GTK_WINDOW (dw); struct import_assistant *ia = init_assistant (parent_window); - GtkBuilder *builder = ia->asst.builder; struct sheet_spec_page *ssp ; if (!init_file (ia, parent_window)) @@ -216,8 +221,6 @@ generate_syntax (const struct import_assistant *ia) if (ia->spreadsheet == NULL) { - size_t var_cnt; - size_t i; syntax_gen_pspp (&s, "GET DATA" "\n /TYPE=TXT" @@ -226,13 +229,14 @@ generate_syntax (const struct import_assistant *ia) if (ia->file.encoding && strcmp (ia->file.encoding, "Auto")) syntax_gen_pspp (&s, " /ENCODING=%sq\n", ia->file.encoding); +#if 0 intro_append_syntax (ia->intro, &s); ds_put_cstr (&s, " /ARRANGEMENT=DELIMITED\n" " /DELCASE=LINE\n"); -#if 0 + if (ia->first_line->skip_lines > 0) ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line->skip_lines + 1); ds_put_cstr (&s, " /DELIMITERS=\""); -- 2.30.2