mirror of
https://github.com/lua/lua.git
synced 2025-07-03 22:53:26 +00:00
Using 'l_uint32' for unicode codepoints in scanner
'l_uint32' is enough for unicode codepoints (versus unsigned long), and the utf-8 library already uses that type.
This commit is contained in:
parent
3f0ea90aa8
commit
d827e96f33
4 changed files with 7 additions and 7 deletions
6
llex.c
6
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");
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue