1 \ implements
split-before
, split-after
and left
-split
2 \
as described in 4.3 (Path resolution
)
4 \ delimeter returned
in R-string
5 : split-before
( addr len delim
-- addr
-R len
-R addr
-L len
-L )
7 ( str char cnt
R: len
<sys
> )
8 2 pick over
+ c
@ 2 pick
= if leave
then
16 \ delimeter returned
in L-string
17 : split-after
( addr len delim
-- addr
-R len
-R addr
-L len
-L )
18 over
1- rot
dup >r
0 ?do
19 ( str char cnt
R: len
<sys
> )
20 2 pick over
+ c
@ 2 pick
= if leave
then
24 dup 0 >= if 1+ else drop r
@ then
29 \ delimiter not
returned
30 : left
-split ( addr len delim
-- addr
-R len
-R addr
-L len
-L )
32 ( str char cnt
R: len
<sys
> )
33 2 pick i
+ c
@ 2 pick
= if leave
then
42 \ delimiter not
returned [THIS FUNCTION IS NOT NEEDED]
43 : right
-split ( addr len delim
-- addr
-R len
-R addr
-L len
-L )
47 c
@ r
@ = if 1- then then
51 \
split <param
-text
> into separate
path and device
strings
52 : split-path-device
( str len
-- pathstr len devstr len
)
53 ascii
, left
-split 2 pick
0= if
54 \
No comma
- so either
<dev
>:<id
> or <dev
>:<id
><path>
55 2dup ascii \ strchr
0= if
56 \
No backslash so just
<dev
> or <dev
>:<id
>
57 s
" " 2swap \
( pathstr len devstr len
)
59 \
Contains backslash, must
be a
<dev
>:<id
><path>
60 ascii
: left
-split \
( pathstr len devstr len
)
63 \
Remove RHS split (unused
)
67 \
Contains comma so
split is already correct