ppc64: Don't set Kp bit on SLB
[openbios.git] / forth / lib / split.fs
blobca9dd0b5962e4eb7175ee8fafd95570bfdb614ef
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 )
6 0 rot dup >r 0 ?do
7 ( str char cnt R: len <sys> )
8 2 pick over + c@ 2 pick = if leave then
9 1+
10 loop
11 nip
12 2dup + r> 2 pick -
13 2swap
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
22 loop
23 nip
24 dup 0 >= if 1+ else drop r@ then
25 2dup + r> 2 pick -
26 2swap
29 \ delimiter not returned
30 : left-split ( addr len delim -- addr-R len-R addr-L len-L )
31 0 rot dup >r 0 ?do
32 ( str char cnt R: len <sys> )
33 2 pick i + c@ 2 pick = if leave then
35 loop
36 nip
37 2dup + 1+ r> 2 pick -
38 dup if 1- then
39 2swap
42 \ delimiter not returned [THIS FUNCTION IS NOT NEEDED]
43 : right-split ( addr len delim -- addr-R len-R addr-L len-L )
44 dup >r
45 split-after
46 dup if 2dup + 1-
47 c@ r@ = if 1- then then
48 r> drop
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 )
58 else
59 \ Contains backslash, must be a <dev>:<id><path>
60 ascii : left-split \ ( pathstr len devstr len )
61 then
63 \ Remove RHS split (unused)
64 4 roll drop
65 4 roll drop
66 else
67 \ Contains comma so split is already correct
68 then