[OpenBIOS] Parsing empty \ comments

Rolf Schroedter Rolf at Rolf-Schroedter.de
Thu Oct 19 22:08:20 CEST 2006

I noticed that kernel/bootstrap.c fails parsing empty \ comments, e.g.
from "bootstrap.fs":

	\ Some comment<lf>
	: tuck  swap over ;

complaining about "tuck not defined". No problem if the 2nd line has a 
	\ <lf>

One could say "That's FORTH", but IMHO this behavior is ugly because
the difference between both cases is not visible. In my case I had an 
configured to truncate trailing spaces in a line ...

I suggest to resolve this problem by not eating <lf> when parsing
for white spaces(delim=0) in parse(f,line,delim ), something like:

static int parse(FILE * f, char *line, char delim)
	int cnt = 0, c;
	while (!feof(f)) {
		c = getc(f);
		if (delim && c == delim)
		if ((!delim) && (c == ' ' || c == '\n' || c == '\t')) {
>>>>>			if (c == '\n') ungetc(c, f);
		line[cnt++] = c;
	line[cnt] = 0;
	return cnt;

A similar change should probably be done at FORTH level in ": 
parse-word" and/or ": parse".

Regards, Rolf.

Rolf Schroedter
German Aerospace Center
Institute of Planetary Research
D-12489 Berlin, Rutherfordstrasse 2
Tel/Fax:  (+49) (30) 67055-416/384
Email:    Rolf.Schroedter at dlr.de

More information about the OpenBIOS mailing list