lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Shmuel Zeigerman wrote:
> KHMan wrote:
>> Checking DJGPP, Cygwin and Linux, nobody mentioned handling of NUL
>> characters in fgets. The Open Group Base Specifications Issue 6
>> based on IEEE Std 1003.1 for fgets also does not mention this.
>> They didn't think it necessary to specify all the corner cases.
> May be they didn't think it necessary because fgets *does* handle
> null characters just fine?
> (At least in 2 compilers I work with: gcc/mingw and bcc32/borland).

Ah, MSVCRT is very old and very non-compliant. Should someone use
fgets in a C program and rely on this behaviour and use mem* calls
to deal with NULs in the data stream, as opposed to the usual
practice of using str* calls on textual strings? Does the
developer has better, safer options?

I wouldn't want to write code that depends on
implementation-specific behaviour if I can help it, so I would
never dream of using fgets (or the Lua equivalent of "*l") for
anything that isn't standard text files. The issue just doesn't
arise. But that's just me, I guess.

I have nothing further to add, so that's all from me for this
thread, I won't post anything more on this topic.

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia