aboutsummaryrefslogtreecommitdiff
path: root/lobject.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 /lobject.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 'lobject.c')
-rw-r--r--lobject.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lobject.c b/lobject.c
index e7ce0141..0d59d344 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.88 2014/07/30 14:00:14 roberto Exp roberto $ 2** $Id: lobject.c,v 2.89 2014/08/01 17:24:02 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -310,8 +310,9 @@ size_t luaO_str2num (const char *s, TValue *o) {
310} 310}
311 311
312 312
313int luaO_utf8esc (char *buff, unsigned int x) { 313int luaO_utf8esc (char *buff, unsigned long x) {
314 int n = 1; /* number of bytes put in buffer (backwards) */ 314 int n = 1; /* number of bytes put in buffer (backwards) */
315 lua_assert(x <= 0x10FFFF);
315 if (x < 0x80) /* ascii? */ 316 if (x < 0x80) /* ascii? */
316 buff[UTF8BUFFSZ - 1] = x; 317 buff[UTF8BUFFSZ - 1] = x;
317 else { /* need continuation bytes */ 318 else { /* need continuation bytes */
@@ -402,7 +403,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
402 } 403 }
403 case 'U': { 404 case 'U': {
404 char buff[UTF8BUFFSZ]; 405 char buff[UTF8BUFFSZ];
405 int l = luaO_utf8esc(buff, va_arg(argp, int)); 406 int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long)));
406 pushstr(L, buff + UTF8BUFFSZ - l, l); 407 pushstr(L, buff + UTF8BUFFSZ - l, l);
407 break; 408 break;
408 } 409 }