Hello,
I have need to strip the line separator from a string now. Something
like perl's chomp could be useful, when a text file is read by
e.g. apr_file_gets().
In perl ...
[EMAIL PROTECTED] zito $ perl -e '$_="BLA\n"; chomp $_; print "X${_}X\n";'
XBLAX
What about to include code like below to APR under ./strings ?
/**
* Strip trailing EOL from a string (in place)
* @param s The string to chop EOL in place.
*/
APR_DECLARE(char *) apr_chomp(char *s);
APR_DECLARE(char *) apr_chomp(char *s)
{
int s_len, eol_len;
char *p;
s_len = strlen(s);
eol_len = strlen(APR_EOL_STR);
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;
}
Maybe I missed another simple way to do this, please tell mi if.
--
Zito