mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Address #174 - fix string/trim
This commit is contained in:
parent
c5010dffb4
commit
9b605b27bd
@ -500,6 +500,8 @@ static Janet cfun_string_trim(int32_t argc, Janet *argv) {
|
||||
trim_help_args(argc, argv, &str, &set);
|
||||
int32_t left_edge = trim_help_leftedge(str, set);
|
||||
int32_t right_edge = trim_help_rightedge(str, set);
|
||||
if (right_edge < left_edge)
|
||||
return janet_stringv(NULL, 0);
|
||||
return janet_stringv(str.bytes + left_edge, right_edge - left_edge);
|
||||
}
|
||||
|
||||
|
@ -190,4 +190,7 @@
|
||||
(assert-error "with-vars 2" (with-vars [abc 456] (error :oops)))
|
||||
(assert (= abc 123) "with-vars 3")
|
||||
|
||||
# Trim empty string
|
||||
(assert (= "" (string/trim " ")) "string/trim regression")
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user