diff options
author | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-11-29 15:25:37 +0100 |
---|---|---|
committer | Thomas Huth <thuth@linux.vnet.ibm.com> | 2011-12-20 17:56:48 +0100 |
commit | e977f3e512684a7ed70156023c269b7f3ea01c20 (patch) | |
tree | 2d2a2d552e3364986ad8c3b375ab21f9b31d8fa8 /slof/fs/base.fs | |
parent | af85b732926273bdb8b5e61623d0af6f988eae94 (diff) | |
download | SLOF-e977f3e512684a7ed70156023c269b7f3ea01c20.zip SLOF-e977f3e512684a7ed70156023c269b7f3ea01c20.tar.gz SLOF-e977f3e512684a7ed70156023c269b7f3ea01c20.tar.bz2 |
Encode FDT properties as string when they contain a valid ASCII string.
There are a lot of properties in the FDT that contain a string, but commands
like ".properties" only displayed them as byte array since all properties
were encoded with "encode-bytes". Now the code tries to detect valid ASCII
strings and encodes such properties with "encode-string" instead.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Diffstat (limited to 'slof/fs/base.fs')
-rw-r--r-- | slof/fs/base.fs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/slof/fs/base.fs b/slof/fs/base.fs index 4fc8ad4..bb95b2d 100644 --- a/slof/fs/base.fs +++ b/slof/fs/base.fs @@ -121,6 +121,16 @@ CONSTANT <2constant> : str= ( str1 len1 str2 len2 -- equal? ) rot over <> IF 3drop false ELSE comp 0= THEN ; +: test-string ( param len -- true | false ) + 0 ?DO + dup i + c@ \ Get character / byte at current index + dup 20 < swap 7e > OR IF \ Is it out of range 32 to 126 (=ASCII) + drop FALSE UNLOOP EXIT \ FALSE means: No ASCII string + THEN + LOOP + drop TRUE \ Only ASCII found --> it is a string +; + : #aligned ( adr alignment -- adr' ) negate swap negate and negate ; : #join ( lo hi #bits -- x ) lshift or ; : #split ( x #bits -- lo hi ) 2dup rshift dup >r swap lshift xor r> ; |