megaparsack icon indicating copy to clipboard operation
megaparsack copied to clipboard

string-ci/p only compares first char case-insensitively

Open dys-bigwig opened this issue 5 years ago • 1 comments

Hi, I had a few things failing and narrowed it down to the use of string-ci/p:

(parse-string (string-ci/p "LDA") "lda")
=>
(failure (message (srcloc 'string 1 0 1 2) #\d '("DA")))

I think it's due to the fact that string-ci/p calls chars/p, which only uses char-parser on the first character, before defaulting to string/p when recurring:

(define (string-ci/p str)
  (chars/p str char-ci/p))

(define (chars/p str char-parser)
  (if (zero? (string-length str))
      (pure "")
      (label/p str (do (char-parser (string-ref str 0))
                       (string/p (substring str 1)) ;should be (chars/p (substring str 1) char-parser) ?
                       (pure str)))))

Thank you.

dys-bigwig avatar Aug 13 '19 03:08 dys-bigwig

Seconded, having this issue. The fix in #29 looks right, although the test-case for it looks wrong.

benknoble avatar Dec 06 '22 19:12 benknoble