From 216447492a88a65cc01f3bb19352e4dafb263a6a Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 18 Aug 2010 00:43:12 +0000 Subject: Chomp all trailing space characters, including new lines, when parsing the config file --- opentracker.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/opentracker.c b/opentracker.c index 579e41e..bb024b0 100644 --- a/opentracker.c +++ b/opentracker.c @@ -374,8 +374,8 @@ int parse_configfile( char * config_filename ) { } while( fgets( inbuf, sizeof(inbuf), accesslist_filehandle ) ) { - char *newl; char *p = inbuf; + size_t strl; /* Skip white spaces */ while(isspace(*p)) ++p; @@ -383,8 +383,10 @@ int parse_configfile( char * config_filename ) { /* Ignore comments and empty lines */ if((*p=='#')||(*p=='\n')||(*p==0)) continue; - /* chomp */ - if(( newl = strchr(p, '\n' ))) *newl = 0; + /* consume trailing new lines and spaces */ + strl = strlen(p); + while( strl && isspace(p[strl-1])) + p[--strl] = 0; /* Scan for commands */ if(!byte_diff(p,15,"tracker.rootdir" ) && isspace(p[15])) { -- cgit v1.2.3