guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-14-76-g6d


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-14-76-g6d6b2d4
Date: Fri, 21 Jan 2011 08:20:14 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=6d6b2d4fcd3fa1cf5f5d0be7cf6f35cb7287a682

The branch, master has been updated
       via  6d6b2d4fcd3fa1cf5f5d0be7cf6f35cb7287a682 (commit)
       via  c869f0c15712830d232513a462c6f66446ca9a71 (commit)
       via  684d664e39dad02f7a44f1c70a753a02d4d1856c (commit)
      from  b04f841d5fa6d3448bb8f976bb27ee3e9a06f83c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6d6b2d4fcd3fa1cf5f5d0be7cf6f35cb7287a682
Author: Andy Wingo <address@hidden>
Date:   Fri Jan 21 09:23:06 2011 +0100

    update NEWS for hungry-eol-escapes
    
    * NEWS: Update for hungry-eol-escapes.

commit c869f0c15712830d232513a462c6f66446ca9a71
Author: Andy Wingo <address@hidden>
Date:   Fri Jan 21 09:21:15 2011 +0100

    document hungry-eol-escapes
    
    * doc/ref/api-data.texi (String Syntax): Document hungry-eol-escapes.
    * doc/ref/api-evaluation.texi (Scheme Read):
    * doc/ref/api-options.texi (Runtime Options): Update read-options 'help
      output.

commit 684d664e39dad02f7a44f1c70a753a02d4d1856c
Author: Andy Wingo <address@hidden>
Date:   Fri Jan 21 08:57:39 2011 +0100

    implement r6rs hungry escaped EOL
    
    * libguile/private-options.h (SCM_HUNGRY_EOL_ESCAPES_P): New private
      option.
    * libguile/read.c: Define SCM_HUNGRY_EOL_ESCAPES_P, defaulting to #f.
      (skip_intraline_whitespace): New helper.
      (scm_read_string): If SCM_HUNGRY_EOL_ESCAPES_P,
      skip_intraline_whitespace after an escaped EOL.
    
    * test-suite/tests/reader.test ("read-options"): Add test.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                         |    6 ++++++
 doc/ref/api-data.texi        |   17 +++++++++++++++++
 doc/ref/api-evaluation.texi  |    8 +++++---
 doc/ref/api-options.texi     |    4 +++-
 libguile/private-options.h   |    3 ++-
 libguile/read.c              |   21 +++++++++++++++++++++
 test-suite/tests/reader.test |   22 +++++++++++++++++++---
 7 files changed, 73 insertions(+), 8 deletions(-)

diff --git a/NEWS b/NEWS
index bf6b4f2..f10da91 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,12 @@ latest prerelease, and a full NEWS corresponding to 1.8 -> 
2.0.
 
 Changes in 1.9.15 (since the 1.9.14 prerelease):
 
+** New reader option: `hungry-eol-escapes'
+
+Guile's string syntax is more compatible with R6RS when the
+`hungry-eol-escapes' option is enabled.  See "String Syntax" in the
+manual, for more information.
+
 ** `expt' and `integer-expt' changes when the base is 0
 
 While `(expt 0 0)' is still 1, `(expt 0 N)' for N > 0 is now 0, and
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 2c990f9..659dc5c 100755
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -2671,6 +2671,23 @@ Backspace character (ASCII 8).
 @item @nicode{\0}
 NUL character (ASCII 0).
 
address@hidden @nicode{\} followed by newline (ASCII 10)
+Nothing.  This way if @nicode{\} is the last character in a line, the
+string will continue with the first character from the next line,
+without a line break.
+
+If the @code{hungry-eol-escapes} reader option is enabled, which is not
+the case by default, leading whitespace on the next line is discarded.
+
address@hidden
+"foo\
+  bar"
address@hidden "foo  bar"
+(read-enable 'hungry-eol-escapes)
+"foo\
+  bar"
address@hidden "foobar"
address@hidden lisp
 @item @nicode{\xHH}
 Character code given by two hexadecimal digits.  For example
 @nicode{\x7f} for an ASCII DEL (127).
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index 022bc48..e20bad4 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2009, 2010
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2009, 2010, 2011
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -331,6 +331,8 @@ case-insensitive  no    Convert symbols to lower case.
 keywords          #f    Style of keyword recognition: #f, 'prefix or 'postfix.
 r6rs-hex-escapes  no    Use R6RS variable-length character and string hex 
escapes.
 square-brackets   yes   Treat `[' and `]' as parentheses, for R6RS 
compatibility.
+hungry-eol-escapes no   In strings, consume leading whitespace after an
+                        escaped end-of-line.
 @end smalllisp
 
 The boolean options may be toggled with @code{read-enable} and
@@ -352,8 +354,8 @@ For example, to make @code{read} fold all symbols to their 
lower case
 (read-enable 'case-insensitive)
 @end lisp
 
-For more information on the effect of the @code{r6rs-hex-escapes} option, see
-(@pxref{String Syntax}).
+For more information on the effect of the @code{r6rs-hex-escapes} and
address@hidden options, see (@pxref{String Syntax}).
 
 
 @node Scheme Write
diff --git a/doc/ref/api-options.texi b/doc/ref/api-options.texi
index 02ea209..1102708 100644
--- a/doc/ref/api-options.texi
+++ b/doc/ref/api-options.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2008, 2009, 2010
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2008, 2009, 2010, 2011
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -420,6 +420,8 @@ case-insensitive  no    Convert symbols to lower case.
 keywords          #f    Style of keyword recognition: #f, 'prefix or 'postfix.
 r6rs-hex-escapes  no    Use R6RS variable-length character and string hex 
escapes.
 square-brackets   yes   Treat `[' and `]' as parentheses, for R6RS 
compatibility.
+hungry-eol-escapes no   In strings, consume leading whitespace after an
+                        escaped end-of-line.
 scheme@@(guile-user) [1]> (read-enable 'case-insensitive)
 $2 = (square-brackets keywords #f case-insensitive positions)
 scheme@@(guile-user) [1]> ,q
diff --git a/libguile/private-options.h b/libguile/private-options.h
index 2c27214..c095688 100644
--- a/libguile/private-options.h
+++ b/libguile/private-options.h
@@ -4,7 +4,7 @@
  * We put this in a private header, since layout of data structures
  * is an implementation detail that we want to hide.
  * 
- * Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+ * Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -63,6 +63,7 @@ SCM_INTERNAL scm_t_option scm_read_opts[];
 #define SCM_KEYWORD_STYLE      scm_read_opts[3].val
 #define SCM_R6RS_ESCAPES_P     scm_read_opts[4].val
 #define SCM_SQUARE_BRACKETS_P  scm_read_opts[5].val
+#define SCM_HUNGRY_EOL_ESCAPES_P scm_read_opts[6].val
 
 #define SCM_N_READ_OPTIONS 6
 
diff --git a/libguile/read.c b/libguile/read.c
index 54384fa..87eecfe 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <unicase.h>
+#include <unictype.h>
 
 #include "libguile/_scm.h"
 #include "libguile/bytevectors.h"
@@ -75,6 +76,8 @@ scm_t_option scm_read_opts[] = {
     "Use R6RS variable-length character and string hex escapes."},
   { SCM_OPTION_BOOLEAN, "square-brackets", 1,
     "Treat `[' and `]' as parentheses, for R6RS compatibility."},
+  { SCM_OPTION_BOOLEAN, "hungry-eol-escapes", 0,
+    "In strings, consume leading whitespace after an escaped end-of-line."},
   { 0, },
 };
 
@@ -486,6 +489,22 @@ scm_read_sexp (scm_t_wchar chr, SCM port)
         }                                                          \
     } while (0)
 
+static void
+skip_intraline_whitespace (SCM port)
+{
+  scm_t_wchar c;
+  
+  do
+    {
+      c = scm_getc (port);
+      if (c == EOF)
+        return;
+    }
+  while (c == '\t' || uc_is_general_category (c, UC_SPACE_SEPARATOR));
+
+  scm_ungetc (c, port);
+}                                         
+
 static SCM
 scm_read_string (int chr, SCM port)
 #define FUNC_NAME "scm_lreadr"
@@ -524,6 +543,8 @@ scm_read_string (int chr, SCM port)
             case '\\':
               break;
             case '\n':
+              if (SCM_HUNGRY_EOL_ESCAPES_P)
+                skip_intraline_whitespace (port);
               continue;
             case '0':
               c = '\0';
diff --git a/test-suite/tests/reader.test b/test-suite/tests/reader.test
index 6f0ed1d..13c8526 100644
--- a/test-suite/tests/reader.test
+++ b/test-suite/tests/reader.test
@@ -1,6 +1,6 @@
 ;;;; reader.test --- Reader test.    -*- coding: iso-8859-1; mode: scheme -*-
 ;;;;
-;;;; Copyright (C) 1999, 2001, 2002, 2003, 2007, 2008, 2009, 2010 Free 
Software Foundation, Inc.
+;;;; Copyright (C) 1999, 2001, 2002, 2003, 2007, 2008, 2009, 2010, 2011 Free 
Software Foundation, Inc.
 ;;;; Jim Blandy <address@hidden>
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
@@ -364,8 +364,24 @@
            (with-output-to-string
              (lambda ()
                (write (integer->char #x80))))))
-       "#\\x80"))))
-
+       "#\\x80")))
+
+  (with-test-prefix "hungry escapes"
+    (pass-if "default not hungry"
+      ;; Assume default setting of not hungry.
+      (equal? (with-input-from-string "\"foo\\\n  bar\""
+                read)
+              "foo  bar"))
+    (pass-if "hungry"
+      (dynamic-wind
+        (lambda ()
+          (read-enable 'hungry-eol-escapes))
+        (lambda ()
+          (equal? (with-input-from-string "\"foo\\\n  bar\""
+                    read)
+                  "foobar"))
+        (lambda ()
+          (read-disable 'hungry-eol-escapes))))))
 
 
 (with-test-prefix "#;"


hooks/post-receive
-- 
GNU Guile



reply via email to

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