Thoughts on `const' parameters

Joe Buck jbuck at epimass.EPI.COM
Thu Dec 8 03:58:02 AEST 1988


In article <957 at vsi.COM> friedl at vsi.COM (Stephen J. Friedl) writes:
>< P.S. - did anybody consider putting `index' and `rindex' into the standard?

In article <9027 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
>< Not for very long.  They have been obsolete since 1980, although
>< systems based on obsolete C technology (such as 4BSD) continue to
>< provide them.  Use strchr() and strrchr() instead.

I can see why you think index and rindex reflect "obsolete C
technology".  strchr is identical to index, and strrchr is identical
to rindex.  But it wasn't BSD who introduced an incompatible name
change, it was the USG folks.  This didn't make the older names
"obsolete", only incompatible, since at that point there were a lot of
Version 7 unixes with the older names out there.  Only with the
adoption of the new C standard will the names "index" and "rindex"
become obsolete.

In article <965 at vsi.COM> friedl at vsi.COM (Stephen J. Friedl) writes:
>OK, does BSD have strchr() and strrchr()?  Which versions of BSD?

Bring your C compiler into the 20th century :-) !  Add

#define strchr index
#define strrchr rindex

to your <string.h> or <strings.h> or whichever one BSD has.
-- 
- Joe Buck	jbuck at epimass.epi.com, or uunet!epimass.epi.com!jbuck,
		or jbuck%epimass.epi.com at uunet.uu.net for old Arpa sites
I am of the opinion that my life belongs to the whole community, and as long
as I live it is my privilege to do for it whatever I can.  -- G. B. Shaw



More information about the Comp.std.c mailing list