Trim both \n and \r\n from config files.

This commit is contained in:
Kurt Zeilenga 2001-09-24 22:18:02 +00:00
parent 790a18cb86
commit 2af75ecc6a
2 changed files with 7 additions and 1 deletions

View file

@ -2227,7 +2227,9 @@ fp_getline( FILE *fp, int *lineno )
}
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
/* trim off \r\n or \n */
if ( (p = strchr( buf, '\n' )) != NULL ) {
if( p > buf && p[-1] == '\r' ) --p;
*p = '\0';
}
if ( ! isspace( (unsigned char) buf[0] ) ) {

View file

@ -259,6 +259,7 @@ getline(
CATLINE( buf );
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
if ( (p = strchr( buf, '\n' )) != NULL ) {
if( p > buf && p[-1] == '\r' ) --p;
*p = '\0';
}
lineno++;
@ -266,6 +267,9 @@ getline(
return( line );
}
/* change leading whitespace to space */
buf[0] = ' ';
CATLINE( buf );
}
buf[0] = '\0';