[Scummvm-devel] Question about readline_NEW
Willem Jan Palenstijn
wjp at usecode.org
Wed Dec 3 10:54:01 CET 2008
On Wed, Dec 03, 2008 at 09:03:27AM +0000, Filippos K wrote:
> Hello
Hi,
> I was wondering about the behavior of readline_NEW. It seems to return
> the newline character at the end of strings (i.e. \n). I've noticed
> this with Drascula's save games and with M4's text sequences (check
> commits 35212 - 35213). There was no such issue with readline_OLD. Is
> this the expected behavior?
Yes. See the documentation for readLine_NEW:
* Reads at most one less than the number of characters specified
* by bufSize from the and stores them in the string buf. Reading
* stops when the end of a line is reached (CR, CR/LF or LF), and
* at end-of-file or error. The newline, if any, is retained (CR
* and CR/LF are translated to LF = 0xA = '\n'). If any characters
* are read and there is no error, a `\0' character is appended
* to end the string.
The reasons for this change in behaviour are that readLine_NEW's
behaviour now matches fgets() and allows you to properly detect when it
has finished reading a line. (Relevant when dealing with lines longer
than the buffer and unterminated lines.)
-Willem Jan
More information about the Scummvm-devel
mailing list