From 53d4cb5c798563c20e4602d5a65eefe00a0ac47c Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 4 Jan 2011 18:59:50 +0000 Subject: * Added support for removal of trailing comments to sv_readdb (bugreport:4680). - Disabled monster BACSOJIN_T (1996) whose drop White Snake Hat (5411) is not enabled (was hidden by '//', which would cause errors now) (since r14412). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14649 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/strlib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/strlib.c b/src/common/strlib.c index 019e2d629..a0cba906c 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -925,6 +925,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc char** fields; // buffer for fields ([0] is reserved) int columns, fields_length; char path[1024], line[1024]; + char* match; snprintf(path, sizeof(path), "%s/%s", directory, filename); @@ -944,9 +945,12 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc while( fgets(line, sizeof(line), fp) ) { lines++; - if( line[0] == '/' && line[1] == '/' ) - continue; - //TODO: strip trailing // comment + + if( ( match = strstr(line, "//") ) != NULL ) + {// strip comments + match[0] = 0; + } + //TODO: strip trailing whitespace if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r') continue; -- cgit v1.2.3-60-g2f50