X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fexecutor.c;h=6a3f1e154d68b9141acf83ed5a37f530c145bb56;hb=d4ae4bc98332969940737c4a5e8f4347f8b9be8c;hp=3afa1ecd022359d2b0e72468c962451fe0477fb4;hpb=2be9bee9da6a2ce27715e58128569594319abfa2;p=pspp diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index 3afa1ecd02..6a3f1e154d 100644 --- a/src/ui/gui/executor.c +++ b/src/ui/gui/executor.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009, 2010 Free Software Foundation + Copyright (C) 2007, 2009, 2010, 2011 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 @@ -27,9 +27,6 @@ #include "ui/gui/psppire-data-store.h" #include "ui/gui/psppire-output-window.h" -extern struct dataset *the_dataset; -extern PsppireDataStore *the_data_store; - /* Lazy casereader callback function used by execute_syntax. */ static struct casereader * create_casereader_from_data_store (void *data_store_) @@ -39,7 +36,7 @@ create_casereader_from_data_store (void *data_store_) } gboolean -execute_syntax (struct lex_reader *lex_reader) +execute_syntax (PsppireDataWindow *window, struct lex_reader *lex_reader) { struct lexer *lexer; gboolean retval = TRUE; @@ -50,9 +47,9 @@ execute_syntax (struct lex_reader *lex_reader) unsigned long int lazy_serial; /* When the user executes a number of snippets of syntax in a - row, none of which read from the active file, the GUI becomes + row, none of which read from the active dataset, the GUI becomes progressively less responsive. The reason is that each syntax - execution encapsulates the active file data in another + execution encapsulates the active dataset data in another datasheet layer. The cumulative effect of having a number of layers of datasheets wastes time and space. @@ -62,14 +59,14 @@ execute_syntax (struct lex_reader *lex_reader) needed. If the data store casereader is never needed, then it is reused the next time syntax is run, without wrapping it in another layer. */ - proto = psppire_data_store_get_proto (the_data_store); - case_cnt = psppire_data_store_get_case_count (the_data_store); + proto = psppire_data_store_get_proto (window->data_store); + case_cnt = psppire_data_store_get_case_count (window->data_store); reader = lazy_casereader_create (proto, case_cnt, create_casereader_from_data_store, - the_data_store, &lazy_serial); - proc_set_active_file_data (the_dataset, reader); + window->data_store, &lazy_serial); + dataset_set_source (window->dataset, reader); - g_return_val_if_fail (proc_has_active_file (the_dataset), FALSE); + g_return_val_if_fail (dataset_has_source (window->dataset), FALSE); lexer = lex_create (); psppire_set_lexer (lexer); @@ -77,7 +74,7 @@ execute_syntax (struct lex_reader *lex_reader) for (;;) { - enum cmd_result result = cmd_parse (lexer, the_dataset); + enum cmd_result result = cmd_parse (lexer, window->dataset); if ( cmd_result_is_failure (result)) { @@ -90,17 +87,21 @@ execute_syntax (struct lex_reader *lex_reader) break; } - lex_destroy (lexer); - psppire_set_lexer (NULL); - - proc_execute (the_dataset); + proc_execute (window->dataset); - psppire_dict_replace_dictionary (the_data_store->dict, - dataset_dict (the_dataset)); + psppire_dict_replace_dictionary (window->data_store->dict, + dataset_dict (window->dataset)); - reader = proc_extract_active_file_data (the_dataset); + reader = dataset_steal_source (window->dataset); if (!lazy_casereader_destroy (reader, lazy_serial)) - psppire_data_store_set_reader (the_data_store, reader); + psppire_data_store_set_reader (window->data_store, reader); + + /* Destroy the lexer only after obtaining the dataset, because the dataset + might depend on the lexer, if the casereader specifies inline data. (In + such a case then we'll always get an error message--the inline data is + missing, otherwise it would have been parsed in the loop above.) */ + lex_destroy (lexer); + psppire_set_lexer (NULL); output_flush (); @@ -110,15 +111,15 @@ execute_syntax (struct lex_reader *lex_reader) /* Executes null-terminated string SYNTAX as syntax. Returns SYNTAX. */ gchar * -execute_syntax_string (gchar *syntax) +execute_syntax_string (PsppireDataWindow *window, gchar *syntax) { - execute_const_syntax_string (syntax); + execute_const_syntax_string (window, syntax); return syntax; } /* Executes null-terminated string SYNTAX as syntax. */ void -execute_const_syntax_string (const gchar *syntax) +execute_const_syntax_string (PsppireDataWindow *window, const gchar *syntax) { - execute_syntax (lex_reader_for_string (syntax)); + execute_syntax (window, lex_reader_for_string (syntax)); }