summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/custom/test.txt14
-rw-r--r--src/map/script.c39
2 files changed, 35 insertions, 18 deletions
diff --git a/npc/custom/test.txt b/npc/custom/test.txt
index bfd297f5d..0fffecf73 100644
--- a/npc/custom/test.txt
+++ b/npc/custom/test.txt
@@ -19,6 +19,15 @@ OnCheck:
//end;
}
return;
+OnCheckStr:
+ .@msg$ = getarg(0,"Unknown Error");
+ .@val$ = getarg(1,"");
+ .@ref$ = getarg(2,"");
+ if (.@val$ != .@ref$) {
+ debugmes "Error: "+.@msg$+": '"+.@val$+"' != '"+.@ref$+"'";
+ //end;
+ }
+ return;
OnInit:
// Array subscript
setarray .@a, 3, 2, 1;
@@ -226,6 +235,11 @@ OnInit:
callsub(OnCheck, "Order of <,>,==", .@y);
+ .@x$ = "string "
+ "concatenation" /* test */ " succeeded";
+ callsub(OnCheckStr, "String concatenation", .@x$, "string concatenation succeeded");
+
+
// Bitwise & operator
.@x = (7&4); // 0111 & 0100 --> 0100
.@y = (4&1); // 0100 & 0001 --> 0000
diff --git a/src/map/script.c b/src/map/script.c
index 73aaafab2..007a3a3d3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1070,26 +1070,29 @@ const char* parse_simpleexpr(const char *p) {
p=np;
} else if(*p=='"') {
script->addc(C_STR);
- p++;
- while( *p && *p != '"' ) {
- if( (unsigned char)p[-1] <= 0x7e && *p == '\\' ) {
- char buf[8];
- size_t len = sv->skip_escaped_c(p) - p;
- size_t n = sv->unescape_c(buf, p, len);
- if( n != 1 )
- ShowDebug("parse_simpleexpr: unexpected length %d after unescape (\"%.*s\" -> %.*s)\n", (int)n, (int)len, p, (int)n, buf);
- p += len;
- script->addb(*buf);
- continue;
- } else if( *p == '\n' ) {
- disp_error_message("parse_simpleexpr: unexpected newline @ string",p);
+ do {
+ p++;
+ while( *p && *p != '"' ) {
+ if( (unsigned char)p[-1] <= 0x7e && *p == '\\' ) {
+ char buf[8];
+ size_t len = sv->skip_escaped_c(p) - p;
+ size_t n = sv->unescape_c(buf, p, len);
+ if( n != 1 )
+ ShowDebug("parse_simpleexpr: unexpected length %d after unescape (\"%.*s\" -> %.*s)\n", (int)n, (int)len, p, (int)n, buf);
+ p += len;
+ script->addb(*buf);
+ continue;
+ } else if( *p == '\n' ) {
+ disp_error_message("parse_simpleexpr: unexpected newline @ string",p);
+ }
+ script->addb(*p++);
}
- script->addb(*p++);
- }
- if(!*p)
- disp_error_message("parse_simpleexpr: unexpected end of file @ string",p);
+ if(!*p)
+ disp_error_message("parse_simpleexpr: unexpected end of file @ string",p);
+ p++; //'"'
+ p = script->skip_space(p);
+ } while( *p && *p == '"' );
script->addb(0);
- p++; //'"'
} else {
int l;
const char* pv;