浏览代码

* Tweaked the loop in parse_script to better handle when the outer brackets aren't checked.
* Fixed a typo in skip_space that stopped skipping characters when it encountered a '*' or '/' in a block comment.
ex: /* this will give a parse error after this character->* */
/* same thing here->/ */

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11487 54d463be-8e91-2dee-dedb-b68131a5f0ec

FlavioJS 17 年之前
父节点
当前提交
7109831b80
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 5 0
      Changelog-Trunk.txt
  2. 9 3
      src/map/script.c

+ 5 - 0
Changelog-Trunk.txt

@@ -3,6 +3,11 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2007/10/16
+	* Tweaked the loop in parse_script to better handle when the outer 
+	  brackets aren't checked.
+	* Fixed a typo in skip_space that stopped skipping characters when it 
+	  encountered a '*' or '/' in a block comment. [FlavioJS]
 2007/10/15
 	* Fixed NPC_CRITICALWOUND to reduce heal by 20% per level [Playtester]
 	* Fixing TK Mission asigning non spawning mobs. [Zephyrus]

+ 9 - 3
src/map/script.c

@@ -461,6 +461,7 @@ static void script_reportdata(struct script_data* data)
 		else
 		{// ???
 			ShowDebug("Data: reference name='%s' type=%s\n", reference_getname(data), script_op2name(data->type));
+			ShowDebug("Please report this!!! - str_data.type=%s\n", script_op2name(str_data[reference_getid(data)].type);
 		}
 		break;
 	case C_POS:// label
@@ -740,7 +741,7 @@ const char* skip_space(const char* p)
 			{
 				if( *p == '\0' )
 					disp_error_message("script:skip_space: end of file while parsing block comment. expected "CL_BOLD"*/"CL_NORM, p);
-				if( *p == '*' || p[1] == '/' )
+				if( *p == '*' && p[1] == '/' )
 				{// end of block comment
 					p += 2;
 					break;
@@ -1897,6 +1898,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
 	int i;
 	struct script_code *code;
 	static int first=1;
+	char end;
 
 	if( src == NULL )
 		return NULL;// empty script
@@ -1961,6 +1963,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
 			script_buf  = NULL;
 			return NULL;
 		}
+		end = '\0';
 	}
 	else
 	{// requires brackets around the script
@@ -1975,11 +1978,13 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
 			script_buf  = NULL;
 			return NULL;
 		}
+		end = '}';
 	}
 
-	while (*p && (*p != '}' || syntax.curly_count != 0) )
+	while( syntax.curly_count != 0 || *p != end )
 	{
-		p=skip_space(p);
+		if( *p == '\0' )
+			disp_error_message("unexpected end of script",p);
 		// label‚¾‚¯“ÁŽê�ˆ—�
 		tmpp=skip_space(skip_word(p));
 		if(*tmpp==':' && !(!strncasecmp(p,"default:",8) && p + 7 == tmpp)){
@@ -1988,6 +1993,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
 			if( parse_options&SCRIPT_USE_LABEL_DB )
 				strdb_put(scriptlabel_db, GETSTRING(str_data[i].str), (void*)script_pos);
 			p=tmpp+1;
+			p=skip_space(p);
 			continue;
 		}