diff --git a/llex.c b/llex.c index 9d93224f..edeb48fe 100644 --- a/llex.c +++ b/llex.c @@ -359,12 +359,12 @@ static int readhexaesc (LexState *ls) { ** for error reporting in case of errors; 'i' counts the number of ** saved characters, so that they can be removed if case of success. */ -static unsigned long readutf8esc (LexState *ls) { - unsigned long r; +static l_uint32 readutf8esc (LexState *ls) { + l_uint32 r; int i = 4; /* number of chars to be removed: start with #"\u{X" */ save_and_next(ls); /* skip 'u' */ esccheck(ls, ls->current == '{', "missing '{'"); - r = cast_ulong(gethexa(ls)); /* must have at least one digit */ + r = cast_uint(gethexa(ls)); /* must have at least one digit */ while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) { i++; esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); diff --git a/llimits.h b/llimits.h index 710dc1b4..b1fc384b 100644 --- a/llimits.h +++ b/llimits.h @@ -138,7 +138,6 @@ typedef LUAI_UACINT l_uacInt; #define cast_num(i) cast(lua_Number, (i)) #define cast_int(i) cast(int, (i)) #define cast_uint(i) cast(unsigned int, (i)) -#define cast_ulong(i) cast(unsigned long, (i)) #define cast_byte(i) cast(lu_byte, (i)) #define cast_uchar(i) cast(unsigned char, (i)) #define cast_char(i) cast(char, (i)) diff --git a/lobject.c b/lobject.c index 68566a2b..57fc6a91 100644 --- a/lobject.c +++ b/lobject.c @@ -382,7 +382,7 @@ size_t luaO_str2num (const char *s, TValue *o) { } -int luaO_utf8esc (char *buff, unsigned long x) { +int luaO_utf8esc (char *buff, l_uint32 x) { int n = 1; /* number of bytes put in buffer (backwards) */ lua_assert(x <= 0x7FFFFFFFu); if (x < 0x80) /* ascii? */ @@ -637,7 +637,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { } case 'U': { /* an 'unsigned long' as a UTF-8 sequence */ char bf[UTF8BUFFSZ]; - int len = luaO_utf8esc(bf, va_arg(argp, unsigned long)); + unsigned long arg = va_arg(argp, unsigned long); + int len = luaO_utf8esc(bf, cast(l_uint32, arg)); addstr2buff(&buff, bf + UTF8BUFFSZ - len, cast_uint(len)); break; } diff --git a/lobject.h b/lobject.h index b5ca3668..bc2f69ab 100644 --- a/lobject.h +++ b/lobject.h @@ -831,7 +831,7 @@ typedef struct Table { if (msg == NULL) luaD_throw(L, LUA_ERRMEM); /* only after 'va_end' */ } -LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); +LUAI_FUNC int luaO_utf8esc (char *buff, l_uint32 x); LUAI_FUNC lu_byte luaO_ceillog2 (unsigned int x); LUAI_FUNC lu_byte luaO_codeparam (unsigned int p); LUAI_FUNC l_mem luaO_applyparam (lu_byte p, l_mem x);