🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3832

Re: strstr - zero-length s2

#3832
From: Mark Brader
Date: Wed, 23 Aug 1995 17:44
31 lines
1821 bytes
The standard specifies in 7.1.1/4.1.1 that

#  A string is a contiguous sequence of characters terminated by and
#  including the first null character. ... The "length" of a string
#  is the number of characters preceding the null character and its
#  "value" is the sequence of the values of the contained characters,
#  in order.

Thus the value of the string corresponding to the string literal "DMR"
is a sequence of 4 characters: <D, M, R, null character>.  And similarly,
the value of a string of length zero is a sequence of one character:
<null character>.

But for this wording, it would be possible to think of the value of a
string as being the sequence of characters, in order, *preceding* the
null; that is, of the same characters that participate in determining
its length.  Some loose wording in the later sections of the standard
actually does appear to take this interpretation; for example, the
definition of strspn() in 7.11.5.6/4.11.5.6.  And of course, in this
interpretation a string of length zero (i.e. an empty or null string,
corresponding to the string literal "") has the value <>, the empty
sequence.

I'm sure that this latter model is what Plauger had in mind in the cited
section of his book.
-- 
Mark Brader              |   "I love talking about nothing.
msb@sq.com               |    It's the only thing I know anything about."
SoftQuad Inc., Toronto   |   -- Lord Goring  (Oscar Wilde: An Ideal Husband)

My text in this article is in the public domain.
Technical Details
Message-ID: <1995Aug23.174403.28376@sq.com>
Path: arc1-ca.pugleaf.net!spool.mu.edu!torn!sq!msb
References: <bnelsonDDo6u7.F01@netcom.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!spool.mu.edu!torn!sq!msb
From: msb@sq.com (Mark Brader)
Subject: Re: strstr - zero-length s2
Message-ID: <1995Aug23.174403.28376@sq.com>
Organization: SoftQuad Inc., Toronto, Canada
References: <bnelsonDDo6u7.F01@netcom.com>
Date: Wed, 23 Aug 1995 17:44:03 GMT