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-2-132-g0f


From: Michael Gran
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-2-132-g0ffc78e
Date: Sat, 29 Aug 2009 14:18:48 +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=0ffc78e38484536bd33c77439487af7a6f7dc079

The branch, master has been updated
       via  0ffc78e38484536bd33c77439487af7a6f7dc079 (commit)
       via  6c2353e1d5b24691797572e3f6a1426c52c496ee (commit)
      from  1893df4145d045c51ec8748dac1e7f56c533f613 (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 0ffc78e38484536bd33c77439487af7a6f7dc079
Author: Michael Gran <address@hidden>
Date:   Sat Aug 29 07:14:49 2009 -0700

    Range check octal-escaped characters
    
    * libguile/read.c (scm_read_character): range check octal escapes

commit 6c2353e1d5b24691797572e3f6a1426c52c496ee
Author: Michael Gran <address@hidden>
Date:   Sat Aug 29 07:11:31 2009 -0700

    More tests for chars.test
    
    Testing out-of-range octals, bad charnames, and write format
    
    * test-suite/tests/chars.test

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

Summary of changes:
 libguile/read.c             |   14 +++++++++---
 test-suite/tests/chars.test |   44 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/libguile/read.c b/libguile/read.c
index a784f34..b2773cd 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -848,12 +848,18 @@ scm_read_character (scm_t_wchar chr, SCM port)
     {
       /* Dirk:FIXME::  This type of character syntax is not R5RS
        * compliant.  Further, it should be verified that the constant
-       * does only consist of octal digits.  Finally, it should be
-       * checked whether the resulting fixnum is in the range of
-       * characters.  */
+       * does only consist of octal digits.  */
       SCM p = scm_string_to_number (charname, scm_from_uint (8));
       if (SCM_I_INUMP (p))
-       return SCM_MAKE_CHAR (SCM_I_INUM (p));
+        {
+          scm_t_wchar c = SCM_I_INUM (p);
+          if (SCM_IS_UNICODE_CHAR (c))
+            return SCM_MAKE_CHAR (c);
+          else
+            scm_i_input_error (FUNC_NAME, port, 
+                               "out-of-range octal character escape: ~a",
+                               scm_list_1 (charname));
+        }
     }
 
   /* The names of characters should never have non-Latin1
diff --git a/test-suite/tests/chars.test b/test-suite/tests/chars.test
index a8aaa58..7dc719c 100644
--- a/test-suite/tests/chars.test
+++ b/test-suite/tests/chars.test
@@ -22,6 +22,12 @@
 (define exception:wrong-type-to-apply
   (cons 'misc-error "^Wrong type to apply:"))
 
+(define exception:unknown-character-name
+  (cons #t "unknown character"))
+
+(define exception:out-of-range-octal
+  (cons #t "out-of-range"))
+
 
 (with-test-prefix "basic char handling"
 
@@ -217,11 +223,21 @@
     (pass-if-exception "integer->char out of range, -1" exception:out-of-range
       (integer->char -1))
 
-    (pass-if-exception "integer->char out of range, surrrogate" 
exception:out-of-range
+    (pass-if-exception "integer->char out of range, surrrogate" 
+                       exception:out-of-range
       (integer->char #xd800))
 
-    (pass-if-exception "integer->char out of range, 0x110000" 
exception:out-of-range
-      (integer->char #x110000)))
+    (pass-if-exception "integer->char out of range, too big" 
+                       exception:out-of-range
+      (integer->char #x110000))
+
+    (pass-if-exception "octal out of range, surrrogate" 
+                       exception:out-of-range-octal
+      (with-input-from-string "#\\154000" read))
+
+    (pass-if-exception "octal out of range, too big" 
+                       exception:out-of-range-octal
+      (with-input-from-string "#\\4200000" read)))
 
   (with-test-prefix "case"
 
@@ -252,7 +268,21 @@
            (eqv? #\Soh #\001)
            (eqv? #\Stx #\002)))
 
-   (pass-if "alt charnames are case insensitive"
-     (eqv? #\null #\nul)
-     (eqv? #\NULL #\nul)
-     (eqv? #\Null #\nul))))
+    (pass-if "alt charnames are case insensitive"
+      (eqv? #\null #\nul)
+      (eqv? #\NULL #\nul)
+      (eqv? #\Null #\nul))
+
+    (pass-if-exception "bad charname" exception:unknown-character-name
+      (with-input-from-string "#\\blammo" read))
+
+    (pass-if "R5RS character names are preferred write format"
+      (string=?
+       (with-output-to-string (lambda () (write #\space)))
+       "#\\space"))
+
+    (pass-if "C0 control character names are preferred write format"
+      (string=?
+       (with-output-to-string (lambda () (write #\soh)))
+       "#\\soh"))))
+


hooks/post-receive
-- 
GNU Guile




reply via email to

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