home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
- From: torek@horse.ee.lbl.gov (Chris Torek)
- Newsgroups: comp.lang.c
- Subject: Re: String function names
- Date: 31 Dec 1992 23:41:02 GMT
- Organization: Lawrence Berkeley Laboratory, Berkeley CA
- Lines: 40
- Message-ID: <28185@dog.ee.lbl.gov>
- References: <alien.01il@acheron.amigans.gen.nz> <1992Dec31.142013.21895@stsci.edu>
- NNTP-Posting-Host: 128.3.112.15
-
- Some time ago, in article <alien.01il@acheron.amigans.gen.nz>
- Ross Smith (alien@acheron.amigans.gen.nz) asked:
- >>Out of curiosity, does anyone know the derivation of the names of the more
- >>obscure string functions? Names like "strcat()" and "strlen()" are obvious
- >>enough, but what on earth are "strcspn()", "strpbrk()", and "strspn()"
- >>supposed to mean?
-
- In article <1992Dec31.142013.21895@stsci.edu> kimball@stsci.edu
- (Timothy Kimball) writes:
- >You got me. And if you look on page 388 of Plauger,
- >_The_C_Standard_Library_, you'll see that he's mystified by it, too-
- >and he sits on the ANSI standards committees!
-
- Someone else posted some guesses, but I think mine are closer. :-)
-
- strspn: span (extend across) characters in a set, hence
- `STRing SPaN'
- strcspn: span characters in the complement of a set, hence
- `STRing Complement SPaN'
-
- Strcoll() comes from `collate' (`assemble and arrange systematically'
- or `compare'). Strpbrk() is something of a puzzle; the best I can come
- up with is `point to break character' (from a set of break characters):
- e.g., one might find white space for token-making using
-
- p = strpbrk(str, " \t\n");
-
- Strstr() and strtok() are fairly stragihtforward (STRing subSTRing and
- STRing TOKen). Strxfrm() is `STRing transFoRM', with x replacing
- `trans'. Except for memmove, strcoll, strerror, and strxfrm---all ANSI
- C inventions---the new functions entered C via System III UNIX, the
- same people who brought you the wretched SysV IPC and shared memory.
- That would explain both the peculiar set of operations (why both
- strpbrk and strtok; why is strtok not reentrant; and why have strpbrk
- and strcspn, which are complementary---strpbrk(a,b) is much like
- a+strcspn(a,b)---without a complement for strspn?) and the inexplicable
- names, all in one swell foop.
- --
- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
- Berkeley, CA Domain: torek@ee.lbl.gov
-