Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Addendum: There are C library implementations that definitely do not work this way. It is possible to implement a C library sscanf() that doesn't call strlen() first thing every time or memchr() over and over on the same block of memory.

Neither P.J. Plauger's nor my Standard C library (which I wrote in the 1990s and used for my 32-bit OS/2 programs) work this way. We both use simple callback functions that use "void*"s that are opaque to the common internals of *scanf() but that are cast to "FILE*" or "const char*" in the various callback functions.

OpenWatcom's C library does the same. Things don't get marshalled into nonce FILE objects on every call. Rather, the callback functions simply look at the next character to see whether it is NUL. They aren't even using memchr() calls to find a NUL in the first position of a string. (-:

* http://perforce.openwatcom.org:4000/@md=d&cd=//depot/V2/src/...



Addendum: The C library on Tru64 Unix didn't work that way either, reportedly.

* https://groups.google.com/g/comp.lang.c/c/SPOnRZ3nEHk/m/dAoB...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: