🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3804

strstr - zero-length s2

#3804
From: Bob Nelson
Date: Mon, 21 Aug 1995 16:51
37 lines
2127 bytes
The Rationale [4.11.5.7] explains that the strstr function "is an
invention of the Committee."

1). From this statement, may one conclude that its design did not
    have to consider "prior art" and/or existing implementations of
    extant strstr()s?

The Standard [7.11.5.7] states: "If s2 points to a string with zero
length, the function returns s1." That's the way it is -- that's
the way I have used and will continue to use it of course, but...

2). Was there perhaps any fleeting thought given (while designing
    strstr) to have the function instead return a pointer to the
    _end_ of s1 if s2 were a zero-length string? What were some of
    the things the Committee had to consider in coming up with
    the s2 as zero-length string behavior for strstr? What are the
    advantages (in terms of usage) of the current design
    as opposed to the alternative I mentioned?

3). Plauger, "The Standard C Library", in the section "Implementing
    <string.h>" says: "The function treats an empty string s2 as
    a special case. It matches the implicit empty string at the start
    of s1."

    Might one of the c.s.c participants expand on what Plauger means
    by this "implicit empty string" and contrast this phrase with
    the null string (null string used to denote "")?

[Disclaimer/Flame Abatement Statement: This post is in *no* way
meant to be argumentative nor is its intent to cast any doubt
whatsoever on either the design or utility of strstr].

-- 
=============================================================================
          Bob Nelson: Dallas, Texas, U.S.A.  -  bnelson@netcom.com
      Linux for fun, M$ for $$$...and the NFL for what really counts!
=============================================================================
Technical Details
Message-ID: <bnelsonDDo6u7.F01@netcom.com>
Path: arc1-ca.pugleaf.net!netcom.com!bnelson

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!netcom.com!bnelson
From: bnelson@netcom.com (Bob Nelson)
Subject: strstr - zero-length s2
Message-ID: <bnelsonDDo6u7.F01@netcom.com>
Organization: a computer running Linux
X-Newsreader: TIN [version 1.2 PL2]
Date: Mon, 21 Aug 1995 16:51:42 GMT
Sender: bnelson@netcom17.netcom.com