[OpenBIOS] [PATCH 1/3] forth: Fix ([IF]) to handle nested [IFDEF] as well

Segher Boessenkool segher at kernel.crashing.org
Sat Dec 4 15:30:03 CET 2010


> Depending on the condition either the [IFDEF] foo or the [ELSE]
> would get compiled as an [IF], eating words until [ELSE] or [THEN]
> respectively. While doing so, [IFDEF] does not get compiled to [IF],
> so we need to handle nested [IFDEF] to account for its [ELSE] or [THEN].
>
> This fixes [IFDEF] not disabling the full section of code.
>
> Thanks to Segher for pointing me in the right direction.
>
> Cc: Segher Boessenkool <segher at kernel.crashing.org>
> Signed-off-by: Andreas Färber <andreas.faerber at web.de>

Signed-off-by: Segher Boessenkool <segher at kernel.crashing.org>

> ---
>  forth/lib/preprocessor.fs |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/forth/lib/preprocessor.fs b/forth/lib/preprocessor.fs
> index ac88885..89d478c 100644
> --- a/forth/lib/preprocessor.fs
> +++ b/forth/lib/preprocessor.fs
> @@ -19,6 +19,7 @@
>      repeat
>
>      2dup " [IF]" strcmp 0= if 1 throw then
> +    2dup " [IFDEF]" strcmp 0= if 1 throw then
>      2dup " [ELSE]" strcmp 0= if 2 throw then
>      2dup " [THEN]" strcmp 0= if 3 throw then
>      " \\" strcmp 0= if linefeed parse 2drop then
> --
> 1.7.3
>




More information about the OpenBIOS mailing list