diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-28 13:13:26 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-01-28 13:13:26 -0200 |
commit | e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce (patch) | |
tree | 0c8fe009fffa187be71ea3e268daf1a6e29d6d9a /lobject.c | |
parent | 89110986d7a9e81960261ae682780d5fd06dc4ac (diff) | |
download | lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.gz lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.tar.bz2 lua-e2b15aa21d2f31ccc93e35f50928e26a8d9c84ce.zip |
janitor work on casts
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.121 2017/11/23 19:29:04 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.122 2017/12/30 20:46:18 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 | */ |
@@ -204,7 +204,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
204 | int e = 0; /* exponent correction */ | 204 | int e = 0; /* exponent correction */ |
205 | int neg; /* 1 if number is negative */ | 205 | int neg; /* 1 if number is negative */ |
206 | int hasdot = 0; /* true after seen a dot */ | 206 | int hasdot = 0; /* true after seen a dot */ |
207 | *endptr = cast(char *, s); /* nothing is valid yet */ | 207 | *endptr = cast_charp(s); /* nothing is valid yet */ |
208 | while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ | 208 | while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ |
209 | neg = isneg(&s); /* check sign */ | 209 | neg = isneg(&s); /* check sign */ |
210 | if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ | 210 | if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ |
@@ -226,7 +226,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
226 | } | 226 | } |
227 | if (nosigdig + sigdig == 0) /* no digits? */ | 227 | if (nosigdig + sigdig == 0) /* no digits? */ |
228 | return 0.0; /* invalid format */ | 228 | return 0.0; /* invalid format */ |
229 | *endptr = cast(char *, s); /* valid up to here */ | 229 | *endptr = cast_charp(s); /* valid up to here */ |
230 | e *= 4; /* each digit multiplies/divides value by 2^4 */ | 230 | e *= 4; /* each digit multiplies/divides value by 2^4 */ |
231 | if (*s == 'p' || *s == 'P') { /* exponent part? */ | 231 | if (*s == 'p' || *s == 'P') { /* exponent part? */ |
232 | int exp1 = 0; /* exponent value */ | 232 | int exp1 = 0; /* exponent value */ |
@@ -239,7 +239,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { | |||
239 | exp1 = exp1 * 10 + *(s++) - '0'; | 239 | exp1 = exp1 * 10 + *(s++) - '0'; |
240 | if (neg1) exp1 = -exp1; | 240 | if (neg1) exp1 = -exp1; |
241 | e += exp1; | 241 | e += exp1; |
242 | *endptr = cast(char *, s); /* valid up to here */ | 242 | *endptr = cast_charp(s); /* valid up to here */ |
243 | } | 243 | } |
244 | if (neg) r = -r; | 244 | if (neg) r = -r; |
245 | return l_mathop(ldexp)(r, e); | 245 | return l_mathop(ldexp)(r, e); |
@@ -353,15 +353,15 @@ int luaO_utf8esc (char *buff, unsigned long x) { | |||
353 | int n = 1; /* number of bytes put in buffer (backwards) */ | 353 | int n = 1; /* number of bytes put in buffer (backwards) */ |
354 | lua_assert(x <= 0x10FFFF); | 354 | lua_assert(x <= 0x10FFFF); |
355 | if (x < 0x80) /* ascii? */ | 355 | if (x < 0x80) /* ascii? */ |
356 | buff[UTF8BUFFSZ - 1] = cast(char, x); | 356 | buff[UTF8BUFFSZ - 1] = cast_char(x); |
357 | else { /* need continuation bytes */ | 357 | else { /* need continuation bytes */ |
358 | unsigned int mfb = 0x3f; /* maximum that fits in first byte */ | 358 | unsigned int mfb = 0x3f; /* maximum that fits in first byte */ |
359 | do { /* add continuation bytes */ | 359 | do { /* add continuation bytes */ |
360 | buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f)); | 360 | buff[UTF8BUFFSZ - (n++)] = cast_char(0x80 | (x & 0x3f)); |
361 | x >>= 6; /* remove added bits */ | 361 | x >>= 6; /* remove added bits */ |
362 | mfb >>= 1; /* now there is one less bit available in first byte */ | 362 | mfb >>= 1; /* now there is one less bit available in first byte */ |
363 | } while (x > mfb); /* still needs continuation byte? */ | 363 | } while (x > mfb); /* still needs continuation byte? */ |
364 | buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */ | 364 | buff[UTF8BUFFSZ - n] = cast_char((~mfb << 1) | x); /* add first byte */ |
365 | } | 365 | } |
366 | return n; | 366 | return n; |
367 | } | 367 | } |
@@ -417,7 +417,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | case 'c': { /* an 'int' as a character */ | 419 | case 'c': { /* an 'int' as a character */ |
420 | char buff = cast(char, va_arg(argp, int)); | 420 | char buff = cast_char(va_arg(argp, int)); |
421 | if (lisprint(cast_uchar(buff))) | 421 | if (lisprint(cast_uchar(buff))) |
422 | pushstr(L, &buff, 1); | 422 | pushstr(L, &buff, 1); |
423 | else /* non-printable character; print its code */ | 423 | else /* non-printable character; print its code */ |