Changeset 13033 in project


Ignore:
Timestamp:
01/19/09 00:55:37 (11 years ago)
Author:
Ivan Raikov
Message:

Make sure end argument to string-search and string-search-positions does not exceed
input string length.

Location:
chicken/branches/chicken-3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chicken/branches/chicken-3/irregex.scm

    r13010 r13033  
    14931493  (let ((irx (irregex x)))
    14941494    (let ((start (if (pair? o) (car o) 0))
    1495           (end (if (and (pair? o) (pair? (cdr o)))
    1496                    (cadr o)
    1497                    (string-length str)))
     1495          (end   (if (and (pair? o) (pair? (cdr o)))
     1496                     (cadr o) (string-length str)))
    14981497          (matches (irregex-new-matches irx)))
    14991498      (irregex-match-string-set! matches str)
  • chicken/branches/chicken-3/regex.scm

    r13010 r13033  
    144144(define (string-search rx str #!optional (start 0) (range (string-length str)))
    145145  (let ((rx (unregexp rx)))
    146     (and-let* ((m (irregex-search rx str start (fx+ start range))))
     146    (and-let* ((n (string-length str))
     147               (m (irregex-search rx str start (min n (fx+ start range)))))
    147148      (let loop ((i (irregex-match-num-submatches m))
    148149                 (res '()))
     
    153154(define (string-search-positions rx str #!optional (start 0) (range (string-length str)))
    154155  (let ((rx (unregexp rx)))
    155     (and-let* ((m (irregex-search rx str start (fx+ start range))))
     156    (and-let* ((n (string-length str))
     157               (m (irregex-search rx str start (min n (fx+ start (fx- n 1))))))
    156158      (let loop ((i (irregex-match-num-submatches m))
    157159                 (res '()))
Note: See TracChangeset for help on using the changeset viewer.