aboutsummaryrefslogtreecommitdiff
path: root/lutf8lib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-10-01 08:52:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-10-01 08:52:33 -0300
commit34b6664dcb28b18ca3f08ed5e36da094b007eb7b (patch)
treea5e2f06e198b146d9a324dc41e4cc4114df14246 /lutf8lib.c
parentd35fff16d5eecf0116193be08586548b53b9f868 (diff)
downloadlua-34b6664dcb28b18ca3f08ed5e36da094b007eb7b.tar.gz
lua-34b6664dcb28b18ca3f08ed5e36da094b007eb7b.tar.bz2
lua-34b6664dcb28b18ca3f08ed5e36da094b007eb7b.zip
better to use 'long' to represent UTF-8 code points
Diffstat (limited to 'lutf8lib.c')
-rw-r--r--lutf8lib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lutf8lib.c b/lutf8lib.c
index e9557d61..3cf2f1cf 100644
--- a/lutf8lib.c
+++ b/lutf8lib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lutf8lib.c,v 1.9 2014/05/14 18:33:37 roberto Exp roberto $ 2** $Id: lutf8lib.c,v 1.10 2014/07/16 13:56:14 roberto Exp roberto $
3** Standard library for UTF-8 manipulation 3** Standard library for UTF-8 manipulation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -123,9 +123,9 @@ static int codepoint (lua_State *L) {
123 123
124 124
125static void pushutfchar (lua_State *L, int arg) { 125static void pushutfchar (lua_State *L, int arg) {
126 int code = luaL_checkint(L, arg); 126 lua_Integer code = luaL_checkinteger(L, arg);
127 luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); 127 luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range");
128 lua_pushfstring(L, "%U", code); 128 lua_pushfstring(L, "%U", (long)code);
129} 129}
130 130
131 131
@@ -157,7 +157,7 @@ static int utfchar (lua_State *L) {
157static int byteoffset (lua_State *L) { 157static int byteoffset (lua_State *L) {
158 size_t len; 158 size_t len;
159 const char *s = luaL_checklstring(L, 1, &len); 159 const char *s = luaL_checklstring(L, 1, &len);
160 int n = luaL_checkint(L, 2); 160 lua_Integer n = luaL_checkinteger(L, 2);
161 lua_Integer posi = (n >= 0) ? 1 : len + 1; 161 lua_Integer posi = (n >= 0) ? 1 : len + 1;
162 posi = u_posrelat(luaL_optinteger(L, 3, posi), len); 162 posi = u_posrelat(luaL_optinteger(L, 3, posi), len);
163 luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, 163 luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3,