? diffs
? lex.patch
? x.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/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/formats/inexactify
? tests/libpspp/.deps
? tests/libpspp/.dirstamp
? tests/libpspp/ll-test
? tests/libpspp/llx-test
Index: src/language/lexer/lexer.c
===================================================================
RCS file: /sources/pspp/pspp/src/language/lexer/lexer.c,v
retrieving revision 1.16
diff -b -w -U5 -r1.16 lexer.c
--- src/language/lexer/lexer.c	5 Dec 2006 11:27:42 -0000	1.16
+++ src/language/lexer/lexer.c	8 Dec 2006 22:29:22 -0000
@@ -1,7 +1,7 @@
 /* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+   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
@@ -39,13 +39,13 @@
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
-/*
-#define DUMP_TOKENS 1
-*/
+
+#define DUMP_TOKENS 0
+
 
 struct lexer 
 {
   struct string line_buffer;
 
@@ -60,11 +60,10 @@
   			    For T_ID, this is not truncated as is 
   			    tokid. */
 
   char *prog; /* Pointer to next token in line_buffer. */
   bool dot;   /* True only if this line ends with a terminal dot. */
-  bool eof;   /* True only if the last token returned was T_STOP. */
 
   int put_token ; /* If nonzero, next token returned by lex_get().
   		    Used only in exceptional circumstances. */
   
   struct string put_tokstr;
@@ -84,11 +83,11 @@
   };
 
 static int parse_string (struct lexer *, enum string_type);
 
 #if DUMP_TOKENS
-static void dump_token (void);
+static void dump_token (struct lexer *);
 #endif
 
 /* Initialization. */
 
 /* Initializes the lexer. */
@@ -100,13 +99,10 @@
   ds_init_empty (&lexer->tokstr);
   ds_init_empty (&lexer->put_tokstr);
   ds_init_empty (&lexer->line_buffer);
   lexer->ss = ss;
 
-  if (!lex_get_line (lexer))
-    lexer->eof = true;
-
   return lexer;
 }
 
 struct source_stream *
 lex_get_source_stream (const struct lexer *lex)
@@ -157,61 +153,62 @@
 /* Parses a single token, setting appropriate global variables to
    indicate the token's attributes. */
 void
 lex_get (struct lexer *lexer)
 {
+  /* Find a token. */
+  for (;;)
+    {
+      if (NULL == lexer->prog && ! lex_get_line (lexer) )
+	{
+	  lexer->token = T_STOP;
+	  return;
+	}
+
   /* If a token was pushed ahead, return it. */
   if (lexer->put_token)
     {
       restore_token (lexer);
 #if DUMP_TOKENS
-      dump_token ();
+	  dump_token (lexer);
 #endif
       return;
     }
 
-  /* Find a token. */
   for (;;)
     {
       /* Skip whitespace. */
-      if (lexer->eof) 
-        {
-          lexer->token = T_STOP;
-          return;
-        }
-
-      for (;;)
-	{
 	  while (isspace ((unsigned char) *lexer->prog))
 	    lexer->prog++;
+
 	  if (*lexer->prog)
 	    break;
 
 	  if (lexer->dot)
 	    {
 	      lexer->dot = 0;
 	      lexer->token = '.';
 #if DUMP_TOKENS
-	      dump_token ();
+	      dump_token (lexer);
 #endif
 	      return;
 	    }
 	  else if (!lex_get_line (lexer))
 	    {
-	      lexer->eof = true;
+	      lexer->prog = NULL;
 	      lexer->token = T_STOP;
 #if DUMP_TOKENS
-	      dump_token ();
+	      dump_token (lexer);
 #endif
 	      return;
 	    }
 
 	  if (lexer->put_token)
 	    {
               restore_token (lexer);
 #if DUMP_TOKENS
-	      dump_token ();
+	      dump_token (lexer);
 #endif
 	      return;
 	    }
 	}
 
@@ -384,11 +381,11 @@
         }
       break;
     }
 
 #if DUMP_TOKENS
-  dump_token ();
+  dump_token (lexer);
 #endif
 }
 
 /* Parses an identifier at the current position into tokid and
    tokstr.
@@ -658,11 +655,11 @@
   if (lexer->put_token)
     return lexer->put_token;
 
   for (;;)
     {
-      if (lexer->eof)
+      if (NULL == lexer->prog && ! lex_get_line (lexer) )
         return 0;
 
       for (;;)
 	{
 	  while (isspace ((unsigned char) *lexer->prog))
@@ -862,14 +859,18 @@
 {
   bool line_starts_command;
   enum getl_syntax syntax;
 
   if (!lex_get_line_raw (lexer, &syntax))
+    {
+      lexer->prog = NULL;
     return false;
+    }
 
   lex_preprocess_line (&lexer->line_buffer, syntax,
                        &line_starts_command, &lexer->dot);
+
   if (line_starts_command)
     lexer->put_token = '.';
 
   lexer->prog = ds_cstr (&lexer->line_buffer);
   return true;
@@ -990,11 +991,11 @@
   for (;;)
     {
       if (!lex_get_line (lexer)) 
         {
           lexer->put_token = T_STOP;
-          lexer->eof = true;
+	  lexer->prog = NULL;
           return;
         }
       
       if (lexer->put_token == '.')
 	break;
@@ -1124,11 +1125,11 @@
 	  ds_put_char (&lexer->tokstr, *lexer->prog++);
 	}
       lexer->prog++;
 
       /* Skip whitespace after final quote mark. */
-      if (lexer->eof)
+      if (lexer->prog == NULL)
 	break;
       for (;;)
 	{
 	  while (isspace ((unsigned char) *lexer->prog))
 	    lexer->prog++;
@@ -1146,11 +1147,11 @@
       if (*lexer->prog != '+')
 	break;
       lexer->prog++;
 
       /* Skip whitespace after plus sign. */
-      if (lexer->eof)
+      if (lexer->prog == NULL)
 	break;
       for (;;)
 	{
 	  while (isspace ((unsigned char) *lexer->prog))
 	    lexer->prog++;
@@ -1199,11 +1200,12 @@
 {
   {
     const char *curfn;
     int curln;
 
-    getl_location (&curfn, &curln);
+    curln = getl_source_location (lexer->ss);
+    curfn = getl_source_name (lexer->ss);
     if (curfn)
       fprintf (stderr, "%s:%d\t", curfn, curln);
   }
   
   switch (lexer->token)
@@ -1232,12 +1234,12 @@
     case 0:
       fprintf (stderr, "MISC\tEOF\n");
       break;
 
     default:
-      if (lex_is_keyword (token))
-	fprintf (stderr, "KEYWORD\t%s\n", lex_token_name (token));
+      if (lex_is_keyword (lexer->token))
+	fprintf (stderr, "KEYWORD\t%s\n", lex_token_name (lexer->token));
       else
 	fprintf (stderr, "PUNCT\t%c\n", lexer->token);
       break;
     }
 }
