pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src language/control/repeat.c language/lex...


From: John Darrington
Subject: [Pspp-cvs] pspp/src language/control/repeat.c language/lex...
Date: Tue, 05 Dec 2006 11:27:42 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     John Darrington <jmd>   06/12/05 11:27:42

Modified files:
        src/language/control: repeat.c 
        src/language/lexer: lexer.c lexer.h 
        src/language/utilities: include.c 
        src/libpspp    : getl.c getl.h message.c message.h msg-locator.c 
                         msg-locator.h 
        src/ui/gui     : message-dialog.c message-dialog.h psppire.c 
        src/ui/terminal: command-line.c command-line.h main.c msg-ui.c 
                         msg-ui.h 

Log message:
        Applied patch  #5611

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/control/repeat.c?cvsroot=pspp&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/lexer.c?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/lexer/lexer.h?cvsroot=pspp&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/utilities/include.c?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/getl.c?cvsroot=pspp&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/getl.h?cvsroot=pspp&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/message.c?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/message.h?cvsroot=pspp&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/msg-locator.c?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/libpspp/msg-locator.h?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/message-dialog.c?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/message-dialog.h?cvsroot=pspp&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire.c?cvsroot=pspp&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/command-line.c?cvsroot=pspp&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/command-line.h?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/main.c?cvsroot=pspp&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/msg-ui.c?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/msg-ui.h?cvsroot=pspp&r1=1.2&r2=1.3

Patches:
Index: language/control/repeat.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/control/repeat.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- language/control/repeat.c   3 Dec 2006 22:16:45 -0000       1.19
+++ language/control/repeat.c   5 Dec 2006 11:27:42 -0000       1.20
@@ -139,7 +139,7 @@
   block->parent.location = do_repeat_location;
 
   if (!ll_is_empty (&block->lines))
-    getl_include_source (&block->parent);
+    getl_include_source (lex_get_source_stream (lexer), &block->parent);
   else
     pool_destroy (block->pool);
 
@@ -310,7 +310,7 @@
       ds_init_string (&text, lex_entire_line_ds (lexer));
 
       /* Record file name. */
-      cur_file_name = getl_source_name ();
+      cur_file_name = getl_source_name (lex_get_source_stream (lexer));
       if (cur_file_name != NULL && 
          (previous_file_name == NULL
            || !strcmp (cur_file_name, previous_file_name)))
@@ -319,7 +319,7 @@
       /* Create a line structure. */
       line = pool_alloc (block->pool, sizeof *line);
       line->file_name = previous_file_name;
-      line->line_number = getl_source_location ();
+      line->line_number = getl_source_location (lex_get_source_stream (lexer));
       ss_alloc_substring_pool (&line->text, ds_ss (&text), block->pool);
       line->syntax = syntax;
 

Index: language/lexer/lexer.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/lexer/lexer.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- language/lexer/lexer.c      3 Dec 2006 22:16:45 -0000       1.15
+++ language/lexer/lexer.c      5 Dec 2006 11:27:42 -0000       1.16
@@ -49,7 +49,7 @@
 {
   struct string line_buffer;
 
-  bool (*read_line) (struct string *, enum getl_syntax *);
+  struct source_stream *ss;
 
   int token;      /* Current token. */
   double tokval;  /* T_POS_NUM, T_NEG_NUM: the token's value. */
@@ -93,14 +93,14 @@
 
 /* Initializes the lexer. */
 struct lexer *
-lex_create (bool (*read_line_func) (struct string *, enum getl_syntax *))
+lex_create (struct source_stream *ss)
 {
   struct lexer *lexer = xzalloc (sizeof (*lexer));
 
   ds_init_empty (&lexer->tokstr);
   ds_init_empty (&lexer->put_tokstr);
   ds_init_empty (&lexer->line_buffer);
-  lexer->read_line = read_line_func;
+  lexer->ss = ss;
 
   if (!lex_get_line (lexer))
     lexer->eof = true;
@@ -108,6 +108,13 @@
   return lexer;
 }
 
+struct source_stream *
+lex_get_source_stream (const struct lexer *lex)
+{
+  return lex->ss;
+}
+
+
 void
 lex_destroy (struct lexer *lexer)
 {
@@ -752,7 +759,7 @@
 void
 lex_discard_rest_of_command (struct lexer *lexer) 
 {
-  if (!getl_is_interactive ())
+  if (!getl_is_interactive (lexer->ss))
     {
       while (lexer->token != T_STOP && lexer->token != '.')
        lex_get (lexer);
@@ -842,7 +849,7 @@
 lex_get_line_raw (struct lexer *lexer, enum getl_syntax *syntax)
 {
   enum getl_syntax dummy;
-  bool ok = lexer->read_line (&lexer->line_buffer,
+  bool ok = getl_read_line (lexer->ss, &lexer->line_buffer,
                               syntax != NULL ? syntax : &dummy);
   return ok;
 }
@@ -976,13 +983,6 @@
     }
 }
    
-/* We're not at eof any more. */
-void
-lex_reset_eof (struct lexer *lexer)
-{
-  lexer->eof = false;
-}
-
 /* Skip a COMMENT command. */
 void
 lex_skip_comment (struct lexer *lexer)

Index: language/lexer/lexer.h
===================================================================
RCS file: /sources/pspp/pspp/src/language/lexer/lexer.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- language/lexer/lexer.h      3 Dec 2006 22:16:45 -0000       1.9
+++ language/lexer/lexer.h      5 Dec 2006 11:27:42 -0000       1.10
@@ -30,10 +30,10 @@
 struct lexer;
 
 /* Initialization. */
-struct lexer * lex_create (bool (*)(struct string *, enum getl_syntax *));
+struct lexer * lex_create (struct source_stream *);
 void lex_destroy (struct lexer *);
 
-
+struct source_stream * lex_get_source_stream (const struct lexer *);
 
 
 /* Common functions. */
@@ -93,7 +93,6 @@
 
 /* Really weird functions. */
 void lex_negative_to_dash (struct lexer *);
-void lex_reset_eof (struct lexer *);
 void lex_skip_comment (struct lexer *);
 
 #endif /* !lexer_h */

Index: language/utilities/include.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/utilities/include.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- language/utilities/include.c        29 Nov 2006 11:50:31 -0000      1.7
+++ language/utilities/include.c        5 Dec 2006 11:27:42 -0000       1.8
@@ -36,6 +36,7 @@
 int
 cmd_include (struct lexer *lexer, struct dataset *ds UNUSED)
 {
+  struct source_stream *ss;
   char *found_fn;
   char *target_fn;
 
@@ -52,13 +53,12 @@
 
   target_fn = ds_cstr (lex_tokstr (lexer));
 
-  found_fn = fn_search_path (target_fn,
-                            getl_include_path (),
-                            NULL);
+  ss = lex_get_source_stream (lexer);
+  found_fn = fn_search_path (target_fn, getl_include_path ( ss ), NULL);
 
   if (found_fn != NULL) 
     {
-      getl_include_source (create_syntax_file_source (found_fn));
+      getl_include_source (ss, create_syntax_file_source (found_fn));
       free (found_fn); 
     }
   else

Index: libpspp/getl.c
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/getl.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libpspp/getl.c      3 Dec 2006 22:16:46 -0000       1.3
+++ libpspp/getl.c      5 Dec 2006 11:27:42 -0000       1.4
@@ -40,66 +40,70 @@
     struct getl_interface *interface;
   };
 
-/* List of source files. */
-static struct ll_list sources ;
+struct source_stream 
+  {
+    struct ll_list sources ;  /* List of source files. */
 
-static struct string the_include_path;
+    struct string the_include_path;
+  };
 
 const char *
-getl_include_path (void)
+getl_include_path (const struct source_stream *ss)
 {
-  return ds_cstr (&the_include_path);
+  return ds_cstr (&ss->the_include_path);
 }
 
 static struct getl_source *
-current_source (struct ll_list *list)
+current_source (const struct source_stream *ss)
 {
-  const struct ll *ll = ll_head (list);
+  const struct ll *ll = ll_head (&ss->sources);
   return ll_data (ll, struct getl_source, ll );
 }
 
 /* Initialize getl. */
-void
-getl_initialize (void)
+struct source_stream *
+create_source_stream (void)
 {
-  ll_init (&sources);
-  ds_init_cstr (&the_include_path,
+  struct source_stream *ss = xzalloc (sizeof (*ss));
+  ll_init (&ss->sources);
+  ds_init_cstr (&ss->the_include_path,
                 fn_getenv_default ("STAT_INCLUDE_PATH", include_path));
+  return ss;
 }
 
 /* Delete everything from the include path. */
 void
-getl_clear_include_path (void)
+getl_clear_include_path (struct source_stream *ss)
 {
-  ds_clear (&the_include_path);
+  ds_clear (&ss->the_include_path);
 }
 
 /* Add to the include path. */
 void
-getl_add_include_dir (const char *path)
+getl_add_include_dir (struct source_stream *ss, const char *path)
 {
-  if (ds_length (&the_include_path))
-    ds_put_char (&the_include_path, ':');
+  if (ds_length (&ss->the_include_path))
+    ds_put_char (&ss->the_include_path, ':');
 
-  ds_put_cstr (&the_include_path, path);
+  ds_put_cstr (&ss->the_include_path, path);
 }
 
 /* Appends source S to the list of source files. */
 void
-getl_append_source (struct getl_interface *i) 
+getl_append_source (struct source_stream *ss, struct getl_interface *i) 
 {
   struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
 
   s->interface = i ;
 
-  ll_push_head (&sources, &s->ll);
+  ll_push_head (&ss->sources, &s->ll);
 }
 
 /* Nests source S within the current source file. */
 void
-getl_include_source (struct getl_interface *i) 
+getl_include_source (struct source_stream *ss, struct getl_interface *i) 
 {
-  struct getl_source *current = current_source (&sources);
+  struct getl_source *current = current_source (ss);
   struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
 
   s->interface = i;
@@ -108,23 +112,23 @@
   s->includes  = NULL;
   current->includes = s;
 
-  ll_push_head (&sources, &s->ll);
+  ll_push_head (&ss->sources, &s->ll);
 }
 
 /* Closes the current source, and move  the current source to the 
    next file in the chain. */
 static void
-close_source (void)
+close_source (struct source_stream *ss)
 {
-  struct getl_source *s = current_source (&sources);
+  struct getl_source *s = current_source (ss);
 
   if ( s->interface->close ) 
     s->interface->close (s->interface);
 
-  ll_pop_head (&sources);
+  ll_pop_head (&ss->sources);
 
   if (s->included_from != NULL)
-    current_source (&sources)->includes = NULL;
+    current_source (ss)->includes = NULL;
 
   free (s);
 }
@@ -132,25 +136,25 @@
 /* Closes all sources until an interactive source is
    encountered. */
 void
-getl_abort_noninteractive (void) 
+getl_abort_noninteractive (struct source_stream *ss) 
 {
-  while ( ! ll_is_empty (&sources))
+  while ( ! ll_is_empty (&ss->sources))
     {
-      const struct getl_source *s = current_source (&sources);
+      const struct getl_source *s = current_source (ss);
       
       if ( !s->interface->interactive (s->interface) ) 
-       close_source ();
+       close_source (ss);
     }
 }
 
 /* Returns true if the current source is interactive,
    false otherwise. */
 bool
-getl_is_interactive (void) 
+getl_is_interactive (const struct source_stream *ss) 
 {
-  const struct getl_source *s = current_source (&sources);
+  const struct getl_source *s = current_source (ss);
 
-  if (ll_is_empty (&sources) ) 
+  if (ll_is_empty (&ss->sources) ) 
     return false;
 
   return s->interface->interactive (s->interface);
@@ -159,11 +163,11 @@
 /* Returns the name of the current source, or NULL if there is no 
    current source */
 const char *
-getl_source_name (void)
+getl_source_name (const struct source_stream *ss)
 {
-  const struct getl_source *s = current_source (&sources);
+  const struct getl_source *s = current_source (ss);
 
-  if ( ll_is_empty (&sources) )
+  if ( ll_is_empty (&ss->sources) )
     return NULL;
 
   if ( ! s->interface->name ) 
@@ -175,11 +179,11 @@
 /* Returns the location within the current source, or -1 if there is
    no current source */
 int
-getl_source_location (void)
+getl_source_location (const struct source_stream *ss)
 {
-  const struct getl_source *s = current_source (&sources);
+  const struct getl_source *s = current_source (ss);
 
-  if ( ll_is_empty (&sources) )
+  if ( ll_is_empty (&ss->sources) )
     return -1;
 
   if ( !s->interface->location )
@@ -191,11 +195,13 @@
 
 /* Close getl. */
 void
-getl_uninitialize (void)
+destroy_source_stream (struct source_stream *ss)
 {
-  while ( !ll_is_empty (&sources))
-    close_source ();
-  ds_destroy (&the_include_path);
+  while ( !ll_is_empty (&ss->sources))
+    close_source (ss);
+  ds_destroy (&ss->the_include_path);
+
+  free (ss);
 }
 
 
@@ -203,11 +209,12 @@
    Returns true when a line has been read, false at end of input.
    On success, sets *SYNTAX to the style of the syntax read. */
 bool
-do_read_line (struct string *line, enum getl_syntax *syntax)
+getl_read_line (struct source_stream *ss, struct string *line,
+               enum getl_syntax *syntax)
 {
-  while (!ll_is_empty (&sources))
+  while (!ll_is_empty (&ss->sources))
     {
-      struct getl_source *s = current_source (&sources);
+      struct getl_source *s = current_source (ss);
 
       ds_clear (line);
       if (s->interface->read (s->interface, line, syntax))
@@ -221,7 +228,7 @@
          
           return true;
         }
-      close_source ();
+      close_source (ss);
     }
 
   return false;

Index: libpspp/getl.h
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/getl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libpspp/getl.h      3 Dec 2006 22:16:46 -0000       1.2
+++ libpspp/getl.h      5 Dec 2006 11:27:42 -0000       1.3
@@ -71,24 +71,25 @@
     int (*location) (const struct getl_interface *);
   };
 
-void getl_initialize (void);
-void getl_uninitialize (void);
+struct source_stream;
 
-void getl_clear_include_path (void);
-void getl_add_include_dir (const char *);
-const char * getl_include_path (void);
+struct source_stream * create_source_stream (void);
+void destroy_source_stream (struct source_stream *);
 
-void getl_abort_noninteractive (void);
-bool getl_is_interactive (void);
+void getl_clear_include_path (struct source_stream *);
+void getl_add_include_dir (struct source_stream *, const char *);
+const char * getl_include_path (const struct source_stream *);
 
-bool getl_read_line (bool *interactive);
+void getl_abort_noninteractive (struct source_stream *);
+bool getl_is_interactive (const struct source_stream *);
 
-bool do_read_line (struct string *line, enum getl_syntax *syntax);
+bool getl_read_line (struct source_stream *, struct string *,
+                    enum getl_syntax *);
 
-void getl_append_source (struct getl_interface *s) ;
-void getl_include_source (struct getl_interface *s) ;
+void getl_append_source (struct source_stream *, struct getl_interface *s) ;
+void getl_include_source (struct source_stream *, struct getl_interface *s) ;
 
-const char * getl_source_name (void);
-int getl_source_location (void);
+const char * getl_source_name (const struct source_stream *);
+int getl_source_location (const struct source_stream *);
 
 #endif /* line-buffer.h */

Index: libpspp/message.c
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/message.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libpspp/message.c   29 Nov 2006 11:50:31 -0000      1.7
+++ libpspp/message.c   5 Dec 2006 11:27:42 -0000       1.8
@@ -63,9 +63,12 @@
   msg_emit (&m);
 }
 
+static struct source_stream *s_stream;
+
 void
-msg_init ( void (*handler) (const struct msg *) )
+msg_init (struct source_stream *ss,  void (*handler) (const struct msg *) )
 {
+  s_stream = ss;
   msg_handler = handler;
 }
 
@@ -99,7 +102,7 @@
 void
 msg_emit (struct msg *m) 
 {
-  get_msg_location (&m->where);
+  get_msg_location (s_stream, &m->where);
   if (!messages_disabled)
     msg_handler (m);
   free (m->text);

Index: libpspp/message.h
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/message.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- libpspp/message.h   29 Nov 2006 11:50:31 -0000      1.14
+++ libpspp/message.h   5 Dec 2006 11:27:42 -0000       1.15
@@ -85,8 +85,10 @@
     char *text;                 /* Error text. */
   };
 
+struct source_stream ;
+
 /* Initialization. */
-void msg_init ( void (*handler) (const struct msg *) );
+void msg_init (struct source_stream *, void (*handler) (const struct msg *) );
 
 void msg_done (void);
 

Index: libpspp/msg-locator.c
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/msg-locator.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libpspp/msg-locator.c       29 Nov 2006 12:19:08 -0000      1.1
+++ libpspp/msg-locator.c       5 Dec 2006 11:27:42 -0000       1.2
@@ -71,7 +71,7 @@
 /* Puts the current file and line number into LOC, or NULL and -1 if
    none. */
 void
-get_msg_location (struct msg_locator *loc)
+get_msg_location (const struct source_stream *ss, struct msg_locator *loc)
 {
   if (nfile_loc)
     {
@@ -79,7 +79,7 @@
     }
   else
     {
-      loc->file_name = getl_source_name ();
-      loc->line_number = getl_source_location ();
+      loc->file_name = getl_source_name (ss);
+      loc->line_number = getl_source_location (ss);
     }
 }

Index: libpspp/msg-locator.h
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/msg-locator.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libpspp/msg-locator.h       29 Nov 2006 12:19:08 -0000      1.1
+++ libpspp/msg-locator.h       5 Dec 2006 11:27:42 -0000       1.2
@@ -31,6 +31,7 @@
    item on top of the stack. */
 void msg_pop_msg_locator (const struct msg_locator *loc);
 
+struct source_stream ;
 /* Puts the current file and line number into LOC, or NULL and -1 if
    none. */
-void get_msg_location (struct msg_locator *loc);
+void get_msg_location (const struct source_stream *ss, struct msg_locator 
*loc);

Index: ui/gui/message-dialog.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/message-dialog.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ui/gui/message-dialog.c     29 Nov 2006 11:50:31 -0000      1.15
+++ ui/gui/message-dialog.c     5 Dec 2006 11:27:42 -0000       1.16
@@ -51,10 +51,10 @@
 
 
 void
-message_dialog_init (void) 
+message_dialog_init (struct source_stream *ss) 
 {
   message_queue = g_queue_new();
-  msg_init (enqueue_msg);
+  msg_init (ss, enqueue_msg);
 }
 
 void

Index: ui/gui/message-dialog.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/message-dialog.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- ui/gui/message-dialog.h     3 Jun 2006 03:24:21 -0000       1.6
+++ ui/gui/message-dialog.h     5 Dec 2006 11:27:42 -0000       1.7
@@ -24,7 +24,9 @@
 
 #include <libpspp/message.h>
 
-void message_dialog_init (void);
+struct source_stream ;
+
+void message_dialog_init (struct source_stream *);
 void message_dialog_done (void);
 void popup_message(const struct msg *m);
 

Index: ui/gui/psppire.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- ui/gui/psppire.c    29 Nov 2006 11:50:31 -0000      1.20
+++ ui/gui/psppire.c    5 Dec 2006 11:27:42 -0000       1.21
@@ -77,6 +77,8 @@
 
 void create_icon_factory (void);
 
+static struct source_stream *the_source_stream ;
+
 int 
 main(int argc, char *argv[]) 
 {
@@ -116,8 +118,8 @@
 
   fmt_init();
   settings_init();
-  getl_initialize ();
-  message_dialog_init();
+  the_source_stream = create_source_stream ();
+  message_dialog_init (the_source_stream);
 
   the_dictionary = psppire_dict_new();
 
@@ -168,7 +170,7 @@
   /* start the event loop */
   gtk_main();
 
-  getl_uninitialize ();
+  destroy_source_stream (the_source_stream);
   message_dialog_done();
 
   settings_done();

Index: ui/terminal/command-line.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/command-line.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- ui/terminal/command-line.c  29 Nov 2006 11:50:32 -0000      1.8
+++ ui/terminal/command-line.c  5 Dec 2006 11:27:42 -0000       1.9
@@ -50,11 +50,12 @@
 
 char *subst_vars (char *);
 
+
 /* Parses the command line specified by ARGC and ARGV as received by
    main().  Returns true if normal execution should proceed,
    false if the command-line indicates that PSPP should exit. */
 bool
-parse_command_line (int argc, char **argv)
+parse_command_line (int argc, char **argv, struct source_stream *ss)
 {
   static struct option long_options[] =
   {
@@ -140,9 +141,9 @@
          break;
        case 'I':
          if (optarg == NULL || !strcmp (optarg, "-"))
-           getl_clear_include_path ();
+           getl_clear_include_path (ss);
          else
-           getl_add_include_dir (optarg);
+           getl_add_include_dir (ss, optarg);
          break;
        case 'l':
          outp_list_classes ();
@@ -195,7 +196,7 @@
       char *pspprc_fn = fn_search_path ("rc", config_path, NULL);
       if (pspprc_fn != NULL) 
         {
-         getl_append_source (create_syntax_file_source (pspprc_fn));
+         getl_append_source (ss, create_syntax_file_source (pspprc_fn));
 
           free (pspprc_fn); 
         }
@@ -206,12 +207,12 @@
       outp_configure_macro (argv[i]);
     else 
       {
-       getl_append_source (create_syntax_file_source (argv[i]));
+       getl_append_source (ss, create_syntax_file_source (argv[i]));
         syntax_files++;
       }
 
   if (!syntax_files || interactive_mode)
-    getl_append_source (create_readln_source () );
+    getl_append_source (ss, create_readln_source () );
 
   return true;
 }

Index: ui/terminal/command-line.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/command-line.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ui/terminal/command-line.h  4 Mar 2006 01:11:58 -0000       1.1
+++ ui/terminal/command-line.h  5 Dec 2006 11:27:42 -0000       1.2
@@ -22,6 +22,8 @@
 
 #include <stdbool.h>
 
-bool parse_command_line (int argc, char **argv);
+struct source_stream ;
+
+bool parse_command_line (int argc, char **argv, struct source_stream *);
 
 #endif /* cmdline.h */

Index: ui/terminal/main.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/main.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- ui/terminal/main.c  29 Nov 2006 11:50:32 -0000      1.23
+++ ui/terminal/main.c  5 Dec 2006 11:27:42 -0000       1.24
@@ -76,6 +76,8 @@
 static struct dataset * the_dataset = NULL;
 
 static struct lexer *the_lexer;
+static struct source_stream *the_source_stream ;
+
 
 /* Program entry point. */
 int
@@ -95,18 +97,18 @@
   outp_init ();
   fn_init ();
   fh_init ();
-  getl_initialize ();
+  the_source_stream = create_source_stream ();
   prompt_init ();
   readln_initialize ();
   settings_init ();
   random_init ();
   the_dataset = create_dataset ();
 
-  if (parse_command_line (argc, argv)) 
+  if (parse_command_line (argc, argv, the_source_stream)) 
     {
-      msg_ui_init ();
+      msg_ui_init (the_source_stream);
       outp_read_devices ();
-      the_lexer = lex_create (do_read_line);
+      the_lexer = lex_create (the_source_stream);
 
       for (;;)
         {
@@ -115,14 +117,15 @@
                                  ? CMD_STATE_DATA : CMD_STATE_INITIAL);
           if (result == CMD_EOF || result == CMD_FINISH)
             break;
-          if (result == CMD_CASCADING_FAILURE && !getl_is_interactive ())
+          if (result == CMD_CASCADING_FAILURE && 
+             !getl_is_interactive (the_source_stream))
             {
               msg (SE, _("Stopping syntax file processing here to avoid "
                          "a cascade of dependent command failures."));
-              getl_abort_noninteractive (); 
+              getl_abort_noninteractive (the_source_stream); 
             }
           else
-            check_msg_count ();
+            check_msg_count (the_source_stream);
         }
     }
   
@@ -196,7 +199,7 @@
       settings_done ();
       fh_done ();
       lex_destroy (the_lexer);
-      getl_uninitialize ();
+      destroy_source_stream (the_source_stream);
       prompt_done ();
       readln_uninitialize ();
 

Index: ui/terminal/msg-ui.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/msg-ui.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ui/terminal/msg-ui.c        29 Nov 2006 11:50:32 -0000      1.7
+++ ui/terminal/msg-ui.c        5 Dec 2006 11:27:42 -0000       1.8
@@ -53,7 +53,7 @@
 }
 
 void
-msg_ui_init (void) 
+msg_ui_init (struct source_stream *ss) 
 {
   msg_file = stdout;
 
@@ -69,7 +69,7 @@
          msg_file = stdout;
        }
     }
-  msg_init (handle_msg);
+  msg_init (ss, handle_msg);
 }
 
 void
@@ -81,13 +81,12 @@
     fclose (msg_file);
 }
 
-
 /* Checks whether we've had so many errors that it's time to quit
    processing this syntax file. */
 void
-check_msg_count (void)
+check_msg_count (struct source_stream *ss)
 {
-  if (!getl_is_interactive ()) 
+  if (!getl_is_interactive (ss)) 
     {
       if (get_errorbreak () && error_count)
         msg (MN, _("Terminating execution of syntax file due to error."));
@@ -100,7 +99,7 @@
       else
         return;
 
-      getl_abort_noninteractive (); 
+      getl_abort_noninteractive (ss); 
     }
 }
 

Index: ui/terminal/msg-ui.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/msg-ui.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ui/terminal/msg-ui.h        7 Nov 2006 12:59:59 -0000       1.2
+++ ui/terminal/msg-ui.h        5 Dec 2006 11:27:42 -0000       1.3
@@ -22,10 +22,12 @@
 
 #include <stdbool.h>
 
+struct source_stream ;
+
 void msg_ui_set_error_file (const char *filename);
-void msg_ui_init (void);
+void msg_ui_init (struct source_stream *);
 void msg_ui_done (void);
-void check_msg_count (void);
+void check_msg_count (struct source_stream *);
 void reset_msg_count (void);
 bool any_errors (void);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]