diff --git a/jsdump.c b/jsdump.c index 560216d..37f84f1 100644 --- a/jsdump.c +++ b/jsdump.c @@ -799,7 +799,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F) switch (c) { case OP_INTEGER: - printf(" %d", (*p++) - 32768); + printf(" %ld", (long)((*p++) - 32768)); break; case OP_NUMBER: printf(" %.9g", F->numtab[*p++]); @@ -840,7 +840,7 @@ void jsC_dumpfunction(js_State *J, js_Function *F) case OP_JFALSE: case OP_JCASE: case OP_TRY: - printf(" %d", *p++); + printf(" %ld", (long)*p++); break; } diff --git a/jsi.h b/jsi.h index d13a9fd..444eb26 100644 --- a/jsi.h +++ b/jsi.h @@ -69,14 +69,29 @@ typedef struct js_StackTrace js_StackTrace; /* Limits */ +#ifndef JS_STACKSIZE #define JS_STACKSIZE 256 /* value stack size */ +#endif +#ifndef JS_ENVLIMIT #define JS_ENVLIMIT 64 /* environment stack size */ +#endif +#ifndef JS_TRYLIMIT #define JS_TRYLIMIT 64 /* exception stack size */ +#endif +#ifndef JS_GCLIMIT #define JS_GCLIMIT 10000 /* run gc cycle every N allocations */ +#endif +#ifndef JS_ASTLIMIT #define JS_ASTLIMIT 100 /* max nested expressions */ +#endif /* instruction size -- change to int if you get integer overflow syntax errors */ + +#ifdef JS_INSTRUCTION +typedef JS_INSTRUCTION js_Instruction; +#else typedef unsigned short js_Instruction; +#endif /* String interning */ diff --git a/regexp.c b/regexp.c index 01e1aa0..672ebc3 100644 --- a/regexp.c +++ b/regexp.c @@ -14,9 +14,21 @@ #define nelem(a) (int)(sizeof (a) / sizeof (a)[0]) #define REPINF 255 +#ifndef MAXSUB #define MAXSUB REG_MAXSUB +#endif +#ifndef MAXPROG #define MAXPROG (32 << 10) +#endif +#ifndef MAXREC #define MAXREC 1024 +#endif +#ifndef MAXSPAN +#define MAXSPAN 64 +#endif +#ifndef MAXCLASS +#define MAXCLASS 16 +#endif typedef struct Reclass Reclass; typedef struct Renode Renode; @@ -25,14 +37,14 @@ typedef struct Rethread Rethread; struct Reclass { Rune *end; - Rune spans[64]; + Rune spans[MAXSPAN]; }; struct Reprog { Reinst *start, *end; int flags; int nsub; - Reclass cclass[16]; + Reclass cclass[MAXCLASS]; }; struct cstate { @@ -194,7 +206,7 @@ static void addrange(struct cstate *g, Rune a, Rune b) { if (a > b) die(g, "invalid character class range"); - if (g->yycc->end + 2 == g->yycc->spans + nelem(g->yycc->spans)) + if (g->yycc->end + 2 >= g->yycc->spans + nelem(g->yycc->spans)) die(g, "too many character class ranges"); *g->yycc->end++ = a; *g->yycc->end++ = b;