summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/npc.c18
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;