From ccbcf5a85c209341e6471269abef23b58633d083 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sun, 28 Oct 2007 23:48:29 +0000 Subject: * Minor adjustment to take into account the end of line. * Fixed the line count in the new error message of npc_parse_function. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11606 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ src/map/npc.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 8f55ed2d2..8bae71d38 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/10/28 + * Minor adjustment to take into account the end of line. + * Fixed the line count in the new error message of npc_parse_function. * Restricted more the parsing of npc code. (fixes bugreport:317) [FlavioJS] * Fixed a bug sending on the attachment message [Zephyrus] 2007/10/27 diff --git a/src/map/npc.c b/src/map/npc.c index 97744a348..3649731ed 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1775,12 +1775,14 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons {// parsing script with curly const char* script_start; - if( strstr(w4,",{") == NULL ) + script_start = strstr(start,",{"); + end = strchr(start,'\n'); + if( strstr(w4,",{") == NULL || script_start == NULL || (end != NULL && script_start > end) ) { ShowError("npc_parse_script: Missing left curly ',{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// can't continue } - script_start = strstr(start,",{")+1; + ++script_start; end = npc_skip_script(script_start, buffer, filepath); if( end == NULL ) @@ -2024,20 +2026,22 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co struct script_code *script; struct script_code *oldscript; const char* end; + const char* script_start; - start = strstr(start,"\t{"); - if( *w4 != '{' || start == NULL ) + script_start = strstr(start,"\t{"); + end = strchr(start,'\n'); + if( *w4 != '{' || script_start == NULL || (end != NULL && script_start > end) ) { ShowError("npc_parse_function: Missing left curly '%%TAB%%{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4); return NULL;// can't continue } + ++script_start; - end = npc_skip_script(start,buffer,filepath); + end = npc_skip_script(script_start,buffer,filepath); if( end == NULL ) return NULL;// (simple) parse error, don't continue - start = strchr(start,'{'); - script = parse_script(start, filepath, strline(buffer,start-buffer), SCRIPT_RETURN_EMPTY_SCRIPT); + script = parse_script(script_start, filepath, strline(buffer,start-buffer), SCRIPT_RETURN_EMPTY_SCRIPT); if( script == NULL )// parse error, continue return end; -- cgit v1.2.3-60-g2f50