shithub: libmujs

Download patch

ref: 45e3a319501f29c7a1c52fe062bb0a9ba37c7137
parent: a98748a0ceb101824f1dcc33a37d44373b11fd91
author: Tor Andersson <tor@ccxvii.net>
date: Mon Feb 24 20:23:52 EST 2014

Some -pedantic warning fixes.

Drop the use of 'inline' in most places... place some trust in the
compiler.

--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 OBJS := $(SRCS:%.c=build/%.o)
 
 CC := clang
-CFLAGS := -Wall -Wextra -Wunreachable-code -Wno-unused-parameter -Werror -g
+CFLAGS := -std=c99 -pedantic -Wall -Wextra -Wunreachable-code -Wno-unused-parameter -Werror -g
 
 default: build js re
 
--- a/jsarray.c
+++ b/jsarray.c
@@ -400,7 +400,7 @@
 static void Ap_toString(js_State *J, unsigned int argc)
 {
 	js_pop(J, argc);
-	return Ap_join(J, 0);
+	Ap_join(J, 0);
 }
 
 static void Ap_indexOf(js_State *J, unsigned int argc)
--- a/jsdump.c
+++ b/jsdump.c
@@ -130,23 +130,23 @@
 	}
 }
 
-static inline void pc(int c)
+static void pc(int c)
 {
 	putchar(c);
 }
 
-static inline void ps(const char *s)
+static void ps(const char *s)
 {
 	fputs(s, stdout);
 }
 
-static inline void in(int d)
+static void in(int d)
 {
 	while (d-- > 0)
 		putchar('\t');
 }
 
-static inline void nl(void)
+static void nl(void)
 {
 	putchar('\n');
 }
--- a/jslex.c
+++ b/jslex.c
@@ -98,7 +98,7 @@
 	return -1;
 }
 
-static inline int jsY_findkeyword(js_State *J, const char *s)
+static int jsY_findkeyword(js_State *J, const char *s)
 {
 	int i = jsY_findword(s, keywords, nelem(keywords));
 	if (i >= 0) {
@@ -119,17 +119,17 @@
 	return c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029;
 }
 
-static inline int jsY_isidentifierstart(int c)
+static int jsY_isidentifierstart(int c)
 {
 	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '$' || c == '_' || isalpharune(c);
 }
 
-static inline int jsY_isidentifierpart(int c)
+static int jsY_isidentifierpart(int c)
 {
 	return (c >= '0' && c <= '9') || jsY_isidentifierstart(c);
 }
 
-static inline int jsY_isdec(int c)
+static int jsY_isdec(int c)
 {
 	return (c >= '0' && c <= '9');
 }
@@ -192,7 +192,7 @@
 	J->lexbuf.len = 0;
 }
 
-static inline void textpush(js_State *J, Rune c)
+static void textpush(js_State *J, Rune c)
 {
 	int n = runelen(c);
 	if (J->lexbuf.len + n > J->lexbuf.cap) {
@@ -202,19 +202,19 @@
 	J->lexbuf.len += runetochar(J->lexbuf.text + J->lexbuf.len, &c);
 }
 
-static inline char *textend(js_State *J)
+static char *textend(js_State *J)
 {
 	textpush(J, 0);
 	return J->lexbuf.text;
 }
 
-static inline void lexlinecomment(js_State *J)
+static void lexlinecomment(js_State *J)
 {
 	while (PEEK && PEEK != '\n')
 		NEXT();
 }
 
-static inline int lexcomment(js_State *J)
+static int lexcomment(js_State *J)
 {
 	/* already consumed initial '/' '*' sequence */
 	while (PEEK != 0) {
@@ -229,7 +229,7 @@
 	return -1;
 }
 
-static inline double lexhex(js_State *J)
+static double lexhex(js_State *J)
 {
 	double n = 0;
 	if (!jsY_ishex(PEEK))
@@ -241,7 +241,7 @@
 	return n;
 }
 
-static inline double lexinteger(js_State *J)
+static double lexinteger(js_State *J)
 {
 	double n = 0;
 	if (!jsY_isdec(PEEK))
@@ -253,7 +253,7 @@
 	return n;
 }
 
-static inline double lexfraction(js_State *J)
+static double lexfraction(js_State *J)
 {
 	double n = 0;
 	double d = 1;
@@ -265,7 +265,7 @@
 	return n / d;
 }
 
-static inline double lexexponent(js_State *J)
+static double lexexponent(js_State *J)
 {
 	double sign;
 	if (ACCEPT('e') || ACCEPT('E')) {
@@ -277,7 +277,7 @@
 	return 0;
 }
 
-static inline int lexnumber(js_State *J)
+static int lexnumber(js_State *J)
 {
 	double n;
 	double e;
@@ -315,7 +315,7 @@
 	return TK_NUMBER;
 }
 
-static inline int lexescape(js_State *J)
+static int lexescape(js_State *J)
 {
 	int x = 0;
 
@@ -354,7 +354,7 @@
 	return 0;
 }
 
-static inline int lexstring(js_State *J)
+static int lexstring(js_State *J)
 {
 	const char *s;
 
@@ -452,7 +452,7 @@
 }
 
 /* simple "return [no Line Terminator here] ..." contexts */
-static inline int isnlthcontext(int last)
+static int isnlthcontext(int last)
 {
 	switch (last) {
 	case TK_BREAK:
--- a/json.c
+++ b/json.c
@@ -5,12 +5,12 @@
 
 #include "utf.h"
 
-static inline void jsonnext(js_State *J)
+static void jsonnext(js_State *J)
 {
 	J->lookahead = jsY_lexjson(J);
 }
 
-static inline int jsonaccept(js_State *J, int t)
+static int jsonaccept(js_State *J, int t)
 {
 	if (J->lookahead == t) {
 		jsonnext(J);
@@ -19,7 +19,7 @@
 	return 0;
 }
 
-static inline void jsonexpect(js_State *J, int t)
+static void jsonexpect(js_State *J, int t)
 {
 	if (!jsonaccept(J, t))
 		js_syntaxerror(J, "JSON: unexpected token: %s (expected %s)",
--- a/jsparse.c
+++ b/jsparse.c
@@ -130,12 +130,12 @@
 
 /* Lookahead */
 
-static inline void next(js_State *J)
+static void next(js_State *J)
 {
 	J->lookahead = jsY_lex(J);
 }
 
-static inline int accept(js_State *J, int t)
+static int accept(js_State *J, int t)
 {
 	if (J->lookahead == t) {
 		next(J);
@@ -144,7 +144,7 @@
 	return 0;
 }
 
-static inline void expect(js_State *J, int t)
+static void expect(js_State *J, int t)
 {
 	if (accept(J, t))
 		return;
@@ -883,7 +883,7 @@
 
 /* Constant folding */
 
-static inline int toint32(double d)
+static int toint32(double d)
 {
 	double two32 = 4294967296.0;
 	double two31 = 2147483648.0;
@@ -899,7 +899,7 @@
 		return d;
 }
 
-static inline unsigned int touint32(double d)
+static unsigned int touint32(double d)
 {
 	return toint32(d);
 }
--- a/jsproperty.c
+++ b/jsproperty.c
@@ -57,7 +57,7 @@
 	return NULL;
 }
 
-static inline js_Property *skew(js_Property *node)
+static js_Property *skew(js_Property *node)
 {
 	if (node->left->level == node->level) {
 		js_Property *temp = node;
@@ -68,7 +68,7 @@
 	return node;
 }
 
-static inline js_Property *split(js_Property *node)
+static js_Property *split(js_Property *node)
 {
 	if (node->right->right->level == node->level) {
 		js_Property *temp = node;
--- a/jsregexp.c
+++ b/jsregexp.c
@@ -146,7 +146,7 @@
 {
 	if (js_isregexp(J, 1) && argc == 1)
 		return;
-	return jsB_new_RegExp(J, argc);
+	jsB_new_RegExp(J, argc);
 }
 
 static void Rp_toString(js_State *J, unsigned int argc)
@@ -176,7 +176,7 @@
 
 static void Rp_exec(js_State *J, unsigned int argc)
 {
-	return js_RegExp_prototype_exec(J, js_toregexp(J, 0), js_tostring(J, 1));
+	js_RegExp_prototype_exec(J, js_toregexp(J, 0), js_tostring(J, 1));
 }
 
 void jsB_initregexp(js_State *J)
--- a/jsstring.c
+++ b/jsstring.c
@@ -322,8 +322,10 @@
 		js_newregexp(J, js_tostring(J, 1), 0);
 
 	re = js_toregexp(J, -1);
-	if (!(re->flags & JS_REGEXP_G))
-		return js_RegExp_prototype_exec(J, re, text);
+	if (!(re->flags & JS_REGEXP_G)) {
+		js_RegExp_prototype_exec(J, re, text);
+		return;
+	}
 
 	re->last = 0;
 
@@ -526,8 +528,9 @@
 static void Sp_replace(js_State *J, unsigned int argc)
 {
 	if (js_isregexp(J, 1))
-		return Sp_replace_regexp(J, argc);
-	return Sp_replace_string(J, argc);
+		Sp_replace_regexp(J, argc);
+	else
+		Sp_replace_string(J, argc);
 }
 
 static void Sp_split_regexp(js_State *J, unsigned int argc)
--- a/regex.c
+++ b/regex.c
@@ -54,7 +54,7 @@
 	longjmp(g->kaboom, 1);
 }
 
-static inline int canon(Rune c)
+static int canon(Rune c)
 {
 	Rune u = toupperrune(c);
 	if (c >= 128 && u < 128)
@@ -398,12 +398,12 @@
 	return rep;
 }
 
-static inline void next(struct cstate *g)
+static void next(struct cstate *g)
 {
 	g->lookahead = lex(g);
 }
 
-static inline int accept(struct cstate *g, int t)
+static int accept(struct cstate *g, int t)
 {
 	if (g->lookahead == t) {
 		next(g);
@@ -832,12 +832,12 @@
 	Resub *m;
 };
 
-static inline int isnewline(int c)
+static int isnewline(int c)
 {
 	return c == 0xA || c == 0xD || c == 0x2028 || c == 0x2029;
 }
 
-static inline int iswordchar(int c)
+static int iswordchar(int c)
 {
 	return c == '_' ||
 		(c >= 'a' && c <= 'z') ||
@@ -845,7 +845,7 @@
 		(c >= '0' && c <= '9');
 }
 
-static inline int incclass(Reclass *cc, Rune c)
+static int incclass(Reclass *cc, Rune c)
 {
 	Rune *p;
 	for (p = cc->spans; p < cc->end; p += 2)
@@ -854,7 +854,7 @@
 	return 0;
 }
 
-static inline int incclasscanon(Reclass *cc, Rune c)
+static int incclasscanon(Reclass *cc, Rune c)
 {
 	Rune *p, r;
 	for (p = cc->spans; p < cc->end; p += 2)
@@ -895,8 +895,8 @@
 			pc = pc->x;
 			continue;
 		case I_SPLIT:
-			// TODO: use I_PROGRESS instead?
 #if 0
+			// TODO: use I_PROGRESS instead?
 			if (match(g, pc->x, s))
 				return 1;
 			pc = pc->y;