chicken-janitors
[Top][All Lists]
Advanced

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

[Chicken-janitors] #831: utf8: Errors in xstring-copy! and utf8-case-map


From: Chicken Trac
Subject: [Chicken-janitors] #831: utf8: Errors in xstring-copy! and utf8-case-map
Date: Sun, 13 May 2012 11:02:50 -0000

#831: utf8: Errors in xstring-copy! and utf8-case-map
------------------------+---------------------------------------------------
 Reporter:  sjamaan     |       Owner:  ashinn
     Type:  defect      |      Status:  new   
 Priority:  minor       |   Milestone:        
Component:  extensions  |     Version:  4.7.x 
 Keywords:              |  
------------------------+---------------------------------------------------
 utf8-srfi-13 has a problem where it's missing a set of parentheses; it's
 passing the procedure {{{-}}} as one of the arguments to {{{+}}}, causing
 an infinite loop in string-xcopy!:

 {{{
 #;1> (use utf8-srfi-13)
 #;2> (define s1 "foo")
 #;3> (define s2 (make-string 3))
 #;4> (string-xcopy! s2 0 s1 1)
 ;; never stops, should put "oof" in s2
 }}}

 This is simple to fix:

 {{{
 Index: utf8-srfi-13.scm
 ===================================================================
 --- utf8-srfi-13.scm    (revision 26685)
 +++ utf8-srfi-13.scm    (working copy)
 @@ -570,7 +570,7 @@

  (define (string-xcopy target tstart s from . opt)
    (let-optionals* opt ((to1 #f) (start 0) (end (utf8-string-length s)))
 -    (let ((to (or to1 (+ from - end start))))
 +    (let ((to (or to1 (+ from (- end start)))))
        (string-append (utf8-substring target 0 tstart)
                       (xsubstring s from to start end)
                       (utf8-substring target
 }}}

 There's another bug in utf8-case-map, which I don't know how to trigger
 (might be worthwhile trying to figure that out to add it as a regression
 test).  There's two places where u32vector-ref is called with only one
 argument.  This is also simple to fix, but as I wasn't able to trigger the
 bug I'm not sure this is correct:

 {{{
 Index: utf8-case-map.scm
 ===================================================================
 --- utf8-case-map.scm   (revision 26685)
 +++ utf8-case-map.scm   (working copy)
 @@ -122,9 +122,9 @@
       (>= hi lo)
       (cond
         ((= i (u32vector-ref tab (* lo 4)))
 -        (u32vector-ref (+ (* lo 4) off)))
 +        (u32vector-ref tab (+ (* lo 4) off)))
         ((= i (u32vector-ref tab (* hi 4)))
 -        (u32vector-ref (+ (* hi 4) off)))
 +        (u32vector-ref tab (+ (* hi 4) off)))
         (else
          (let loop ((a lo) (b hi))
            (if (= a b)
 }}}

 These bugs were found by the scrutinizer, see
 http://parenteses.org/mario/misc/specialize-report/install/utf8.html

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/831>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

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