mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 08:09:34 -05:00
Trim both \n and \r\n from config files.
This commit is contained in:
parent
790a18cb86
commit
2af75ecc6a
2 changed files with 7 additions and 1 deletions
|
|
@ -2227,7 +2227,9 @@ fp_getline( FILE *fp, int *lineno )
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
|
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
|
||||||
|
/* trim off \r\n or \n */
|
||||||
if ( (p = strchr( buf, '\n' )) != NULL ) {
|
if ( (p = strchr( buf, '\n' )) != NULL ) {
|
||||||
|
if( p > buf && p[-1] == '\r' ) --p;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
if ( ! isspace( (unsigned char) buf[0] ) ) {
|
if ( ! isspace( (unsigned char) buf[0] ) ) {
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@ getline(
|
||||||
CATLINE( buf );
|
CATLINE( buf );
|
||||||
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
|
while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
|
||||||
if ( (p = strchr( buf, '\n' )) != NULL ) {
|
if ( (p = strchr( buf, '\n' )) != NULL ) {
|
||||||
|
if( p > buf && p[-1] == '\r' ) --p;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
lineno++;
|
lineno++;
|
||||||
|
|
@ -266,6 +267,9 @@ getline(
|
||||||
return( line );
|
return( line );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* change leading whitespace to space */
|
||||||
|
buf[0] = ' ';
|
||||||
|
|
||||||
CATLINE( buf );
|
CATLINE( buf );
|
||||||
}
|
}
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue