[mw-devel] [Git][arthur/mw][master] duktape: Convert cesu8 to utf8 in js_mwexec and js_say

Andrew Price welshbyte at sucs.org
Fri Jul 28 12:19:39 BST 2017


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
c3c702a8 by Andrew Price at 2017-07-28T12:18:42+01:00
duktape: Convert cesu8 to utf8 in js_mwexec and js_say

- - - - -


1 changed file:

- src/client/js-duk.c


Changes:

=====================================
src/client/js-duk.c
=====================================
--- a/src/client/js-duk.c
+++ b/src/client/js-duk.c
@@ -154,7 +154,7 @@ static duk_ret_t js_print(duk_context *cx)
 
 static duk_ret_t js_mwexec(duk_context *cx)
 {
-	char *mutablestr;
+	char *utf8;
 
 	if (duk_is_undefined(cx, -1)) {
 		fprintf(stderr, "mwjs error: exec() requires an argument\n");
@@ -164,15 +164,17 @@ static duk_ret_t js_mwexec(duk_context *cx)
 		fprintf(stderr, "mwjs error: exec() requires a string\n");
 		return DUK_RET_SYNTAX_ERROR;
 	}
-	mutablestr = strdup(duk_get_string(cx, -1));
+	utf8 = cesu8_to_utf8(duk_get_string(cx, -1));
 	duk_pop(cx);
-	DoCommand(mutablestr, chattable);
-	free(mutablestr);
+	DoCommand(utf8, chattable);
+	free(utf8);
 	return 0;
 }
 
 static duk_ret_t js_say(duk_context *cx)
 {
+	char *utf8;
+
 	if (duk_is_undefined(cx, -1)) {
 		fprintf(stderr, "mwjs error: say() requires an argument\n");
 		return DUK_RET_SYNTAX_ERROR;
@@ -186,8 +188,10 @@ static duk_ret_t js_say(duk_context *cx)
 		fprintf(stderr, "mwjs error: say() takes a string or a number\n");
 		return DUK_RET_ERROR;
 	}
-	chat_say(duk_to_string(cx, -1));
+	utf8 = cesu8_to_utf8(duk_to_string(cx, -1));
+	chat_say(utf8);
 	duk_pop(cx);
+	free(utf8);
 	return 0;
 }
 



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/c3c702a853e722f458a301951326404e683f38e4

---
View it on GitLab: https://projects.sucs.org/arthur/mw/commit/c3c702a853e722f458a301951326404e683f38e4
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20170728/c72991da/attachment-0001.html>


More information about the mw-devel mailing list