ref: e4a6860f6ec750782d9e50c8b29883a5cf92eda2
parent: fe723b6f8b0e5381235a9d8da63d251cdf8ae63b
author: Tor Andersson <[email protected]>
date: Mon Feb 24 19:22:17 EST 2014
More signedness fixes.
--- a/js.h
+++ b/js.h
@@ -76,8 +76,8 @@
void js_loadstring(js_State *J, const char *filename, const char *source);
void js_loadfile(js_State *J, const char *filename);
-void js_call(js_State *J, int n);
-void js_construct(js_State *J, int n);
+void js_call(js_State *J, unsigned int n);
+void js_construct(js_State *J, unsigned int n);
const char *js_ref(js_State *J);
void js_unref(js_State *J, const char *ref);
--- a/jsbuiltin.h
+++ b/jsbuiltin.h
@@ -18,7 +18,7 @@
void jsB_propn(js_State *J, const char *name, double number);
void jsB_props(js_State *J, const char *name, const char *string);
-typedef struct js_Buffer { int n, m; char s[64]; } js_Buffer;
+typedef struct js_Buffer { unsigned int n, m; char s[64]; } js_Buffer;
static void sb_putc(js_Buffer **sbp, int c)
{
--- a/jscompile.c
+++ b/jscompile.c
@@ -77,7 +77,7 @@
static int addnumber(JF, double value)
{
- int i;
+ unsigned int i;
for (i = 0; i < F->numlen; ++i)
if (F->numtab[i] == value)
return i;
@@ -91,7 +91,7 @@
static int addstring(JF, const char *value)
{
- int i;
+ unsigned int i;
for (i = 0; i < F->strlen; ++i)
if (!strcmp(F->strtab[i], value))
return i;
@@ -106,7 +106,7 @@
static void addlocal(JF, const char *name, int reuse)
{
if (reuse) {
- int i;
+ unsigned int i;
for (i = 0; i < F->varlen; ++i)
if (!strcmp(F->vartab[i], name))
return;
@@ -120,10 +120,10 @@
static int findlocal(JF, const char *name)
{
- int i;
- for (i = F->varlen - 1; i >= 0; --i)
- if (!strcmp(F->vartab[i], name))
- return i + 1;
+ unsigned int i;
+ for (i = F->varlen; i > 0; --i)
+ if (!strcmp(F->vartab[i-1], name))
+ return i;
return -1;
}
--- a/jscompile.h
+++ b/jscompile.h
@@ -123,23 +123,23 @@
const char *name;
int script;
int lightweight;
- int arguments;
- int numparams;
+ unsigned int arguments;
+ unsigned int numparams;
short *code;
- int codecap, codelen;
+ unsigned int codecap, codelen;
js_Function **funtab;
- int funcap, funlen;
+ unsigned int funcap, funlen;
double *numtab;
- int numcap, numlen;
+ unsigned int numcap, numlen;
const char **strtab;
- int strcap, strlen;
+ unsigned int strcap, strlen;
const char **vartab;
- int varcap, varlen;
+ unsigned int varcap, varlen;
const char *filename;
int line;
--- a/jsdump.c
+++ b/jsdump.c
@@ -715,7 +715,7 @@
{
short *p = F->code;
short *end = F->code + F->codelen;
- int i;
+ unsigned int i;
printf("%s(%d)\n", F->name, F->numparams);
if (F->lightweight) printf("\tlightweight\n");
--- a/jsfunction.c
+++ b/jsfunction.c
@@ -53,7 +53,7 @@
{
js_Object *self = js_toobject(J, 0);
char *s;
- int i, n;
+ unsigned int i, n;
if (!js_iscallable(J, 0))
js_typeerror(J, "not a function");
--- a/jsgc.c
+++ b/jsgc.c
@@ -53,7 +53,7 @@
static void jsG_markfunction(js_State *J, int mark, js_Function *fun)
{
- int i;
+ unsigned int i;
fun->gcmark = mark;
for (i = 0; i < fun->funlen; ++i)
if (fun->funtab[i]->gcmark != mark)
--- a/jsrun.c
+++ b/jsrun.c
@@ -762,11 +762,11 @@
/* Function calls */
-static void jsR_calllwfunction(js_State *J, int n, js_Function *F, js_Environment *scope)
+static void jsR_calllwfunction(js_State *J, unsigned int n, js_Function *F, js_Environment *scope)
{
js_Environment *saveE;
js_Value v;
- int i;
+ unsigned int i;
saveE = J->E;
@@ -787,11 +787,11 @@
J->E = saveE;
}
-static void jsR_callfunction(js_State *J, int n, js_Function *F, js_Environment *scope)
+static void jsR_callfunction(js_State *J, unsigned int n, js_Function *F, js_Environment *scope)
{
js_Environment *saveE;
js_Value v;
- int i;
+ unsigned int i;
saveE = J->E;
@@ -830,7 +830,7 @@
J->E = saveE;
}
-static void jsR_callscript(js_State *J, int n, js_Function *F)
+static void jsR_callscript(js_State *J, unsigned int n, js_Function *F)
{
js_Value v;
js_pop(J, n);
@@ -840,7 +840,7 @@
js_pushvalue(J, v);
}
-static void jsR_callcfunction(js_State *J, int n, int min, js_CFunction F)
+static void jsR_callcfunction(js_State *J, unsigned int n, int min, js_CFunction F)
{
int rv, i;
@@ -858,7 +858,7 @@
}
}
-void js_call(js_State *J, int n)
+void js_call(js_State *J, unsigned int n)
{
js_Object *obj;
int savebot;
@@ -884,7 +884,7 @@
BOT = savebot;
}
-void js_construct(js_State *J, int n)
+void js_construct(js_State *J, unsigned int n)
{
js_Object *obj;
js_Object *prototype;
--- a/regex.c
+++ b/regex.c
@@ -552,9 +552,9 @@
const char *p;
};
-static int count(Renode *node)
+static unsigned int count(Renode *node)
{
- int min, max;
+ unsigned int min, max;
if (!node) return 0;
switch (node->type) {
default: return 1;
@@ -864,7 +864,7 @@
return 0;
}
-static int strncmpcanon(const char *a, const char *b, int n)
+static int strncmpcanon(const char *a, const char *b, unsigned int n)
{
Rune ra, rb;
int c;
@@ -884,7 +884,8 @@
{
const char *p;
Rune c;
- int n;
+ unsigned int n;
+ int v;
for (;;) {
switch (pc->opcode) {
@@ -918,9 +919,9 @@
continue;
case I_NLA:
++g->nla;
- n = match(g, pc->x, s);
+ v = match(g, pc->x, s);
--g->nla;
- if (n)
+ if (v)
return 0;
pc = pc->y;
continue;
@@ -965,7 +966,7 @@
}
break;
case I_REF:
- n = (int)(g->m[pc->n].ep - g->m[pc->n].sp);
+ n = g->m[pc->n].ep - g->m[pc->n].sp;
if (g->icase) {
if (strncmpcanon(s, g->m[pc->n].sp, n))
return 0;
@@ -991,15 +992,15 @@
break;
return 0;
case I_WORD:
- n = s > g->bol && iswordchar(s[-1]);
- n ^= iswordchar(s[0]);
- if (n)
+ v = s > g->bol && iswordchar(s[-1]);
+ v ^= iswordchar(s[0]);
+ if (v)
break;
return 0;
case I_NWORD:
- n = s > g->bol && iswordchar(s[-1]);
- n ^= iswordchar(s[0]);
- if (!n)
+ v = s > g->bol && iswordchar(s[-1]);
+ v ^= iswordchar(s[0]);
+ if (!v)
break;
return 0;
case I_LPAR:
--- a/utf.c
+++ b/utf.c
@@ -42,7 +42,7 @@
Bad = Runeerror,
};
-int
+unsigned int
chartorune(Rune *rune, const char *str)
{
int c, c1, c2;
@@ -98,10 +98,10 @@
return 1;
}
-int
+unsigned int
runetochar(char *str, const Rune *rune)
{
- int c;
+ unsigned int c;
/*
* one character sequence
@@ -133,7 +133,7 @@
return 3;
}
-int
+unsigned int
runelen(int c)
{
Rune rune;
@@ -143,11 +143,11 @@
return runetochar(str, &rune);
}
-int
+unsigned int
utflen(const char *s)
{
- int c;
- int n;
+ unsigned int c;
+ unsigned int n;
Rune rune;
n = 0;
--- a/utf.h
+++ b/utf.h
@@ -25,10 +25,10 @@
Runeerror = 0xFFFD, /* decoding error in UTF */
};
-int chartorune(Rune *rune, const char *str);
-int runetochar(char *str, const Rune *rune);
-int runelen(int c);
-int utflen(const char *s);
+unsigned int chartorune(Rune *rune, const char *str);
+unsigned int runetochar(char *str, const Rune *rune);
+unsigned int runelen(int c);
+unsigned int utflen(const char *s);
int isalpharune(Rune c);
int islowerrune(Rune c);