Summary
irregex-match-end gives odd results with chunked searches
Metadata
- Id: 6864361d2c3cf2ea6ebf1031400b227d35c22063
- Trac id: 889
- Type: defect
- Reporter: megane
- Owner:
- Cc:
- Status: closed
- Component: core libraries
- Estimated difficulty:
- Resolution: invalid
- Priority: major
- Milestone:
- Version: 4.7.x
- Changetime: 2012-07-31 01:50:39 UTC
- Created: 2012-07-25 16:39:46 UTC
- Keywords: irregex
Description
I expected (irregex-match-end-index m 0) to return 4 in the following example:
(let* ((chkr (make-irregex-chunker
(lambda (c)
(and (pair? c)
(cdr c))) car))
(m (irregex-search/chunked "(b)" chkr '("foo" "bar"))))
(print m)
(print (irregex-match-start-index m 0))
(print (irregex-match-end-index m 0))
(print (irregex-match-start-index m 1))
(print (irregex-match-end-index m 1)))
;; #<regexp-match (1 submatch)>
;; 3
;; 1
;; 3
;; 1
The result with the version from http://code.google.com/p/irregex/ was:
#(*irregex-match-tag* #(#<procedure (? c)> #<procedure (car p)> #<procedure (? cnk)> #<procedure (? cnk)> #<procedure (? cnk1 start cnk2 end)> #f) () (foo bar) 3 (bar) 1 (foo bar) 3 (bar) 1 #f #f #f #f) 3 1 3 1
Changes and comments
[2012-07-31 01:50:39 UTC] ashinn changed status from new to closed
[2012-07-31 01:50:39 UTC] ashinn set resolution to invalid
[2012-07-31 01:50:39 UTC] ashinn wrote:
This is correct. In the chunked API, the indexes are not absolute, but instead are relative to the start of the chunk. You can get the chunk with irregex-match-start/end-chunk.
If this is hard to work with you can use irregex-match-substring which will just give you a string regardless of whether the data was chunked or not.