X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fgetl.c;h=302cd9137ddbc7b748ae07c9c4c34103ffecbf86;hb=6ed74d8699a65ef63f04ccef33ab1c8600d6eb9f;hp=b4617122677840ecd65a9670a3d424e3f03964d6;hpb=458d169f64134f4e0a9d9b72398666a01761fcf8;p=pspp-builds.git
diff --git a/src/libpspp/getl.c b/src/libpspp/getl.c
index b4617122..302cd913 100644
--- a/src/libpspp/getl.c
+++ b/src/libpspp/getl.c
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009 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
@@ -14,15 +14,17 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
-#include
#include
+#include
+
#include "getl.h"
#include
#include
#include
-#include
+
+#include "xalloc.h"
struct getl_source
{
@@ -32,6 +34,8 @@ struct getl_source
struct ll ll; /* Element in the sources list */
struct getl_interface *interface;
+ enum syntax_mode syntax_mode;
+ enum error_mode error_mode;
};
struct source_stream
@@ -54,6 +58,26 @@ current_source (const struct source_stream *ss)
return ll_data (ll, struct getl_source, ll );
}
+enum syntax_mode
+source_stream_current_syntax_mode (const struct source_stream *ss)
+{
+ struct getl_source *cs = current_source (ss);
+
+ return cs->syntax_mode;
+}
+
+
+
+enum error_mode
+source_stream_current_error_mode (const struct source_stream *ss)
+{
+ struct getl_source *cs = current_source (ss);
+
+ return cs->error_mode;
+}
+
+
+
/* Initialize getl. */
struct source_stream *
create_source_stream (const char *initial_include_path)
@@ -88,18 +112,26 @@ getl_add_include_dir (struct source_stream *ss, const char *path)
/* Appends source S to the list of source files. */
void
-getl_append_source (struct source_stream *ss, struct getl_interface *i)
+getl_append_source (struct source_stream *ss,
+ struct getl_interface *i,
+ enum syntax_mode syntax_mode,
+ enum error_mode err_mode)
{
struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
s->interface = i ;
+ s->syntax_mode = syntax_mode;
+ s->error_mode = err_mode;
ll_push_tail (&ss->sources, &s->ll);
}
/* Nests source S within the current source file. */
void
-getl_include_source (struct source_stream *ss, struct getl_interface *i)
+getl_include_source (struct source_stream *ss,
+ struct getl_interface *i,
+ enum syntax_mode syntax_mode,
+ enum error_mode err_mode)
{
struct getl_source *current = current_source (ss);
struct getl_source *s = xzalloc (sizeof ( struct getl_source ));
@@ -108,6 +140,8 @@ getl_include_source (struct source_stream *ss, struct getl_interface *i)
s->included_from = current ;
s->includes = NULL;
+ s->syntax_mode = syntax_mode;
+ s->error_mode = err_mode;
current->includes = s;
ll_push_head (&ss->sources, &s->ll);
@@ -205,10 +239,9 @@ destroy_source_stream (struct source_stream *ss)
/* Reads a single line into LINE.
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
-getl_read_line (struct source_stream *ss, struct string *line,
- enum getl_syntax *syntax)
+getl_read_line (struct source_stream *ss, struct string *line)
{
assert (ss != NULL);
while (!ll_is_empty (&ss->sources))
@@ -216,12 +249,12 @@ getl_read_line (struct source_stream *ss, struct string *line,
struct getl_source *s = current_source (ss);
ds_clear (line);
- if (s->interface->read (s->interface, line, syntax))
+ if (s->interface->read (s->interface, line))
{
while (s)
{
if (s->interface->filter)
- s->interface->filter (s->interface, line, *syntax);
+ s->interface->filter (s->interface, line);
s = s->included_from;
}