Changeset 33055 in project


Ignore:
Timestamp:
01/08/16 00:52:58 (4 years ago)
Author:
Alex Shinn
Message:

Handle empty substring border case in string-index-right.
Fixes issue #1252.

Location:
release/4/utf8
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/utf8/tags/3.4.3/tests/run.scm

    r32302 r33055  
    272272ƒéº»åžƒ" "東麻垃" 1 3))
    273273
     274(test #f (string-index "" #\@))
     275(test #f (string-index "foo" #\@))
     276(test #f (string-index "foo" #\@ 0 0))
     277(test #f (string-index-right "" #\@))
     278(test #f (string-index-right "foo" #\@))
     279(test #f (string-index-right "foo" #\@ 0 0))
    274280(test 1 (string-index "文字列の文字怜玢" (string-ref "字" 0)))
    275281(test 5 (string-index-right "文字列の文字怜玢" (string-ref "字" 0)))
  • release/4/utf8/tags/3.4.3/utf8-srfi-13.scm

    r29770 r33055  
    413413(define (with-string-index+offset proc s x . opt)
    414414  (if (equal? s "")
    415       #f
     415      (proc #f #f)
    416416      (let-optionals* opt ((start 0) (end -1))
    417417        (let ((size (string-length s))
     
    429429(define (with-string-index+offset-right proc s x . opt)
    430430  (if (equal? s "")
    431       #f
     431      (proc #f #f)
    432432      (let-optionals* opt ((start 0) (end (utf8-string-length s)))
    433         (let* ((size (string-length s))
    434                (pred (char-predicate x)))
    435           (let lp ((i (- end 1)) (off (utf8-index->offset s (- end 1))))
    436             (if (< i start)
    437                 (proc #f #f)
    438                 (let ((ch (sp-ref s off)))
    439                   (if (pred ch)
    440                       (proc i off)
    441                       (if (zero? i)
    442                           (lp -1 -1)
    443                           (lp (- i 1) (utf8-prev-char s off)))))))))))
     433        (let ((pred (char-predicate x)))
     434          (if (>= start end)
     435              (proc #f #f)
     436              (let lp ((i (- end 1)) (off (utf8-index->offset s (- end 1))))
     437                (if (< i start)
     438                    (proc #f #f)
     439                    (let ((ch (sp-ref s off)))
     440                      (if (pred ch)
     441                          (proc i off)
     442                          (if (zero? i)
     443                              (lp -1 -1)
     444                              (lp (- i 1) (utf8-prev-char s off))))))))))))
    444445
    445446(define (arg1 a b) a)
  • release/4/utf8/tags/3.4.3/utf8.setup

    r32981 r33055  
    22(use make)
    33
    4 (define version "3.4.2")
     4(define version "3.4.3")
    55
    66(make (("utf8-lolevel.so" ("utf8-lolevel.scm")
  • release/4/utf8/trunk/tests/run.scm

    r32302 r33055  
    272272ƒéº»åžƒ" "東麻垃" 1 3))
    273273
     274(test #f (string-index "" #\@))
     275(test #f (string-index "foo" #\@))
     276(test #f (string-index "foo" #\@ 0 0))
     277(test #f (string-index-right "" #\@))
     278(test #f (string-index-right "foo" #\@))
     279(test #f (string-index-right "foo" #\@ 0 0))
    274280(test 1 (string-index "文字列の文字怜玢" (string-ref "字" 0)))
    275281(test 5 (string-index-right "文字列の文字怜玢" (string-ref "字" 0)))
  • release/4/utf8/trunk/utf8-srfi-13.scm

    r29770 r33055  
    413413(define (with-string-index+offset proc s x . opt)
    414414  (if (equal? s "")
    415       #f
     415      (proc #f #f)
    416416      (let-optionals* opt ((start 0) (end -1))
    417417        (let ((size (string-length s))
     
    429429(define (with-string-index+offset-right proc s x . opt)
    430430  (if (equal? s "")
    431       #f
     431      (proc #f #f)
    432432      (let-optionals* opt ((start 0) (end (utf8-string-length s)))
    433         (let* ((size (string-length s))
    434                (pred (char-predicate x)))
    435           (let lp ((i (- end 1)) (off (utf8-index->offset s (- end 1))))
    436             (if (< i start)
    437                 (proc #f #f)
    438                 (let ((ch (sp-ref s off)))
    439                   (if (pred ch)
    440                       (proc i off)
    441                       (if (zero? i)
    442                           (lp -1 -1)
    443                           (lp (- i 1) (utf8-prev-char s off)))))))))))
     433        (let ((pred (char-predicate x)))
     434          (if (>= start end)
     435              (proc #f #f)
     436              (let lp ((i (- end 1)) (off (utf8-index->offset s (- end 1))))
     437                (if (< i start)
     438                    (proc #f #f)
     439                    (let ((ch (sp-ref s off)))
     440                      (if (pred ch)
     441                          (proc i off)
     442                          (if (zero? i)
     443                              (lp -1 -1)
     444                              (lp (- i 1) (utf8-prev-char s off))))))))))))
    444445
    445446(define (arg1 a b) a)
  • release/4/utf8/trunk/utf8.setup

    r32981 r33055  
    22(use make)
    33
    4 (define version "3.4.2")
     4(define version "3.4.3")
    55
    66(make (("utf8-lolevel.so" ("utf8-lolevel.scm")
Note: See TracChangeset for help on using the changeset viewer.