can we ungetc ?
Posted: Mon Dec 22, 2003 3:54 pm
In C programming sometimes to look ahead at the next file character a ch=getc(infile) is done and then if the logic requires that ch not be handled now a ungetc( ch, infile) is used to put the char back for later processing.
How feasible would it be to have the same facility available for (read-char
viz (unread-char ? I tried (write-char back into a file opened as update but that doesn't work. viz
> (set 'aFile (open "myfile.ext" "u"))
1
> (setq ch (read-char aFile))
97
> (write-char aFile ch)
1
> (setq ch (read-char aFile))
113
>
If it's not easy at the C source level for newlisp I'll try a getc & ungetc with defines or macros (anybody got such functions?).
I want getc/ungetc for a fairly 'no thinking please' C to newlisp port of a C program.
Regards
Nigel
Nigel
How feasible would it be to have the same facility available for (read-char
viz (unread-char ? I tried (write-char back into a file opened as update but that doesn't work. viz
> (set 'aFile (open "myfile.ext" "u"))
1
> (setq ch (read-char aFile))
97
> (write-char aFile ch)
1
> (setq ch (read-char aFile))
113
>
If it's not easy at the C source level for newlisp I'll try a getc & ungetc with defines or macros (anybody got such functions?).
I want getc/ungetc for a fairly 'no thinking please' C to newlisp port of a C program.
Regards
Nigel
Nigel