home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 19099 < prev    next >
Encoding:
Internet Message Format  |  1992-12-31  |  2.3 KB

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