Improving path-join.

This commit is contained in:
Brad Nelson
2023-05-25 19:35:13 -07:00
parent 8c31cbd694
commit 0f47287dfa
2 changed files with 15 additions and 1 deletions

View File

@ -55,9 +55,11 @@ internals definitions
0 value included-files 0 value included-files
: path-join { a a# b b# -- a n } : path-join { a a# b b# -- a n }
b if
b c@ [char] / = if 0 to a# then
then
a# b# + { r# } r# cell+ cell+ allocate throw { r } a# b# + { r# } r# cell+ cell+ allocate throw { r }
2 cells +to r 2 cells +to r
b c@ [char] / = if 0 to a# then
begin b b# starts./ while begin b b# starts./ while
2 +to b -2 +to b# 2 +to b -2 +to b#
a# b# + to r# a# b# + to r#

View File

@ -53,3 +53,15 @@ e: test-needs
out: x.fs 2 out: x.fs 2
out: x.fs 3 out: x.fs 3
;e ;e
e: test-path-join
also internals
s" /foo/bar/" s" /" path-join s" /" str= assert
s" /foo/bar/" s" baz" path-join s" /foo/bar/baz" str= assert
s" /foo/bar/" s" ./baz" path-join s" /foo/bar/baz" str= assert
s" /foo/bar/" s" ../baz" path-join s" /foo/baz" str= assert
s" /foo/bar/" s" baz/qux" path-join s" /foo/bar/baz/qux" str= assert
s" /foo/bar/" s" ./baz/qux" path-join s" /foo/bar/baz/qux" str= assert
s" /foo/bar/" s" " path-join s" /foo/bar/" str= assert
s" ./foo/" s" ../bar" path-join s" ./bar" str= assert
;e