apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vaclav Ovsik <Vaclav.Ov...@i.cz>
Subject Re: to add function apr_chomp into string functions?
Date Thu, 27 Mar 2003 12:52:41 GMT
On Thu, Mar 27, 2003 at 12:14:27PM +0100, Vaclav Ovsik wrote:
> APR_DECLARE(char *) apr_chomp(char *s)
> {
>     int s_len, eol_len;
>     char *p;
> 
>     s_len = strlen(s);
>     eol_len = ststrlenrlen(APR_EOL_STR);

     eol_len = sizeof(APR_EOL_STR) -1;

>     if ( s_len < eol_len )
>         return s;
>     p = s + s_len - eol_len;
>     if ( strcmp(p, APR_EOL_STR) == 0 )
>         *p = (char)0;
>     return s;
> }

strlen() from const string is superfluous, sizeof -1 at compile time
may be better.
-- 
Zito

Mime
View raw message