aboutsummaryrefslogtreecommitdiff
path: root/slof/fs/node.fs
diff options
context:
space:
mode:
authorThomas Huth <thuth@linux.vnet.ibm.com>2011-10-25 10:41:09 +0200
committerThomas Huth <thuth@linux.vnet.ibm.com>2011-11-17 12:10:36 +0100
commit16c43ff8de4a1e0a21d1eac1295e7ad6884774ce (patch)
treedcb17858bbcd1038733880479ca575a3f663e73e /slof/fs/node.fs
parente32f09a2fbf9ab7709c2c9a1e82f0eb1b9e2e9c6 (diff)
downloadSLOF-16c43ff8de4a1e0a21d1eac1295e7ad6884774ce.zip
SLOF-16c43ff8de4a1e0a21d1eac1295e7ad6884774ce.tar.gz
SLOF-16c43ff8de4a1e0a21d1eac1295e7ad6884774ce.tar.bz2
Enhance the behavior of find-package according to IEEE 1275 proposal 215
According to IEEE 1275 Proposal 215 (Extensible Client Services Package), the find-package method can be used to get the phandle of arbitrary nodes (i.e. not only support packages) when the name starts with a slash. Some FCODE programs depend on this behavior so we've got to support this, too! Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'slof/fs/node.fs')
-rw-r--r--slof/fs/node.fs30
1 files changed, 26 insertions, 4 deletions
diff --git a/slof/fs/node.fs b/slof/fs/node.fs
index e747b5e..e224bbe 100644
--- a/slof/fs/node.fs
+++ b/slof/fs/node.fs
@@ -483,11 +483,33 @@ VARIABLE interpose-node
\ The /packages node.
0 VALUE packages
-\ We can't use the standard find-node stuff, as we are required to find the
-\ newest (i.e., last in our tree) matching package, not just any.
+\ Find a support package (or arbitrary nodes when name is absolute)
: find-package ( name len -- false | phandle true )
- 0 >r packages child BEGIN dup WHILE dup >r node>name 2over string=ci r> swap
- IF r> drop dup >r THEN peer REPEAT 3drop r> dup IF true THEN ;
+ dup 0 <= IF
+ 2drop FALSE EXIT
+ THEN
+ \ According to IEEE 1275 Proposal 215 (Extensible Client Services Package),
+ \ the find-package method can be used to get the phandle of arbitrary nodes
+ \ (i.e. not only support packages) when the name starts with a slash.
+ \ Some FCODE programs depend on this behavior so let's support this, too!
+ over c@ [char] / = IF
+ find-node dup IF TRUE THEN EXIT
+ THEN
+ \ Ok, let's look for support packages instead. We can't use the standard
+ \ find-node stuff, as we are required to find the newest (i.e., last in our
+ \ tree) matching package, not just any.
+ 0 >r packages child
+ BEGIN
+ dup
+ WHILE
+ dup >r node>name 2over string=ci r> swap IF
+ r> drop dup >r
+ THEN
+ peer
+ REPEAT
+ 3drop
+ r> dup IF true THEN
+;
: open-package ( arg len phandle -- ihandle | 0 ) open-node ;
: close-package ( ihandle -- ) close-node ;