Originally posted by [b]Rayce[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=387
1. Fixed parse error bug that if command connects immediately behind "break;" or "continue;"
when "if", "for", or "while" is closed.
Now following example is LEGAL.
CODE
while(1)
break;next; // break;<command> is no longer invalid.
2. Fixed bug which can't use "else" or "while" when "if();" or "do;" is closed.
Now following example is LEGAL.
CODE
if(rand(2)); // if(); was not closed correctly.
else
mes "hoge";
3. Fixed bug which can't close "if", "for" or "while" when user-defined function is only declared.
Now following example is LEGAL.
CODE
if(rand(2))
function test;
else
mes "hoge"; // else is no longer invalid.
4. Fixed parse error bug that if command connects immediately behind "}"
when user-defined function syntax is closed.
Now following example is LEGAL.
CODE
function test {
mes "hoge";
}next; // }<command> is no longer invalid.
5. Force "{" after function-name in user-defined function syntax.
Now following weird example is ERROR.
CODE
function test // lack of {
mes getarg(0);
test "hoge";
Unified-diff of fixed script.c is following (Rev.11693)
CODE
Index: src/map/script.c
===================================================================
--- src/map/script.c (revision 11693)
+++ src/map/script.c (working copy)
@@ -1085,8 +1085,8 @@
p=skip_space(p);
if(*p==';') {
// if(); for(); while(); のために閉じ判定
- p = parse_syntax_close(p);
- return p+1;
+ p = parse_syntax_close(p + 1);
+ return p;
}
if(*p==')' && parse_syntax_for_flag)
return p+1;
@@ -1219,7 +1219,6 @@
if(*p != ';') {
disp_error_message("parse_syntax: need ';'",p);
}
- p++;
// if, for , while の閉じ判定
p = parse_syntax_close(p + 1);
return p;
@@ -1330,7 +1329,7 @@
p = skip_space(p2);
if(*p != ';')
disp_error_message("parse_syntax: need ';'",p);
- p++;
+
// if, for , while の閉じ判定
p = parse_syntax_close(p + 1);
return p;
@@ -1474,16 +1473,20 @@
p = skip_word(func_name);
if( p == func_name )
disp_error_message("parse_syntax:function: function name is missing or invalid", p);
- if( *skip_space(p) == ';' )
+ p2 = skip_space(p);
+ if(*p2 == ';')
{// function <name>;
// function declaration - just register the name
int l;
l = add_word(func_name);
if( str_data[l].type == C_NOP )//## ??? [FlavioJS]
str_data[l].type = C_USERFUNC;
- return skip_space(p) + 1;
+
+ // if, for, while の閉じ判定
+ p = parse_syntax_close(p2 + 1);
+ return p;
}
- else
+ else if(*p2 == '{')
{// function <name> <line/block of code>
char label[256];
int l;
@@ -1510,6 +1513,10 @@
strdb_put(scriptlabel_db, GETSTRING(str_data[l].str), (void*)script_pos);
return skip_space(p);
}
+ else
+ {
+ disp_error_message("expect ';' or '{' at function syntax",p);
+ }
}
break;
case 'i':
@@ -1765,7 +1772,7 @@
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count--;
- return p + 1;
+ return p;
} else {
*flag = 0;
return p;