[Sablevm-developer] I think I know where the problem is...
Brought to you by:
egagnon
From: Etienne M. G. <eg...@j-...> - 2000-12-12 01:28:50
|
Hi Brent. You set up your main loop: while ((start = fgets (start, MAXPATHLENGTH, file))) ... It does not do what you meant. fgets is a pain to work with, but it is feasible; when you use it, you have a few things to consider: in [ s = fgets(...,MAX,...) ] (1) if s == NULL: we have reached EOF (2) while (s != NULL) && (strlen(s) == MAX - 1) && (s[MAX-2] != '\n') accumulate the option text! (3) else s is a single line (or the tail of) I suggest that you first accumulate the complete line (with a function). Why not define a getline() function (using fgets)? Do NOT read/copy the definition of the libc library, as it might conflict with SableVM's copyright notice. [Unless you build a separate library for it, based on glibc]. Also, you had an extra "len" variable declaration that was probably in the way... Etienne -- ---------------------------------------------------------------------- Etienne M. Gagnon, M.Sc. e-mail: eg...@j-... Author of SableCC: http://www.sable.mcgill.ca/sablecc/ and SableVM: http://www.sablevm.org/ ---------------------------------------------------------------------- |