diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-31 16:46:07 -0300 |
| commit | e1d072571ec6f9d830e575a2ecdc95fd43428e53 (patch) | |
| tree | 830fab7f2acb9adaee2d63073d339cc9557a5437 | |
| parent | 7651a5c6b2ee6ec59cadec6199319d482071f176 (diff) | |
| download | lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.gz lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.tar.bz2 lua-e1d072571ec6f9d830e575a2ecdc95fd43428e53.zip | |
better syntax for type casts
Diffstat (limited to '')
| -rw-r--r-- | lapi.c | 10 | ||||
| -rw-r--r-- | lbaselib.c | 2 | ||||
| -rw-r--r-- | lcode.c | 10 | ||||
| -rw-r--r-- | ldblib.c | 4 | ||||
| -rw-r--r-- | ldo.c | 6 | ||||
| -rw-r--r-- | lfunc.c | 7 | ||||
| -rw-r--r-- | lgc.c | 4 | ||||
| -rw-r--r-- | liolib.c | 30 | ||||
| -rw-r--r-- | llex.c | 14 | ||||
| -rw-r--r-- | llex.h | 4 | ||||
| -rw-r--r-- | lmem.c | 7 | ||||
| -rw-r--r-- | lmem.h | 16 | ||||
| -rw-r--r-- | lobject.h | 12 | ||||
| -rw-r--r-- | lopcodes.c | 3 | ||||
| -rw-r--r-- | lopcodes.h | 42 | ||||
| -rw-r--r-- | lparser.c | 8 | ||||
| -rw-r--r-- | lstate.c | 4 | ||||
| -rw-r--r-- | lstring.c | 10 | ||||
| -rw-r--r-- | lstring.h | 8 | ||||
| -rw-r--r-- | lstrlib.c | 6 | ||||
| -rw-r--r-- | ltable.c | 14 | ||||
| -rw-r--r-- | ltable.h | 2 | ||||
| -rw-r--r-- | ltests.c | 50 | ||||
| -rw-r--r-- | ltests.h | 6 | ||||
| -rw-r--r-- | ltm.c | 4 | ||||
| -rw-r--r-- | lvm.c | 6 |
26 files changed, 148 insertions, 141 deletions
| @@ -544,8 +544,8 @@ LUA_API int lua_dostring (lua_State *L, const l_char *str) { | |||
| 544 | */ | 544 | */ |
| 545 | 545 | ||
| 546 | /* GC values are expressed in Kbytes: #bytes/2^10 */ | 546 | /* GC values are expressed in Kbytes: #bytes/2^10 */ |
| 547 | #define GCscale(x) ((int)((x)>>10)) | 547 | #define GCscale(x) (cast(int, (x)>>10)) |
| 548 | #define GCunscale(x) ((lu_mem)(x)<<10) | 548 | #define GCunscale(x) (cast(lu_mem, (x)<<10)) |
| 549 | 549 | ||
| 550 | LUA_API int lua_getgcthreshold (lua_State *L) { | 550 | LUA_API int lua_getgcthreshold (lua_State *L) { |
| 551 | int threshold; | 551 | int threshold; |
| @@ -602,7 +602,7 @@ LUA_API int lua_name2tag (lua_State *L, const l_char *name) { | |||
| 602 | tag = LUA_TNONE; | 602 | tag = LUA_TNONE; |
| 603 | else { | 603 | else { |
| 604 | lua_assert(ttype(v) == LUA_TNUMBER); | 604 | lua_assert(ttype(v) == LUA_TNUMBER); |
| 605 | tag = (int)nvalue(v); | 605 | tag = cast(int, nvalue(v)); |
| 606 | } | 606 | } |
| 607 | lua_unlock(L); | 607 | lua_unlock(L); |
| 608 | return tag; | 608 | return tag; |
| @@ -695,7 +695,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 695 | api_check(L, ttype(t) == LUA_TTABLE); | 695 | api_check(L, ttype(t) == LUA_TTABLE); |
| 696 | value = luaH_getstr(hvalue(t), luaS_newliteral(L, l_s("n"))); /* = t.n */ | 696 | value = luaH_getstr(hvalue(t), luaS_newliteral(L, l_s("n"))); /* = t.n */ |
| 697 | if (ttype(value) == LUA_TNUMBER) | 697 | if (ttype(value) == LUA_TNUMBER) |
| 698 | n = (int)nvalue(value); | 698 | n = cast(int, nvalue(value)); |
| 699 | else { | 699 | else { |
| 700 | lua_Number max = 0; | 700 | lua_Number max = 0; |
| 701 | int i = hvalue(t)->size; | 701 | int i = hvalue(t)->size; |
| @@ -707,7 +707,7 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 707 | max = nvalue(key(nd)); | 707 | max = nvalue(key(nd)); |
| 708 | nd++; | 708 | nd++; |
| 709 | } | 709 | } |
| 710 | n = (int)max; | 710 | n = cast(int, max); |
| 711 | } | 711 | } |
| 712 | lua_unlock(L); | 712 | lua_unlock(L); |
| 713 | return n; | 713 | return n; |
| @@ -141,7 +141,7 @@ static int luaB_getglobal (lua_State *L) { | |||
| 141 | static int gettag (lua_State *L, int narg) { | 141 | static int gettag (lua_State *L, int narg) { |
| 142 | switch (lua_rawtag(L, narg)) { | 142 | switch (lua_rawtag(L, narg)) { |
| 143 | case LUA_TNUMBER: | 143 | case LUA_TNUMBER: |
| 144 | return (int)lua_tonumber(L, narg); | 144 | return (int)(lua_tonumber(L, narg)); |
| 145 | case LUA_TSTRING: { | 145 | case LUA_TSTRING: { |
| 146 | const l_char *name = lua_tostring(L, narg); | 146 | const l_char *name = lua_tostring(L, narg); |
| 147 | int tag = lua_name2tag(L, name); | 147 | int tag = lua_name2tag(L, name); |
| @@ -41,7 +41,7 @@ static Instruction previous_instruction (FuncState *fs) { | |||
| 41 | if (fs->pc > fs->lasttarget) /* no jumps to current position? */ | 41 | if (fs->pc > fs->lasttarget) /* no jumps to current position? */ |
| 42 | return fs->f->code[fs->pc-1]; /* returns previous instruction */ | 42 | return fs->f->code[fs->pc-1]; /* returns previous instruction */ |
| 43 | else | 43 | else |
| 44 | return (Instruction)(-1);/* no optimizations after an invalid instruction */ | 44 | return cast(Instruction, -1);/* invalid instruction avoids optimizations */ |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | 47 | ||
| @@ -203,7 +203,7 @@ void luaK_reserveregs (FuncState *fs, int n) { | |||
| 203 | if (fs->freereg > fs->f->maxstacksize) { | 203 | if (fs->freereg > fs->f->maxstacksize) { |
| 204 | if (fs->freereg >= MAXSTACK) | 204 | if (fs->freereg >= MAXSTACK) |
| 205 | luaK_error(fs->ls, l_s("function or expression too complex")); | 205 | luaK_error(fs->ls, l_s("function or expression too complex")); |
| 206 | fs->f->maxstacksize = (short)fs->freereg; | 206 | fs->f->maxstacksize = cast(short, fs->freereg); |
| 207 | } | 207 | } |
| 208 | } | 208 | } |
| 209 | 209 | ||
| @@ -225,8 +225,8 @@ static void freeexp (FuncState *fs, expdesc *e) { | |||
| 225 | static int addk (FuncState *fs, TObject *k) { | 225 | static int addk (FuncState *fs, TObject *k) { |
| 226 | const TObject *index = luaH_get(fs->h, k); | 226 | const TObject *index = luaH_get(fs->h, k); |
| 227 | if (ttype(index) == LUA_TNUMBER) { | 227 | if (ttype(index) == LUA_TNUMBER) { |
| 228 | lua_assert(luaO_equalObj(&fs->f->k[(int)nvalue(index)], k)); | 228 | lua_assert(luaO_equalObj(&fs->f->k[cast(int, nvalue(index))], k)); |
| 229 | return (int)nvalue(index); | 229 | return cast(int, nvalue(index)); |
| 230 | } | 230 | } |
| 231 | else { /* constant not found; create a new entry */ | 231 | else { /* constant not found; create a new entry */ |
| 232 | TObject o; | 232 | TObject o; |
| @@ -329,7 +329,7 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
| 329 | } | 329 | } |
| 330 | case VNUMBER: { | 330 | case VNUMBER: { |
| 331 | lua_Number f = e->u.n; | 331 | lua_Number f = e->u.n; |
| 332 | int i = (int)f; | 332 | int i = cast(int, f); |
| 333 | if ((lua_Number)i == f && -MAXARG_sBc <= i && i <= MAXARG_sBc) | 333 | if ((lua_Number)i == f && -MAXARG_sBc <= i && i <= MAXARG_sBc) |
| 334 | luaK_codeAsBc(fs, OP_LOADINT, reg, i); /* f has a small int value */ | 334 | luaK_codeAsBc(fs, OP_LOADINT, reg, i); /* f has a small int value */ |
| 335 | else | 335 | else |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.36 2001/03/26 14:31:49 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.37 2001/06/06 18:00:19 roberto Exp $ |
| 3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -37,7 +37,7 @@ static int getinfo (lua_State *L) { | |||
| 37 | const l_char *options = luaL_opt_string(L, 2, l_s("flnSu")); | 37 | const l_char *options = luaL_opt_string(L, 2, l_s("flnSu")); |
| 38 | l_char buff[20]; | 38 | l_char buff[20]; |
| 39 | if (lua_isnumber(L, 1)) { | 39 | if (lua_isnumber(L, 1)) { |
| 40 | if (!lua_getstack(L, (int)lua_tonumber(L, 1), &ar)) { | 40 | if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { |
| 41 | lua_pushnil(L); /* level out of range */ | 41 | lua_pushnil(L); /* level out of range */ |
| 42 | return 1; | 42 | return 1; |
| 43 | } | 43 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.137 2001/07/12 19:34:03 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.138 2001/07/16 20:24:48 roberto Exp $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -176,7 +176,7 @@ struct CallS { /* data to `f_call' */ | |||
| 176 | }; | 176 | }; |
| 177 | 177 | ||
| 178 | static void f_call (lua_State *L, void *ud) { | 178 | static void f_call (lua_State *L, void *ud) { |
| 179 | struct CallS *c = (struct CallS *)ud; | 179 | struct CallS *c = cast(struct CallS *, ud); |
| 180 | luaD_call(L, c->func); | 180 | luaD_call(L, c->func); |
| 181 | if (c->nresults != LUA_MULTRET) | 181 | if (c->nresults != LUA_MULTRET) |
| 182 | luaD_adjusttop(L, c->func + c->nresults); | 182 | luaD_adjusttop(L, c->func + c->nresults); |
| @@ -207,7 +207,7 @@ struct SParser { /* data to `f_parser' */ | |||
| 207 | }; | 207 | }; |
| 208 | 208 | ||
| 209 | static void f_parser (lua_State *L, void *ud) { | 209 | static void f_parser (lua_State *L, void *ud) { |
| 210 | struct SParser *p = (struct SParser *)ud; | 210 | struct SParser *p = cast(struct SParser *, ud); |
| 211 | Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z); | 211 | Proto *tf = p->bin ? luaU_undump(L, p->z) : luaY_parser(L, p->z); |
| 212 | luaV_Lclosure(L, tf, 0); | 212 | luaV_Lclosure(L, tf, 0); |
| 213 | } | 213 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 1.44 2001/06/05 18:17:01 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 1.45 2001/06/28 14:57:17 roberto Exp $ |
| 3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -15,11 +15,12 @@ | |||
| 15 | #include "lstate.h" | 15 | #include "lstate.h" |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | #define sizeclosure(n) ((int)sizeof(Closure) + (int)sizeof(TObject)*((n)-1)) | 18 | #define sizeclosure(n) (cast(int, sizeof(Closure)) + \ |
| 19 | cast(int, sizeof(TObject)*((n)-1))) | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | Closure *luaF_newclosure (lua_State *L, int nelems) { | 22 | Closure *luaF_newclosure (lua_State *L, int nelems) { |
| 22 | Closure *c = (Closure *)luaM_malloc(L, sizeclosure(nelems)); | 23 | Closure *c = cast(Closure *, luaM_malloc(L, sizeclosure(nelems))); |
| 23 | c->next = G(L)->rootcl; | 24 | c->next = G(L)->rootcl; |
| 24 | G(L)->rootcl = c; | 25 | G(L)->rootcl = c; |
| 25 | c->mark = c; | 26 | c->mark = c; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 1.108 2001/06/26 13:20:45 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.109 2001/06/28 14:57:17 roberto Exp $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -305,7 +305,7 @@ static void collectstrings (lua_State *L, int all) { | |||
| 305 | } | 305 | } |
| 306 | } | 306 | } |
| 307 | } | 307 | } |
| 308 | if (G(L)->strt.nuse < (ls_nstr)(G(L)->strt.size/4) && | 308 | if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) && |
| 309 | G(L)->strt.size > MINPOWER2) | 309 | G(L)->strt.size > MINPOWER2) |
| 310 | luaS_resize(L, G(L)->strt.size/2); /* table is too big */ | 310 | luaS_resize(L, G(L)->strt.size/2); /* table is too big */ |
| 311 | } | 311 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 1.120 2001/07/16 18:48:31 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.121 2001/07/22 00:59:36 roberto Exp $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -73,7 +73,7 @@ static int pushresult (lua_State *L, int i) { | |||
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | static FILE *getopthandle (lua_State *L, int inout) { | 75 | static FILE *getopthandle (lua_State *L, int inout) { |
| 76 | FILE *p = (FILE *)lua_touserdata(L, 1); | 76 | FILE *p = (FILE *)(lua_touserdata(L, 1)); |
| 77 | if (p != NULL) { /* is it a userdata ? */ | 77 | if (p != NULL) { /* is it a userdata ? */ |
| 78 | if (!checkfile(L, 1)) { /* not a valid file handle? */ | 78 | if (!checkfile(L, 1)) { /* not a valid file handle? */ |
| 79 | if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0) | 79 | if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0) |
| @@ -88,7 +88,7 @@ static FILE *getopthandle (lua_State *L, int inout) { | |||
| 88 | if (!checkfile(L,-1)) | 88 | if (!checkfile(L,-1)) |
| 89 | luaL_verror(L, l_s("global variable `%.10s' is not a valid file handle"), | 89 | luaL_verror(L, l_s("global variable `%.10s' is not a valid file handle"), |
| 90 | filenames[inout]); | 90 | filenames[inout]); |
| 91 | p = (FILE *)lua_touserdata(L, -1); | 91 | p = (FILE *)(lua_touserdata(L, -1)); |
| 92 | } | 92 | } |
| 93 | return p; /* leave handle at stack top to avoid GC */ | 93 | return p; /* leave handle at stack top to avoid GC */ |
| 94 | } | 94 | } |
| @@ -127,7 +127,7 @@ static void resetfile (lua_State *L, int inout) { | |||
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | static int io_close (lua_State *L) { | 129 | static int io_close (lua_State *L) { |
| 130 | FILE *f = (FILE *)luaL_check_userdata(L, 1, FILEHANDLE); | 130 | FILE *f = (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); |
| 131 | int status = 1; | 131 | int status = 1; |
| 132 | if (f != stdin && f != stdout && f != stderr) { | 132 | if (f != stdin && f != stdout && f != stderr) { |
| 133 | lua_settop(L, 1); /* make sure file is on top */ | 133 | lua_settop(L, 1); /* make sure file is on top */ |
| @@ -139,7 +139,7 @@ static int io_close (lua_State *L) { | |||
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | static int file_collect (lua_State *L) { | 141 | static int file_collect (lua_State *L) { |
| 142 | FILE *f = (FILE *)luaL_check_userdata(L, 1, FILEHANDLE); | 142 | FILE *f = (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); |
| 143 | if (f != stdin && f != stdout && f != stderr) | 143 | if (f != stdin && f != stdout && f != stderr) |
| 144 | CLOSEFILE(L, f); | 144 | CLOSEFILE(L, f); |
| 145 | return 0; | 145 | return 0; |
| @@ -328,7 +328,7 @@ static int io_read (lua_State *L) { | |||
| 328 | size_t pl = lua_strlen(L, n) - 2; | 328 | size_t pl = lua_strlen(L, n) - 2; |
| 329 | luaL_arg_check(L, 0 < pl && pl <= LUA_MAXUNTIL, n, | 329 | luaL_arg_check(L, 0 < pl && pl <= LUA_MAXUNTIL, n, |
| 330 | l_s("invalid read-until length")); | 330 | l_s("invalid read-until length")); |
| 331 | success = read_until(L, f, p+2, (int)pl); | 331 | success = read_until(L, f, p+2, (int)(pl)); |
| 332 | break; | 332 | break; |
| 333 | } | 333 | } |
| 334 | default: | 334 | default: |
| @@ -373,7 +373,7 @@ static int io_write (lua_State *L) { | |||
| 373 | static int io_seek (lua_State *L) { | 373 | static int io_seek (lua_State *L) { |
| 374 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; | 374 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; |
| 375 | static const l_char *const modenames[] = {l_s("set"), l_s("cur"), l_s("end"), NULL}; | 375 | static const l_char *const modenames[] = {l_s("set"), l_s("cur"), l_s("end"), NULL}; |
| 376 | FILE *f = (FILE *)luaL_check_userdata(L, 1, FILEHANDLE); | 376 | FILE *f = (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); |
| 377 | int op = luaL_findstring(luaL_opt_string(L, 2, l_s("cur")), modenames); | 377 | int op = luaL_findstring(luaL_opt_string(L, 2, l_s("cur")), modenames); |
| 378 | long offset = luaL_opt_long(L, 3, 0); | 378 | long offset = luaL_opt_long(L, 3, 0); |
| 379 | luaL_arg_check(L, op != -1, 2, l_s("invalid mode")); | 379 | luaL_arg_check(L, op != -1, 2, l_s("invalid mode")); |
| @@ -388,8 +388,8 @@ static int io_seek (lua_State *L) { | |||
| 388 | 388 | ||
| 389 | 389 | ||
| 390 | static int io_flush (lua_State *L) { | 390 | static int io_flush (lua_State *L) { |
| 391 | FILE *f = (lua_isnull(L, 1)) ? (FILE *)NULL : | 391 | FILE *f = (lua_isnull(L, 1)) ? (FILE *)(NULL) : |
| 392 | (FILE *)luaL_check_userdata(L, 1, FILEHANDLE); | 392 | (FILE *)(luaL_check_userdata(L, 1, FILEHANDLE)); |
| 393 | return pushresult(L, fflush(f) == 0); | 393 | return pushresult(L, fflush(f) == 0); |
| 394 | } | 394 | } |
| 395 | 395 | ||
| @@ -461,7 +461,7 @@ static int getfield (lua_State *L, const l_char *key, int d) { | |||
| 461 | lua_pushstring(L, key); | 461 | lua_pushstring(L, key); |
| 462 | lua_rawget(L, -2); | 462 | lua_rawget(L, -2); |
| 463 | if (lua_isnumber(L, -1)) | 463 | if (lua_isnumber(L, -1)) |
| 464 | res = (int)lua_tonumber(L, -1); | 464 | res = (int)(lua_tonumber(L, -1)); |
| 465 | else { | 465 | else { |
| 466 | if (d == -2) | 466 | if (d == -2) |
| 467 | luaL_verror(L, l_s("field `%.20s' missing in date table"), key); | 467 | luaL_verror(L, l_s("field `%.20s' missing in date table"), key); |
| @@ -474,9 +474,9 @@ static int getfield (lua_State *L, const l_char *key, int d) { | |||
| 474 | 474 | ||
| 475 | static int io_date (lua_State *L) { | 475 | static int io_date (lua_State *L) { |
| 476 | const l_char *s = luaL_opt_string(L, 1, l_s("%c")); | 476 | const l_char *s = luaL_opt_string(L, 1, l_s("%c")); |
| 477 | time_t t = (time_t)luaL_opt_number(L, 2, -1); | 477 | time_t t = (time_t)(luaL_opt_number(L, 2, -1)); |
| 478 | struct tm *stm; | 478 | struct tm *stm; |
| 479 | if (t == (time_t)-1) /* no time given? */ | 479 | if (t == (time_t)(-1)) /* no time given? */ |
| 480 | t = time(NULL); /* use current time */ | 480 | t = time(NULL); /* use current time */ |
| 481 | if (*s == l_c('!')) { /* UTC? */ | 481 | if (*s == l_c('!')) { /* UTC? */ |
| 482 | stm = gmtime(&t); | 482 | stm = gmtime(&t); |
| @@ -525,7 +525,7 @@ static int io_time (lua_State *L) { | |||
| 525 | ts.tm_year = getfield(L, l_s("year"), -2)-1900; | 525 | ts.tm_year = getfield(L, l_s("year"), -2)-1900; |
| 526 | ts.tm_isdst = getfield(L, l_s("isdst"), -1); | 526 | ts.tm_isdst = getfield(L, l_s("isdst"), -1); |
| 527 | t = mktime(&ts); | 527 | t = mktime(&ts); |
| 528 | if (t == (time_t)-1) | 528 | if (t == (time_t)(-1)) |
| 529 | lua_pushnil(L); | 529 | lua_pushnil(L); |
| 530 | else | 530 | else |
| 531 | lua_pushnumber(L, t); | 531 | lua_pushnumber(L, t); |
| @@ -535,8 +535,8 @@ static int io_time (lua_State *L) { | |||
| 535 | 535 | ||
| 536 | 536 | ||
| 537 | static int io_difftime (lua_State *L) { | 537 | static int io_difftime (lua_State *L) { |
| 538 | lua_pushnumber(L, difftime((time_t)luaL_check_number(L, 1), | 538 | lua_pushnumber(L, difftime((time_t)(luaL_check_number(L, 1)), |
| 539 | (time_t)luaL_opt_number(L, 2, 0))); | 539 | (time_t)(luaL_opt_number(L, 2, 0)))); |
| 540 | return 1; | 540 | return 1; |
| 541 | } | 541 | } |
| 542 | 542 | ||
| @@ -41,7 +41,7 @@ void luaX_init (lua_State *L) { | |||
| 41 | for (i=0; i<NUM_RESERVED; i++) { | 41 | for (i=0; i<NUM_RESERVED; i++) { |
| 42 | TString *ts = luaS_new(L, token2string[i]); | 42 | TString *ts = luaS_new(L, token2string[i]); |
| 43 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); | 43 | lua_assert(strlen(token2string[i])+1 <= TOKEN_LEN); |
| 44 | ts->tsv.marked = (unsigned short)(RESERVEDMARK+i); /* reserved word */ | 44 | ts->tsv.marked = cast(unsigned short, RESERVEDMARK+i); /* reserved word */ |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| @@ -71,7 +71,7 @@ void luaX_error (LexState *ls, const l_char *s, int token) { | |||
| 71 | l_char buff[TOKEN_LEN]; | 71 | l_char buff[TOKEN_LEN]; |
| 72 | luaX_token2str(token, buff); | 72 | luaX_token2str(token, buff); |
| 73 | if (buff[0] == l_c('\0')) | 73 | if (buff[0] == l_c('\0')) |
| 74 | luaX_syntaxerror(ls, s, (l_char *)G(ls->L)->Mbuffer); | 74 | luaX_syntaxerror(ls, s, cast(l_char *, G(ls->L)->Mbuffer)); |
| 75 | else | 75 | else |
| 76 | luaX_syntaxerror(ls, s, buff); | 76 | luaX_syntaxerror(ls, s, buff); |
| 77 | } | 77 | } |
| @@ -134,7 +134,7 @@ void luaX_setinput (lua_State *L, LexState *LS, ZIO *z, TString *source) { | |||
| 134 | if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \ | 134 | if (((len)+(n))*sizeof(l_char) > G(L)->Mbuffsize) \ |
| 135 | luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char) | 135 | luaO_openspace(L, (len)+(n)+EXTRABUFF, l_char) |
| 136 | 136 | ||
| 137 | #define save(L, c, l) (((l_char *)G(L)->Mbuffer)[l++] = (l_char)c) | 137 | #define save(L, c, l) (cast(l_char *, G(L)->Mbuffer)[l++] = (l_char)c) |
| 138 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) | 138 | #define save_and_next(L, LS, l) (save(L, LS->current, l), next(LS)) |
| 139 | 139 | ||
| 140 | 140 | ||
| @@ -185,7 +185,7 @@ static void read_number (LexState *LS, int comma, SemInfo *seminfo) { | |||
| 185 | } | 185 | } |
| 186 | } | 186 | } |
| 187 | save(L, l_c('\0'), l); | 187 | save(L, l_c('\0'), l); |
| 188 | if (!luaO_str2d((l_char *)G(L)->Mbuffer, &seminfo->r)) | 188 | if (!luaO_str2d(cast(l_char *, G(L)->Mbuffer), &seminfo->r)) |
| 189 | luaX_error(LS, l_s("malformed number"), TK_NUMBER); | 189 | luaX_error(LS, l_s("malformed number"), TK_NUMBER); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| @@ -231,7 +231,7 @@ static void read_long_string (LexState *LS, SemInfo *seminfo) { | |||
| 231 | } endloop: | 231 | } endloop: |
| 232 | save_and_next(L, LS, l); /* skip the second `]' */ | 232 | save_and_next(L, LS, l); /* skip the second `]' */ |
| 233 | save(L, l_c('\0'), l); | 233 | save(L, l_c('\0'), l); |
| 234 | seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+2, l-5); | 234 | seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+2, l-5); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | 237 | ||
| @@ -283,7 +283,7 @@ static void read_string (LexState *LS, int del, SemInfo *seminfo) { | |||
| 283 | } | 283 | } |
| 284 | save_and_next(L, LS, l); /* skip delimiter */ | 284 | save_and_next(L, LS, l); /* skip delimiter */ |
| 285 | save(L, l_c('\0'), l); | 285 | save(L, l_c('\0'), l); |
| 286 | seminfo->ts = luaS_newlstr(L, (l_char *)G(L)->Mbuffer+1, l-3); | 286 | seminfo->ts = luaS_newlstr(L, cast(l_char *, G(L)->Mbuffer)+1, l-3); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | 289 | ||
| @@ -371,7 +371,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) { | |||
| 371 | else if (isalpha(LS->current) || LS->current == l_c('_')) { | 371 | else if (isalpha(LS->current) || LS->current == l_c('_')) { |
| 372 | /* identifier or reserved word */ | 372 | /* identifier or reserved word */ |
| 373 | size_t l = readname(LS); | 373 | size_t l = readname(LS); |
| 374 | TString *ts = luaS_newlstr(LS->L, (l_char *)G(LS->L)->Mbuffer, l); | 374 | TString *ts = luaS_newlstr(LS->L, cast(l_char *, G(LS->L)->Mbuffer), l); |
| 375 | if (ts->tsv.marked >= RESERVEDMARK) /* reserved word? */ | 375 | if (ts->tsv.marked >= RESERVEDMARK) /* reserved word? */ |
| 376 | return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED; | 376 | return ts->tsv.marked-RESERVEDMARK+FIRST_RESERVED; |
| 377 | seminfo->ts = ts; | 377 | seminfo->ts = ts; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llex.h,v 1.36 2001/06/20 21:07:57 roberto Exp roberto $ | 2 | ** $Id: llex.h,v 1.37 2001/07/22 00:59:36 roberto Exp $ |
| 3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -33,7 +33,7 @@ enum RESERVED { | |||
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | /* number of reserved words */ | 35 | /* number of reserved words */ |
| 36 | #define NUM_RESERVED ((int)(TK_WHILE-FIRST_RESERVED+1)) | 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | typedef union { | 39 | typedef union { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.c,v 1.48 2001/02/23 17:17:25 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.49 2001/03/26 14:31:49 roberto Exp $ |
| 3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -34,8 +34,9 @@ void *luaM_growaux (lua_State *L, void *block, int *size, int size_elems, | |||
| 34 | newsize = limit; /* still have at least MINPOWER2 free places */ | 34 | newsize = limit; /* still have at least MINPOWER2 free places */ |
| 35 | else luaD_error(L, errormsg); | 35 | else luaD_error(L, errormsg); |
| 36 | } | 36 | } |
| 37 | newblock = luaM_realloc(L, block, (lu_mem)(*size)*(lu_mem)size_elems, | 37 | newblock = luaM_realloc(L, block, |
| 38 | (lu_mem)newsize*(lu_mem)size_elems); | 38 | cast(lu_mem, *size)*cast(lu_mem, size_elems), |
| 39 | cast(lu_mem, newsize)*cast(lu_mem, size_elems)); | ||
| 39 | *size = newsize; /* update only when everything else is OK */ | 40 | *size = newsize; /* update only when everything else is OK */ |
| 40 | return newblock; | 41 | return newblock; |
| 41 | } | 42 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmem.h,v 1.21 2001/02/20 18:15:33 roberto Exp roberto $ | 2 | ** $Id: lmem.h,v 1.22 2001/02/23 17:17:25 roberto Exp $ |
| 3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,20 +21,20 @@ void *luaM_growaux (lua_State *L, void *block, int *size, int size_elem, | |||
| 21 | #define luaM_free(L, b, s) luaM_realloc(L, (b), (s), 0) | 21 | #define luaM_free(L, b, s) luaM_realloc(L, (b), (s), 0) |
| 22 | #define luaM_freelem(L, b, t) luaM_realloc(L, (b), sizeof(t), 0) | 22 | #define luaM_freelem(L, b, t) luaM_realloc(L, (b), sizeof(t), 0) |
| 23 | #define luaM_freearray(L, b, n, t) luaM_realloc(L, (b), \ | 23 | #define luaM_freearray(L, b, n, t) luaM_realloc(L, (b), \ |
| 24 | ((lu_mem)(n)*(lu_mem)sizeof(t)), 0) | 24 | cast(lu_mem, n)*cast(lu_mem, sizeof(t)), 0) |
| 25 | 25 | ||
| 26 | #define luaM_malloc(L, t) luaM_realloc(L, NULL, 0, (t)) | 26 | #define luaM_malloc(L, t) luaM_realloc(L, NULL, 0, (t)) |
| 27 | #define luaM_new(L, t) ((t *)luaM_malloc(L, sizeof(t))) | 27 | #define luaM_new(L, t) cast(t *, luaM_malloc(L, sizeof(t))) |
| 28 | #define luaM_newvector(L, n,t) ((t *)luaM_malloc(L, \ | 28 | #define luaM_newvector(L, n,t) cast(t *, luaM_malloc(L, \ |
| 29 | (lu_mem)(n)*(lu_mem)sizeof(t))) | 29 | cast(lu_mem, n)*cast(lu_mem, sizeof(t)))) |
| 30 | 30 | ||
| 31 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ | 31 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ |
| 32 | if (((nelems)+1) > (size)) \ | 32 | if (((nelems)+1) > (size)) \ |
| 33 | ((v)=(t *)luaM_growaux(L,v,&(size),sizeof(t),limit,e)) | 33 | ((v)=cast(t *, luaM_growaux(L,v,&(size),sizeof(t),limit,e))) |
| 34 | 34 | ||
| 35 | #define luaM_reallocvector(L, v,oldn,n,t) \ | 35 | #define luaM_reallocvector(L, v,oldn,n,t) \ |
| 36 | ((v)=(t *)luaM_realloc(L, v,(lu_mem)(oldn)*(lu_mem)sizeof(t), \ | 36 | ((v)=cast(t *, luaM_realloc(L, v,cast(lu_mem, oldn)*cast(lu_mem, sizeof(t)), \ |
| 37 | (lu_mem)(n)*(lu_mem)sizeof(t))) | 37 | cast(lu_mem, n)*cast(lu_mem, sizeof(t))))) |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | #endif | 40 | #endif |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 1.109 2001/06/28 14:56:25 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 1.110 2001/08/27 15:16:28 roberto Exp $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -22,6 +22,10 @@ | |||
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | #ifndef cast | ||
| 26 | #define cast(t, exp) ((t)(exp)) | ||
| 27 | #endif | ||
| 28 | |||
| 25 | 29 | ||
| 26 | /* tags for values visible from Lua == first user-created tag */ | 30 | /* tags for values visible from Lua == first user-created tag */ |
| 27 | #define NUM_TAGS 6 | 31 | #define NUM_TAGS 6 |
| @@ -96,7 +100,7 @@ typedef union TString { | |||
| 96 | } TString; | 100 | } TString; |
| 97 | 101 | ||
| 98 | 102 | ||
| 99 | #define getstr(ts) ((l_char *)((ts) + 1)) | 103 | #define getstr(ts) cast(l_char *, (ts) + 1) |
| 100 | #define svalue(o) getstr(tsvalue(o)) | 104 | #define svalue(o) getstr(tsvalue(o)) |
| 101 | 105 | ||
| 102 | 106 | ||
| @@ -196,7 +200,7 @@ typedef struct Hash { | |||
| 196 | /* | 200 | /* |
| 197 | ** `module' operation for hashing (size is always a power of 2) | 201 | ** `module' operation for hashing (size is always a power of 2) |
| 198 | */ | 202 | */ |
| 199 | #define lmod(s,size) ((int)((s) & ((size)-1))) | 203 | #define lmod(s,size) (cast(int, (s) & ((size)-1))) |
| 200 | 204 | ||
| 201 | 205 | ||
| 202 | /* | 206 | /* |
| @@ -217,7 +221,7 @@ typedef struct CallInfo { | |||
| 217 | extern const TObject luaO_nilobject; | 221 | extern const TObject luaO_nilobject; |
| 218 | 222 | ||
| 219 | 223 | ||
| 220 | #define luaO_openspace(L,n,t) ((t *)luaO_openspaceaux(L,(n)*sizeof(t))) | 224 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) |
| 221 | void *luaO_openspaceaux (lua_State *L, size_t n); | 225 | void *luaO_openspaceaux (lua_State *L, size_t n); |
| 222 | 226 | ||
| 223 | int luaO_equalObj (const TObject *t1, const TObject *t2); | 227 | int luaO_equalObj (const TObject *t1, const TObject *t2); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.c,v 1.2 2001/07/03 17:02:02 roberto Exp roberto $ | 2 | ** $Id: lopcodes.c,v 1.3 2001/08/27 15:14:57 roberto Exp $ |
| 3 | ** extracted automatically from lopcodes.h by mkprint.lua | 3 | ** extracted automatically from lopcodes.h by mkprint.lua |
| 4 | ** DO NOT EDIT | 4 | ** DO NOT EDIT |
| 5 | ** See Copyright Notice in lua.h | 5 | ** See Copyright Notice in lua.h |
| @@ -9,6 +9,7 @@ | |||
| 9 | #define LUA_PRIVATE | 9 | #define LUA_PRIVATE |
| 10 | #include "lua.h" | 10 | #include "lua.h" |
| 11 | 11 | ||
| 12 | #include "lobject.h" | ||
| 12 | #include "lopcodes.h" | 13 | #include "lopcodes.h" |
| 13 | 14 | ||
| 14 | 15 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.78 2001/07/24 17:19:07 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.79 2001/08/27 15:14:57 roberto Exp $ |
| 3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -76,37 +76,37 @@ enum OpMode {iABC, iABc, iAsBc}; /* basic instruction format */ | |||
| 76 | ** the following macros help to manipulate instructions | 76 | ** the following macros help to manipulate instructions |
| 77 | */ | 77 | */ |
| 78 | 78 | ||
| 79 | #define GET_OPCODE(i) ((OpCode)((i)&MASK1(SIZE_OP,0))) | 79 | #define GET_OPCODE(i) (cast(OpCode, (i)&MASK1(SIZE_OP,0))) |
| 80 | #define SET_OPCODE(i,o) (((i)&MASK0(SIZE_OP,0)) | (Instruction)(o)) | 80 | #define SET_OPCODE(i,o) (((i)&MASK0(SIZE_OP,0)) | cast(Instruction, o)) |
| 81 | 81 | ||
| 82 | #define GETARG_A(i) ((int)((i)>>POS_A)) | 82 | #define GETARG_A(i) (cast(int, (i)>>POS_A)) |
| 83 | #define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ | 83 | #define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ |
| 84 | ((Instruction)(u)<<POS_A))) | 84 | (cast(Instruction, u)<<POS_A))) |
| 85 | 85 | ||
| 86 | #define GETARG_B(i) ((int)(((i)>>POS_B) & MASK1(SIZE_B,0))) | 86 | #define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0))) |
| 87 | #define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ | 87 | #define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ |
| 88 | ((Instruction)(b)<<POS_B))) | 88 | (cast(Instruction, b)<<POS_B))) |
| 89 | 89 | ||
| 90 | #define GETARG_C(i) ((int)(((i)>>POS_C) & MASK1(SIZE_C,0))) | 90 | #define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0))) |
| 91 | #define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ | 91 | #define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ |
| 92 | ((Instruction)(b)<<POS_C))) | 92 | (cast(Instruction, b)<<POS_C))) |
| 93 | 93 | ||
| 94 | #define GETARG_Bc(i) ((int)(((i)>>POS_Bc) & MASK1(SIZE_Bc,0))) | 94 | #define GETARG_Bc(i) (cast(int, ((i)>>POS_Bc) & MASK1(SIZE_Bc,0))) |
| 95 | #define SETARG_Bc(i,b) ((i) = (((i)&MASK0(SIZE_Bc,POS_Bc)) | \ | 95 | #define SETARG_Bc(i,b) ((i) = (((i)&MASK0(SIZE_Bc,POS_Bc)) | \ |
| 96 | ((Instruction)(b)<<POS_Bc))) | 96 | (cast(Instruction, b)<<POS_Bc))) |
| 97 | 97 | ||
| 98 | #define GETARG_sBc(i) (GETARG_Bc(i)-MAXARG_sBc) | 98 | #define GETARG_sBc(i) (GETARG_Bc(i)-MAXARG_sBc) |
| 99 | #define SETARG_sBc(i,b) SETARG_Bc((i),(unsigned int)((b)+MAXARG_sBc)) | 99 | #define SETARG_sBc(i,b) SETARG_Bc((i),cast(unsigned int, (b)+MAXARG_sBc)) |
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | #define CREATE_ABC(o,a,b,c) ((Instruction)(o) \ | 102 | #define CREATE_ABC(o,a,b,c) (cast(Instruction, o) \ |
| 103 | | ((Instruction)(a)<<POS_A) \ | 103 | | (cast(Instruction, a)<<POS_A) \ |
| 104 | | ((Instruction)(b)<<POS_B) \ | 104 | | (cast(Instruction, b)<<POS_B) \ |
| 105 | | ((Instruction)(c)<<POS_C)) | 105 | | (cast(Instruction, c)<<POS_C)) |
| 106 | 106 | ||
| 107 | #define CREATE_ABc(o,a,bc) ((Instruction)(o) \ | 107 | #define CREATE_ABc(o,a,bc) (cast(Instruction, o) \ |
| 108 | | ((Instruction)(a)<<POS_A) \ | 108 | | (cast(Instruction, a)<<POS_A) \ |
| 109 | | ((Instruction)(bc)<<POS_Bc)) | 109 | | (cast(Instruction, bc)<<POS_Bc)) |
| 110 | 110 | ||
| 111 | 111 | ||
| 112 | 112 | ||
| @@ -184,7 +184,7 @@ OP_CLOSURE /* A Bc R(A) := closure(KPROTO[Bc], R(A), ... ,R(A+n)) */ | |||
| 184 | } OpCode; | 184 | } OpCode; |
| 185 | 185 | ||
| 186 | 186 | ||
| 187 | #define NUM_OPCODES ((int)OP_CLOSURE+1) | 187 | #define NUM_OPCODES (cast(int, OP_CLOSURE+1)) |
| 188 | 188 | ||
| 189 | 189 | ||
| 190 | 190 | ||
| @@ -215,7 +215,7 @@ enum OpModeMask { | |||
| 215 | 215 | ||
| 216 | extern const lu_byte luaP_opmodes[NUM_OPCODES]; | 216 | extern const lu_byte luaP_opmodes[NUM_OPCODES]; |
| 217 | 217 | ||
| 218 | #define getOpMode(m) ((enum OpMode)(luaP_opmodes[m] & 3)) | 218 | #define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) |
| 219 | #define testOpMode(m, b) (luaP_opmodes[m] & (1 << (b))) | 219 | #define testOpMode(m, b) (luaP_opmodes[m] & (1 << (b))) |
| 220 | 220 | ||
| 221 | 221 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 1.153 2001/08/10 20:53:03 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.154 2001/08/27 15:16:28 roberto Exp $ |
| 3 | ** Lua Parser | 3 | ** Lua Parser |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -266,7 +266,7 @@ static void code_params (LexState *ls, int nparams, short dots) { | |||
| 266 | FuncState *fs = ls->fs; | 266 | FuncState *fs = ls->fs; |
| 267 | adjustlocalvars(ls, nparams); | 267 | adjustlocalvars(ls, nparams); |
| 268 | luaX_checklimit(ls, fs->nactloc, MAXPARAMS, l_s("parameters")); | 268 | luaX_checklimit(ls, fs->nactloc, MAXPARAMS, l_s("parameters")); |
| 269 | fs->f->numparams = (short)fs->nactloc; /* `self' could be there already */ | 269 | fs->f->numparams = cast(short, fs->nactloc); /* `self' could be there already */ |
| 270 | fs->f->is_vararg = dots; | 270 | fs->f->is_vararg = dots; |
| 271 | if (dots) { | 271 | if (dots) { |
| 272 | new_localvarstr(ls, l_s("arg"), 0); | 272 | new_localvarstr(ls, l_s("arg"), 0); |
| @@ -758,13 +758,13 @@ static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { | |||
| 758 | else simpleexp(ls, v); | 758 | else simpleexp(ls, v); |
| 759 | /* expand while operators have priorities higher than `limit' */ | 759 | /* expand while operators have priorities higher than `limit' */ |
| 760 | op = getbinopr(ls->t.token); | 760 | op = getbinopr(ls->t.token); |
| 761 | while (op != OPR_NOBINOPR && (int)priority[op].left > limit) { | 761 | while (op != OPR_NOBINOPR && cast(int, priority[op].left) > limit) { |
| 762 | expdesc v2; | 762 | expdesc v2; |
| 763 | BinOpr nextop; | 763 | BinOpr nextop; |
| 764 | next(ls); | 764 | next(ls); |
| 765 | luaK_infix(ls->fs, op, v); | 765 | luaK_infix(ls->fs, op, v); |
| 766 | /* read sub-expression with higher priority */ | 766 | /* read sub-expression with higher priority */ |
| 767 | nextop = subexpr(ls, &v2, (int)priority[op].right); | 767 | nextop = subexpr(ls, &v2, cast(int, priority[op].right)); |
| 768 | luaK_posfix(ls->fs, op, v, &v2); | 768 | luaK_posfix(ls->fs, op, v, &v2); |
| 769 | op = nextop; | 769 | op = nextop; |
| 770 | } | 770 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 1.65 2001/06/21 16:41:34 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 1.66 2001/07/17 17:54:46 roberto Exp $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -33,7 +33,7 @@ static void close_state (lua_State *L, lua_State *OL); | |||
| 33 | ** open parts that may cause memory-allocation errors | 33 | ** open parts that may cause memory-allocation errors |
| 34 | */ | 34 | */ |
| 35 | static void f_luaopen (lua_State *L, void *ud) { | 35 | static void f_luaopen (lua_State *L, void *ud) { |
| 36 | struct Sopen *so = (struct Sopen *)ud; | 36 | struct Sopen *so = cast(struct Sopen *, ud); |
| 37 | if (so->stacksize == 0) | 37 | if (so->stacksize == 0) |
| 38 | so->stacksize = DEFAULT_STACK_SIZE; | 38 | so->stacksize = DEFAULT_STACK_SIZE; |
| 39 | else | 39 | else |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.c,v 1.65 2001/06/15 20:36:57 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 1.66 2001/08/27 15:16:28 roberto Exp $ |
| 3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -35,7 +35,7 @@ void luaS_resize (lua_State *L, int newsize) { | |||
| 35 | TString *next = p->tsv.nexthash; /* save next */ | 35 | TString *next = p->tsv.nexthash; /* save next */ |
| 36 | lu_hash h = p->tsv.hash; | 36 | lu_hash h = p->tsv.hash; |
| 37 | int h1 = lmod(h, newsize); /* new position */ | 37 | int h1 = lmod(h, newsize); /* new position */ |
| 38 | lua_assert((int)(h%newsize) == lmod(h, newsize)); | 38 | lua_assert(cast(int, h%newsize) == lmod(h, newsize)); |
| 39 | p->tsv.nexthash = newhash[h1]; /* chain it in new position */ | 39 | p->tsv.nexthash = newhash[h1]; /* chain it in new position */ |
| 40 | newhash[h1] = p; | 40 | newhash[h1] = p; |
| 41 | p = next; | 41 | p = next; |
| @@ -48,7 +48,7 @@ void luaS_resize (lua_State *L, int newsize) { | |||
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { | 50 | static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { |
| 51 | TString *ts = (TString *)luaM_malloc(L, sizestring(l)); | 51 | TString *ts = cast(TString *, luaM_malloc(L, sizestring(l))); |
| 52 | stringtable *tb; | 52 | stringtable *tb; |
| 53 | ts->tsv.nexthash = NULL; | 53 | ts->tsv.nexthash = NULL; |
| 54 | ts->tsv.len = l; | 54 | ts->tsv.len = l; |
| @@ -61,7 +61,7 @@ static TString *newlstr (lua_State *L, const l_char *str, size_t l, lu_hash h) { | |||
| 61 | ts->tsv.nexthash = tb->hash[h]; /* chain new entry */ | 61 | ts->tsv.nexthash = tb->hash[h]; /* chain new entry */ |
| 62 | tb->hash[h] = ts; | 62 | tb->hash[h] = ts; |
| 63 | tb->nuse++; | 63 | tb->nuse++; |
| 64 | if (tb->nuse > (ls_nstr)tb->size && tb->size <= MAX_INT/2) | 64 | if (tb->nuse > cast(ls_nstr, tb->size) && tb->size <= MAX_INT/2) |
| 65 | luaS_resize(L, tb->size*2); /* too crowded */ | 65 | luaS_resize(L, tb->size*2); /* too crowded */ |
| 66 | return ts; | 66 | return ts; |
| 67 | } | 67 | } |
| @@ -85,7 +85,7 @@ TString *luaS_newlstr (lua_State *L, const l_char *str, size_t l) { | |||
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | Udata *luaS_newudata (lua_State *L, size_t s) { | 87 | Udata *luaS_newudata (lua_State *L, size_t s) { |
| 88 | Udata *u = (Udata *)luaM_malloc(L, sizeudata(s)); | 88 | Udata *u = cast(Udata *, luaM_malloc(L, sizeudata(s))); |
| 89 | u->uv.len = s; | 89 | u->uv.len = s; |
| 90 | u->uv.tag = 0; | 90 | u->uv.tag = 0; |
| 91 | u->uv.value = u + 1; | 91 | u->uv.value = u + 1; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.h,v 1.32 2001/06/06 18:00:19 roberto Exp roberto $ | 2 | ** $Id: lstring.h,v 1.33 2001/06/15 20:36:57 roberto Exp $ |
| 3 | ** String table (keep all strings handled by Lua) | 3 | ** String table (keep all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,10 +21,10 @@ | |||
| 21 | #define RESERVEDMARK 3 | 21 | #define RESERVEDMARK 3 |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | #define sizestring(l) ((lu_mem)sizeof(union TString)+ \ | 24 | #define sizestring(l) (cast(lu_mem, sizeof(union TString))+ \ |
| 25 | ((lu_mem)(l)+1)*sizeof(l_char)) | 25 | (cast(lu_mem, l)+1)*sizeof(l_char)) |
| 26 | 26 | ||
| 27 | #define sizeudata(l) ((lu_mem)sizeof(union Udata)+(l)) | 27 | #define sizeudata(l) (cast(lu_mem, sizeof(union Udata))+(l)) |
| 28 | 28 | ||
| 29 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) | 29 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) |
| 30 | #define luaS_newliteral(L, s) (luaS_newlstr(L, l_s("") s, \ | 30 | #define luaS_newliteral(L, s) (luaS_newlstr(L, l_s("") s, \ |
| @@ -91,7 +91,7 @@ static int str_byte (lua_State *L) { | |||
| 91 | size_t l; | 91 | size_t l; |
| 92 | const l_char *s = luaL_check_lstr(L, 1, &l); | 92 | const l_char *s = luaL_check_lstr(L, 1, &l); |
| 93 | sint32 pos = posrelat(luaL_opt_long(L, 2, 1), l); | 93 | sint32 pos = posrelat(luaL_opt_long(L, 2, 1), l); |
| 94 | luaL_arg_check(L, 0<pos && (size_t)pos<=l, 2, l_s("out of range")); | 94 | luaL_arg_check(L, 0 < pos && (size_t)(pos) <= l, 2, l_s("out of range")); |
| 95 | lua_pushnumber(L, uchar(s[pos-1])); | 95 | lua_pushnumber(L, uchar(s[pos-1])); |
| 96 | return 1; | 96 | return 1; |
| 97 | } | 97 | } |
| @@ -424,7 +424,7 @@ static int str_find (lua_State *L) { | |||
| 424 | const l_char *s = luaL_check_lstr(L, 1, &l1); | 424 | const l_char *s = luaL_check_lstr(L, 1, &l1); |
| 425 | const l_char *p = luaL_check_lstr(L, 2, &l2); | 425 | const l_char *p = luaL_check_lstr(L, 2, &l2); |
| 426 | sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1; | 426 | sint32 init = posrelat(luaL_opt_long(L, 3, 1), l1) - 1; |
| 427 | luaL_arg_check(L, 0 <= init && (size_t)init <= l1, 3, l_s("out of range")); | 427 | luaL_arg_check(L, 0 <= init && (size_t)(init) <= l1, 3, l_s("out of range")); |
| 428 | if (lua_gettop(L) > 3 || /* extra argument? */ | 428 | if (lua_gettop(L) > 3 || /* extra argument? */ |
| 429 | strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */ | 429 | strpbrk(p, SPECIALS) == NULL) { /* or no special characters? */ |
| 430 | const l_char *s2 = lmemfind(s+init, l1-init, p, l2); | 430 | const l_char *s2 = lmemfind(s+init, l1-init, p, l2); |
| @@ -603,7 +603,7 @@ static int str_format (lua_State *L) { | |||
| 603 | sprintf(buff, form, luaL_check_int(L, arg)); | 603 | sprintf(buff, form, luaL_check_int(L, arg)); |
| 604 | break; | 604 | break; |
| 605 | case l_c('o'): case l_c('u'): case l_c('x'): case l_c('X'): | 605 | case l_c('o'): case l_c('u'): case l_c('x'): case l_c('X'): |
| 606 | sprintf(buff, form, (unsigned int)luaL_check_number(L, arg)); | 606 | sprintf(buff, form, (unsigned int)(luaL_check_number(L, arg))); |
| 607 | break; | 607 | break; |
| 608 | case l_c('e'): case l_c('E'): case l_c('f'): | 608 | case l_c('e'): case l_c('E'): case l_c('f'): |
| 609 | case l_c('g'): case l_c('G'): | 609 | case l_c('g'): case l_c('G'): |
| @@ -32,9 +32,9 @@ | |||
| 32 | #define TagDefault LUA_TTABLE | 32 | #define TagDefault LUA_TTABLE |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | #define hashnum(t,n) (node(t, lmod((lu_hash)(ls_hash)(n), t->size))) | 35 | #define hashnum(t,n) (node(t, lmod(cast(lu_hash, cast(ls_hash, n)), t->size))) |
| 36 | #define hashstr(t,str) (node(t, lmod((str)->tsv.hash, t->size))) | 36 | #define hashstr(t,str) (node(t, lmod((str)->tsv.hash, t->size))) |
| 37 | #define hashpointer(t,p) (node(t, lmod(IntPoint(p), t->size))) | 37 | #define hashpointer(t,p) (node(t, lmod(IntPoint(p), t->size))) |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | /* | 40 | /* |
| @@ -61,8 +61,8 @@ Node *luaH_next (lua_State *L, Hash *t, const TObject *key) { | |||
| 61 | const TObject *v = luaH_get(t, key); | 61 | const TObject *v = luaH_get(t, key); |
| 62 | if (v == &luaO_nilobject) | 62 | if (v == &luaO_nilobject) |
| 63 | luaD_error(L, l_s("invalid key for `next'")); | 63 | luaD_error(L, l_s("invalid key for `next'")); |
| 64 | i = (int)(((const lu_byte *)v - | 64 | i = cast(int, (cast(const lu_byte *, v) - |
| 65 | (const lu_byte *)(val(node(t, 0)))) / sizeof(Node)) + 1; | 65 | cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node)) + 1; |
| 66 | } | 66 | } |
| 67 | for (; i<t->size; i++) { | 67 | for (; i<t->size; i++) { |
| 68 | Node *n = node(t, i); | 68 | Node *n = node(t, i); |
| @@ -259,8 +259,8 @@ const TObject *luaH_get (Hash *t, const TObject *key) { | |||
| 259 | switch (ttype(key)) { | 259 | switch (ttype(key)) { |
| 260 | case LUA_TSTRING: return luaH_getstr(t, tsvalue(key)); | 260 | case LUA_TSTRING: return luaH_getstr(t, tsvalue(key)); |
| 261 | case LUA_TNUMBER: { | 261 | case LUA_TNUMBER: { |
| 262 | int k = (int)nvalue(key); | 262 | int k = cast(int, nvalue(key)); |
| 263 | if ((lua_Number)k == nvalue(key)) /* is an integer index? */ | 263 | if (cast(lua_Number, k) == nvalue(key)) /* is an integer index? */ |
| 264 | return luaH_getnum(t, k); /* use specialized version */ | 264 | return luaH_getnum(t, k); /* use specialized version */ |
| 265 | /* else go through */ | 265 | /* else go through */ |
| 266 | } | 266 | } |
| @@ -14,7 +14,7 @@ | |||
| 14 | #define key(_n) (&(_n)->key) | 14 | #define key(_n) (&(_n)->key) |
| 15 | #define val(_n) (&(_n)->val) | 15 | #define val(_n) (&(_n)->val) |
| 16 | 16 | ||
| 17 | #define settableval(p,v) setobj((TObject *)p, v) | 17 | #define settableval(p,v) setobj(cast(TObject *, p), v) |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | const TObject *luaH_getnum (Hash *t, int key); | 20 | const TObject *luaH_getnum (Hash *t, int key); |
| @@ -64,7 +64,7 @@ static void setnameval (lua_State *L, const l_char *name, int val) { | |||
| 64 | #define MARK 0x55 /* 01010101 (a nice pattern) */ | 64 | #define MARK 0x55 /* 01010101 (a nice pattern) */ |
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | #define blocksize(b) ((size_t *)(b) - HEADER/sizeof(size_t)) | 67 | #define blocksize(b) (cast(size_t *, b) - HEADER/sizeof(size_t)) |
| 68 | 68 | ||
| 69 | unsigned long memdebug_numblocks = 0; | 69 | unsigned long memdebug_numblocks = 0; |
| 70 | unsigned long memdebug_total = 0; | 70 | unsigned long memdebug_total = 0; |
| @@ -77,7 +77,7 @@ static void *checkblock (void *block) { | |||
| 77 | size_t size = *b; | 77 | size_t size = *b; |
| 78 | int i; | 78 | int i; |
| 79 | for (i=0;i<MARKSIZE;i++) | 79 | for (i=0;i<MARKSIZE;i++) |
| 80 | lua_assert(*(((char *)b)+HEADER+size+i) == MARK+i); /* corrupted block? */ | 80 | lua_assert(*(cast(char *, b)+HEADER+size+i) == MARK+i); /* corrupted block? */ |
| 81 | return b; | 81 | return b; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -111,19 +111,19 @@ void *debug_realloc (void *block, size_t oldsize, size_t size) { | |||
| 111 | if (newblock == NULL) return NULL; | 111 | if (newblock == NULL) return NULL; |
| 112 | if (oldsize > size) oldsize = size; | 112 | if (oldsize > size) oldsize = size; |
| 113 | if (block) { | 113 | if (block) { |
| 114 | memcpy((char *)newblock+HEADER, block, oldsize); | 114 | memcpy(cast(char *, newblock)+HEADER, block, oldsize); |
| 115 | freeblock(block); /* erase (and check) old copy */ | 115 | freeblock(block); /* erase (and check) old copy */ |
| 116 | } | 116 | } |
| 117 | /* initialize new part of the block with something `weird' */ | 117 | /* initialize new part of the block with something `weird' */ |
| 118 | memset((char *)newblock+HEADER+oldsize, -MARK, size-oldsize); | 118 | memset(cast(char *, newblock)+HEADER+oldsize, -MARK, size-oldsize); |
| 119 | memdebug_total += size; | 119 | memdebug_total += size; |
| 120 | if (memdebug_total > memdebug_maxmem) | 120 | if (memdebug_total > memdebug_maxmem) |
| 121 | memdebug_maxmem = memdebug_total; | 121 | memdebug_maxmem = memdebug_total; |
| 122 | memdebug_numblocks++; | 122 | memdebug_numblocks++; |
| 123 | *(size_t *)newblock = size; | 123 | *cast(size_t *, newblock) = size; |
| 124 | for (i=0;i<MARKSIZE;i++) | 124 | for (i=0;i<MARKSIZE;i++) |
| 125 | *((char *)newblock+HEADER+size+i) = (char)(MARK+i); | 125 | *(cast(char *, newblock)+HEADER+size+i) = cast(char, MARK+i); |
| 126 | return (char *)newblock+HEADER; | 126 | return cast(char *, newblock)+HEADER; |
| 127 | } | 127 | } |
| 128 | } | 128 | } |
| 129 | 129 | ||
| @@ -343,13 +343,13 @@ static int unref (lua_State *L) { | |||
| 343 | 343 | ||
| 344 | static int newuserdata (lua_State *L) { | 344 | static int newuserdata (lua_State *L) { |
| 345 | size_t size = luaL_check_int(L, 1); | 345 | size_t size = luaL_check_int(L, 1); |
| 346 | l_char *p = (l_char *)lua_newuserdata(L, size); | 346 | l_char *p = cast(l_char *, lua_newuserdata(L, size)); |
| 347 | while (size--) *p++ = l_c('\0'); | 347 | while (size--) *p++ = l_c('\0'); |
| 348 | return 1; | 348 | return 1; |
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | static int newuserdatabox (lua_State *L) { | 351 | static int newuserdatabox (lua_State *L) { |
| 352 | lua_newuserdatabox(L, (void *)luaL_check_int(L, 1)); | 352 | lua_newuserdatabox(L, cast(void *, luaL_check_int(L, 1))); |
| 353 | return 1; | 353 | return 1; |
| 354 | } | 354 | } |
| 355 | 355 | ||
| @@ -362,20 +362,20 @@ static int settag (lua_State *L) { | |||
| 362 | 362 | ||
| 363 | static int udataval (lua_State *L) { | 363 | static int udataval (lua_State *L) { |
| 364 | luaL_checktype(L, 1, LUA_TUSERDATA); | 364 | luaL_checktype(L, 1, LUA_TUSERDATA); |
| 365 | lua_pushnumber(L, (int)lua_touserdata(L, 1)); | 365 | lua_pushnumber(L, cast(int, lua_touserdata(L, 1))); |
| 366 | return 1; | 366 | return 1; |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | static int newtag (lua_State *L) { | 369 | static int newtag (lua_State *L) { |
| 370 | lua_pushnumber(L, lua_newtype(L, lua_tostring(L, 1), | 370 | lua_pushnumber(L, lua_newtype(L, lua_tostring(L, 1), |
| 371 | (int)lua_tonumber(L, 2))); | 371 | cast(int, lua_tonumber(L, 2)))); |
| 372 | return 1; | 372 | return 1; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | static int doonnewstack (lua_State *L) { | 375 | static int doonnewstack (lua_State *L) { |
| 376 | lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1)); | 376 | lua_State *L1 = lua_newthread(L, luaL_check_int(L, 1)); |
| 377 | if (L1 == NULL) return 0; | 377 | if (L1 == NULL) return 0; |
| 378 | *((int **)L1) = &islocked; /* initialize the lock */ | 378 | *cast(int **, L1) = &islocked; /* initialize the lock */ |
| 379 | lua_dostring(L1, luaL_check_string(L, 2)); | 379 | lua_dostring(L1, luaL_check_string(L, 2)); |
| 380 | lua_pushnumber(L, 1); | 380 | lua_pushnumber(L, 1); |
| 381 | lua_close(L1); | 381 | lua_close(L1); |
| @@ -384,13 +384,13 @@ static int doonnewstack (lua_State *L) { | |||
| 384 | 384 | ||
| 385 | 385 | ||
| 386 | static int s2d (lua_State *L) { | 386 | static int s2d (lua_State *L) { |
| 387 | lua_pushnumber(L, *(double *)luaL_check_string(L, 1)); | 387 | lua_pushnumber(L, *cast(double *, luaL_check_string(L, 1))); |
| 388 | return 1; | 388 | return 1; |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | static int d2s (lua_State *L) { | 391 | static int d2s (lua_State *L) { |
| 392 | double d = luaL_check_number(L, 1); | 392 | double d = luaL_check_number(L, 1); |
| 393 | lua_pushlstring(L, (l_char *)&d, sizeof(d)); | 393 | lua_pushlstring(L, cast(l_char *, &d), sizeof(d)); |
| 394 | return 1; | 394 | return 1; |
| 395 | } | 395 | } |
| 396 | 396 | ||
| @@ -398,7 +398,7 @@ static int d2s (lua_State *L) { | |||
| 398 | static int newstate (lua_State *L) { | 398 | static int newstate (lua_State *L) { |
| 399 | lua_State *L1 = lua_open(luaL_check_int(L, 1)); | 399 | lua_State *L1 = lua_open(luaL_check_int(L, 1)); |
| 400 | if (L1) { | 400 | if (L1) { |
| 401 | *((int **)L1) = &islocked; /* initialize the lock */ | 401 | *cast(int **, L1) = &islocked; /* initialize the lock */ |
| 402 | lua_pushnumber(L, (unsigned long)L1); | 402 | lua_pushnumber(L, (unsigned long)L1); |
| 403 | } | 403 | } |
| 404 | else | 404 | else |
| @@ -407,7 +407,7 @@ static int newstate (lua_State *L) { | |||
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | static int loadlib (lua_State *L) { | 409 | static int loadlib (lua_State *L) { |
| 410 | lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); | 410 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1))); |
| 411 | lua_register(L1, "mathlibopen", lua_mathlibopen); | 411 | lua_register(L1, "mathlibopen", lua_mathlibopen); |
| 412 | lua_register(L1, "strlibopen", lua_strlibopen); | 412 | lua_register(L1, "strlibopen", lua_strlibopen); |
| 413 | lua_register(L1, "iolibopen", lua_iolibopen); | 413 | lua_register(L1, "iolibopen", lua_iolibopen); |
| @@ -417,7 +417,7 @@ static int loadlib (lua_State *L) { | |||
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | static int closestate (lua_State *L) { | 419 | static int closestate (lua_State *L) { |
| 420 | lua_State *L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); | 420 | lua_State *L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1))); |
| 421 | lua_close(L1); | 421 | lua_close(L1); |
| 422 | lua_unlock(L); /* close cannot unlock that */ | 422 | lua_unlock(L); /* close cannot unlock that */ |
| 423 | return 0; | 423 | return 0; |
| @@ -427,7 +427,7 @@ static int doremote (lua_State *L) { | |||
| 427 | lua_State *L1; | 427 | lua_State *L1; |
| 428 | const l_char *code = luaL_check_string(L, 2); | 428 | const l_char *code = luaL_check_string(L, 2); |
| 429 | int status; | 429 | int status; |
| 430 | L1 = (lua_State *)(unsigned long)luaL_check_number(L, 1); | 430 | L1 = cast(lua_State *, cast(unsigned long, luaL_check_number(L, 1))); |
| 431 | status = lua_dostring(L1, code); | 431 | status = lua_dostring(L1, code); |
| 432 | if (status != 0) { | 432 | if (status != 0) { |
| 433 | lua_pushnil(L); | 433 | lua_pushnil(L); |
| @@ -472,12 +472,12 @@ static void skip (const l_char **pc) { | |||
| 472 | while (**pc != l_c('\0') && strchr(delimits, **pc)) (*pc)++; | 472 | while (**pc != l_c('\0') && strchr(delimits, **pc)) (*pc)++; |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | static int getnum (lua_State *L, const l_char **pc) { | 475 | static int getnum_aux (lua_State *L, const l_char **pc) { |
| 476 | int res = 0; | 476 | int res = 0; |
| 477 | int sig = 1; | 477 | int sig = 1; |
| 478 | skip(pc); | 478 | skip(pc); |
| 479 | if (**pc == l_c('.')) { | 479 | if (**pc == l_c('.')) { |
| 480 | res = (int)lua_tonumber(L, -1); | 480 | res = cast(int, lua_tonumber(L, -1)); |
| 481 | lua_pop(L, 1); | 481 | lua_pop(L, 1); |
| 482 | (*pc)++; | 482 | (*pc)++; |
| 483 | return res; | 483 | return res; |
| @@ -486,11 +486,11 @@ static int getnum (lua_State *L, const l_char **pc) { | |||
| 486 | sig = -1; | 486 | sig = -1; |
| 487 | (*pc)++; | 487 | (*pc)++; |
| 488 | } | 488 | } |
| 489 | while (isdigit((int)**pc)) res = res*10 + (*(*pc)++) - l_c('0'); | 489 | while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - l_c('0'); |
| 490 | return sig*res; | 490 | return sig*res; |
| 491 | } | 491 | } |
| 492 | 492 | ||
| 493 | static const l_char *getname (l_char *buff, const l_char **pc) { | 493 | static const l_char *getname_aux (l_char *buff, const l_char **pc) { |
| 494 | int i = 0; | 494 | int i = 0; |
| 495 | skip(pc); | 495 | skip(pc); |
| 496 | while (**pc != l_c('\0') && !strchr(delimits, **pc)) | 496 | while (**pc != l_c('\0') && !strchr(delimits, **pc)) |
| @@ -502,8 +502,8 @@ static const l_char *getname (l_char *buff, const l_char **pc) { | |||
| 502 | 502 | ||
| 503 | #define EQ(s1) (strcmp(s1, inst) == 0) | 503 | #define EQ(s1) (strcmp(s1, inst) == 0) |
| 504 | 504 | ||
| 505 | #define getnum ((getnum)(L, &pc)) | 505 | #define getnum (getnum_aux(L, &pc)) |
| 506 | #define getname ((getname)(buff, &pc)) | 506 | #define getname (getname_aux(buff, &pc)) |
| 507 | 507 | ||
| 508 | 508 | ||
| 509 | static int testC (lua_State *L) { | 509 | static int testC (lua_State *L) { |
| @@ -661,7 +661,7 @@ static const struct luaL_reg tests_funcs[] = { | |||
| 661 | 661 | ||
| 662 | 662 | ||
| 663 | void luaB_opentests (lua_State *L) { | 663 | void luaB_opentests (lua_State *L) { |
| 664 | *((int **)L) = &islocked; /* init lock */ | 664 | *cast(int **, L) = &islocked; /* init lock */ |
| 665 | lua_state = L; /* keep first state to be opened */ | 665 | lua_state = L; /* keep first state to be opened */ |
| 666 | /* open lib in a new table */ | 666 | /* open lib in a new table */ |
| 667 | lua_newtable(L); | 667 | lua_newtable(L); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.h,v 1.6 2001/03/02 17:27:50 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 1.7 2001/06/28 19:58:57 roberto Exp $ |
| 3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -43,8 +43,8 @@ void *debug_realloc (void *block, size_t oldsize, size_t size); | |||
| 43 | /* test for lock/unlock */ | 43 | /* test for lock/unlock */ |
| 44 | #define LUA_USERSTATE int *lock; | 44 | #define LUA_USERSTATE int *lock; |
| 45 | extern int islocked; | 45 | extern int islocked; |
| 46 | #define lua_lock(L) lua_assert((**((int **)L))++ == 0) | 46 | #define lua_lock(L) lua_assert((**cast(int **, L))++ == 0) |
| 47 | #define lua_unlock(L) lua_assert(--(**((int **)L)) == 0) | 47 | #define lua_unlock(L) lua_assert(--(**cast(int **, L)) == 0) |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | extern lua_State *lua_state; | 50 | extern lua_State *lua_state; |
| @@ -61,7 +61,7 @@ static const lu_byte luaT_validevents[NUM_TAGS][TM_N] = { | |||
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | int luaT_validevent (int t, int e) { /* ORDER LUA_T */ | 63 | int luaT_validevent (int t, int e) { /* ORDER LUA_T */ |
| 64 | return (t >= NUM_TAGS) ? 1 : (int)luaT_validevents[t][e]; | 64 | return (t >= NUM_TAGS) ? 1 : cast(int, luaT_validevents[t][e]); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | 67 | ||
| @@ -88,7 +88,7 @@ int luaT_newtag (lua_State *L, const l_char *name, int basictype) { | |||
| 88 | TObject otag; | 88 | TObject otag; |
| 89 | ts = luaS_new(L, name); | 89 | ts = luaS_new(L, name); |
| 90 | v = luaH_getstr(G(L)->type2tag, ts); | 90 | v = luaH_getstr(G(L)->type2tag, ts); |
| 91 | if (ttype(v) == LUA_TNUMBER) return (int)nvalue(v); | 91 | if (ttype(v) == LUA_TNUMBER) return cast(int, nvalue(v)); |
| 92 | setnvalue(&otag, tag); | 92 | setnvalue(&otag, tag); |
| 93 | luaH_setstr(L, G(L)->type2tag, ts, &otag); | 93 | luaH_setstr(L, G(L)->type2tag, ts, &otag); |
| 94 | } | 94 | } |
| @@ -293,8 +293,8 @@ void luaV_strconc (lua_State *L, int total, StkId top) { | |||
| 293 | luaG_concaterror(L, top-2, top-1); | 293 | luaG_concaterror(L, top-2, top-1); |
| 294 | } else if (tsvalue(top-1)->tsv.len > 0) { /* if len=0, do nothing */ | 294 | } else if (tsvalue(top-1)->tsv.len > 0) { /* if len=0, do nothing */ |
| 295 | /* at least two string values; get as many as possible */ | 295 | /* at least two string values; get as many as possible */ |
| 296 | lu_mem tl = (lu_mem)tsvalue(top-1)->tsv.len + | 296 | lu_mem tl = cast(lu_mem, tsvalue(top-1)->tsv.len) + |
| 297 | (lu_mem)tsvalue(top-2)->tsv.len; | 297 | cast(lu_mem, tsvalue(top-2)->tsv.len); |
| 298 | l_char *buffer; | 298 | l_char *buffer; |
| 299 | int i; | 299 | int i; |
| 300 | while (n < total && !tostring(L, top-n-1)) { /* collect total length */ | 300 | while (n < total && !tostring(L, top-n-1)) { /* collect total length */ |
| @@ -618,7 +618,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) { | |||
| 618 | runtime_check(L, ttype(ra) == LUA_TTABLE && | 618 | runtime_check(L, ttype(ra) == LUA_TTABLE && |
| 619 | ttype(ra+1) == LUA_TNUMBER); | 619 | ttype(ra+1) == LUA_TNUMBER); |
| 620 | t = hvalue(ra); | 620 | t = hvalue(ra); |
| 621 | n = (int)nvalue(ra+1); | 621 | n = cast(int, nvalue(ra+1)); |
| 622 | n = luaH_nexti(t, n); | 622 | n = luaH_nexti(t, n); |
| 623 | if (n != -1) { /* repeat loop? */ | 623 | if (n != -1) { /* repeat loop? */ |
| 624 | Node *node = node(t, n); | 624 | Node *node = node(t, n); |
