[OpenBIOS] [PATCH 2/7] string.fs: add functions to support ROT13 string encoding/decoding
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Sat Feb 13 16:26:48 CET 2016
On 13/02/16 01:32, Segher Boessenkool wrote:
> Let's factor this a bit better...
>
> : rot13 ( c - c )
> dup upc [char] A [char] M between IF d# 13 + EXIT THEN
> dup upc [char] N [char] Z between IF d# 13 - THEN ;
>
> : $rot13 ( str len -- ) bounds ?DO i c@ rot13 i c! LOOP ;
>
> : rot13-str ( str len -- newstr len ) strdup 2dup $rot13 ;
>
>
> Hope I didn't mess this up ;-)
Yeah, your Forth is obviously much better then mine ;) Thanks for this,
I'll include it in the next revision of the copyright patchset (albeit
with a few minor cosmetic tweaks).
ATB,
Mark.
More information about the OpenBIOS
mailing list