shithub: libmujs

Download patch

ref: c7e9ab0b052f258508098073c5b488095ad871fa
parent: ef891c5c9e8a49415674edf768a6f88c8f353809
author: Tor Andersson <tor@ccxvii.net>
date: Mon Feb 24 18:50:06 EST 2014

Fix signed/unsigned comparison warnings.

--- a/js.h
+++ b/js.h
@@ -26,7 +26,7 @@
 
 typedef struct js_State js_State;
 
-typedef int (*js_CFunction)(js_State *J, int argc);
+typedef int (*js_CFunction)(js_State *J, unsigned int argc);
 
 /* Basic functions */
 js_State *js_newstate(void);
@@ -111,7 +111,7 @@
 void js_pushboolean(js_State *J, int v);
 void js_pushnumber(js_State *J, double v);
 void js_pushstring(js_State *J, const char *v);
-void js_pushlstring(js_State *J, const char *v, int n);
+void js_pushlstring(js_State *J, const char *v, unsigned int n);
 void js_pushliteral(js_State *J, const char *v);
 
 void js_newobject(js_State *J);
@@ -120,8 +120,8 @@
 void js_newnumber(js_State *J, double v);
 void js_newstring(js_State *J, const char *v);
 void js_newerror(js_State *J, const char *message);
-void js_newcfunction(js_State *J, js_CFunction fun, int length);
-void js_newcconstructor(js_State *J, js_CFunction fun, js_CFunction con, int length);
+void js_newcfunction(js_State *J, js_CFunction fun, unsigned int length);
+void js_newcconstructor(js_State *J, js_CFunction fun, js_CFunction con, unsigned int length);
 void js_newuserdata(js_State *J, const char *tag, void *data);
 void js_newregexp(js_State *J, const char *pattern, int flags);
 
--- a/jsarray.c
+++ b/jsarray.c
@@ -45,9 +45,9 @@
 	js_delproperty(J, idx, buf);
 }
 
-static int jsB_new_Array(js_State *J, int argc)
+static int jsB_new_Array(js_State *J, unsigned int argc)
 {
-	int i;
+	unsigned int i;
 
 	js_newarray(J);
 
@@ -69,7 +69,7 @@
 	return 1;
 }
 
-static int Ap_concat(js_State *J, int argc)
+static int Ap_concat(js_State *J, unsigned int argc)
 {
 	unsigned int n, len, i;
 
@@ -99,7 +99,7 @@
 	return 1;
 }
 
-static int Ap_join(js_State *J, int argc)
+static int Ap_join(js_State *J, unsigned int argc)
 {
 	char * volatile out = NULL;
 	const char *sep;
@@ -155,7 +155,7 @@
 	return 1;
 }
 
-static int Ap_pop(js_State *J, int argc)
+static int Ap_pop(js_State *J, unsigned int argc)
 {
 	unsigned int n;
 
@@ -173,10 +173,9 @@
 	return 1;
 }
 
-static int Ap_push(js_State *J, int argc)
+static int Ap_push(js_State *J, unsigned int argc)
 {
-	unsigned int n;
-	int i;
+	unsigned int i, n;
 
 	n = js_getlength(J, 0);
 
@@ -191,7 +190,7 @@
 	return 1;
 }
 
-static int Ap_reverse(js_State *J, int argc)
+static int Ap_reverse(js_State *J, unsigned int argc)
 {
 	unsigned int len, middle, lower;
 
@@ -220,7 +219,7 @@
 	return 1;
 }
 
-static int Ap_shift(js_State *J, int argc)
+static int Ap_shift(js_State *J, unsigned int argc)
 {
 	unsigned int k, len;
 
@@ -247,22 +246,22 @@
 	return 1;
 }
 
-static int Ap_slice(js_State *J, int argc)
+static int Ap_slice(js_State *J, unsigned int argc)
 {
-	unsigned int len;
-	int s, e, n;
+	unsigned int len, s, e, n;
+	double sv, ev;
 
 	js_newarray(J);
 
 	len = js_getlength(J, 0);
-	s = js_tointeger(J, 1);
-	e = js_isdefined(J, 2) ? js_tointeger(J, 2) : len;
+	sv = js_tointeger(J, 1);
+	ev = js_isdefined(J, 2) ? js_tointeger(J, 2) : len;
 
-	if (s < 0) s = s + len;
-	if (e < 0) e = e + len;
+	if (sv < 0) sv = sv + len;
+	if (ev < 0) ev = ev + len;
 
-	s = s < 0 ? 0 : s > len ? len : s;
-	e = e < 0 ? 0 : e > len ? len : e;
+	s = sv < 0 ? 0 : sv > len ? len : sv;
+	e = ev < 0 ? 0 : ev > len ? len : ev;
 
 	for (n = 0; s < e; ++s, ++n)
 		if (js_hasindex(J, 0, s))
@@ -307,7 +306,7 @@
 	return 0;
 }
 
-static int Ap_sort(js_State *J, int argc)
+static int Ap_sort(js_State *J, unsigned int argc)
 {
 	unsigned int len, i, k;
 	int hasx, hasy, hasfn;
@@ -337,21 +336,21 @@
 	return 1;
 }
 
-static int Ap_splice(js_State *J, int argc)
+static int Ap_splice(js_State *J, unsigned int argc)
 {
-	unsigned int len;
-	int start, del, add, k;
+	unsigned int len, start, del, add, k;
+	double f;
 
 	js_newarray(J);
 
 	len = js_getlength(J, 0);
 
-	start = js_tointeger(J, 1);
-	if (start < 0) start = start + len;
-	start = start < 0 ? 0 : start > len ? len : start;
+	f = js_tointeger(J, 1);
+	if (f < 0) f = f + len;
+	start = f < 0 ? 0 : f > len ? len : f;
 
-	del = js_tointeger(J, 2);
-	del = del < 0 ? 0 : del > len - start ? len - start : del;
+	f = js_tointeger(J, 2);
+	del = f < 0 ? 0 : f > len - start ? len - start : f;
 
 	/* copy deleted items to return array */
 	for (k = 0; k < del; ++k)
@@ -389,10 +388,9 @@
 	return 1;
 }
 
-static int Ap_unshift(js_State *J, int argc)
+static int Ap_unshift(js_State *J, unsigned int argc)
 {
-	unsigned int k, len;
-	int i;
+	unsigned int i, k, len;
 
 	len = js_getlength(J, 0);
 
@@ -416,13 +414,13 @@
 	return 1;
 }
 
-static int Ap_toString(js_State *J, int argc)
+static int Ap_toString(js_State *J, unsigned int argc)
 {
 	js_pop(J, argc);
 	return Ap_join(J, 0);
 }
 
-static int Ap_indexOf(js_State *J, int argc)
+static int Ap_indexOf(js_State *J, unsigned int argc)
 {
 	int k, len, from;
 
@@ -446,7 +444,7 @@
 	return 1;
 }
 
-static int Ap_lastIndexOf(js_State *J, int argc)
+static int Ap_lastIndexOf(js_State *J, unsigned int argc)
 {
 	int k, len, from;
 
@@ -470,7 +468,7 @@
 	return 1;
 }
 
-static int Ap_every(js_State *J, int argc)
+static int Ap_every(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -499,7 +497,7 @@
 	return 1;
 }
 
-static int Ap_some(js_State *J, int argc)
+static int Ap_some(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -528,7 +526,7 @@
 	return 1;
 }
 
-static int Ap_forEach(js_State *J, int argc)
+static int Ap_forEach(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -554,7 +552,7 @@
 	return 0;
 }
 
-static int Ap_map(js_State *J, int argc)
+static int Ap_map(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -583,7 +581,7 @@
 	return 1;
 }
 
-static int Ap_filter(js_State *J, int argc)
+static int Ap_filter(js_State *J, unsigned int argc)
 {
 	int k, to, len;
 
@@ -617,7 +615,7 @@
 	return 1;
 }
 
-static int Ap_reduce(js_State *J, int argc)
+static int Ap_reduce(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -657,7 +655,7 @@
 	return 1; /* return accumulator */
 }
 
-static int Ap_reduceRight(js_State *J, int argc)
+static int Ap_reduceRight(js_State *J, unsigned int argc)
 {
 	int k, len;
 
@@ -697,7 +695,7 @@
 	return 1; /* return accumulator */
 }
 
-static int A_isArray(js_State *J, int argc)
+static int A_isArray(js_State *J, unsigned int argc)
 {
 	if (js_isobject(J, 1)) {
 		js_Object *T = js_toobject(J, 1);
--- a/jsboolean.c
+++ b/jsboolean.c
@@ -2,19 +2,19 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
-static int jsB_new_Boolean(js_State *J, int argc)
+static int jsB_new_Boolean(js_State *J, unsigned int argc)
 {
 	js_newboolean(J, js_toboolean(J, 1));
 	return 1;
 }
 
-static int jsB_Boolean(js_State *J, int argc)
+static int jsB_Boolean(js_State *J, unsigned int argc)
 {
 	js_pushboolean(J, js_toboolean(J, 1));
 	return 1;
 }
 
-static int Bp_toString(js_State *J, int argc)
+static int Bp_toString(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CBOOLEAN) js_typeerror(J, "not a boolean");
@@ -22,7 +22,7 @@
 	return 1;
 }
 
-static int Bp_valueOf(js_State *J, int argc)
+static int Bp_valueOf(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CBOOLEAN) js_typeerror(J, "not a boolean");
--- a/jsbuiltin.c
+++ b/jsbuiltin.c
@@ -28,7 +28,7 @@
 	js_defproperty(J, -2, name, JS_DONTENUM);
 }
 
-static int jsB_eval(js_State *J, int argc)
+static int jsB_eval(js_State *J, unsigned int argc)
 {
 	if (!js_isstring(J, -1)) {
 		js_copy(J, 1);
@@ -40,7 +40,7 @@
 	return 1;
 }
 
-static int jsB_parseInt(js_State *J, int argc)
+static int jsB_parseInt(js_State *J, unsigned int argc)
 {
 	const char *s = js_tostring(J, 1);
 	double radix = js_isdefined(J, 2) ? js_tonumber(J, 2) : 10;
@@ -49,7 +49,7 @@
 	return 1;
 }
 
-static int jsB_parseFloat(js_State *J, int argc)
+static int jsB_parseFloat(js_State *J, unsigned int argc)
 {
 	const char *s = js_tostring(J, 1);
 	while (jsY_iswhite(*s) || jsY_isnewline(*s)) ++s;
@@ -57,7 +57,7 @@
 	return 1;
 }
 
-static int jsB_isNaN(js_State *J, int argc)
+static int jsB_isNaN(js_State *J, unsigned int argc)
 {
 	double n = js_tonumber(J, 1);
 	js_pushboolean(J, isnan(n));
@@ -64,7 +64,7 @@
 	return 1;
 }
 
-static int jsB_isFinite(js_State *J, int argc)
+static int jsB_isFinite(js_State *J, unsigned int argc)
 {
 	double n = js_tonumber(J, 1);
 	js_pushboolean(J, isfinite(n));
@@ -143,22 +143,22 @@
 #define URIMARK "-_.!~*`()"
 #define URIUNESCAPED URIALPHA URIDIGIT URIMARK
 
-static int jsB_decodeURI(js_State *J, int argc)
+static int jsB_decodeURI(js_State *J, unsigned int argc)
 {
 	return Decode(J, js_tostring(J, 1), URIRESERVED "#");
 }
 
-static int jsB_decodeURIComponent(js_State *J, int argc)
+static int jsB_decodeURIComponent(js_State *J, unsigned int argc)
 {
 	return Decode(J, js_tostring(J, 1), "");
 }
 
-static int jsB_encodeURI(js_State *J, int argc)
+static int jsB_encodeURI(js_State *J, unsigned int argc)
 {
 	return Encode(J, js_tostring(J, 1), URIUNESCAPED URIRESERVED "#");
 }
 
-static int jsB_encodeURIComponent(js_State *J, int argc)
+static int jsB_encodeURIComponent(js_State *J, unsigned int argc)
 {
 	return Encode(J, js_tostring(J, 1), URIUNESCAPED);
 }
--- a/jsdate.c
+++ b/jsdate.c
@@ -263,7 +263,7 @@
 	return 1;
 }
 
-static int D_parse(js_State *J, int argc)
+static int D_parse(js_State *J, unsigned int argc)
 {
 	double t = parseDate(js_tostring(J, 1));
 	js_pushnumber(J, t);
@@ -270,7 +270,7 @@
 	return 1;
 }
 
-static int D_UTC(js_State *J, int argc)
+static int D_UTC(js_State *J, unsigned int argc)
 {
 	double y, m, d, H, M, S, ms, t;
 	y = js_tonumber(J, 1);
@@ -287,19 +287,19 @@
 	return 1;
 }
 
-static int D_now(js_State *J, int argc)
+static int D_now(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, Now());
 	return 1;
 }
 
-static int jsB_Date(js_State *J, int argc)
+static int jsB_Date(js_State *J, unsigned int argc)
 {
 	js_pushstring(J, fmtlocal(FMT_DATETIME, Now()));
 	return 1;
 }
 
-static int jsB_new_Date(js_State *J, int argc)
+static int jsB_new_Date(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Value v;
@@ -334,7 +334,7 @@
 	return 1;
 }
 
-static int Dp_valueOf(js_State *J, int argc)
+static int Dp_valueOf(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, t);
@@ -341,7 +341,7 @@
 	return 1;
 }
 
-static int Dp_toString(js_State *J, int argc)
+static int Dp_toString(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushstring(J, fmtlocal(FMT_DATETIME, t));
@@ -348,7 +348,7 @@
 	return 1;
 }
 
-static int Dp_toDateString(js_State *J, int argc)
+static int Dp_toDateString(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushstring(J, fmtlocal(FMT_DATE, t));
@@ -355,7 +355,7 @@
 	return 1;
 }
 
-static int Dp_toTimeString(js_State *J, int argc)
+static int Dp_toTimeString(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushstring(J, fmtlocal(FMT_TIME, t));
@@ -362,7 +362,7 @@
 	return 1;
 }
 
-static int Dp_toUTCString(js_State *J, int argc)
+static int Dp_toUTCString(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushstring(J, fmtutc(FMT_DATETIME, t));
@@ -369,7 +369,7 @@
 	return 1;
 }
 
-static int Dp_toISOString(js_State *J, int argc)
+static int Dp_toISOString(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushstring(J, fmtutc(FMT_DATETIME_ISO, t));
@@ -376,7 +376,7 @@
 	return 1;
 }
 
-static int Dp_getFullYear(js_State *J, int argc)
+static int Dp_getFullYear(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, YearFromTime(LocalTime(t)));
@@ -383,7 +383,7 @@
 	return 1;
 }
 
-static int Dp_getMonth(js_State *J, int argc)
+static int Dp_getMonth(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, MonthFromTime(LocalTime(t)));
@@ -390,7 +390,7 @@
 	return 1;
 }
 
-static int Dp_getDate(js_State *J, int argc)
+static int Dp_getDate(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, DateFromTime(LocalTime(t)));
@@ -397,7 +397,7 @@
 	return 1;
 }
 
-static int Dp_getDay(js_State *J, int argc)
+static int Dp_getDay(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, WeekDay(LocalTime(t)));
@@ -404,7 +404,7 @@
 	return 1;
 }
 
-static int Dp_getHours(js_State *J, int argc)
+static int Dp_getHours(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, HourFromTime(LocalTime(t)));
@@ -411,7 +411,7 @@
 	return 1;
 }
 
-static int Dp_getMinutes(js_State *J, int argc)
+static int Dp_getMinutes(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, MinFromTime(LocalTime(t)));
@@ -418,7 +418,7 @@
 	return 1;
 }
 
-static int Dp_getSeconds(js_State *J, int argc)
+static int Dp_getSeconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, SecFromTime(LocalTime(t)));
@@ -425,7 +425,7 @@
 	return 1;
 }
 
-static int Dp_getMilliseconds(js_State *J, int argc)
+static int Dp_getMilliseconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, msFromTime(LocalTime(t)));
@@ -432,7 +432,7 @@
 	return 1;
 }
 
-static int Dp_getUTCFullYear(js_State *J, int argc)
+static int Dp_getUTCFullYear(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, YearFromTime(t));
@@ -439,7 +439,7 @@
 	return 1;
 }
 
-static int Dp_getUTCMonth(js_State *J, int argc)
+static int Dp_getUTCMonth(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, MonthFromTime(t));
@@ -446,7 +446,7 @@
 	return 1;
 }
 
-static int Dp_getUTCDate(js_State *J, int argc)
+static int Dp_getUTCDate(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, DateFromTime(t));
@@ -453,7 +453,7 @@
 	return 1;
 }
 
-static int Dp_getUTCDay(js_State *J, int argc)
+static int Dp_getUTCDay(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, WeekDay(t));
@@ -460,7 +460,7 @@
 	return 1;
 }
 
-static int Dp_getUTCHours(js_State *J, int argc)
+static int Dp_getUTCHours(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, HourFromTime(t));
@@ -467,7 +467,7 @@
 	return 1;
 }
 
-static int Dp_getUTCMinutes(js_State *J, int argc)
+static int Dp_getUTCMinutes(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, MinFromTime(t));
@@ -474,7 +474,7 @@
 	return 1;
 }
 
-static int Dp_getUTCSeconds(js_State *J, int argc)
+static int Dp_getUTCSeconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, SecFromTime(t));
@@ -481,7 +481,7 @@
 	return 1;
 }
 
-static int Dp_getUTCMilliseconds(js_State *J, int argc)
+static int Dp_getUTCMilliseconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, msFromTime(t));
@@ -488,7 +488,7 @@
 	return 1;
 }
 
-static int Dp_getTimezoneOffset(js_State *J, int argc)
+static int Dp_getTimezoneOffset(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	js_pushnumber(J, (t - LocalTime(t)) / msPerMinute);
@@ -495,12 +495,12 @@
 	return 1;
 }
 
-static int Dp_setTime(js_State *J, int argc)
+static int Dp_setTime(js_State *J, unsigned int argc)
 {
 	return js_setdate(J, 0, js_tonumber(J, 1));
 }
 
-static int Dp_setMilliseconds(js_State *J, int argc)
+static int Dp_setMilliseconds(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double h = HourFromTime(t);
@@ -510,7 +510,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(Day(t), MakeTime(h, m, s, ms))));
 }
 
-static int Dp_setSeconds(js_State *J, int argc)
+static int Dp_setSeconds(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double h = HourFromTime(t);
@@ -520,7 +520,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(Day(t), MakeTime(h, m, s, ms))));
 }
 
-static int Dp_setMinutes(js_State *J, int argc)
+static int Dp_setMinutes(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double h = HourFromTime(t);
@@ -530,7 +530,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(Day(t), MakeTime(h, m, s, ms))));
 }
 
-static int Dp_setHours(js_State *J, int argc)
+static int Dp_setHours(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double h = js_tonumber(J, 1);
@@ -540,7 +540,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(Day(t), MakeTime(h, m, s, ms))));
 }
 
-static int Dp_setDate(js_State *J, int argc)
+static int Dp_setDate(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double y = YearFromTime(t);
@@ -549,7 +549,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(MakeDay(y, m, d), TimeWithinDay(t))));
 }
 
-static int Dp_setMonth(js_State *J, int argc)
+static int Dp_setMonth(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double y = YearFromTime(t);
@@ -558,7 +558,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(MakeDay(y, m, d), TimeWithinDay(t))));
 }
 
-static int Dp_setFullYear(js_State *J, int argc)
+static int Dp_setFullYear(js_State *J, unsigned int argc)
 {
 	double t = LocalTime(js_todate(J, 0));
 	double y = js_tonumber(J, 1);
@@ -567,7 +567,7 @@
 	return js_setdate(J, 0, UTC(MakeDate(MakeDay(y, m, d), TimeWithinDay(t))));
 }
 
-static int Dp_setUTCMilliseconds(js_State *J, int argc)
+static int Dp_setUTCMilliseconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double h = HourFromTime(t);
@@ -577,7 +577,7 @@
 	return js_setdate(J, 0, MakeDate(Day(t), MakeTime(h, m, s, ms)));
 }
 
-static int Dp_setUTCSeconds(js_State *J, int argc)
+static int Dp_setUTCSeconds(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double h = HourFromTime(t);
@@ -587,7 +587,7 @@
 	return js_setdate(J, 0, MakeDate(Day(t), MakeTime(h, m, s, ms)));
 }
 
-static int Dp_setUTCMinutes(js_State *J, int argc)
+static int Dp_setUTCMinutes(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double h = HourFromTime(t);
@@ -597,7 +597,7 @@
 	return js_setdate(J, 0, MakeDate(Day(t), MakeTime(h, m, s, ms)));
 }
 
-static int Dp_setUTCHours(js_State *J, int argc)
+static int Dp_setUTCHours(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double h = js_tonumber(J, 1);
@@ -607,7 +607,7 @@
 	return js_setdate(J, 0, MakeDate(Day(t), MakeTime(h, m, s, ms)));
 }
 
-static int Dp_setUTCDate(js_State *J, int argc)
+static int Dp_setUTCDate(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double y = YearFromTime(t);
@@ -616,7 +616,7 @@
 	return js_setdate(J, 0, MakeDate(MakeDay(y, m, d), TimeWithinDay(t)));
 }
 
-static int Dp_setUTCMonth(js_State *J, int argc)
+static int Dp_setUTCMonth(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double y = YearFromTime(t);
@@ -625,7 +625,7 @@
 	return js_setdate(J, 0, MakeDate(MakeDay(y, m, d), TimeWithinDay(t)));
 }
 
-static int Dp_setUTCFullYear(js_State *J, int argc)
+static int Dp_setUTCFullYear(js_State *J, unsigned int argc)
 {
 	double t = js_todate(J, 0);
 	double y = js_tonumber(J, 1);
@@ -634,7 +634,7 @@
 	return js_setdate(J, 0, MakeDate(MakeDay(y, m, d), TimeWithinDay(t)));
 }
 
-static int Dp_toJSON(js_State *J, int argc)
+static int Dp_toJSON(js_State *J, unsigned int argc)
 {
 	js_Object *obj = js_toobject(J, 0);
 	js_Value tv = js_toprimitive(J, 0, JS_HNUMBER);
--- a/jserror.c
+++ b/jserror.c
@@ -5,7 +5,7 @@
 #define QQ(X) #X
 #define Q(X) QQ(X)
 
-static int Ep_toString(js_State *J, int argc)
+static int Ep_toString(js_State *J, unsigned int argc)
 {
 	const char *name = "Error";
 	const char *message = "";
@@ -37,7 +37,7 @@
 	return 1;
 }
 
-static int jsB_ErrorX(js_State *J, int argc, js_Object *prototype)
+static int jsB_ErrorX(js_State *J, unsigned int argc, js_Object *prototype)
 {
 	js_pushobject(J, jsV_newobject(J, JS_CERROR, prototype));
 	if (js_isdefined(J, 1)) {
@@ -55,8 +55,8 @@
 }
 
 #define DERROR(name, Name) \
-	static int jsB_##Name(js_State *J, int n) { \
-		return jsB_ErrorX(J, n, J->Name##_prototype); \
+	static int jsB_##Name(js_State *J, unsigned int argc) { \
+		return jsB_ErrorX(J, argc, J->Name##_prototype); \
 	} \
 	void js_new##name(js_State *J, const char *s) { \
 		js_newerrorx(J, s, J->Name##_prototype); \
--- a/jsfunction.c
+++ b/jsfunction.c
@@ -4,13 +4,13 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
-static int jsB_Function(js_State *J, int argc)
+static int jsB_Function(js_State *J, unsigned int argc)
 {
 	const char *source;
 	js_Buffer *sb;
 	js_Ast *parse;
 	js_Function *fun;
-	int i;
+	unsigned int i;
 
 	if (js_isundefined(J, 1))
 		source = "";
@@ -43,13 +43,13 @@
 	return 1;
 }
 
-static int jsB_Function_prototype(js_State *J, int argc)
+static int jsB_Function_prototype(js_State *J, unsigned int argc)
 {
 	js_pushundefined(J);
 	return 1;
 }
 
-static int Fp_toString(js_State *J, int argc)
+static int Fp_toString(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	char *s;
@@ -82,7 +82,7 @@
 	return 1;
 }
 
-static int Fp_apply(js_State *J, int argc)
+static int Fp_apply(js_State *J, unsigned int argc)
 {
 	int i, n;
 	char name[20];
@@ -106,9 +106,9 @@
 	return 1;
 }
 
-static int Fp_call(js_State *J, int argc)
+static int Fp_call(js_State *J, unsigned int argc)
 {
-	int i;
+	unsigned int i;
 
 	if (!js_iscallable(J, 0))
 		js_typeerror(J, "not a function");
--- a/jslex.c
+++ b/jslex.c
@@ -68,7 +68,7 @@
 
 const char *jsY_tokenstring(int token)
 {
-	if (token >= 0 && token < nelem(tokenstring))
+	if (token >= 0 && token < (int)nelem(tokenstring))
 		if (tokenstring[token])
 			return tokenstring[token];
 	return "<unknown>";
--- a/jsmath.c
+++ b/jsmath.c
@@ -2,106 +2,106 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
-static int Math_abs(js_State *J, int argc)
+static int Math_abs(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, abs(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_acos(js_State *J, int argc)
+static int Math_acos(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, acos(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_asin(js_State *J, int argc)
+static int Math_asin(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, asin(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_atan(js_State *J, int argc)
+static int Math_atan(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, atan(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_atan2(js_State *J, int argc)
+static int Math_atan2(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, atan2(js_tonumber(J, 1), js_tonumber(J, 2)));
 	return 1;
 }
 
-static int Math_ceil(js_State *J, int argc)
+static int Math_ceil(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, ceil(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_cos(js_State *J, int argc)
+static int Math_cos(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, cos(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_exp(js_State *J, int argc)
+static int Math_exp(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, exp(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_floor(js_State *J, int argc)
+static int Math_floor(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, floor(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_log(js_State *J, int argc)
+static int Math_log(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, log(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_pow(js_State *J, int argc)
+static int Math_pow(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, pow(js_tonumber(J, 1), js_tonumber(J, 2)));
 	return 1;
 }
 
-static int Math_random(js_State *J, int argc)
+static int Math_random(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, (double)rand() / (RAND_MAX - 1));
 	return 1;
 }
 
-static int Math_round(js_State *J, int argc)
+static int Math_round(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, round(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_sin(js_State *J, int argc)
+static int Math_sin(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, sin(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_sqrt(js_State *J, int argc)
+static int Math_sqrt(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, sqrt(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_tan(js_State *J, int argc)
+static int Math_tan(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, tan(js_tonumber(J, 1)));
 	return 1;
 }
 
-static int Math_max(js_State *J, int argc)
+static int Math_max(js_State *J, unsigned int argc)
 {
 	double n = js_tonumber(J, 1);
-	int i;
+	unsigned int i;
 	for (i = 2; i <= argc; ++i) {
 		double m = js_tonumber(J, i);
 		n = n > m ? n : m;
@@ -110,10 +110,10 @@
 	return 1;
 }
 
-static int Math_min(js_State *J, int argc)
+static int Math_min(js_State *J, unsigned int argc)
 {
 	double n = js_tonumber(J, 1);
-	int i;
+	unsigned int i;
 	for (i = 2; i <= argc; ++i) {
 		double m = js_tonumber(J, i);
 		n = n < m ? n : m;
--- a/jsnumber.c
+++ b/jsnumber.c
@@ -2,19 +2,19 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
-static int jsB_new_Number(js_State *J, int argc)
+static int jsB_new_Number(js_State *J, unsigned int argc)
 {
 	js_newnumber(J, js_isdefined(J, 1) ? js_tonumber(J, 1) : 0);
 	return 1;
 }
 
-static int jsB_Number(js_State *J, int argc)
+static int jsB_Number(js_State *J, unsigned int argc)
 {
 	js_pushnumber(J, js_isdefined(J, 1) ? js_tonumber(J, 1) : 0);
 	return 1;
 }
 
-static int Np_valueOf(js_State *J, int argc)
+static int Np_valueOf(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
@@ -22,7 +22,7 @@
 	return 1;
 }
 
-static int Np_toString(js_State *J, int argc)
+static int Np_toString(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CNUMBER) js_typeerror(J, "not a number");
@@ -30,7 +30,7 @@
 	return 1;
 }
 
-static int Np_toFixed(js_State *J, int argc)
+static int Np_toFixed(js_State *J, unsigned int argc)
 {
 	char buf[40];
 	js_Object *self = js_toobject(J, 0);
@@ -41,7 +41,7 @@
 	return 1;
 }
 
-static int Np_toExponential(js_State *J, int argc)
+static int Np_toExponential(js_State *J, unsigned int argc)
 {
 	char buf[40];
 	js_Object *self = js_toobject(J, 0);
@@ -52,7 +52,7 @@
 	return 1;
 }
 
-static int Np_toPrecision(js_State *J, int argc)
+static int Np_toPrecision(js_State *J, unsigned int argc)
 {
 	char buf[40];
 	js_Object *self = js_toobject(J, 0);
--- a/jsobject.c
+++ b/jsobject.c
@@ -2,7 +2,7 @@
 #include "jsvalue.h"
 #include "jsbuiltin.h"
 
-static int jsB_new_Object(js_State *J, int argc)
+static int jsB_new_Object(js_State *J, unsigned int argc)
 {
 	if (argc == 0 || js_isundefined(J, 1) || js_isnull(J, 1))
 		js_newobject(J);
@@ -11,7 +11,7 @@
 	return 1;
 }
 
-static int jsB_Object(js_State *J, int argc)
+static int jsB_Object(js_State *J, unsigned int argc)
 {
 	if (argc == 0 || js_isundefined(J, 1) || js_isnull(J, 1))
 		js_newobject(J);
@@ -20,7 +20,7 @@
 	return 1;
 }
 
-static int Op_toString(js_State *J, int argc)
+static int Op_toString(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	switch (self->type) {
@@ -45,18 +45,17 @@
 		js_pushliteral(J, "]");
 		js_concat(J);
 		break;
-	default: js_pushliteral(J, "[Object unknown]"); break;
 	}
 	return 1;
 }
 
-static int Op_valueOf(js_State *J, int argc)
+static int Op_valueOf(js_State *J, unsigned int argc)
 {
 	js_copy(J, 0);
 	return 1;
 }
 
-static int Op_hasOwnProperty(js_State *J, int argc)
+static int Op_hasOwnProperty(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	const char *name = js_tostring(J, 1);
@@ -65,7 +64,7 @@
 	return 1;
 }
 
-static int Op_isPrototypeOf(js_State *J, int argc)
+static int Op_isPrototypeOf(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (js_isobject(J, 1)) {
@@ -82,7 +81,7 @@
 	return 1;
 }
 
-static int Op_propertyIsEnumerable(js_State *J, int argc)
+static int Op_propertyIsEnumerable(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	const char *name = js_tostring(J, 1);
@@ -91,7 +90,7 @@
 	return 1;
 }
 
-static int O_getPrototypeOf(js_State *J, int argc)
+static int O_getPrototypeOf(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	if (!js_isobject(J, 1))
@@ -104,7 +103,7 @@
 	return 1;
 }
 
-static int O_getOwnPropertyDescriptor(js_State *J, int argc)
+static int O_getOwnPropertyDescriptor(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -141,7 +140,7 @@
 	return 1;
 }
 
-static int O_getOwnPropertyNames(js_State *J, int argc)
+static int O_getOwnPropertyNames(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -243,7 +242,7 @@
 	js_pop(J, 2);
 }
 
-static int O_defineProperty(js_State *J, int argc)
+static int O_defineProperty(js_State *J, unsigned int argc)
 {
 	if (!js_isobject(J, 1)) js_typeerror(J, "not an object");
 	if (!js_isobject(J, 3)) js_typeerror(J, "not an object");
@@ -252,7 +251,7 @@
 	return 1;
 }
 
-static int O_defineProperties(js_State *J, int argc)
+static int O_defineProperties(js_State *J, unsigned int argc)
 {
 	js_Object *props;
 	js_Property *ref;
@@ -273,7 +272,7 @@
 	return 1;
 }
 
-static int O_create(js_State *J, int argc)
+static int O_create(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Object *proto;
@@ -304,7 +303,7 @@
 	return 1;
 }
 
-static int O_keys(js_State *J, int argc)
+static int O_keys(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -335,7 +334,7 @@
 	return 1;
 }
 
-static int O_preventExtensions(js_State *J, int argc)
+static int O_preventExtensions(js_State *J, unsigned int argc)
 {
 	if (!js_isobject(J, 1))
 		js_typeerror(J, "not an object");
@@ -344,7 +343,7 @@
 	return 1;
 }
 
-static int O_isExtensible(js_State *J, int argc)
+static int O_isExtensible(js_State *J, unsigned int argc)
 {
 	if (!js_isobject(J, 1))
 		js_typeerror(J, "not an object");
@@ -352,7 +351,7 @@
 	return 1;
 }
 
-static int O_seal(js_State *J, int argc)
+static int O_seal(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -370,7 +369,7 @@
 	return 1;
 }
 
-static int O_isSealed(js_State *J, int argc)
+static int O_isSealed(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -395,7 +394,7 @@
 	return 1;
 }
 
-static int O_freeze(js_State *J, int argc)
+static int O_freeze(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
@@ -413,7 +412,7 @@
 	return 1;
 }
 
-static int O_isFrozen(js_State *J, int argc)
+static int O_isFrozen(js_State *J, unsigned int argc)
 {
 	js_Object *obj;
 	js_Property *ref;
--- a/json.c
+++ b/json.c
@@ -92,7 +92,7 @@
 	}
 }
 
-static int JSON_parse(js_State *J, int argc)
+static int JSON_parse(js_State *J, unsigned int argc)
 {
 	const char *source = js_tostring(J, 1);
 	jsY_initlex(J, "JSON", source);
@@ -237,7 +237,7 @@
 	return 1;
 }
 
-static int JSON_stringify(js_State *J, int argc)
+static int JSON_stringify(js_State *J, unsigned int argc)
 {
 	js_Buffer *sb = NULL;
 	if (argc > 0) {
--- a/jsregexp.c
+++ b/jsregexp.c
@@ -32,8 +32,8 @@
 int js_RegExp_prototype_exec(js_State *J, js_Regexp *re, const char *text)
 {
 	Resub m[10];
+	unsigned int i;
 	int opts;
-	int i;
 
 	opts = 0;
 	if (re->flags & JS_REGEXP_G) {
@@ -66,7 +66,7 @@
 	return 1;
 }
 
-static int Rp_test(js_State *J, int argc)
+static int Rp_test(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	const char *text;
@@ -78,7 +78,7 @@
 
 	opts = 0;
 	if (re->flags & JS_REGEXP_G) {
-		if (re->last < 0 || re->last > strlen(text)) {
+		if (re->last > strlen(text)) {
 			re->last = 0;
 			js_pushboolean(J, 0);
 			return 1;
@@ -103,7 +103,7 @@
 	return 1;
 }
 
-static int jsB_new_RegExp(js_State *J, int argc)
+static int jsB_new_RegExp(js_State *J, unsigned int argc)
 {
 	js_Regexp *old;
 	const char *pattern;
@@ -145,7 +145,7 @@
 	return 1;
 }
 
-static int jsB_RegExp(js_State *J, int argc)
+static int jsB_RegExp(js_State *J, unsigned int argc)
 {
 	if (js_isregexp(J, 1) && argc == 1)
 		return 1;
@@ -152,7 +152,7 @@
 	return jsB_new_RegExp(J, argc);
 }
 
-static int Rp_toString(js_State *J, int argc)
+static int Rp_toString(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	char *out;
@@ -178,7 +178,7 @@
 	return 1;
 }
 
-static int Rp_exec(js_State *J, int argc)
+static int Rp_exec(js_State *J, unsigned int argc)
 {
 	return js_RegExp_prototype_exec(J, js_toregexp(J, 0), js_tostring(J, 1));
 }
--- a/jsrun.c
+++ b/jsrun.c
@@ -68,7 +68,7 @@
 	++TOP;
 }
 
-void js_pushlstring(js_State *J, const char *v, int n)
+void js_pushlstring(js_State *J, const char *v, unsigned int n)
 {
 	char buf[256];
 	if (n + 1 < sizeof buf) {
--- a/jsstring.c
+++ b/jsstring.c
@@ -50,19 +50,19 @@
 	return i;
 }
 
-static int jsB_new_String(js_State *J, int argc)
+static int jsB_new_String(js_State *J, unsigned int argc)
 {
 	js_newstring(J, js_isdefined(J, 1) ? js_tostring(J, 1) : "");
 	return 1;
 }
 
-static int jsB_String(js_State *J, int argc)
+static int jsB_String(js_State *J, unsigned int argc)
 {
 	js_pushliteral(J, js_isdefined(J, 1) ? js_tostring(J, 1) : "");
 	return 1;
 }
 
-static int Sp_toString(js_State *J, int argc)
+static int Sp_toString(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CSTRING) js_typeerror(J, "not a string");
@@ -70,7 +70,7 @@
 	return 1;
 }
 
-static int Sp_valueOf(js_State *J, int argc)
+static int Sp_valueOf(js_State *J, unsigned int argc)
 {
 	js_Object *self = js_toobject(J, 0);
 	if (self->type != JS_CSTRING) js_typeerror(J, "not a string");
@@ -78,7 +78,7 @@
 	return 1;
 }
 
-static int Sp_charAt(js_State *J, int argc)
+static int Sp_charAt(js_State *J, unsigned int argc)
 {
 	char buf[UTFmax + 1];
 	const char *s = js_tostring(J, 0);
@@ -93,7 +93,7 @@
 	return 1;
 }
 
-static int Sp_charCodeAt(js_State *J, int argc)
+static int Sp_charCodeAt(js_State *J, unsigned int argc)
 {
 	const char *s = js_tostring(J, 0);
 	int pos = js_tointeger(J, 1);
@@ -105,11 +105,11 @@
 	return 1;
 }
 
-static int Sp_concat(js_State *J, int argc)
+static int Sp_concat(js_State *J, unsigned int argc)
 {
 	char * volatile out;
 	const char *s;
-	int i, n;
+	unsigned int i, n;
 
 	if (argc == 0)
 		return 1;
@@ -137,7 +137,7 @@
 	return 1;
 }
 
-static int Sp_indexOf(js_State *J, int argc)
+static int Sp_indexOf(js_State *J, unsigned int argc)
 {
 	const char *haystack = js_tostring(J, 0);
 	const char *needle = js_tostring(J, 1);
@@ -157,7 +157,7 @@
 	return 1;
 }
 
-static int Sp_lastIndexOf(js_State *J, int argc)
+static int Sp_lastIndexOf(js_State *J, unsigned int argc)
 {
 	const char *haystack = js_tostring(J, 0);
 	const char *needle = js_tostring(J, 1);
@@ -175,7 +175,7 @@
 	return 1;
 }
 
-static int Sp_localeCompare(js_State *J, int argc)
+static int Sp_localeCompare(js_State *J, unsigned int argc)
 {
 	const char *a = js_tostring(J, 0);
 	const char *b = js_tostring(J, 1);
@@ -182,7 +182,7 @@
 	return strcmp(a, b);
 }
 
-static int Sp_slice(js_State *J, int argc)
+static int Sp_slice(js_State *J, unsigned int argc)
 {
 	const char *str = js_tostring(J, 0);
 	const char *ss, *ee;
@@ -208,7 +208,7 @@
 	return 1;
 }
 
-static int Sp_substring(js_State *J, int argc)
+static int Sp_substring(js_State *J, unsigned int argc)
 {
 	const char *str = js_tostring(J, 0);
 	const char *ss, *ee;
@@ -231,7 +231,7 @@
 	return 1;
 }
 
-static int Sp_toLowerCase(js_State *J, int argc)
+static int Sp_toLowerCase(js_State *J, unsigned int argc)
 {
 	const char *src = js_tostring(J, 0);
 	char *dst = malloc(UTFmax * strlen(src) + 1);
@@ -253,7 +253,7 @@
 	return 1;
 }
 
-static int Sp_toUpperCase(js_State *J, int argc)
+static int Sp_toUpperCase(js_State *J, unsigned int argc)
 {
 	const char *src = js_tostring(J, 0);
 	char *dst = malloc(UTFmax * strlen(src) + 1);
@@ -281,7 +281,7 @@
 		c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029;
 }
 
-static int Sp_trim(js_State *J, int argc)
+static int Sp_trim(js_State *J, unsigned int argc)
 {
 	const char *s, *e;
 	s = js_tostring(J, 0);
@@ -294,9 +294,9 @@
 	return 1;
 }
 
-static int S_fromCharCode(js_State *J, int argc)
+static int S_fromCharCode(js_State *J, unsigned int argc)
 {
-	int i;
+	unsigned int i;
 	Rune c;
 	char *s, *p;
 
@@ -319,7 +319,7 @@
 	return 1;
 }
 
-static int Sp_match(js_State *J, int argc)
+static int Sp_match(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	Resub m[10];
@@ -365,7 +365,7 @@
 	return 1;
 }
 
-static int Sp_search(js_State *J, int argc)
+static int Sp_search(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	Resub m[10];
@@ -390,7 +390,7 @@
 	return 1;
 }
 
-static int Sp_replace_regexp(js_State *J, int argc)
+static int Sp_replace_regexp(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	Resub m[10];
@@ -484,7 +484,7 @@
 	return 1;
 }
 
-static int Sp_replace_string(js_State *J, int argc)
+static int Sp_replace_string(js_State *J, unsigned int argc)
 {
 	const char *source, *needle, *s, *r;
 	js_Buffer *sb = NULL;
@@ -544,7 +544,7 @@
 	return 1;
 }
 
-static int Sp_replace(js_State *J, int argc)
+static int Sp_replace(js_State *J, unsigned int argc)
 {
 	if (js_isregexp(J, 1))
 		return Sp_replace_regexp(J, argc);
@@ -551,7 +551,7 @@
 	return Sp_replace_string(J, argc);
 }
 
-static int Sp_split_regexp(js_State *J, int argc)
+static int Sp_split_regexp(js_State *J, unsigned int argc)
 {
 	js_Regexp *re;
 	Resub m[10];
@@ -612,7 +612,7 @@
 	return 1;
 }
 
-static int Sp_split_string(js_State *J, int argc)
+static int Sp_split_string(js_State *J, unsigned int argc)
 {
 	const char *str = js_tostring(J, 0);
 	const char *sep = js_tostring(J, 1);
@@ -651,7 +651,7 @@
 	return 1;
 }
 
-static int Sp_split(js_State *J, int argc)
+static int Sp_split(js_State *J, unsigned int argc)
 {
 	if (js_isundefined(J, 1)) {
 		js_newarray(J);
--- a/jsvalue.c
+++ b/jsvalue.c
@@ -267,7 +267,7 @@
 	js_pushobject(J, obj);
 }
 
-void js_newcfunction(js_State *J, js_CFunction cfun, int length)
+void js_newcfunction(js_State *J, js_CFunction cfun, unsigned int length)
 {
 	js_Object *obj = jsV_newobject(J, JS_CCFUNCTION, J->Function_prototype);
 	obj->u.c.function = cfun;
@@ -287,7 +287,7 @@
 }
 
 /* prototype -- constructor */
-void js_newcconstructor(js_State *J, js_CFunction cfun, js_CFunction ccon, int length)
+void js_newcconstructor(js_State *J, js_CFunction cfun, js_CFunction ccon, unsigned int length)
 {
 	js_Object *obj = jsV_newobject(J, JS_CCFUNCTION, J->Function_prototype);
 	obj->u.c.function = cfun;
--- a/jsvalue.h
+++ b/jsvalue.h
@@ -74,7 +74,7 @@
 		struct {
 			js_CFunction function;
 			js_CFunction constructor;
-			int length;
+			unsigned int length;
 		} c;
 		js_Regexp r;
 		struct {
--- a/main.c
+++ b/main.c
@@ -4,7 +4,7 @@
 
 #define PS1 "> "
 
-static int jsB_gc(js_State *J, int argc)
+static int jsB_gc(js_State *J, unsigned int argc)
 {
 	int report = js_toboolean(J, 1);
 	js_gc(J, report);
@@ -11,7 +11,7 @@
 	return 0;
 }
 
-static int jsB_load(js_State *J, int argc)
+static int jsB_load(js_State *J, unsigned int argc)
 {
 	const char *filename = js_tostring(J, 1);
 	int rv = js_dofile(J, filename);
@@ -19,9 +19,9 @@
 	return 1;
 }
 
-static int jsB_print(js_State *J, int argc)
+static int jsB_print(js_State *J, unsigned int argc)
 {
-	int i;
+	unsigned int i;
 	for (i = 1; i <= argc; ++i) {
 		const char *s = js_tostring(J, i);
 		if (i > 1) putchar(' ');
--- a/regex.c
+++ b/regex.c
@@ -25,7 +25,7 @@
 struct Reprog {
 	Reinst *start, *end;
 	int icase, newline;
-	int ncap;
+	unsigned int ncap;
 	Reclass cclass[16];
 };
 
@@ -35,8 +35,8 @@
 	int flags;
 
 	const char *source;
-	int ncclass;
-	int ncap;
+	unsigned int ncclass;
+	unsigned int ncap;
 	int nref[10];
 
 	int lookahead;
@@ -1032,7 +1032,7 @@
 	struct estate g;
 	Resub gm[10];
 	Rune c;
-	int i;
+	unsigned int i;
 
 	g.icase = prog->icase;
 	g.newline = prog->newline;