Changeset 39689 in project


Ignore:
Timestamp:
03/13/21 16:08:11 (6 weeks ago)
Author:
Kooda
Message:

C5 srfi-13 egg: fix xsubstring, bug report #1590

Location:
release/5/srfi-13
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/5/srfi-13/tags/0.3.1/srfi-13.scm

    r37913 r39689  
    19481948           (nspans (quotient nleft slen)))      ; # whole spans to copy
    19491949
    1950       ;; Copy the whole spans in the middle.
    1951       (do ((i (+ tstart ncopied) (+ i slen))    ; Current target index.
    1952            (nspans nspans (- nspans 1)))        ; # spans to copy
    1953           ((zero? nspans)
    1954            ;; Copy the partial-span @ the end & we're done.
    1955            (%string-copy! target i s start (+ start (- total-chars (- i tstart)))))
    1956 
    1957         (%string-copy! target i s start end))))); Copy a whole span.
     1950      (if (negative? nleft) ;; Total length is shorter that original string
     1951          target
     1952          ;; Copy the whole spans in the middle.
     1953          (do ((i (+ tstart ncopied) (+ i slen))    ; Current target index.
     1954               (nspans nspans (- nspans 1)))        ; # spans to copy
     1955              ((zero? nspans)
     1956               ;; Copy the partial-span @ the end & we're done.
     1957               (%string-copy! target i s start (+ start (- total-chars (- i tstart)))))
     1958
     1959            (%string-copy! target i s start end)))))); Copy a whole span.
    19581960
    19591961
  • release/5/srfi-13/tags/0.3.1/tests/run.scm

    r35498 r39689  
    423423(test "xsubstring" ""
    424424       (xsubstring "abcdefg" 9 9 3 6))
     425(test "xsubstring" "fo"
     426       (xsubstring "foo" 0 2))
    425427
    426428(test "string-xcopy!" "ZZcdefabZZ"
  • release/5/srfi-13/trunk/srfi-13.scm

    r37913 r39689  
    19481948           (nspans (quotient nleft slen)))      ; # whole spans to copy
    19491949
    1950       ;; Copy the whole spans in the middle.
    1951       (do ((i (+ tstart ncopied) (+ i slen))    ; Current target index.
    1952            (nspans nspans (- nspans 1)))        ; # spans to copy
    1953           ((zero? nspans)
    1954            ;; Copy the partial-span @ the end & we're done.
    1955            (%string-copy! target i s start (+ start (- total-chars (- i tstart)))))
    1956 
    1957         (%string-copy! target i s start end))))); Copy a whole span.
     1950      (if (negative? nleft) ;; Total length is shorter that original string
     1951          target
     1952          ;; Copy the whole spans in the middle.
     1953          (do ((i (+ tstart ncopied) (+ i slen))    ; Current target index.
     1954               (nspans nspans (- nspans 1)))        ; # spans to copy
     1955              ((zero? nspans)
     1956               ;; Copy the partial-span @ the end & we're done.
     1957               (%string-copy! target i s start (+ start (- total-chars (- i tstart)))))
     1958
     1959            (%string-copy! target i s start end)))))); Copy a whole span.
    19581960
    19591961
  • release/5/srfi-13/trunk/tests/run.scm

    r35498 r39689  
    423423(test "xsubstring" ""
    424424       (xsubstring "abcdefg" 9 9 3 6))
     425(test "xsubstring" "fo"
     426       (xsubstring "foo" 0 2))
    425427
    426428(test "string-xcopy!" "ZZcdefabZZ"
Note: See TracChangeset for help on using the changeset viewer.