From 76b9daa5dc6943d7f7823e1cad035f925dd10aa4 Mon Sep 17 00:00:00 2001 From: robertc <> Date: Mon, 9 Jun 2003 11:09:34 +0000 Subject: [PATCH] Summary: parseConfigFile had a const correctness flaw. Keywords: Summary: parseConfigFile had a const correctness flaw. It used a char * pointer to handle the result of a strrchr, which on some platforms leads to compiler warnings. Refactored to avoid this. --- src/cache_cf.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/cache_cf.cc b/src/cache_cf.cc index f7932fd588..e966cccfc6 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.442 2003/05/21 02:58:11 robertc Exp $ + * $Id: cache_cf.cc,v 1.443 2003/06/09 05:09:34 robertc Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -273,6 +273,19 @@ update_maxobjsize(void) store_maxobjsize = ms; } +static void +SetConfigFilename(char const *file_name, bool is_pipe) +{ + cfg_filename = file_name; + + char const *token; + + if (is_pipe) + cfg_filename = file_name + 1; + else if ((token = strrchr(cfg_filename, '/'))) + cfg_filename = token + 1; +} + int parseConfigFile(const char *file_name) { @@ -301,12 +314,7 @@ parseConfigFile(const char *file_name) #endif - cfg_filename = file_name; - - if (is_pipe) - cfg_filename = file_name + 1; - else if ((token = strrchr(cfg_filename, '/'))) - cfg_filename = token + 1; + SetConfigFilename(file_name, bool(is_pipe)); memset(config_input_line, '\0', BUFSIZ); @@ -344,8 +352,7 @@ parseConfigFile(const char *file_name) #if PROBABLY_NOT_WANTED_HERE - if ((token = strrchr(cfg_filename, '/'))) - cfg_filename = token + 1; + SetConfigFilename(cfg_filename, false); #endif -- 2.47.2