On 20/06/2023, Richard B. Kreckel <kreckel@in.terlu.de> wrote:
Could you, please, polish your patch a little? In particular, explain the role of the magic '*' char. Also how it works at boundaries of YY_READ_BUF_SIZE.
Hi, Richy. The '*' value is only there so that if max_size is 0 and no characters are read, the final newline check (c=='\n') would not compare to an uninitialized variable. This should never happen, as far as I understand, but if it does, we still do the right thing. Related to that, the max_size value passed to the function is YY_READ_BUF_SIZE minus the current buffer content; this is ensured by Flex. But in any case, I did not invent this code: I copy-pasted it directly from the interactive mode with HAVE_LIBREADLINE disabled; this way I can convince myself that it's correct, because it's already used a few lines up :) I'm attaching the patch.