X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fexecutor.c;h=754d09ae5681b44b357f7882db701fa8eb6d631a;hb=9ade26c8349b4434008c46cf09bc7473ec743972;hp=aa2fae51ce127b95cfe6c607da50c2da95fe406f;hpb=8b71948cd57dbd2787cb4c50525b957e9be8a62b;p=pspp-builds.git diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index aa2fae51..754d09ae 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 Free Software Foundation + Copyright (C) 2007, 2009, 2010 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 @@ -16,18 +16,18 @@ #include -#include "executor.h" -#include "psppire-data-store.h" -#include -#include -#include -#include -#include -#include -#include "psppire-output-window.h" +#include "ui/gui/executor.h" + +#include "data/lazy-casereader.h" +#include "data/procedure.h" +#include "language/command.h" +#include "language/lexer/lexer.h" +#include "libpspp/cast.h" +#include "output/driver.h" +#include "ui/gui/psppire-data-store.h" +#include "ui/gui/psppire-output-window.h" extern struct dataset *the_dataset; -extern struct source_stream *the_source_stream; extern PsppireDataStore *the_data_store; /* Lazy casereader callback function used by execute_syntax. */ @@ -39,7 +39,7 @@ create_casereader_from_data_store (void *data_store_) } gboolean -execute_syntax (struct getl_interface *sss) +execute_syntax (struct lex_reader *lex_reader) { struct lexer *lexer; gboolean retval = TRUE; @@ -71,9 +71,9 @@ execute_syntax (struct getl_interface *sss) g_return_val_if_fail (proc_has_active_file (the_dataset), FALSE); - lexer = lex_create (the_source_stream); - - getl_append_source (the_source_stream, sss, GETL_BATCH, ERRMODE_CONTINUE); + lexer = lex_create (); + psppire_set_lexer (lexer); + lex_append (lexer, lex_reader); for (;;) { @@ -82,8 +82,7 @@ execute_syntax (struct getl_interface *sss) if ( cmd_result_is_failure (result)) { retval = FALSE; - if ( source_stream_current_error_mode (the_source_stream) - == ERRMODE_STOP ) + if ( lex_get_error_mode (lexer) == LEX_ERROR_STOP ) break; } @@ -91,9 +90,10 @@ execute_syntax (struct getl_interface *sss) break; } - getl_abort_noninteractive (the_source_stream); - lex_destroy (lexer); + psppire_set_lexer (NULL); + + proc_execute (the_dataset); psppire_dict_replace_dictionary (the_data_store->dict, dataset_dict (the_dataset)); @@ -102,7 +102,23 @@ execute_syntax (struct getl_interface *sss) if (!lazy_casereader_destroy (reader, lazy_serial)) psppire_data_store_set_reader (the_data_store, reader); - som_flush (); + output_flush (); return retval; } + +/* Executes null-terminated string SYNTAX as syntax. + Returns SYNTAX. */ +gchar * +execute_syntax_string (gchar *syntax) +{ + execute_const_syntax_string (syntax); + return syntax; +} + +/* Executes null-terminated string SYNTAX as syntax. */ +void +execute_const_syntax_string (const gchar *syntax) +{ + execute_syntax (lex_reader_for_string (syntax)); +}