Such text in the definition of strchr, would be included
to remind you of how a string is actually defined.
ISO/IEC 9899:1999 (E)
7. Library
7.1 Introduction
7.1.1 Definitions of terms
1 A string is a contiguous sequence of characters
terminated by
and including the first null character.
That is true of the representation of a string. To store a four character
string we have to allocate five bytes and copy five bytes, after all. If we do
not reserve that space, or ensure that the null is propagated somehow, then we
do not have a string object.
But, on the other hand, strlen("abc") is 3. Only those characters prior to the
nul are counted, and that quantity is called the length of the string.
Something outside of the measured length of an object is not part of that
object. Or at best it is ambiguous. (For instance, the height of some building,
for some given purpose, may or may not exclude an antenna mast on top.)
If strings had a header indicating their length, followed by the data then
7.1.1 would have define a string as being that header and that data.
It is highly implausible that the text in strchr is given for the purpose of
reminding the reader what a string is. It is to give a requirement of behavior
which only comes into play when the search character is null.
In fact, this kind of text is given in quite a few places. In contexts where it
may not be clear, there is a reminder "including the terminating null
character". Furthermore, in a few places, there is the opposite reminder: "not
including the terminating null character". So, which of those places are
the reminders about how a string is defined, and which are the exceptions?
What these are are reminders of the definition of a string is two-fold and
ambiguous: it is either the abstract sequence of characters, or the storage
object, depending on context.
Consider stpbrk. Its definition has no reminder. What should strpbrk("", "")
return? If 7.1.1 gives the definition of an abstract string, then "" must be
considered to be the string consisting of the null character. The "" passed as
a right argument must denote a set which contains the null character, and since
that character is found in the left argument, a pointer should be returned
to the left argument's null. But, in fact, the return value in this case is
the null pointer. An empty string denotes an empty set, and a string in which
no character can be found.
Likewise, if that text about the null character were not given in the
definition of strchr, the interpretation would have to be that the null
character is never found, and so a null pointer is returned. A null character
normally cannot be found in a string because the search terminates when the
terminator is encountered. Null-finding behavior is an exception.