This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Suggestion of three new functions for glibc
- From: Bruno Haible <bruno at clisp dot org>
- To: libc-alpha at sources dot redhat dot com
- Cc: Aki Tossavainen <cmouse at quakenet dot org>
- Date: Wed, 22 Oct 2003 22:57:55 +0200
- Subject: Re: Suggestion of three new functions for glibc
> void strtrimleft(char *string, const char *trimmers) {
> void strtrimright(char *string, const char *trimmers) {
You're assuming that a character and a 'char' are the same thing. This
is wrong nowadays. For example, if I wanted to remove spaces from an
UTF-8 string, the set of trimmers would be
{ "\x20", "\xe2\x80\x82", "\xe2\x80\x83", "\xe2\x80\x84", ... }
i.e. an array of 'char*', not an array of 'char'.
> for(cp = string + strlen(string); (cp >= string)&&(strchr(trimmers,*cp)); cp--);
Parsing a string from the end is a no-no when the string is encoded using
some encoding like BIG5, GBK or SHIFT_JIS.
Furthermore, the function you propose are neither
- so generally useful that they need to be in libc,
- dependent on the kernel
therefore I'd say they don't belong in libc.
Bruno