parsing the end of line in Linux and Windows

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

parsing the end of line in Linux and Windows

Marcos Cruz

I tried the following code from an adventure game by Leo Wong:

        \ FROM:
        \ TOOLS.F FOR ADVTR.F   LEO WONG 27 JUNE 02003 FYJ +
        STARTLOG \ Debugging
                BL WORD DUP COUNT S" ))" COMPARE
                DUP DUP COUNT CR TYPE SPACE C@ . \ Debugging
                C@ 0=  IF REFILL 0= ABORT" (( NEEDS ))"  THEN
        DUP COUNT CR ." FOUND: " TYPE \ Debugging
        ENDLOG \ Debugging
        ; IMMEDIATE

I wanted to use multiline comments in my own program.  I have some block
comments but they have (...) inside, so I use 0 [IF] ... [THEN] but I wanted
to try a simpler way.

Well, the multiline comments worked fine in the command line, but not in the

After some exploring (lines marked with "Debugging") I discovered the word
WORD parsed "))" like a 3-character string... because it included a <CR> end
of line character!

Although I work with Linux SP-Forth, my source had DOS end of lines (<CR>
<NL>) because I thougth both versions of SP-Forth would understand it (I want
to compile the same source for Windows and Linux).

I changed the source format to Unix end of lines (<NL>) and the problem was
solved. Using the Mac format (<CR>) doesn't work at all: end of lines are not

I have tried the same code in Windows SP-Forth: The code works only if the
source has DOS end of lines (<CR><NL>).

So Windows SP-Forth expects <CR><NL> and Linux SP-Forth expects <NL>. That is
logical. But considering that SP-Forth lets the programmer create executables
for both systems, I think it would be nice if both versions of SP-Forth would
parse code with any end of line (DOS or Unix).



All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
Spf-dev mailing list
[hidden email]