Menu

#9 strnchr needs to be revisited

1.0
open
nobody
None
False
351:342a043be4c8
375:5f3d507ef3f1
2014-04-23
2013-06-13
No

The history of this one is that the DOS CATALOG buffer returned is space-padded for each of the 8.3 parts of the filename. Thus the name "HELLO.C" would appear as

"HELLO   C  "

strnchr() was a quick implementation to allow ls to locate the first space, searching at most 8 (then 3) characters.

There are two issues:

  1. It's been pointed out that technically, NULL should be returned if the character is not found. I can't lay my hands on any official definition of strnchr() so I can't say either way.

  2. It's inefficient, and would probably be better coded directly in assembler.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB