From 2af75ecc6ac1ca38c1677ad90f20c46dfb7186f5 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 Sep 2001 22:18:02 +0000 Subject: [PATCH] Trim both \n and \r\n from config files. --- servers/slapd/config.c | 2 ++ servers/slurpd/config.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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'; -- 2.39.5