Fix field splitting on outside spaces
* geesh/word.scm (split-fields): Make outside spaces in word-parts count for field splitting. * tests/word.scm: Test this.
This commit is contained in:
parent
da1d561f22
commit
a2f5403367
|
@ -75,12 +75,13 @@ set @var{ifs}."
|
||||||
(str (let ((str-parts (string-split str ifs)))
|
(str (let ((str-parts (string-split str ifs)))
|
||||||
(if (every string-null? str-parts)
|
(if (every string-null? str-parts)
|
||||||
'(wedge)
|
'(wedge)
|
||||||
(infix 'wedge (filter (compose not string-null?)
|
(filter (lambda (x)
|
||||||
str-parts)))))))
|
(or (eq? x 'wedge) (not (string-null? x))))
|
||||||
|
(infix 'wedge str-parts)))))))
|
||||||
|
|
||||||
(let ((wedged (append-map (cut wedge-apart <> ifs)
|
(let ((wedged (append-map (cut wedge-apart <> ifs)
|
||||||
(normalize-word qword))))
|
(normalize-word qword))))
|
||||||
(list-split wedged 'wedge)))
|
(filter pair? (list-split wedged 'wedge))))
|
||||||
|
|
||||||
(define (remove-quotes qword)
|
(define (remove-quotes qword)
|
||||||
"Remove quote forms from @var{qword} and concatenate the result into a
|
"Remove quote forms from @var{qword} and concatenate the result into a
|
||||||
|
|
|
@ -60,6 +60,14 @@ the `set' built-in for details on these options.)"
|
||||||
'("foo" "bar")
|
'("foo" "bar")
|
||||||
(expand-word #f '("foo bar")))
|
(expand-word #f '("foo bar")))
|
||||||
|
|
||||||
|
(test-equal "Splits a word on leading space"
|
||||||
|
'("foo" "bar")
|
||||||
|
(expand-word #f '("foo" " bar")))
|
||||||
|
|
||||||
|
(test-equal "Splits a word on trailing space"
|
||||||
|
'("foo" "bar")
|
||||||
|
(expand-word #f '("foo " "bar")))
|
||||||
|
|
||||||
(test-equal "Ignores leading spaces"
|
(test-equal "Ignores leading spaces"
|
||||||
'("foo")
|
'("foo")
|
||||||
(expand-word #f '(" foo")))
|
(expand-word #f '(" foo")))
|
||||||
|
|
Loading…
Reference in New Issue