diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-22 14:06:11 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-22 14:06:11 -0300 |
| commit | 9fa63a62682c1353eeabd4575152941fa6f3e70f (patch) | |
| tree | 1aad2dd0de78388f6be134399ae4183692ce377f | |
| parent | 0593256707ceddb1bc9cd4b25b822a7fbcfedd66 (diff) | |
| download | lua-9fa63a62682c1353eeabd4575152941fa6f3e70f.tar.gz lua-9fa63a62682c1353eeabd4575152941fa6f3e70f.tar.bz2 lua-9fa63a62682c1353eeabd4575152941fa6f3e70f.zip | |
Some 'unsigned int' changed to 'unsigned'
'unsigned int' is too long sometimes. (We already write 'long' instead
of 'long int'...)
| -rw-r--r-- | lcode.h | 2 | ||||
| -rw-r--r-- | llimits.h | 2 | ||||
| -rw-r--r-- | lstate.c | 2 | ||||
| -rw-r--r-- | lstring.c | 6 | ||||
| -rw-r--r-- | lstring.h | 4 | ||||
| -rw-r--r-- | ltable.c | 20 | ||||
| -rw-r--r-- | ltable.h | 8 | ||||
| -rw-r--r-- | ltablib.c | 3 | ||||
| -rw-r--r-- | ltests.c | 2 |
9 files changed, 24 insertions, 25 deletions
| @@ -60,7 +60,7 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; | |||
| 60 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) | 60 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) |
| 61 | 61 | ||
| 62 | LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); | 62 | LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); |
| 63 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); | 63 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned Bx); |
| 64 | LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, | 64 | LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, |
| 65 | int B, int C, int k); | 65 | int B, int C, int k); |
| 66 | LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); | 66 | LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); |
| @@ -91,7 +91,7 @@ typedef signed char ls_byte; | |||
| 91 | #define L_P2I size_t | 91 | #define L_P2I size_t |
| 92 | #endif | 92 | #endif |
| 93 | 93 | ||
| 94 | #define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX)) | 94 | #define point2uint(p) cast_uint((L_P2I)(p) & UINT_MAX) |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | 97 | ||
| @@ -320,7 +320,7 @@ LUA_API int lua_closethread (lua_State *L, lua_State *from) { | |||
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | 322 | ||
| 323 | LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned int seed) { | 323 | LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) { |
| 324 | int i; | 324 | int i; |
| 325 | lua_State *L; | 325 | lua_State *L; |
| 326 | global_State *g; | 326 | global_State *g; |
| @@ -40,7 +40,7 @@ int luaS_eqlngstr (TString *a, TString *b) { | |||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { | 43 | unsigned luaS_hash (const char *str, size_t l, unsigned seed) { |
| 44 | unsigned int h = seed ^ cast_uint(l); | 44 | unsigned int h = seed ^ cast_uint(l); |
| 45 | for (; l > 0; l--) | 45 | for (; l > 0; l--) |
| 46 | h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); | 46 | h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); |
| @@ -48,7 +48,7 @@ unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | unsigned int luaS_hashlongstr (TString *ts) { | 51 | unsigned luaS_hashlongstr (TString *ts) { |
| 52 | lua_assert(ts->tt == LUA_VLNGSTR); | 52 | lua_assert(ts->tt == LUA_VLNGSTR); |
| 53 | if (ts->extra == 0) { /* no hash? */ | 53 | if (ts->extra == 0) { /* no hash? */ |
| 54 | size_t len = ts->u.lnglen; | 54 | size_t len = ts->u.lnglen; |
| @@ -155,7 +155,7 @@ size_t luaS_sizelngstr (size_t len, int kind) { | |||
| 155 | ** creates a new string object | 155 | ** creates a new string object |
| 156 | */ | 156 | */ |
| 157 | static TString *createstrobj (lua_State *L, size_t totalsize, int tag, | 157 | static TString *createstrobj (lua_State *L, size_t totalsize, int tag, |
| 158 | unsigned int h) { | 158 | unsigned h) { |
| 159 | TString *ts; | 159 | TString *ts; |
| 160 | GCObject *o; | 160 | GCObject *o; |
| 161 | o = luaC_newobj(L, tag, totalsize); | 161 | o = luaC_newobj(L, tag, totalsize); |
| @@ -43,8 +43,8 @@ | |||
| 43 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) | 43 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); | 46 | LUAI_FUNC unsigned luaS_hash (const char *str, size_t l, unsigned seed); |
| 47 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); | 47 | LUAI_FUNC unsigned luaS_hashlongstr (TString *ts); |
| 48 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); | 48 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); |
| 49 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); | 49 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); |
| 50 | LUAI_FUNC void luaS_clearcache (global_State *g); | 50 | LUAI_FUNC void luaS_clearcache (global_State *g); |
| @@ -358,8 +358,8 @@ static unsigned int arrayindex (lua_Integer k) { | |||
| 358 | ** elements in the array part, then elements in the hash part. The | 358 | ** elements in the array part, then elements in the hash part. The |
| 359 | ** beginning of a traversal is signaled by 0. | 359 | ** beginning of a traversal is signaled by 0. |
| 360 | */ | 360 | */ |
| 361 | static unsigned int findindex (lua_State *L, Table *t, TValue *key, | 361 | static unsigned findindex (lua_State *L, Table *t, TValue *key, |
| 362 | unsigned int asize) { | 362 | unsigned asize) { |
| 363 | unsigned int i; | 363 | unsigned int i; |
| 364 | if (ttisnil(key)) return 0; /* first iteration */ | 364 | if (ttisnil(key)) return 0; /* first iteration */ |
| 365 | i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; | 365 | i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0; |
| @@ -462,7 +462,7 @@ static int keyinarray (Table *t, lua_Integer key) { | |||
| 462 | ** will go to the array part; return the optimal size. (The condition | 462 | ** will go to the array part; return the optimal size. (The condition |
| 463 | ** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.) | 463 | ** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.) |
| 464 | */ | 464 | */ |
| 465 | static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { | 465 | static unsigned computesizes (unsigned nums[], unsigned *pna) { |
| 466 | int i; | 466 | int i; |
| 467 | unsigned int twotoi; /* 2^i (candidate for optimal size) */ | 467 | unsigned int twotoi; /* 2^i (candidate for optimal size) */ |
| 468 | unsigned int a = 0; /* number of elements smaller than 2^i */ | 468 | unsigned int a = 0; /* number of elements smaller than 2^i */ |
| @@ -506,7 +506,7 @@ l_sinline int arraykeyisempty (const Table *t, lua_Integer key) { | |||
| 506 | ** number of keys that will go into corresponding slice and return | 506 | ** number of keys that will go into corresponding slice and return |
| 507 | ** total number of non-nil keys. | 507 | ** total number of non-nil keys. |
| 508 | */ | 508 | */ |
| 509 | static unsigned int numusearray (const Table *t, unsigned int *nums) { | 509 | static unsigned numusearray (const Table *t, unsigned *nums) { |
| 510 | int lg; | 510 | int lg; |
| 511 | unsigned int ttlg; /* 2^lg */ | 511 | unsigned int ttlg; /* 2^lg */ |
| 512 | unsigned int ause = 0; /* summation of 'nums' */ | 512 | unsigned int ause = 0; /* summation of 'nums' */ |
| @@ -533,7 +533,7 @@ static unsigned int numusearray (const Table *t, unsigned int *nums) { | |||
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | 535 | ||
| 536 | static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) { | 536 | static int numusehash (const Table *t, unsigned *nums, unsigned *pna) { |
| 537 | int totaluse = 0; /* total number of elements */ | 537 | int totaluse = 0; /* total number of elements */ |
| 538 | int ause = 0; /* elements added to 'nums' (can go to array part) */ | 538 | int ause = 0; /* elements added to 'nums' (can go to array part) */ |
| 539 | int i = sizenode(t); | 539 | int i = sizenode(t); |
| @@ -567,8 +567,8 @@ static size_t concretesize (unsigned int size) { | |||
| 567 | 567 | ||
| 568 | 568 | ||
| 569 | static ArrayCell *resizearray (lua_State *L , Table *t, | 569 | static ArrayCell *resizearray (lua_State *L , Table *t, |
| 570 | unsigned int oldasize, | 570 | unsigned oldasize, |
| 571 | unsigned int newasize) { | 571 | unsigned newasize) { |
| 572 | size_t oldasizeb = concretesize(oldasize); | 572 | size_t oldasizeb = concretesize(oldasize); |
| 573 | size_t newasizeb = concretesize(newasize); | 573 | size_t newasizeb = concretesize(newasize); |
| 574 | void *a = luaM_reallocvector(L, t->array, oldasizeb, newasizeb, lu_byte); | 574 | void *a = luaM_reallocvector(L, t->array, oldasizeb, newasizeb, lu_byte); |
| @@ -583,7 +583,7 @@ static ArrayCell *resizearray (lua_State *L , Table *t, | |||
| 583 | ** comparison ensures that the shift in the second one does not | 583 | ** comparison ensures that the shift in the second one does not |
| 584 | ** overflow. | 584 | ** overflow. |
| 585 | */ | 585 | */ |
| 586 | static void setnodevector (lua_State *L, Table *t, unsigned int size) { | 586 | static void setnodevector (lua_State *L, Table *t, unsigned size) { |
| 587 | if (size == 0) { /* no elements to hash part? */ | 587 | if (size == 0) { /* no elements to hash part? */ |
| 588 | t->node = cast(Node *, dummynode); /* use common 'dummynode' */ | 588 | t->node = cast(Node *, dummynode); /* use common 'dummynode' */ |
| 589 | t->lsizenode = 0; | 589 | t->lsizenode = 0; |
| @@ -695,8 +695,8 @@ static void clearNewSlice (Table *t, unsigned oldasize, unsigned newasize) { | |||
| 695 | ** nils and reinserts the elements of the old hash back into the new | 695 | ** nils and reinserts the elements of the old hash back into the new |
| 696 | ** parts of the table. | 696 | ** parts of the table. |
| 697 | */ | 697 | */ |
| 698 | void luaH_resize (lua_State *L, Table *t, unsigned int newasize, | 698 | void luaH_resize (lua_State *L, Table *t, unsigned newasize, |
| 699 | unsigned int nhsize) { | 699 | unsigned nhsize) { |
| 700 | Table newt; /* to keep the new hash part */ | 700 | Table newt; /* to keep the new hash part */ |
| 701 | unsigned int oldasize = setlimittosize(t); | 701 | unsigned int oldasize = setlimittosize(t); |
| 702 | ArrayCell *newarray; | 702 | ArrayCell *newarray; |
| @@ -151,13 +151,13 @@ LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, | |||
| 151 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, | 151 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, |
| 152 | TValue *value, int hres); | 152 | TValue *value, int hres); |
| 153 | LUAI_FUNC Table *luaH_new (lua_State *L); | 153 | LUAI_FUNC Table *luaH_new (lua_State *L); |
| 154 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, | 154 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned nasize, |
| 155 | unsigned int nhsize); | 155 | unsigned nhsize); |
| 156 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); | 156 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned nasize); |
| 157 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); | 157 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); |
| 158 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); | 158 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); |
| 159 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); | 159 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); |
| 160 | LUAI_FUNC unsigned int luaH_realasize (const Table *t); | 160 | LUAI_FUNC unsigned luaH_realasize (const Table *t); |
| 161 | 161 | ||
| 162 | 162 | ||
| 163 | #if defined(LUA_DEBUG) | 163 | #if defined(LUA_DEBUG) |
| @@ -329,8 +329,7 @@ static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) { | |||
| 329 | /* | 329 | /* |
| 330 | ** Quicksort algorithm (recursive function) | 330 | ** Quicksort algorithm (recursive function) |
| 331 | */ | 331 | */ |
| 332 | static void auxsort (lua_State *L, IdxT lo, IdxT up, | 332 | static void auxsort (lua_State *L, IdxT lo, IdxT up, unsigned rnd) { |
| 333 | unsigned int rnd) { | ||
| 334 | while (lo < up) { /* loop for tail recursion */ | 333 | while (lo < up) { /* loop for tail recursion */ |
| 335 | IdxT p; /* Pivot index */ | 334 | IdxT p; /* Pivot index */ |
| 336 | IdxT n; /* to be used later */ | 335 | IdxT n; /* to be used later */ |
| @@ -1008,7 +1008,7 @@ static int table_query (lua_State *L) { | |||
| 1008 | lua_pushinteger(L, t->alimit); | 1008 | lua_pushinteger(L, t->alimit); |
| 1009 | return 3; | 1009 | return 3; |
| 1010 | } | 1010 | } |
| 1011 | else if ((unsigned int)i < asize) { | 1011 | else if (cast_uint(i) < asize) { |
| 1012 | lua_pushinteger(L, i); | 1012 | lua_pushinteger(L, i); |
| 1013 | arr2obj(t, i + 1, s2v(L->top.p)); | 1013 | arr2obj(t, i + 1, s2v(L->top.p)); |
| 1014 | api_incr_top(L); | 1014 | api_incr_top(L); |
