mirror of
https://git.checksum.fail/alec/mujs.git
synced 2026-05-01 18:19:42 +03:00
Bump VERSION to commit 0b4ed7e
This commit is contained in:
@@ -1 +1 @@
|
|||||||
commit 7368c02b4409107ed64aea19a1c32e6852c76d66
|
commit 0b4ed7e4ba37030fdd00f6a17b6de75cd7d7954b
|
||||||
|
|||||||
@@ -63,6 +63,38 @@ static void Ap_concat(js_State *J)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ugly cycle detection for Array.prototype.join */
|
||||||
|
static void Ap_join(js_State *J);
|
||||||
|
static void Ap_toString(js_State *J);
|
||||||
|
static int Ap_join_cycle(js_State *J)
|
||||||
|
{
|
||||||
|
js_Object *needle = js_toobject(J, 0);
|
||||||
|
int top = J->tracetop - 1;
|
||||||
|
while (top > 0) {
|
||||||
|
int stk = J->trace[top].stack;
|
||||||
|
js_Value *fun = &J->stack[stk-1];
|
||||||
|
if (fun->t.type != JS_TOBJECT) return 0;
|
||||||
|
if (fun->u.object->type != JS_CCFUNCTION) return 0;
|
||||||
|
if (fun->u.object->u.c.function == Ap_join)
|
||||||
|
{
|
||||||
|
js_Value *obj = &J->stack[stk];
|
||||||
|
if (obj->t.type != JS_TOBJECT) return 0;
|
||||||
|
if (obj->u.object == needle)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (fun->u.object->u.c.function == Ap_toString)
|
||||||
|
{
|
||||||
|
/* join calls toString which calls join which calls toString, etc */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
--top;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void Ap_join(js_State *J)
|
static void Ap_join(js_State *J)
|
||||||
{
|
{
|
||||||
char * volatile out = NULL;
|
char * volatile out = NULL;
|
||||||
@@ -71,6 +103,11 @@ static void Ap_join(js_State *J)
|
|||||||
int seplen;
|
int seplen;
|
||||||
int k, n, len, rlen;
|
int k, n, len, rlen;
|
||||||
|
|
||||||
|
if (Ap_join_cycle(J)) {
|
||||||
|
js_pushliteral(J, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
len = js_getlength(J, 0);
|
len = js_getlength(J, 0);
|
||||||
|
|
||||||
if (js_isdefined(J, 1)) {
|
if (js_isdefined(J, 1)) {
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ struct js_StackTrace
|
|||||||
const char *name;
|
const char *name;
|
||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
|
int stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Exception handling */
|
/* Exception handling */
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ static void textpush(js_State *J, Rune c)
|
|||||||
n = runelen(c);
|
n = runelen(c);
|
||||||
if (J->lexbuf.len + n > J->lexbuf.cap) {
|
if (J->lexbuf.len + n > J->lexbuf.cap) {
|
||||||
newcap = J->lexbuf.cap * 2;
|
newcap = J->lexbuf.cap * 2;
|
||||||
J->lexbuf.text = js_realloc(J, J->lexbuf.text, J->lexbuf.cap);
|
J->lexbuf.text = js_realloc(J, J->lexbuf.text, newcap);
|
||||||
J->lexbuf.cap = newcap;
|
J->lexbuf.cap = newcap;
|
||||||
}
|
}
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
|
|||||||
@@ -1289,6 +1289,7 @@ static void jsR_pushtrace(js_State *J, const char *name, const char *file, int l
|
|||||||
if (J->tracetop + 1 == JS_ENVLIMIT)
|
if (J->tracetop + 1 == JS_ENVLIMIT)
|
||||||
js_error(J, "call stack overflow");
|
js_error(J, "call stack overflow");
|
||||||
++J->tracetop;
|
++J->tracetop;
|
||||||
|
J->trace[J->tracetop].stack = J->bot;
|
||||||
J->trace[J->tracetop].name = name;
|
J->trace[J->tracetop].name = name;
|
||||||
J->trace[J->tracetop].file = file;
|
J->trace[J->tracetop].file = file;
|
||||||
J->trace[J->tracetop].line = line;
|
J->trace[J->tracetop].line = line;
|
||||||
|
|||||||
@@ -76,13 +76,18 @@ int js_utfptrtoidx(const char *s, const char *p)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while (s < p) {
|
while (s < p) {
|
||||||
if (*(unsigned char *)s < Runeself)
|
if (*(unsigned char *)s < Runeself)
|
||||||
|
{
|
||||||
++s;
|
++s;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
s += chartorune(&rune, s);
|
s += chartorune(&rune, s);
|
||||||
if (rune >= 0x10000)
|
if (rune >= 0x10000)
|
||||||
i += 2;
|
i += 2;
|
||||||
else
|
else
|
||||||
i += 1;
|
i += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -462,6 +467,7 @@ static void Sp_match(js_State *J)
|
|||||||
int len;
|
int len;
|
||||||
const char *a, *b, *c, *e;
|
const char *a, *b, *c, *e;
|
||||||
Resub m;
|
Resub m;
|
||||||
|
Rune rune;
|
||||||
|
|
||||||
text = checkstring(J, 0);
|
text = checkstring(J, 0);
|
||||||
|
|
||||||
@@ -497,7 +503,7 @@ static void Sp_match(js_State *J)
|
|||||||
|
|
||||||
a = c;
|
a = c;
|
||||||
if (c - b == 0)
|
if (c - b == 0)
|
||||||
++a;
|
a += chartorune(&rune, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
@@ -532,12 +538,12 @@ static void Sp_search(js_State *J)
|
|||||||
static void Sp_replace_regexp(js_State *J)
|
static void Sp_replace_regexp(js_State *J)
|
||||||
{
|
{
|
||||||
js_Regexp *re;
|
js_Regexp *re;
|
||||||
const char *source, *s, *r;
|
const char *source, *source0, *s, *r;
|
||||||
js_Buffer *sb = NULL;
|
js_Buffer *sb = NULL;
|
||||||
int n, x;
|
int n, x;
|
||||||
Resub m;
|
Resub m;
|
||||||
|
|
||||||
source = checkstring(J, 0);
|
source = source0 = checkstring(J, 0);
|
||||||
re = js_toregexp(J, 1);
|
re = js_toregexp(J, 1);
|
||||||
|
|
||||||
if (js_doregexec(J, re->prog, source, &m, 0)) {
|
if (js_doregexec(J, re->prog, source, &m, 0)) {
|
||||||
@@ -577,7 +583,7 @@ loop:
|
|||||||
case 0: --r; /* end of string; back up */
|
case 0: --r; /* end of string; back up */
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case '$': js_putc(J, &sb, '$'); break;
|
case '$': js_putc(J, &sb, '$'); break;
|
||||||
case '`': js_putm(J, &sb, source, s); break;
|
case '`': js_putm(J, &sb, source0, s); break;
|
||||||
case '\'': js_puts(J, &sb, s + n); break;
|
case '\'': js_puts(J, &sb, s + n); break;
|
||||||
case '&':
|
case '&':
|
||||||
js_putm(J, &sb, s, s + n);
|
js_putm(J, &sb, s, s + n);
|
||||||
@@ -709,6 +715,7 @@ static void Sp_split_regexp(js_State *J)
|
|||||||
int limit, len, k;
|
int limit, len, k;
|
||||||
const char *p, *a, *b, *c, *e;
|
const char *p, *a, *b, *c, *e;
|
||||||
Resub m;
|
Resub m;
|
||||||
|
Rune rune;
|
||||||
|
|
||||||
text = checkstring(J, 0);
|
text = checkstring(J, 0);
|
||||||
re = js_toregexp(J, 1);
|
re = js_toregexp(J, 1);
|
||||||
@@ -741,7 +748,7 @@ static void Sp_split_regexp(js_State *J)
|
|||||||
|
|
||||||
/* empty string at end of last match */
|
/* empty string at end of last match */
|
||||||
if (b == c && b == p) {
|
if (b == c && b == p) {
|
||||||
++a;
|
a += chartorune(&rune, a);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,16 +127,16 @@
|
|||||||
var msg = !neg_str ? err : "[Mismatch @negative " + neg_str + "]" + "\n " + err;
|
var msg = !neg_str ? err : "[Mismatch @negative " + neg_str + "]" + "\n " + err;
|
||||||
|
|
||||||
info += (result.runtime ? "[run] " : "[load] ") + msg;
|
info += (result.runtime ? "[run] " : "[load] ") + msg;
|
||||||
if (err && err.stackTrace && (result.runtime || full_mode)) {
|
if (err && err.stack && (result.runtime || full_mode)) {
|
||||||
if (full_mode) {
|
if (full_mode) {
|
||||||
info += err.stackTrace;
|
info += err.stack;
|
||||||
} else {
|
} else {
|
||||||
// trim the internal loader from the trace
|
// trim the internal loader from the trace
|
||||||
var internal = err.stackTrace.indexOf("\n" + load("mujs_blahblah()").err.stackTrace.trim().split("\n")[1]);
|
var internal = err.stack.indexOf("\n" + load("mujs_blahblah()").err.stack.trim().split("\n")[1]);
|
||||||
if (internal >= 0)
|
if (internal >= 0)
|
||||||
info += err.stackTrace.substring(0, internal);
|
info += err.stack.substring(0, internal);
|
||||||
else
|
else
|
||||||
info += err.stackTrace;
|
info += err.stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user