Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Dr Nick <nospam-4@temporary-address.org.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: strsup - supplementary string functions |
| References | <2dc6b2f9-f029-43a0-b7e6-6258548a1a2f@googlegroups.com> |
| Date | 2013-01-24 07:44 +0000 |
| Message-ID | <878v7jdnzj.fsf@temporary-address.org.uk> (permalink) |
Malcolm McLean <malcolm.mclean5@btinternet.com> writes: > I'm putting together a little library of supplementary string > functions, > strsup.c. > > The functions are intended to be fairly short, and to operate on char > *s. > They should ideally be implementable as a single function which can be > snipped > and pasted. > > Unlike the string.h functions they can depend on malloc(). > > The obvious first function is strdup(). > > I've also got > > strcount - count the instances of character ch in str. > trim - remove leadign and trailing whitespace from a string > singlespace - repalce all runs of whitespace in a string with a single > space character. > split - return an array of fields, split on a delimiter character. > compnumeric - compare two strings with embedded numbers. > replace - replace all substrings with new passed string. > > Any ideas for more? Unless you change your mind and create (yet another, we've all done it) structure based string type, here's a suggestion: have a very clear convention in the naming as to which of your functions return the original string, perhaps modified (convert case, trim the right-hand-end) and which return a new string. In fact, think hard about this all over (should replace always create a new string, create a new string when lengthening but not shortening, or realloc when necessary?).
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
strsup - supplementary string functions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-01-22 10:14 -0800
Re: strsup - supplementary string functions Keith Thompson <kst-u@mib.org> - 2013-01-22 11:23 -0800
Re: strsup - supplementary string functions James Kuyper <jameskuyper@verizon.net> - 2013-01-22 14:34 -0500
Re: strsup - supplementary string functions Keith Thompson <kst-u@mib.org> - 2013-01-22 11:44 -0800
Re: strsup - supplementary string functions Johann Klammer <klammerj@NOSPAM.a1.net> - 2013-01-22 22:57 +0100
Re: strsup - supplementary string functions Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-01-23 21:13 +0000
Re: strsup - supplementary string functions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-23 23:08 +0000
Re: strsup - supplementary string functions Bjorn Augestad <bjorn.augestad@gmail.com> - 2013-01-23 22:54 +0100
Re: strsup - supplementary string functions Dr Nick <nospam-4@temporary-address.org.uk> - 2013-01-24 07:44 +0000
Re: strsup - supplementary string functions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-01-24 01:12 -0800
Re: strsup - supplementary string functions "BartC" <bc@freeuk.com> - 2013-01-25 18:27 +0000
Re: strsup - supplementary string functions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-01-28 01:24 -0800
Re: strsup - supplementary string functions John McCue <jmccue@jmcbsd0.hsd1.ma.comcast.net> - 2013-01-24 22:28 +0000
Re: strsup - supplementary string functions JohnF <john@please.see.sig.for.email.com> - 2013-01-25 10:57 +0000
Re: strsup - supplementary string functions 88888 Dihedral <dihedral88888@googlemail.com> - 2013-01-25 12:45 -0800
Re: strsup - supplementary string functions ssmitch@gmail.com - 2013-01-29 08:17 -0800
Re: strsup - supplementary string functions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2013-01-29 09:57 -0800
Re: strsup - supplementary string functions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-01-30 03:46 +0000
Re: strsup - supplementary string functions Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-31 14:50 -0800
Re: strsup - supplementary string functions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-02-02 02:45 +0000
Re: strsup - supplementary string functions Tim Rentsch <txr@alumni.caltech.edu> - 2013-02-03 14:33 -0800
csiph-web