3 ms·
It turns out that the strlen() behaviour was present as far back as the 4BSD libc [1] circa 1980, and via the Net/2 releases has found its way into NetBSD/FreeB
by kiwidrew 6y ago
It turns out that the strlen() behaviour was present as far back as the 4BSD libc [1] circa 1980, and via the Net/2 releases has found its way into NetBSD/FreeBSD/OpenBSD along with countless other BSD-derived libc implementations.
Of course, the underlying vfscanf() implementation that reads from a FILE* simply proceeds one character at a time; the pseudo-quadratic behaviour arising from the strlen() call is simply an artifact of the simplistic "simulate a file using a string" wrapper in sscanf().
[1] https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/libc/stdio/scanf.c https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/l...