libite/chomp.c
/**
 * chomp - Perl like chomp function, chop off last char(s) if newline.
 * @str: String to chomp
 *
 * This function is like Perl chomp, but it's set to chop of all
 * trailing newlines.
 *
 * Returns:
 * If @str is a valid pointer this function returns @str, otherwise
 * @errno is set to %EINVAL and this function returns %NULL.
 */
Perl like chomp function, chop off last char(s) if newline.
@str: String to chomp

This function is like Perl chomp, but it's set to chop of all
trailing newlines.

If @str is a valid pointer this function returns @str, otherwise
@errno is set to %EINVAL and this function returns %NULL.
Perl like chomp function chop off last char ( s ) if newline . @str : String to chomp This function is like Perl chomp but it ' s set to chop of all trailing newlines . If @str is a valid pointer this function returns @str otherwise @errno is set to %EINVAL and this function returns %NULL .
char *chomp(char *str)
{
	char *p;
	if (!str || strlen(str) < 1) {
		errno = EINVAL;
		return NULL;
	}
	p = str + strlen(str) - 1;
        while (*p == '\n')
		*p-- = 0;
	return str;
}
char * chomp ( char * str ) { char * p ; if ( ! str || strlen ( str ) < 1 ) { errno = EINVAL ; return NULL ; } p = str + strlen ( str ) - 1 ; while ( * p == ' \n ' ) * p -- = 0 ; return str ; }
chomp - Perl like chomp function, chop off last char(s) if newline.
chomp - Perl like chomp function chop off last char ( s ) if newline .