? crosstabs.sps
? diffs
? files
? header_h
? lb.patch
? leaks.patch
? doc/.dirstamp
? gl/.deps
? gl/Makefile
? gl/Makefile.am
? gl/Makefile.in
? gl/alloca.c
? gl/alloca.h
? gl/alloca_.h
? gl/asnprintf.c
? gl/asprintf.c
? gl/byteswap_.h
? gl/c-ctype.c
? gl/c-ctype.h
? gl/c-strtod.c
? gl/c-strtod.h
? gl/charset.alias
? gl/config.charset
? gl/configmake.h
? gl/error.c
? gl/error.h
? gl/exit.h
? gl/exitfail.c
? gl/exitfail.h
? gl/full-read.c
? gl/full-read.h
? gl/full-write.c
? gl/full-write.h
? gl/getdelim.c
? gl/getdelim.h
? gl/gethostname.c
? gl/getline.c
? gl/getline.h
? gl/getlogin_r.c
? gl/getlogin_r.h
? gl/getopt.c
? gl/getopt1.c
? gl/getopt_.h
? gl/getopt_int.h
? gl/gettext.h
? gl/intprops.h
? gl/lbrkprop.h
? gl/linebreak.c
? gl/linebreak.h
? gl/localcharset.c
? gl/localcharset.h
? gl/mbchar.c
? gl/mbchar.h
? gl/mbuiter.h
? gl/memcasecmp.c
? gl/memcasecmp.h
? gl/memchr.c
? gl/memcmp.c
? gl/memmem.c
? gl/memmem.h
? gl/memmove.c
? gl/mempcpy.c
? gl/mempcpy.h
? gl/memset.c
? gl/minmax.h
? gl/printf-args.c
? gl/printf-args.h
? gl/printf-parse.c
? gl/printf-parse.h
? gl/progname.c
? gl/progname.h
? gl/readlink.c
? gl/ref-add.sed
? gl/ref-add.sin
? gl/ref-del.sed
? gl/ref-del.sin
? gl/safe-read.c
? gl/safe-read.h
? gl/safe-write.c
? gl/safe-write.h
? gl/size_max.h
? gl/snprintf.c
? gl/snprintf.h
? gl/stat-macros.h
? gl/stdbool_.h
? gl/stdint.h
? gl/stdint_.h
? gl/stpcpy.c
? gl/stpcpy.h
? gl/strcase.h
? gl/strcasecmp.c
? gl/strcspn.c
? gl/strerror.c
? gl/strftime.c
? gl/strftime.h
? gl/strncasecmp.c
? gl/strndup.c
? gl/strndup.h
? gl/strnlen.c
? gl/strnlen.h
? gl/strnlen1.c
? gl/strnlen1.h
? gl/strpbrk.c
? gl/strpbrk.h
? gl/strsep.c
? gl/strsep.h
? gl/strstr.c
? gl/strstr.h
? gl/strtod.c
? gl/strtok_r.c
? gl/strtok_r.h
? gl/strtol.c
? gl/strtoul.c
? gl/time_r.c
? gl/time_r.h
? gl/utf16-ucs4.h
? gl/utf8-ucs4.h
? gl/vasnprintf.c
? gl/vasnprintf.h
? gl/vasprintf.c
? gl/vasprintf.h
? gl/vsnprintf.c
? gl/vsnprintf.h
? gl/wcwidth.h
? gl/xalloc-die.c
? gl/xalloc.h
? gl/xasprintf.c
? gl/xmalloc.c
? gl/xreadlink.c
? gl/xreadlink.h
? gl/xsize.h
? gl/xstrndup.c
? gl/xstrndup.h
? gl/xvasprintf.c
? gl/xvasprintf.h
? gl/m4/absolute-header.m4
? gl/m4/alloca.m4
? gl/m4/assert.m4
? gl/m4/byteswap.m4
? gl/m4/c-strtod.m4
? gl/m4/codeset.m4
? gl/m4/eoverflow.m4
? gl/m4/error.m4
? gl/m4/exitfail.m4
? gl/m4/extensions.m4
? gl/m4/getdelim.m4
? gl/m4/gethostname.m4
? gl/m4/getline.m4
? gl/m4/getlogin_r.m4
? gl/m4/getopt.m4
? gl/m4/gettext.m4
? gl/m4/glibc2.m4
? gl/m4/glibc21.m4
? gl/m4/gnulib-cache.m4
? gl/m4/gnulib-comp.m4
? gl/m4/gnulib-tool.m4
? gl/m4/iconv.m4
? gl/m4/inline.m4
? gl/m4/intdiv0.m4
? gl/m4/intl.m4
? gl/m4/intldir.m4
? gl/m4/intmax.m4
? gl/m4/intmax_t.m4
? gl/m4/inttypes-pri.m4
? gl/m4/inttypes_h.m4
? gl/m4/lcmessage.m4
? gl/m4/lib-ld.m4
? gl/m4/lib-link.m4
? gl/m4/lib-prefix.m4
? gl/m4/linebreak.m4
? gl/m4/localcharset.m4
? gl/m4/lock.m4
? gl/m4/longdouble.m4
? gl/m4/longlong.m4
? gl/m4/mbchar.m4
? gl/m4/mbiter.m4
? gl/m4/mbrtowc.m4
? gl/m4/mbstate_t.m4
? gl/m4/memcasecmp.m4
? gl/m4/memchr.m4
? gl/m4/memcmp.m4
? gl/m4/memmem.m4
? gl/m4/memmove.m4
? gl/m4/mempcpy.m4
? gl/m4/memset.m4
? gl/m4/minmax.m4
? gl/m4/nls.m4
? gl/m4/onceonly_2_57.m4
? gl/m4/po.m4
? gl/m4/printf-posix.m4
? gl/m4/progtest.m4
? gl/m4/readlink.m4
? gl/m4/safe-read.m4
? gl/m4/safe-write.m4
? gl/m4/size_max.m4
? gl/m4/snprintf.m4
? gl/m4/ssize_t.m4
? gl/m4/stdarg.m4
? gl/m4/stdbool.m4
? gl/m4/stdint.m4
? gl/m4/stdint_h.m4
? gl/m4/stpcpy.m4
? gl/m4/strcase.m4
? gl/m4/strcspn.m4
? gl/m4/strerror.m4
? gl/m4/strftime.m4
? gl/m4/strndup.m4
? gl/m4/strnlen.m4
? gl/m4/strpbrk.m4
? gl/m4/strsep.m4
? gl/m4/strstr.m4
? gl/m4/strtod.m4
? gl/m4/strtok_r.m4
? gl/m4/strtol.m4
? gl/m4/strtoul.m4
? gl/m4/time_r.m4
? gl/m4/tm_gmtoff.m4
? gl/m4/uintmax_t.m4
? gl/m4/ulonglong.m4
? gl/m4/unistd_h.m4
? gl/m4/utf-ucs4.m4
? gl/m4/vasnprintf.m4
? gl/m4/vasprintf.m4
? gl/m4/visibility.m4
? gl/m4/vsnprintf.m4
? gl/m4/wchar_t.m4
? gl/m4/wcwidth.m4
? gl/m4/wint_t.m4
? gl/m4/xalloc.m4
? gl/m4/xreadlink.m4
? gl/m4/xsize.m4
? gl/m4/xstrndup.m4
? gl/m4/xvasprintf.m4
? intl/ChangeLog
? intl/Makefile
? intl/Makefile.in
? intl/VERSION
? intl/bindtextdom.c
? intl/config.charset
? intl/dcgettext.c
? intl/dcigettext.c
? intl/dcngettext.c
? intl/dgettext.c
? intl/dngettext.c
? intl/eval-plural.h
? intl/explodename.c
? intl/finddomain.c
? intl/gettext.c
? intl/gettextP.h
? intl/gmo.h
? intl/hash-string.h
? intl/intl-compat.c
? intl/l10nflist.c
? intl/langprefs.c
? intl/libgnuintl.h.in
? intl/loadinfo.h
? intl/loadmsgcat.c
? intl/localcharset.c
? intl/localcharset.h
? intl/locale.alias
? intl/localealias.c
? intl/localename.c
? intl/log.c
? intl/ngettext.c
? intl/os2compat.c
? intl/os2compat.h
? intl/osdep.c
? intl/plural-exp.c
? intl/plural-exp.h
? intl/plural.c
? intl/plural.y
? intl/printf-args.c
? intl/printf-args.h
? intl/printf-parse.c
? intl/printf-parse.h
? intl/printf.c
? intl/ref-add.sin
? intl/ref-del.sin
? intl/relocatable.c
? intl/relocatable.h
? intl/textdomain.c
? intl/vasnprintf.c
? intl/vasnprintf.h
? intl/vasnwprintf.h
? intl/wprintf-parse.h
? intl/xsize.h
? lib/gsl-extras/.deps
? lib/gsl-extras/.dirstamp
? lib/gtksheet/.deps
? lib/gtksheet/.dirstamp
? lib/linreg/.deps
? lib/linreg/.dirstamp
? m4/Makefile.am
? m4/codeset.m4
? m4/gettext.m4
? m4/glibc2.m4
? m4/glibc21.m4
? m4/iconv.m4
? m4/intdiv0.m4
? m4/intmax.m4
? m4/inttypes-pri.m4
? m4/inttypes.m4
? m4/inttypes_h.m4
? m4/isc-posix.m4
? m4/lcmessage.m4
? m4/lib-ld.m4
? m4/lib-link.m4
? m4/lib-prefix.m4
? m4/longdouble.m4
? m4/longlong.m4
? m4/nls.m4
? m4/po.m4
? m4/printf-posix.m4
? m4/progtest.m4
? m4/signed.m4
? m4/size_max.m4
? m4/stdint_h.m4
? m4/uintmax_t.m4
? m4/ulonglong.m4
? m4/wchar_t.m4
? m4/wint_t.m4
? m4/xsize.m4
? src/data/.deps
? src/data/.dirstamp
? src/language/.deps
? src/language/.dirstamp
? src/language/control/.deps
? src/language/control/.dirstamp
? src/language/data-io/.deps
? src/language/data-io/.dirstamp
? src/language/data-io/file-handle.c
? src/language/data-io/list.c
? src/language/dictionary/.deps
? src/language/dictionary/.dirstamp
? src/language/expressions/.deps
? src/language/expressions/.dirstamp
? src/language/lexer/.deps
? src/language/lexer/.dirstamp
? src/language/lexer/q2c
? src/language/stats/.deps
? src/language/stats/.dirstamp
? src/language/stats/correlations.c
? src/language/stats/crosstabs.c
? src/language/stats/examine.c
? src/language/stats/frequencies.c
? src/language/stats/means.c
? src/language/stats/oneway.c
? src/language/stats/rank.c
? src/language/stats/regression.c
? src/language/stats/t-test.c
? src/language/tests/.deps
? src/language/tests/.dirstamp
? src/language/utilities/.deps
? src/language/utilities/.dirstamp
? src/language/utilities/set.c
? src/language/xforms/.deps
? src/language/xforms/.dirstamp
? src/libpspp/.deps
? src/libpspp/.dirstamp
? src/libpspp/version.c
? src/math/.deps
? src/math/.dirstamp
? src/math/linreg/.deps
? src/math/linreg/.dirstamp
? src/math/ts/.deps
? src/math/ts/.dirstamp
? src/output/.deps
? src/output/.dirstamp
? src/output/charts/.deps
? src/output/charts/.dirstamp
? src/ui/.deps
? src/ui/.dirstamp
? src/ui/gui/.deps
? src/ui/gui/.dirstamp
? src/ui/gui/psppire
? src/ui/terminal/.deps
? src/ui/terminal/.dirstamp
? src/ui/terminal/pspp
? tests/formats/.deps
? tests/formats/.dirstamp
? tests/libpspp/.deps
? tests/libpspp/.dirstamp
Index: src/language/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/language/automake.mk,v
retrieving revision 1.3
diff -U3 -r1.3 automake.mk
--- src/language/automake.mk	17 Mar 2006 00:41:57 -0000	1.3
+++ src/language/automake.mk	17 Nov 2006 03:14:02 -0000
@@ -13,8 +13,12 @@
 noinst_LIBRARIES += src/language/liblanguage.a 
 
 src_language_liblanguage_a_SOURCES = \
-	src/language/line-buffer.c \
-	src/language/line-buffer.h \
+	src/language/lb-syntax-file.c \
+	src/language/lb-syntax-file.h \
+	src/language/lb-interactive.c \
+	src/language/lb-interactive.h \
+	src/language/prompt.c \
+	src/language/prompt.h \
 	src/language/command.c \
 	src/language/command.h \
 	src/language/command.def 
Index: src/language/command.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/command.c,v
retrieving revision 1.19
diff -U3 -r1.19 command.c
--- src/language/command.c	11 Nov 2006 23:10:00 -0000	1.19
+++ src/language/command.c	17 Nov 2006 03:14:03 -0000
@@ -32,7 +32,7 @@
 #include <data/settings.h>
 #include <data/variable.h>
 #include <language/lexer/lexer.h>
-#include <language/line-buffer.h>
+#include <language/prompt.h>
 #include <libpspp/alloc.h>
 #include <libpspp/assertion.h>
 #include <libpspp/compiler.h>
Index: src/language/lb-interactive.c
===================================================================
RCS file: src/language/lb-interactive.c
diff -N src/language/lb-interactive.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/lb-interactive.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,61 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <libpspp/alloc.h>
+#include <libpspp/line-buffer.h>
+#include "lb-interactive.h"
+
+
+struct string;
+
+struct interactive_source 
+  {
+    struct getl_source parent ;
+
+    bool (*interactive_func) (struct string *line,
+		      enum getl_prompt_style) ;
+    
+  };
+
+
+static bool
+read_interactive (struct getl_source *s, struct string *line)
+{
+  struct interactive_source *is  =
+    (struct interactive_source *) s ;
+
+  return is->interactive_func (line, get_prompt_style ());
+}
+
+/* Creates an interactive source with the given FUNCTION. */
+struct getl_source *
+create_interactive_source (bool (*function) (struct string *line,
+                                             enum getl_prompt_style)) 
+{
+  struct interactive_source *is  = xzalloc (sizeof (*is));
+
+  is->interactive_func = function;
+
+  is->parent.interactive = true;
+
+  is->parent.read = read_interactive;
+
+  return (struct getl_source *) is;
+}
+
Index: src/language/lb-interactive.h
===================================================================
RCS file: src/language/lb-interactive.h
diff -N src/language/lb-interactive.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/lb-interactive.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,31 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#if !LB_INTERACTIVE
+#define LB_INTERACTIVE 1
+
+#include "prompt.h"
+
+struct getl_source ;
+struct string;
+
+struct getl_source * create_interactive_source 
+    (bool (*function) (struct string *line,  enum getl_prompt_style)) ;
+
+#endif
Index: src/language/lb-syntax-file.c
===================================================================
RCS file: src/language/lb-syntax-file.c
diff -N src/language/lb-syntax-file.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/lb-syntax-file.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,145 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <config.h>
+
+#include "lb-syntax-file.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include <data/file-name.h>
+#include <data/settings.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/lexer/lexer.h>
+#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
+#include <libpspp/message.h>
+#include <libpspp/message.h>
+#include <libpspp/str.h>
+#include <libpspp/verbose-msg.h>
+#include <libpspp/version.h>
+#include <output/table.h>
+
+#include <libpspp/ll.h>
+
+#include "prompt.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+#include <libpspp/line-buffer.h>
+
+
+struct syntax_file_source 
+  {
+    struct getl_source parent ;
+
+    FILE *syntax_file;
+
+    /* Current location. */
+    char *fn;				/* File name. */
+    int ln;				/* Line number. */
+  };
+
+static const char *
+name (const struct getl_source *s)
+{
+  const struct syntax_file_source *sfs = (const struct syntax_file_source *) s;
+  return sfs->fn;
+}
+
+static int
+line_number (const struct getl_source *s)
+{
+  const struct syntax_file_source *sfs = (const struct syntax_file_source *) s;
+  return sfs->ln;
+}
+
+
+/* Reads a line from syntax file source S into LINE.
+   Returns true if successful, false at end of file. */
+bool
+read_syntax_file (struct getl_source *s, struct string *line)
+{
+  struct syntax_file_source *sfs = (struct syntax_file_source *) s;
+
+  /* Open file, if not yet opened. */
+  if (sfs->syntax_file == NULL)
+    {
+      verbose_msg (1, _("opening \"%s\" as syntax file"), sfs->fn);
+      sfs->syntax_file = fn_open (sfs->fn, "r");
+
+      if (sfs->syntax_file == NULL)
+        {
+          msg (ME, _("Opening `%s': %s."), sfs->fn, strerror (errno));
+          return false;
+        }
+    }
+
+  /* Read line from file and remove new-line.
+     Skip initial "#! /usr/bin/pspp" line. */
+  do 
+    {
+      sfs->ln++;
+      if (!ds_read_line (line, sfs->syntax_file))
+        {
+          if (ferror (sfs->syntax_file))
+            msg (ME, _("Reading `%s': %s."), sfs->fn, strerror (errno));
+          return false;
+        }
+      ds_chomp (line, '\n');
+    }
+  while (sfs->ln == 1 && !memcmp (ds_cstr (line), "#!", 2));
+
+  /* Echo to listing file, if configured to do so. */
+  if (get_echo ())
+    tab_output_text (TAB_LEFT | TAB_FIX, ds_cstr (line));
+
+  return true;
+}
+
+static void
+syntax_close (struct getl_source *s)
+{
+  struct syntax_file_source *sfs = (struct syntax_file_source *) s;
+
+  if (sfs->syntax_file && EOF == fn_close (sfs->fn, sfs->syntax_file))
+    msg (MW, _("Closing `%s': %s."), sfs->fn, strerror (errno));
+  free (sfs->fn);
+}
+
+/* Creates a syntax file source with file name FN. */
+struct getl_source *
+create_syntax_file_source (const char *fn) 
+{
+  struct syntax_file_source *ss = xzalloc (sizeof (*ss));
+
+  ss->fn = xstrdup (fn);
+
+  ss->parent.read = read_syntax_file ;
+  ss->parent.close = syntax_close ;
+  ss->parent.name = name ;
+  ss->parent.location = line_number;
+
+  return (struct getl_source *) ss;
+}
+
Index: src/language/lb-syntax-file.h
===================================================================
RCS file: src/language/lb-syntax-file.h
diff -N src/language/lb-syntax-file.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/lb-syntax-file.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,36 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#if !LB_SYNTAX
+#define LB_SYNTAX 1
+
+#include <stdbool.h>
+
+struct string;
+struct getl_source;
+
+
+bool read_syntax_file (struct getl_source *s, struct string *line);
+
+
+/* Creates a syntax file source with file name FN. */
+struct getl_source * create_syntax_file_source (const char *fn) ;
+
+
+#endif
Index: src/language/line-buffer.c
===================================================================
RCS file: src/language/line-buffer.c
diff -N src/language/line-buffer.c
--- src/language/line-buffer.c	28 Oct 2006 08:31:22 -0000	1.16
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,587 +0,0 @@
-/* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
-
-   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 2 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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA. */
-
-#include <config.h>
-
-#include <language/line-buffer.h>
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <data/file-name.h>
-#include <data/settings.h>
-#include <data/variable.h>
-#include <language/command.h>
-#include <language/lexer/lexer.h>
-#include <libpspp/alloc.h>
-#include <libpspp/assertion.h>
-#include <libpspp/message.h>
-#include <libpspp/message.h>
-#include <libpspp/str.h>
-#include <libpspp/verbose-msg.h>
-#include <libpspp/version.h>
-#include <output/table.h>
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-
-/* Source file. */
-struct getl_source
-  {
-    struct getl_source *included_from;	/* File that this is nested inside. */
-    struct getl_source *includes;	/* File nested inside this file. */
-    struct getl_source *next;		/* Next file in list. */
-
-    /* Current location. */
-    char *fn;				/* File name. */
-    int ln;				/* Line number. */
-
-    enum getl_source_type
-      {
-        SYNTAX_FILE,
-        FILTER,
-        FUNCTION,
-        INTERACTIVE
-      }
-    type;
-
-    union 
-      {
-        /* SYNTAX_FILE. */
-        FILE *syntax_file;
-
-        /* FILTER. */
-        struct 
-          {
-            void (*filter) (struct string *line, void *aux);
-            void (*close) (void *aux);
-            void *aux;
-          }
-        filter;
-
-        /* FUNCTION. */
-        struct 
-          {
-            bool (*read) (struct string *line, char **fn, int *ln, void *aux);
-            void (*close) (void *aux);
-            void *aux;
-          }
-        function;
-
-        /* INTERACTIVE. */
-        bool (*interactive) (struct string *line, enum getl_prompt_style);
-      }
-    u;
-
-  };
-
-/* List of source files. */
-static struct getl_source *cur_source;
-static struct getl_source *last_source;
-
-static struct string getl_include_path;
-
-
-static void close_source (void);
-
-static void init_prompts (void);
-static void uninit_prompts (void);
-static enum getl_prompt_style get_prompt_style (void);
-
-
-/* Initialize getl. */
-void
-getl_initialize (void)
-{
-  ds_init_cstr (&getl_include_path,
-                fn_getenv_default ("STAT_INCLUDE_PATH", include_path));
-  init_prompts ();
-}
-
-
-/* Delete everything from the include path. */
-void
-getl_clear_include_path (void)
-{
-  ds_clear (&getl_include_path);
-}
-
-/* Add to the include path. */
-void
-getl_add_include_dir (const char *path)
-{
-  if (ds_length (&getl_include_path))
-    ds_put_char (&getl_include_path, ':');
-
-  ds_put_cstr (&getl_include_path, path);
-}
-
-/* Appends source S to the list of source files. */
-static void
-append_source (struct getl_source *s) 
-{
-  s->included_from = s->includes = s->next = NULL;
-  if (last_source == NULL)
-    cur_source = s;
-  else
-    last_source->next = s;
-  last_source = s;
-}
-
-/* Nests source S within the current source file. */
-static void
-include_source (struct getl_source *s) 
-{
-  if (last_source == NULL)
-    append_source (s);
-  else 
-    {
-      s->included_from = cur_source;
-      s->includes = s->next = NULL;
-      s->next = NULL;
-      cur_source->includes = s;
-      cur_source = s;
-    }
-}
-
-/* Creates a source of the given TYPE.
-   Type-specific data must be initialized by the caller. */
-static struct getl_source *
-create_source (enum getl_source_type type) 
-{
-  struct getl_source *s = xmalloc (sizeof *s);
-  s->fn = NULL;
-  s->ln = 0;
-  s->type = type;
-  return s;
-}
-
-/* Creates a syntax file source with file name FN. */
-static struct getl_source *
-create_syntax_file_source (const char *fn) 
-{
-  struct getl_source *s = create_source (SYNTAX_FILE);
-  s->fn = xstrdup (fn);
-  s->u.syntax_file = NULL;
-  return s;
-}
-
-/* Creates a filter source with the given FILTER and CLOSE
-   functions that receive auxiliary data AUX. */
-static struct getl_source *
-create_filter_source (void (*filter) (struct string *, void *aux),
-                      void (*close) (void *aux),
-                      void *aux)
-{
-  struct getl_source *s = create_source (FILTER);
-  s->u.filter.filter = filter;
-  s->u.filter.close = close;
-  s->u.filter.aux = aux;
-  return s;
-}
-
-/* Creates a function source with the given READ and CLOSE
-   functions that receive auxiliary data AUX. */
-static struct getl_source *
-create_function_source (bool (*read) (struct string *line,
-                                      char **fn, int *ln, void *aux),
-                        void (*close) (void *aux),
-                        void *aux)
-{
-  struct getl_source *s = create_source (FUNCTION);
-  s->u.function.read = read;
-  s->u.function.close = close;
-  s->u.function.aux = aux;
-  return s;
-}
-
-/* Creates an interactive source with the given FUNCTION. */
-static struct getl_source *
-create_interactive_source (bool (*function) (struct string *line,
-                                             enum getl_prompt_style)) 
-{
-  struct getl_source *s = xmalloc (sizeof *s);
-  s->fn = NULL;
-  s->ln = 0;
-  s->type = INTERACTIVE;
-  s->u.interactive = function;
-  return s;
-}
-
-/* Adds FN to the tail end of the list of source files to
-   execute. */
-void
-getl_append_syntax_file (const char *fn)
-{
-  append_source (create_syntax_file_source (fn));
-}
-
-/* Inserts the given file with name FN into the current file
-   after the current line. */
-void
-getl_include_syntax_file (const char *fn)
-{
-  if (cur_source != NULL) 
-    {
-      char *found_fn = fn_search_path (fn, ds_cstr (&getl_include_path),
-                                       fn_dir_name (cur_source->fn));
-      if (found_fn != NULL) 
-        {
-          include_source (create_syntax_file_source (found_fn));
-          free (found_fn); 
-        }
-      else
-        msg (SE, _("Can't find `%s' in include file search path."), fn);
-    }
-  else 
-    getl_append_syntax_file (fn); 
-}
-
-/* Inserts the given filter into the current file after the
-   current line.  Each line read while the filter is in place
-   will be passed through FILTER, which may modify it as
-   necessary.  When the filter is closed, CLOSE will be called.
-   AUX will be passed to both functions.
-
-   The filter cannot itself output any new lines, and it will be
-   closed as soon as any line would be read from it.  This means
-   that, for a filter to be useful, another source must be nested
-   inside it with, e.g., getl_include_syntax_file(). */
-void
-getl_include_filter (void (*filter) (struct string *, void *aux),
-                     void (*close) (void *aux),
-                     void *aux) 
-{
-  include_source (create_filter_source (filter, close, aux));
-}
-
-/* Inserts the given functional source into the current file
-   after the current line.  Lines are read by calling READ, which
-   should write the next line in LINE, store the file name and
-   line number of the line in *FN and *LN, and return true.  The
-   string stored in *FN will not be freed by getl.  When no lines
-   are left, READ should return false.
-
-   When the source is closed, CLOSE will be called.
-
-   AUX will be passed to both READ and CLOSE. */
-void
-getl_include_function (bool (*read) (struct string *line,
-                                     char **fn, int *ln, void *aux),
-                       void (*close) (void *aux),
-                       void *aux) 
-{
-  include_source (create_function_source (read, close, aux));
-}
-
-/* Adds an interactive source to the end of the list of sources.
-   FUNCTION will be called to obtain a line.  It should store the
-   line in LINE.  PROMPT is the prompt to be displayed to the
-   user.  FUNCTION should return true when a line has been
-   obtained or false at end of file. */
-void
-getl_append_interactive (bool (*function) (struct string *line,
-                                           enum getl_prompt_style)) 
-{
-  append_source (create_interactive_source (function));
-}
-
-/* Closes all sources until an interactive source is
-   encountered. */
-void
-getl_abort_noninteractive (void) 
-{
-  while (cur_source != NULL && cur_source->type != INTERACTIVE)
-    close_source ();
-}
-
-/* Returns true if the current source is interactive,
-   false otherwise. */
-bool
-getl_is_interactive (void) 
-{
-  return cur_source != NULL && cur_source->type == INTERACTIVE;
-}
-
-/* Closes the current file, whether it be a main file or included
-   file, then moves cur_source to the next file in the chain. */
-static void
-close_source (void)
-{
-  struct getl_source *s;
-
-  s = cur_source;
-  switch (s->type) 
-    {
-    case SYNTAX_FILE:
-      if (s->u.syntax_file && EOF == fn_close (s->fn, s->u.syntax_file))
-        msg (MW, _("Closing `%s': %s."), s->fn, strerror (errno));
-      free (s->fn);
-      break;
-
-    case FILTER:
-      if (s->u.filter.close != NULL)
-        s->u.filter.close (s->u.filter.aux);
-      break;
-
-    case FUNCTION:
-      if (s->u.function.close != NULL)
-        s->u.function.close (s->u.function.aux);
-      break;
-
-    case INTERACTIVE:
-      break;
-    }
-
-  if (s->included_from != NULL)
-    {
-      cur_source = s->included_from;
-      cur_source->includes = NULL;
-    }
-  else
-    {
-      cur_source = s->next;
-      if (cur_source == NULL)
-	last_source = NULL;
-    }
-
-  free (s);
-}
-
-/* Puts the current file and line number in *FN and *LN, respectively,
-   or NULL and -1 if none. */
-void
-getl_location (const char **fn, int *ln)
-{
-  if (fn != NULL)
-    *fn = cur_source ? cur_source->fn : "";
-  if (ln != NULL)
-    *ln = cur_source ? cur_source->ln : -1;
-}
-
-/* File locator stack. */
-static const struct msg_locator **file_loc;
-
-static int nfile_loc, mfile_loc;
-
-/* Close getl. */
-void
-getl_uninitialize (void)
-{
-  while (cur_source != NULL)
-    close_source ();
-  ds_destroy (&getl_include_path);
-  free(file_loc);
-  file_loc = NULL;
-  nfile_loc = mfile_loc = 0;
-  uninit_prompts ();
-}
-
-
-/* File locator stack functions. */
-
-/* Pushes F onto the stack of file locations. */
-void
-msg_push_msg_locator (const struct msg_locator *loc)
-{
-  if (nfile_loc >= mfile_loc)
-    {
-      if (mfile_loc == 0)
-	mfile_loc = 8;
-      else
-	mfile_loc *= 2;
-
-      file_loc = xnrealloc (file_loc, mfile_loc, sizeof *file_loc);
-    }
-
-  file_loc[nfile_loc++] = loc;
-}
-
-/* Pops F off the stack of file locations.
-   Argument F is only used for verification that that is actually the
-   item on top of the stack. */
-void
-msg_pop_msg_locator (const struct msg_locator *loc)
-{
-  assert (nfile_loc >= 0 && file_loc[nfile_loc - 1] == loc);
-  nfile_loc--;
-}
-
-/* Puts the current file and line number into LOC, or NULL and -1 if
-   none. */
-void
-get_msg_location (struct msg_locator *loc)
-{
-  if (nfile_loc)
-    *loc = *file_loc[nfile_loc - 1];
-  else
-    getl_location (&loc->file_name, &loc->line_number);
-}
-
-/* Reads a line from syntax file source S into LINE.
-   Returns true if successful, false at end of file. */
-static bool
-read_syntax_file (struct string *line, struct getl_source *s)
-{
-  /* Open file, if not yet opened. */
-  if (s->u.syntax_file == NULL)
-    {
-      verbose_msg (1, _("opening \"%s\" as syntax file"), s->fn);
-      s->u.syntax_file = fn_open (s->fn, "r");
-
-      if (s->u.syntax_file == NULL)
-        {
-          msg (ME, _("Opening `%s': %s."), s->fn, strerror (errno));
-          return false;
-        }
-    }
-
-  /* Read line from file and remove new-line.
-     Skip initial "#! /usr/bin/pspp" line. */
-  do 
-    {
-      s->ln++;
-      if (!ds_read_line (line, s->u.syntax_file))
-        {
-          if (ferror (s->u.syntax_file))
-            msg (ME, _("Reading `%s': %s."), s->fn, strerror (errno));
-          return false;
-        }
-      ds_chomp (line, '\n');
-    }
-  while (s->ln == 1 && !memcmp (ds_cstr (line), "#!", 2));
-
-  /* Echo to listing file, if configured to do so. */
-  if (get_echo ())
-    tab_output_text (TAB_LEFT | TAB_FIX, ds_cstr (line));
-
-  return true;
-}
-
-/* Reads a line from source S into LINE.
-   Returns true if successful, false at end of file. */
-static bool
-read_line_from_source (struct string *line, struct getl_source *s)
-{
-  ds_clear (line);
-  switch (s->type) 
-    {
-    case SYNTAX_FILE:
-      return read_syntax_file (line, s);
-    case FILTER:
-      return false;
-    case FUNCTION:
-      return s->u.function.read (line, &s->fn, &s->ln, s->u.function.aux);
-    case INTERACTIVE:
-      return s->u.interactive (line, get_prompt_style ());
-    }
-
-  NOT_REACHED ();
-}
-
-/* Reads a single line into LINE.
-   Returns true when a line has been read, false at end of input.
-   If INTERACTIVE is non-null, then when true is returned
-   *INTERACTIVE will be set to true if the line was obtained
-   interactively, false otherwise. */
-bool
-do_read_line (struct string *line, bool *interactive)
-{
-  while (cur_source != NULL)
-    {
-      struct getl_source *s = cur_source;
-      if (read_line_from_source (line, s))
-        {
-          if (interactive != NULL)
-            *interactive = s->type == INTERACTIVE;
-
-          while ((s = s->included_from) != NULL)
-            if (s->type == FILTER)
-              s->u.filter.filter (line, s->u.filter.aux);
-
-          return true;
-        }
-      close_source ();
-    }
-
-  return false;
-}
-
-
-/* Current prompts in each style. */
-static char *prompts[GETL_PROMPT_CNT];
-
-/* Current prompting style. */
-static enum getl_prompt_style current_style;
-
-/* Initializes prompts. */
-static void
-init_prompts (void) 
-{
-  prompts[GETL_PROMPT_FIRST] = xstrdup ("PSPP> ");
-  prompts[GETL_PROMPT_LATER] = xstrdup ("    > ");
-  prompts[GETL_PROMPT_DATA] = xstrdup ("data> ");
-  current_style = GETL_PROMPT_FIRST;
-}
-
-/* Frees prompts. */
-static void
-uninit_prompts (void) 
-{
-  int i;
-
-  for (i = 0; i < GETL_PROMPT_CNT; i++) 
-    {
-      free (prompts[i]);
-      prompts[i] = NULL;
-    }
-}
-
-/* Gets the command prompt for the given STYLE. */
-const char * 
-getl_get_prompt (enum getl_prompt_style style)
-{
-  assert (style < GETL_PROMPT_CNT);
-  return prompts[style];
-}
-
-/* Sets the given STYLE's prompt to STRING. */
-void
-getl_set_prompt (enum getl_prompt_style style, const char *string)
-{
-  assert (style < GETL_PROMPT_CNT);
-  free (prompts[style]);
-  prompts[style] = xstrdup (string);
-}
-
-/* Sets STYLE as the current prompt style. */
-void
-getl_set_prompt_style (enum getl_prompt_style style) 
-{
-  assert (style < GETL_PROMPT_CNT);
-  current_style = style;
-}
-
-/* Returns the current prompt. */
-static enum getl_prompt_style
-get_prompt_style (void) 
-{
-  return current_style;
-}
Index: src/language/line-buffer.h
===================================================================
RCS file: src/language/line-buffer.h
diff -N src/language/line-buffer.h
--- src/language/line-buffer.h	28 Oct 2006 08:31:22 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-/* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
-
-   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 2 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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA. */
-
-#ifndef GETL_H
-#define GETL_H 1
-
-#include <stdbool.h>
-#include <libpspp/str.h>
-
-enum getl_prompt_style
-  {
-    GETL_PROMPT_FIRST,		/* First line of command. */
-    GETL_PROMPT_LATER,          /* Second or later line of command. */
-    GETL_PROMPT_DATA,		/* Between BEGIN DATA and END DATA. */
-    GETL_PROMPT_CNT
-  };
-
-
-void getl_initialize (void);
-void getl_uninitialize (void);
-
-void getl_clear_include_path (void);
-void getl_add_include_dir (const char *);
-
-void getl_append_syntax_file (const char *);
-void getl_include_syntax_file (const char *);
-void getl_include_filter (void (*filter) (struct string *, void *aux),
-                          void (*close) (void *aux),
-                          void *aux);
-void getl_include_function (bool (*read) (struct string *line,
-                                          char **fn, int *ln, void *aux),
-                            void (*close) (void *aux),
-                            void *aux);
-void getl_append_interactive (bool (*function) (struct string *line,
-                                                enum getl_prompt_style));
-void getl_abort_noninteractive (void);
-bool getl_is_interactive (void);
-
-bool getl_read_line (bool *interactive);
-
-const char *getl_get_prompt (enum getl_prompt_style);
-void getl_set_prompt (enum getl_prompt_style, const char *);
-void getl_set_prompt_style (enum getl_prompt_style);
-
-struct msg_locator;
-void get_msg_location (struct msg_locator *loc);
-
-void getl_location (const char **fn, int *ln);
-
-bool do_read_line (struct string *line, bool *interactive);
-
-
-#endif /* line-buffer.h */
Index: src/language/prompt.c
===================================================================
RCS file: src/language/prompt.c
diff -N src/language/prompt.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/prompt.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,101 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "prompt.h"
+
+#include <data/file-name.h>
+#include <data/settings.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/lexer/lexer.h>
+#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
+#include <libpspp/message.h>
+#include <libpspp/message.h>
+#include <libpspp/str.h>
+#include <libpspp/verbose-msg.h>
+#include <libpspp/version.h>
+#include <output/table.h>
+
+/* Current prompts in each style. */
+static char *prompts[GETL_PROMPT_CNT];
+
+/* Current prompting style. */
+static enum getl_prompt_style current_style;
+
+/* Initializes prompts. */
+void
+init_prompts (void) 
+{
+  prompts[GETL_PROMPT_FIRST] = xstrdup ("PSPP> ");
+  prompts[GETL_PROMPT_LATER] = xstrdup ("    > ");
+  prompts[GETL_PROMPT_DATA] = xstrdup ("data> ");
+  current_style = GETL_PROMPT_FIRST;
+}
+
+/* Frees prompts. */
+void
+uninit_prompts (void) 
+{
+  int i;
+
+  for (i = 0; i < GETL_PROMPT_CNT; i++) 
+    {
+      free (prompts[i]);
+      prompts[i] = NULL;
+    }
+}
+
+/* Gets the command prompt for the given STYLE. */
+const char * 
+getl_get_prompt (enum getl_prompt_style style)
+{
+  assert (style < GETL_PROMPT_CNT);
+  return prompts[style];
+}
+
+/* Sets the given STYLE's prompt to STRING. */
+void
+getl_set_prompt (enum getl_prompt_style style, const char *string)
+{
+  assert (style < GETL_PROMPT_CNT);
+  free (prompts[style]);
+  prompts[style] = xstrdup (string);
+}
+
+/* Sets STYLE as the current prompt style. */
+void
+getl_set_prompt_style (enum getl_prompt_style style) 
+{
+  assert (style < GETL_PROMPT_CNT);
+  current_style = style;
+}
+
+/* Returns the current prompt. */
+enum getl_prompt_style
+get_prompt_style (void) 
+{
+  return current_style;
+}
Index: src/language/prompt.h
===================================================================
RCS file: src/language/prompt.h
diff -N src/language/prompt.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/prompt.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,52 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#ifndef PROMPT_H
+#define PROMPT_H 1
+
+#include <stdbool.h>
+
+enum getl_prompt_style
+  {
+    GETL_PROMPT_FIRST,		/* First line of command. */
+    GETL_PROMPT_LATER,          /* Second or later line of command. */
+    GETL_PROMPT_DATA,		/* Between BEGIN DATA and END DATA. */
+    GETL_PROMPT_CNT
+  };
+
+
+void init_prompts (void);
+void uninit_prompts (void);
+
+struct string;
+
+void getl_append_interactive (bool (*function) (struct string *line,
+                                                enum getl_prompt_style));
+
+
+enum getl_prompt_style get_prompt_style (void);
+
+const char *getl_get_prompt (enum getl_prompt_style);
+void getl_set_prompt (enum getl_prompt_style, const char *);
+void getl_set_prompt_style (enum getl_prompt_style);
+
+
+
+
+#endif /* line-buffer.h */
Index: src/language/control/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/language/control/automake.mk,v
retrieving revision 1.2
diff -U3 -r1.2 automake.mk
--- src/language/control/automake.mk	15 Mar 2006 03:29:10 -0000	1.2
+++ src/language/control/automake.mk	17 Nov 2006 03:14:03 -0000
@@ -10,5 +10,9 @@
 	src/language/control/loop.c \
 	src/language/control/temporary.c \
 	src/language/control/repeat.c \
-	src/language/control/repeat.h
+	src/language/control/repeat.h \
+	src/language/control/lb-filter.c \
+	src/language/control/lb-filter.h \
+	src/language/control/lb-function.h \
+	src/language/control/lb-function.c
 
Index: src/language/control/lb-filter.c
===================================================================
RCS file: src/language/control/lb-filter.c
diff -N src/language/control/lb-filter.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/control/lb-filter.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,79 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <libpspp/line-buffer.h>
+
+#include <libpspp/alloc.h>
+#include <libpspp/compiler.h>
+
+#include "lb-filter.h"
+
+struct filter_source
+  {
+    struct getl_source parent ;
+
+    void (*filter) (struct string *line, void *aux) ;
+    void (*close) (void *aux) ;
+    void *aux ;
+  };
+
+static void
+filter_close (struct getl_source *s)
+{
+  struct filter_source *f = (struct filter_source *) s;
+
+  if (f->close != NULL)
+    f->close (f->aux);
+}
+
+static bool
+filter_read (struct getl_source *s UNUSED, struct string *line UNUSED)
+{
+  return false;
+}
+
+
+static void  
+filter_filter (struct getl_source *s, struct string *line)
+{
+  struct filter_source *f = (struct filter_source *) s;
+
+  f->filter (line, f->aux);
+}
+
+
+/* Creates a filter source with the given FILTER and CLOSE
+   functions that receive auxiliary data AUX. */
+struct getl_source *
+create_filter_source (void (*filter) (struct string *, void *aux),
+                      void (*close) (void *aux),
+                      void *aux)
+{
+  struct filter_source *f = xzalloc ( sizeof *f);
+
+  f->filter = filter;
+  f->close = close;
+  f->aux = aux;
+
+  f->parent.close = filter_close ;
+  f->parent.read = filter_read;
+  f->parent.filter = filter_filter;
+  
+  return  (struct getl_source *) f;
+}
Index: src/language/control/lb-filter.h
===================================================================
RCS file: src/language/control/lb-filter.h
diff -N src/language/control/lb-filter.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/control/lb-filter.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,32 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#if !LB_FILTER_H
+#define LB_FILTER_H 1
+
+struct string;
+struct getl_source;
+
+struct getl_source *
+create_filter_source (void (*filter) (struct string *, void *aux),
+                      void (*close) (void *aux),
+                      void *aux);
+
+#endif
+
Index: src/language/control/lb-function.c
===================================================================
RCS file: src/language/control/lb-function.c
diff -N src/language/control/lb-function.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/control/lb-function.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,97 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include "lb-function.h"
+#include <libpspp/line-buffer.h>
+
+#include <libpspp/alloc.h>
+
+struct function_source
+  {
+    struct getl_source parent ;  
+
+    int ln; 
+    char *fn;
+    
+    bool (*read) (struct string *line, char **fn, int *ln, void *aux);
+    void (*close) (void *aux);
+    void *aux;
+  };
+
+
+static const char *
+name (const struct getl_source *s)
+{
+  const struct function_source *f = (const struct function_source *) s;
+  
+  return f->fn;
+}
+
+
+static int
+line_number (const struct getl_source *s)
+{
+  const struct function_source *f = (const struct function_source *) s;
+  
+  return f->ln;
+}
+
+
+
+
+static bool
+read_function (struct getl_source *s, struct string *line)
+{
+  struct function_source *f = (struct function_source *) s;
+
+  return f->read (line, &f->fn, &f->ln, f->aux);
+}
+
+static void
+function_close (struct getl_source *s)
+{
+  struct function_source *f = (struct function_source *) s;
+
+  if (f->close != NULL)
+    f->close (f->aux);
+}
+
+/* Creates a function source with the given READ and CLOSE
+   functions that receive auxiliary data AUX. */
+struct getl_source *
+create_function_source (bool (*read) (struct string *line,
+                                      char **fn, int *ln, void *aux),
+                        void (*close) (void *aux),
+                        void *aux)
+{
+  struct function_source *f = xzalloc ( sizeof *f);
+
+  f->read = read;
+  f->close = close;
+  f->aux = aux;
+
+  f->parent.read = read_function;
+  f->parent.close = function_close;
+
+  f->parent.name = name;
+  f->parent.location = line_number;
+  
+  return (struct getl_source *) f;
+}
+
Index: src/language/control/lb-function.h
===================================================================
RCS file: src/language/control/lb-function.h
diff -N src/language/control/lb-function.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/language/control/lb-function.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,35 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#if !LB_FUNCTION
+#define LB_FUNCTION 1
+
+#include  <stdbool.h>
+
+
+struct string;
+struct getl_source;
+
+struct getl_source *
+create_function_source ( bool (*read) (struct string *line,
+                                      char **fn, int *ln, void *aux),
+                        void (*close) (void *aux),
+                        void *aux);
+
+#endif
Index: src/language/control/repeat.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/control/repeat.c,v
retrieving revision 1.15
diff -U3 -r1.15 repeat.c
--- src/language/control/repeat.c	11 Nov 2006 23:10:00 -0000	1.15
+++ src/language/control/repeat.c	17 Nov 2006 03:14:03 -0000
@@ -25,16 +25,18 @@
 #include <math.h>
 #include <stdlib.h>
 
+#include "lb-filter.h"
+#include "lb-function.h"
+
 #include <data/dictionary.h>
 #include <data/procedure.h>
 #include <data/settings.h>
+#include <libpspp/line-buffer.h>
 #include <language/command.h>
 #include <language/lexer/lexer.h>
 #include <language/lexer/variable-parser.h>
-#include <language/line-buffer.h>
 #include <libpspp/alloc.h>
 #include <libpspp/message.h>
-#include <libpspp/message.h>
 #include <libpspp/misc.h>
 #include <libpspp/pool.h>
 #include <libpspp/str.h>
@@ -111,8 +113,11 @@
   
   block->cur_line = NULL;
   block->loop_idx = -1;
-  getl_include_filter (do_repeat_filter, do_repeat_close, block);
-  getl_include_function (do_repeat_read, NULL, block);
+
+  getl_include_source (create_filter_source (do_repeat_filter, 
+					     do_repeat_close, block));
+
+  getl_include_source (create_function_source (do_repeat_read, NULL, block));
 
   return CMD_SUCCESS;
 
@@ -288,7 +293,6 @@
         return false;
 
       /* If the current file has changed then record the fact. */
-      getl_location (&cur_file_name, &cur_line_number);
       if (previous_file_name == NULL 
           || !strcmp (cur_file_name, previous_file_name))
         previous_file_name = pool_strdup (block->pool, cur_file_name);
Index: src/language/data-io/data-reader.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/data-io/data-reader.c,v
retrieving revision 1.16
diff -U3 -r1.16 data-reader.c
--- src/language/data-io/data-reader.c	11 Nov 2006 23:10:00 -0000	1.16
+++ src/language/data-io/data-reader.c	17 Nov 2006 03:14:03 -0000
@@ -32,7 +32,8 @@
 #include <language/command.h>
 #include <language/data-io/file-handle.h>
 #include <language/lexer/lexer.h>
-#include <language/line-buffer.h>
+#include <libpspp/line-buffer.h>
+#include <language/prompt.h>
 #include <libpspp/alloc.h>
 #include <libpspp/assertion.h>
 #include <libpspp/message.h>
Index: src/language/data-io/file-handle.q
===================================================================
RCS file: /sources/pspp/pspp/src/language/data-io/file-handle.q,v
retrieving revision 1.9
diff -U3 -r1.9 file-handle.q
--- src/language/data-io/file-handle.q	11 Nov 2006 23:10:00 -0000	1.9
+++ src/language/data-io/file-handle.q	17 Nov 2006 03:14:03 -0000
@@ -26,7 +26,6 @@
 #include <data/file-name.h>
 #include <language/command.h>
 #include <language/lexer/lexer.h>
-#include <language/line-buffer.h>
 #include <libpspp/assertion.h>
 #include <libpspp/message.h>
 #include <libpspp/magic.h>
Index: src/language/lexer/lexer.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/lexer/lexer.c,v
retrieving revision 1.13
diff -U3 -r1.13 lexer.c
--- src/language/lexer/lexer.c	14 Nov 2006 12:29:25 -0000	1.13
+++ src/language/lexer/lexer.c	17 Nov 2006 03:14:03 -0000
@@ -30,9 +30,9 @@
 #include <libpspp/assertion.h>
 #include <language/command.h>
 #include <libpspp/message.h>
-#include <language/line-buffer.h>
 #include <libpspp/magic.h>
 #include <data/settings.h>
+#include <libpspp/line-buffer.h>
 #include <libpspp/str.h>
 
 #include "size_max.h"
Index: src/language/utilities/include.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/utilities/include.c,v
retrieving revision 1.6
diff -U3 -r1.6 include.c
--- src/language/utilities/include.c	11 Nov 2006 23:10:00 -0000	1.6
+++ src/language/utilities/include.c	17 Nov 2006 03:14:03 -0000
@@ -23,9 +23,12 @@
 #include <libpspp/alloc.h>
 #include <language/command.h>
 #include <libpspp/message.h>
-#include <language/line-buffer.h>
+#include <libpspp/line-buffer.h>
+#include <language/lb-syntax-file.h>
 #include <language/lexer/lexer.h>
 #include <libpspp/str.h>
+#include <data/file-name.h>
+
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -33,6 +36,9 @@
 int
 cmd_include (struct lexer *lexer, struct dataset *ds UNUSED)
 {
+  char *found_fn;
+  char *target_fn;
+
   /* Skip optional FILE=. */
   if (lex_match_id (lexer, "FILE"))
     lex_match (lexer, '=');
@@ -43,7 +49,21 @@
       lex_error (lexer, _("expecting file name")); 
       return CMD_CASCADING_FAILURE;
     }
-  getl_include_syntax_file (ds_cstr (lex_tokstr (lexer)));
+
+  target_fn = ds_cstr (lex_tokstr (lexer));
+
+  found_fn = fn_search_path (target_fn,
+			     getl_include_path (),
+			     NULL);
+
+  if (found_fn != NULL) 
+    {
+      getl_include_source (create_syntax_file_source (found_fn));
+      free (found_fn); 
+    }
+  else
+    msg (SE, _("Can't find `%s' in include file search path."), 
+	 target_fn);
 
   lex_get (lexer);
   return lex_end_of_command (lexer);
Index: src/language/utilities/set.q
===================================================================
RCS file: /sources/pspp/pspp/src/language/utilities/set.q,v
retrieving revision 1.19
diff -U3 -r1.19 set.q
--- src/language/utilities/set.q	11 Nov 2006 23:10:01 -0000	1.19
+++ src/language/utilities/set.q	17 Nov 2006 03:14:03 -0000
@@ -33,7 +33,7 @@
 #include <language/command.h>
 #include <language/lexer/format-parser.h>
 #include <language/lexer/lexer.h>
-#include <language/line-buffer.h>
+#include <language/prompt.h>
 #include <libpspp/alloc.h>
 #include <libpspp/compiler.h>
 #include <libpspp/copyleft.h>
Index: src/libpspp/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/automake.mk,v
retrieving revision 1.15
diff -U3 -r1.15 automake.mk
--- src/libpspp/automake.mk	28 Oct 2006 04:01:55 -0000	1.15
+++ src/libpspp/automake.mk	17 Nov 2006 03:14:03 -0000
@@ -25,6 +25,10 @@
 	src/libpspp/i18n.h \
 	src/libpspp/integer-format.c \
 	src/libpspp/integer-format.h \
+	src/libpspp/line-buffer.h \
+	src/libpspp/line-buffer.c \
+	src/libpspp/msg-locator.c \
+	src/libpspp/msg-locator.h \
 	src/libpspp/ll.c \
 	src/libpspp/ll.h \
 	src/libpspp/llx.c \
Index: src/libpspp/line-buffer.c
===================================================================
RCS file: src/libpspp/line-buffer.c
diff -N src/libpspp/line-buffer.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/libpspp/line-buffer.c	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,212 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <stdlib.h>
+
+#include <config.h>
+
+#include "line-buffer.h"
+
+#include <libpspp/str.h>
+#include <libpspp/ll.h>
+#include <libpspp/version.h>
+
+#include <data/file-name.h>
+
+/* List of source files. */
+static struct ll_list sources ;
+
+static struct string the_include_path;
+
+const char *
+getl_include_path (void)
+{
+  return ds_cstr (&the_include_path);
+}
+
+static struct getl_source *
+current_source (struct ll_list *list)
+{
+  const struct ll *ll = ll_head (list);
+  return ll_data (ll, struct getl_source, ll );
+}
+
+/* Initialize getl. */
+void
+getl_initialize (void)
+{
+  ll_init (&sources);
+  ds_init_cstr (&the_include_path,
+                fn_getenv_default ("STAT_INCLUDE_PATH", include_path));
+}
+
+/* Delete everything from the include path. */
+void
+getl_clear_include_path (void)
+{
+  ds_clear (&the_include_path);
+}
+
+/* Add to the include path. */
+void
+getl_add_include_dir (const char *path)
+{
+  if (ds_length (&the_include_path))
+    ds_put_char (&the_include_path, ':');
+
+  ds_put_cstr (&the_include_path, path);
+}
+
+/* Appends source S to the list of source files. */
+void
+getl_append_source (struct getl_source *s) 
+{
+  ll_push_head (&sources, &s->ll);
+}
+
+/* Nests source S within the current source file. */
+void
+getl_include_source (struct getl_source *s) 
+{
+  struct getl_source *current = current_source (&sources);
+
+  s->included_from = current ;
+  s->includes  = NULL;
+  current->includes = s;
+
+  getl_append_source (s);
+}
+
+/* Closes the current source, and move  the current source to the 
+   next file in the chain. */
+static void
+close_source (void)
+{
+  struct getl_source *s = current_source (&sources);
+
+  if ( s->close ) 
+    s->close (s);
+
+  ll_pop_head (&sources);
+
+  if (s->included_from != NULL)
+    current_source (&sources)->includes = NULL;
+
+  free (s);
+}
+
+/* Closes all sources until an interactive source is
+   encountered. */
+void
+getl_abort_noninteractive (void) 
+{
+  while ( ! ll_is_empty (&sources))
+    {
+      const struct getl_source *s = current_source (&sources);
+      
+      if ( !s->interactive ) 
+	close_source ();
+    }
+}
+
+/* Returns true if the current source is interactive,
+   false otherwise. */
+bool
+getl_is_interactive (void) 
+{
+  const struct getl_source *s = current_source (&sources);
+
+  if (ll_is_empty (&sources) ) 
+    return false;
+
+  return s->interactive;
+}
+
+/* Returns the name of the current source, or NULL if there is no 
+   current source */
+const char *
+getl_source_name (void)
+{
+  const struct getl_source *s = current_source (&sources);
+
+  if ( ll_is_empty (&sources) )
+    return NULL;
+
+  if ( ! s->name ) 
+    return NULL;
+
+  return s->name (s);
+}
+
+/* Returns the location within the current source, or -1 if there is
+   no current source */
+int
+getl_source_location (void)
+{
+  const struct getl_source *s = current_source (&sources);
+
+  if ( ll_is_empty (&sources) )
+    return -1;
+
+  if ( !s->location )
+    return -1;
+
+  return s->location (s);
+}
+
+
+/* Close getl. */
+void
+getl_uninitialize (void)
+{
+  while ( !ll_is_empty (&sources))
+    close_source ();
+  ds_destroy (&the_include_path);
+}
+
+
+/* Reads a single line into LINE.
+   Returns true when a line has been read, false at end of input.
+   If INTERACTIVE is non-null, then when true is returned
+   *INTERACTIVE will be set to true if the line was obtained
+   interactively, false otherwise. */
+bool
+do_read_line (struct string *line, bool *interactive)
+{
+  while (!ll_is_empty (&sources))
+    {
+      struct getl_source *s = current_source (&sources);
+
+      ds_clear (line);
+      if (s->read (s, line))
+        {
+          if (interactive != NULL)
+            *interactive = s->interactive;
+
+          while ((s = s->included_from) != NULL)
+            if (s->filter)
+	      s->filter (s, line);
+
+          return true;
+        }
+      close_source ();
+    }
+
+  return false;
+}
Index: src/libpspp/line-buffer.h
===================================================================
RCS file: src/libpspp/line-buffer.h
diff -N src/libpspp/line-buffer.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/libpspp/line-buffer.h	17 Nov 2006 03:14:03 -0000
@@ -0,0 +1,66 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#ifndef GETL_H
+#define GETL_H 1
+
+#include <stdbool.h>
+#include <libpspp/ll.h>
+
+struct string; 
+
+/* Source file. */
+struct getl_source
+  {
+    struct getl_source *included_from;	/* File that this is nested inside. */
+    struct getl_source *includes;	/* File nested inside this file. */
+    
+    struct ll  ll;   /* Element in the sources list */
+
+    bool interactive ; 
+
+    bool  (*read)  (struct getl_source *, struct string *);
+    void  (*close) (struct getl_source *);
+    void  (*filter) (struct getl_source *, struct string *line);
+
+    const char * (*name) (const struct getl_source *);
+    int (*location) (const struct getl_source *);
+  };
+
+void getl_initialize (void);
+void getl_uninitialize (void);
+
+void getl_clear_include_path (void);
+void getl_add_include_dir (const char *);
+const char * getl_include_path (void);
+
+void getl_abort_noninteractive (void);
+bool getl_is_interactive (void);
+
+bool getl_read_line (bool *interactive);
+
+bool do_read_line (struct string *line, bool *interactive);
+
+void getl_append_source (struct getl_source *s) ;
+void getl_include_source (struct getl_source *s) ;
+
+const char * getl_source_name (void);
+int getl_source_location (void);
+
+#endif /* line-buffer.h */
Index: src/libpspp/message.c
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/message.c,v
retrieving revision 1.6
diff -U3 -r1.6 message.c
--- src/libpspp/message.c	18 Jul 2006 04:57:01 -0000	1.6
+++ src/libpspp/message.c	17 Nov 2006 03:14:03 -0000
@@ -19,7 +19,8 @@
 
 #include <config.h>
 
-#include <libpspp/message.h>
+#include "message.h"
+#include "msg-locator.h"
 
 #include <assert.h>
 #include <stdarg.h>
@@ -39,8 +40,6 @@
 
 /* Message handler as set by msg_init(). */
 static void (*msg_handler)  (const struct msg *);
-static void (*msg_location) (struct msg_locator *);
-
 
 /* Disables emitting messages if positive. */
 static int messages_disabled;
@@ -65,11 +64,9 @@
 }
 
 void
-msg_init ( void (*handler) (const struct msg *), 
-	   void (*location) (struct msg_locator *) ) 
+msg_init ( void (*handler) (const struct msg *) )
 {
   msg_handler = handler;
-  msg_location = location;
 }
 
 void
@@ -102,7 +99,7 @@
 void
 msg_emit (struct msg *m) 
 {
-  msg_location (&m->where);
+  get_msg_location (&m->where);
   if (!messages_disabled)
     msg_handler (m);
   free (m->text);
Index: src/libpspp/message.h
===================================================================
RCS file: /sources/pspp/pspp/src/libpspp/message.h,v
retrieving revision 1.13
diff -U3 -r1.13 message.h
--- src/libpspp/message.h	18 Jul 2006 04:57:01 -0000	1.13
+++ src/libpspp/message.h	17 Nov 2006 03:14:04 -0000
@@ -86,8 +86,7 @@
   };
 
 /* Initialization. */
-void msg_init ( void (*handler) (const struct msg *), 
-		void (*location) (struct msg_locator *) ) ;
+void msg_init ( void (*handler) (const struct msg *) );
 
 void msg_done (void);
 
Index: src/libpspp/msg-locator.c
===================================================================
RCS file: src/libpspp/msg-locator.c
diff -N src/libpspp/msg-locator.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/libpspp/msg-locator.c	17 Nov 2006 03:14:04 -0000
@@ -0,0 +1,85 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+#include <config.h>
+#include <stdlib.h>
+#include <libpspp/alloc.h>
+#include "msg-locator.h"
+#include <libpspp/message.h>
+#include <libpspp/assertion.h>
+#include "line-buffer.h"
+
+/* File locator stack. */
+static const struct msg_locator **file_loc;
+
+static int nfile_loc, mfile_loc;
+
+void
+msg_locator_done (void)
+{
+  free(file_loc);
+  file_loc = NULL;
+  nfile_loc = mfile_loc = 0;
+}
+
+
+/* File locator stack functions. */
+
+/* Pushes F onto the stack of file locations. */
+void
+msg_push_msg_locator (const struct msg_locator *loc)
+{
+  if (nfile_loc >= mfile_loc)
+    {
+      if (mfile_loc == 0)
+	mfile_loc = 8;
+      else
+	mfile_loc *= 2;
+
+      file_loc = xnrealloc (file_loc, mfile_loc, sizeof *file_loc);
+    }
+
+  file_loc[nfile_loc++] = loc;
+}
+
+/* Pops F off the stack of file locations.
+   Argument F is only used for verification that that is actually the
+   item on top of the stack. */
+void
+msg_pop_msg_locator (const struct msg_locator *loc)
+{
+  assert (nfile_loc >= 0 && file_loc[nfile_loc - 1] == loc);
+  nfile_loc--;
+}
+
+/* Puts the current file and line number into LOC, or NULL and -1 if
+   none. */
+void
+get_msg_location (struct msg_locator *loc)
+{
+  if (nfile_loc)
+    {
+      *loc = *file_loc[nfile_loc - 1];
+    }
+  else
+    {
+      loc->file_name = getl_source_name ();
+      loc->line_number = getl_source_location ();
+    }
+}
Index: src/libpspp/msg-locator.h
===================================================================
RCS file: src/libpspp/msg-locator.h
diff -N src/libpspp/msg-locator.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/libpspp/msg-locator.h	17 Nov 2006 03:14:04 -0000
@@ -0,0 +1,36 @@
+/* PSPP - computes sample statistics.
+   Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+   Written by Ben Pfaff <blp@gnu.org>.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
+
+struct msg_locator ;
+
+void msg_locator_done (void);
+
+/* File locator stack functions. */
+
+/* Pushes F onto the stack of file locations. */
+void msg_push_msg_locator (const struct msg_locator *loc);
+
+/* Pops F off the stack of file locations.
+   Argument F is only used for verification that that is actually the
+   item on top of the stack. */
+void msg_pop_msg_locator (const struct msg_locator *loc);
+
+/* Puts the current file and line number into LOC, or NULL and -1 if
+   none. */
+void get_msg_location (struct msg_locator *loc);
Index: src/ui/gui/message-dialog.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/message-dialog.c,v
retrieving revision 1.14
diff -U3 -r1.14 message-dialog.c
--- src/ui/gui/message-dialog.c	4 Jul 2006 04:39:05 -0000	1.14
+++ src/ui/gui/message-dialog.c	17 Nov 2006 03:14:04 -0000
@@ -29,6 +29,7 @@
 #define N_(msgid) msgid
 
 #include <libpspp/message.h>
+#include <libpspp/msg-locator.h>
 #include "message-dialog.h"
 #include "progname.h"
 
@@ -49,22 +50,13 @@
 static GQueue *message_queue;
 
 
-static void 
-msg_location (struct msg_locator *loc)
-{
-  loc->file_name = NULL; 
-  loc->line_number = -1;
-}
-
-
 void
 message_dialog_init (void) 
 {
   message_queue = g_queue_new();
-  msg_init (enqueue_msg, msg_location);
+  msg_init (enqueue_msg);
 }
 
-
 void
 message_dialog_done (void)
 {
Index: src/ui/gui/psppire.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire.c,v
retrieving revision 1.19
diff -U3 -r1.19 psppire.c
--- src/ui/gui/psppire.c	3 Nov 2006 04:53:52 -0000	1.19
+++ src/ui/gui/psppire.c	17 Nov 2006 03:14:04 -0000
@@ -27,6 +27,7 @@
 #include <libpspp/copyleft.h>
 #include <data/format.h>
 #include <data/settings.h>
+#include <libpspp/line-buffer.h>
 
 #include <getopt.h>
 #include <gtk/gtk.h>
@@ -113,11 +114,9 @@
 
   glade_init();
 
-
-
   fmt_init();
   settings_init();
-
+  getl_initialize ();
   message_dialog_init();
 
   the_dictionary = psppire_dict_new();
@@ -169,6 +168,7 @@
   /* start the event loop */
   gtk_main();
 
+  getl_uninitialize ();
   message_dialog_done();
 
   settings_done();
Index: src/ui/terminal/command-line.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/command-line.c,v
retrieving revision 1.7
diff -U3 -r1.7 command-line.c
--- src/ui/terminal/command-line.c	7 Nov 2006 12:59:59 -0000	1.7
+++ src/ui/terminal/command-line.c	17 Nov 2006 03:14:04 -0000
@@ -30,12 +30,14 @@
 #include <libpspp/assertion.h>
 #include <libpspp/copyleft.h>
 #include <libpspp/message.h>
-#include <language/line-buffer.h>
+#include <language/lb-interactive.h>
+#include <language/lb-syntax-file.h>
 #include "progname.h"
 #include <data/settings.h>
 #include "read-line.h"
 #include <output/output.h>
 #include <data/file-name.h>
+#include <libpspp/line-buffer.h>
 #include <libpspp/str.h>
 #include <libpspp/version.h>
 #include <libpspp/verbose-msg.h>
@@ -194,7 +196,8 @@
       char *pspprc_fn = fn_search_path ("rc", config_path, NULL);
       if (pspprc_fn != NULL) 
         {
-          getl_append_syntax_file (pspprc_fn);
+	  getl_append_source (create_syntax_file_source (pspprc_fn));
+
           free (pspprc_fn); 
         }
     }
@@ -204,12 +207,12 @@
       outp_configure_macro (argv[i]);
     else 
       {
-        getl_append_syntax_file (argv[i]);
+	getl_append_source (create_syntax_file_source (argv[i]));
         syntax_files++;
       }
 
   if (!syntax_files || interactive_mode)
-    getl_append_interactive (readln_read);
+    getl_append_source (create_interactive_source (readln_read));
 
   return true;
 }
Index: src/ui/terminal/main.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/main.c,v
retrieving revision 1.22
diff -U3 -r1.22 main.c
--- src/ui/terminal/main.c	16 Nov 2006 12:47:22 -0000	1.22
+++ src/ui/terminal/main.c	17 Nov 2006 03:14:04 -0000
@@ -28,8 +28,10 @@
 #include "progname.h"
 #include "read-line.h"
 
+
 #include <data/dictionary.h>
 #include <data/file-handle-def.h>
+#include <libpspp/line-buffer.h>
 #include <data/file-name.h>
 #include <data/format.h>
 #include <data/procedure.h>
@@ -38,7 +40,7 @@
 #include <gsl/gsl_errno.h>
 #include <language/command.h>
 #include <language/lexer/lexer.h>
-#include <language/line-buffer.h>
+#include <language/prompt.h>
 #include <libpspp/compiler.h>
 #include <libpspp/message.h>
 #include <libpspp/version.h>
@@ -94,6 +96,7 @@
   fn_init ();
   fh_init ();
   getl_initialize ();
+  init_prompts ();
   readln_initialize ();
   settings_init ();
   random_init ();
@@ -194,6 +197,7 @@
       fh_done ();
       lex_destroy (the_lexer);
       getl_uninitialize ();
+      uninit_prompts ();
       readln_uninitialize ();
 
       outp_done ();
Index: src/ui/terminal/msg-ui.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/msg-ui.c,v
retrieving revision 1.5
diff -U3 -r1.5 msg-ui.c
--- src/ui/terminal/msg-ui.c	7 Nov 2006 12:59:59 -0000	1.5
+++ src/ui/terminal/msg-ui.c	17 Nov 2006 03:14:04 -0000
@@ -24,10 +24,14 @@
 #include "exit.h"
 #include "linebreak.h"
 
-#include <language/line-buffer.h>
+#include <libpspp/msg-locator.h>
+#include <libpspp/line-buffer.h>
 #include <data/settings.h>
 #include <libpspp/message.h>
+#include <libpspp/str.h>
 #include <errno.h>
+#include <stdio.h>
+
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -65,7 +69,7 @@
 	  msg_file = stdout;
 	}
     }
-  msg_init (handle_msg, get_msg_location);
+  msg_init (handle_msg);
 }
 
 void
Index: src/ui/terminal/read-line.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/terminal/read-line.h,v
retrieving revision 1.3
diff -U3 -r1.3 read-line.h
--- src/ui/terminal/read-line.h	28 Jun 2006 05:49:03 -0000	1.3
+++ src/ui/terminal/read-line.h	17 Nov 2006 03:14:04 -0000
@@ -21,7 +21,7 @@
 #define READLN_H
 
 #include <libpspp/str.h>
-#include <language/line-buffer.h>
+#include <language/prompt.h>
 
 void readln_initialize (void);
 void readln_uninitialize (void);
