Changeset

1844:a4a8fe2a560c

util.encodings: Don't throw an error but return nil when passed nil or a non-string value
author Matthew Wild <mwild1@gmail.com>
date Tue, 29 Sep 2009 19:05:32 +0100
parents 1842:8337c0d4aee4
children 1845:e52dbae3c05d 1846:fdb43fc1bafc
files util-src/encodings.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util-src/encodings.c	Tue Sep 29 14:22:02 2009 +0100
+++ b/util-src/encodings.c	Tue Sep 29 19:05:32 2009 +0100
@@ -124,8 +124,12 @@
 
 static int stringprep_prep(lua_State *L, const Stringprep_profile *profile)
 {
+	if(!lua_isstring(L, 1)) {
+		lua_pushnil(L);
+		return 1;
+	}
 	size_t len;
-	const char *s = luaL_checklstring(L, 1, &len);
+	const char *s = lua_tolstring(L, 1, &len);
 	char string[1024];
 	int ret;
 	if (len >= 1024) {