From: Kurt Zeilenga Date: Mon, 24 Sep 2001 22:18:02 +0000 (+0000) Subject: Trim both \n and \r\n from config files. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1064 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2af75ecc6ac1ca38c1677ad90f20c46dfb7186f5;p=openldap Trim both \n and \r\n from config files. --- diff --git a/servers/slapd/config.c b/servers/slapd/config.c index e80b9b78d4..fc71756e2a 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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] ) ) { diff --git a/servers/slurpd/config.c b/servers/slurpd/config.c index 845e75b8e4..d56ca94f78 100644 --- a/servers/slurpd/config.c +++ b/servers/slurpd/config.c @@ -259,13 +259,17 @@ getline( CATLINE( buf ); while ( fgets( buf, sizeof(buf), fp ) != NULL ) { if ( (p = strchr( buf, '\n' )) != NULL ) { - *p = '\0'; + if( p > buf && p[-1] == '\r' ) --p; + *p = '\0'; } lineno++; if ( ! isspace( (unsigned char) buf[0] ) ) { return( line ); } + /* change leading whitespace to space */ + buf[0] = ' '; + CATLINE( buf ); } buf[0] = '\0';