changing {} style to match majority of previous style

This commit is contained in:
Philippe Teuwen 2019-03-10 11:20:22 +01:00
commit 961d929f4d
320 changed files with 5502 additions and 10485 deletions

View file

@ -77,8 +77,7 @@ static const Node dummynode_ = {
/*
** hash for lua_Numbers
*/
static Node *hashnum(const Table *t, lua_Number n)
{
static Node *hashnum(const Table *t, lua_Number n) {
int i;
luai_hashnum(i, n);
if (i < 0) {
@ -95,8 +94,7 @@ static Node *hashnum(const Table *t, lua_Number n)
** returns the `main' position of an element in a table (that is, the index
** of its hash value)
*/
static Node *mainposition(const Table *t, const TValue *key)
{
static Node *mainposition(const Table *t, const TValue *key) {
switch (ttype(key)) {
case LUA_TNUMBER:
return hashnum(t, nvalue(key));
@ -126,8 +124,7 @@ static Node *mainposition(const Table *t, const TValue *key)
** returns the index for `key' if `key' is an appropriate key to live in
** the array part of the table, -1 otherwise.
*/
static int arrayindex(const TValue *key)
{
static int arrayindex(const TValue *key) {
if (ttisnumber(key)) {
lua_Number n = nvalue(key);
int k;
@ -144,8 +141,7 @@ static int arrayindex(const TValue *key)
** elements in the array part, then elements in the hash part. The
** beginning of a traversal is signaled by -1.
*/
static int findindex(lua_State *L, Table *t, StkId key)
{
static int findindex(lua_State *L, Table *t, StkId key) {
int i;
if (ttisnil(key)) return -1; /* first iteration */
i = arrayindex(key);
@ -156,8 +152,8 @@ static int findindex(lua_State *L, Table *t, StkId key)
for (;;) { /* check whether `key' is somewhere in the chain */
/* key may be dead already, but it is ok to use it in `next' */
if (luaV_rawequalobj(gkey(n), key) ||
(ttisdeadkey(gkey(n)) && iscollectable(key) &&
deadvalue(gkey(n)) == gcvalue(key))) {
(ttisdeadkey(gkey(n)) && iscollectable(key) &&
deadvalue(gkey(n)) == gcvalue(key))) {
i = cast_int(n - gnode(t, 0)); /* key index in hash table */
/* hash elements are numbered after array ones */
return i + t->sizearray;
@ -169,8 +165,7 @@ static int findindex(lua_State *L, Table *t, StkId key)
}
int luaH_next(lua_State *L, Table *t, StkId key)
{
int luaH_next(lua_State *L, Table *t, StkId key) {
int i = findindex(L, t, key); /* find original element */
for (i++; i < t->sizearray; i++) { /* try first array part */
if (!ttisnil(&t->array[i])) { /* a non-nil value? */
@ -197,8 +192,7 @@ int luaH_next(lua_State *L, Table *t, StkId key)
*/
static int computesizes(int nums[], int *narray)
{
static int computesizes(int nums[], int *narray) {
int i;
int twotoi; /* 2^i */
int a = 0; /* number of elements smaller than 2^i */
@ -220,8 +214,7 @@ static int computesizes(int nums[], int *narray)
}
static int countint(const TValue *key, int *nums)
{
static int countint(const TValue *key, int *nums) {
int k = arrayindex(key);
if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
nums[luaO_ceillog2(k)]++; /* count as such */
@ -231,8 +224,7 @@ static int countint(const TValue *key, int *nums)
}
static int numusearray(const Table *t, int *nums)
{
static int numusearray(const Table *t, int *nums) {
int lg;
int ttlg; /* 2^lg */
int ause = 0; /* summation of `nums' */
@ -257,8 +249,7 @@ static int numusearray(const Table *t, int *nums)
}
static int numusehash(const Table *t, int *nums, int *pnasize)
{
static int numusehash(const Table *t, int *nums, int *pnasize) {
int totaluse = 0; /* total number of elements */
int ause = 0; /* summation of `nums' */
int i = sizenode(t);
@ -274,8 +265,7 @@ static int numusehash(const Table *t, int *nums, int *pnasize)
}
static void setarrayvector(lua_State *L, Table *t, int size)
{
static void setarrayvector(lua_State *L, Table *t, int size) {
int i;
luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
for (i = t->sizearray; i < size; i++)
@ -284,8 +274,7 @@ static void setarrayvector(lua_State *L, Table *t, int size)
}
static void setnodevector(lua_State *L, Table *t, int size)
{
static void setnodevector(lua_State *L, Table *t, int size) {
int lsize;
if (size == 0) { /* no elements to hash part? */
t->node = cast(Node *, dummynode); /* use common `dummynode' */
@ -309,8 +298,7 @@ static void setnodevector(lua_State *L, Table *t, int size)
}
void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize)
{
void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize) {
int i;
int oldasize = t->sizearray;
int oldhsize = t->lsizenode;
@ -343,15 +331,13 @@ void luaH_resize(lua_State *L, Table *t, int nasize, int nhsize)
}
void luaH_resizearray(lua_State *L, Table *t, int nasize)
{
void luaH_resizearray(lua_State *L, Table *t, int nasize) {
int nsize = isdummy(t->node) ? 0 : sizenode(t);
luaH_resize(L, t, nasize, nsize);
}
static void rehash(lua_State *L, Table *t, const TValue *ek)
{
static void rehash(lua_State *L, Table *t, const TValue *ek) {
int nasize, na;
int nums[MAXBITS + 1]; /* nums[i] = number of keys with 2^(i-1) < k <= 2^i */
int i;
@ -376,8 +362,7 @@ static void rehash(lua_State *L, Table *t, const TValue *ek)
*/
Table *luaH_new(lua_State *L)
{
Table *luaH_new(lua_State *L) {
Table *t = &luaC_newobj(L, LUA_TTABLE, sizeof(Table), NULL, 0)->h;
t->metatable = NULL;
t->flags = cast_byte(~0);
@ -388,8 +373,7 @@ Table *luaH_new(lua_State *L)
}
void luaH_free(lua_State *L, Table *t)
{
void luaH_free(lua_State *L, Table *t) {
if (!isdummy(t->node))
luaM_freearray(L, t->node, cast(size_t, sizenode(t)));
luaM_freearray(L, t->array, t->sizearray);
@ -397,8 +381,7 @@ void luaH_free(lua_State *L, Table *t)
}
static Node *getfreepos(Table *t)
{
static Node *getfreepos(Table *t) {
while (t->lastfree > t->node) {
t->lastfree--;
if (ttisnil(gkey(t->lastfree)))
@ -416,8 +399,7 @@ static Node *getfreepos(Table *t)
** put new key in its main position; otherwise (colliding node is in its main
** position), new key goes to an empty position.
*/
TValue *luaH_newkey(lua_State *L, Table *t, const TValue *key)
{
TValue *luaH_newkey(lua_State *L, Table *t, const TValue *key) {
Node *mp;
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
else if (ttisnumber(key) && luai_numisnan(L, nvalue(key)))
@ -457,8 +439,7 @@ TValue *luaH_newkey(lua_State *L, Table *t, const TValue *key)
/*
** search function for integers
*/
const TValue *luaH_getint(Table *t, int key)
{
const TValue *luaH_getint(Table *t, int key) {
/* (1 <= key && key <= t->sizearray) */
if (cast(unsigned int, key - 1) < cast(unsigned int, t->sizearray))
return &t->array[key - 1];
@ -478,8 +459,7 @@ const TValue *luaH_getint(Table *t, int key)
/*
** search function for short strings
*/
const TValue *luaH_getstr(Table *t, TString *key)
{
const TValue *luaH_getstr(Table *t, TString *key) {
Node *n = hashstr(t, key);
lua_assert(key->tsv.tt == LUA_TSHRSTR);
do { /* check whether `key' is somewhere in the chain */
@ -494,8 +474,7 @@ const TValue *luaH_getstr(Table *t, TString *key)
/*
** main search function
*/
const TValue *luaH_get(Table *t, const TValue *key)
{
const TValue *luaH_get(Table *t, const TValue *key) {
switch (ttype(key)) {
case LUA_TSHRSTR:
return luaH_getstr(t, rawtsvalue(key));
@ -526,8 +505,7 @@ const TValue *luaH_get(Table *t, const TValue *key)
** beware: when using this function you probably need to check a GC
** barrier and invalidate the TM cache.
*/
TValue *luaH_set(lua_State *L, Table *t, const TValue *key)
{
TValue *luaH_set(lua_State *L, Table *t, const TValue *key) {
const TValue *p = luaH_get(t, key);
if (p != luaO_nilobject)
return cast(TValue *, p);
@ -535,8 +513,7 @@ TValue *luaH_set(lua_State *L, Table *t, const TValue *key)
}
void luaH_setint(lua_State *L, Table *t, int key, TValue *value)
{
void luaH_setint(lua_State *L, Table *t, int key, TValue *value) {
const TValue *p = luaH_getint(t, key);
TValue *cell;
if (p != luaO_nilobject)
@ -550,8 +527,7 @@ void luaH_setint(lua_State *L, Table *t, int key, TValue *value)
}
static int unbound_search(Table *t, unsigned int j)
{
static int unbound_search(Table *t, unsigned int j) {
unsigned int i = j; /* i is zero or a present index */
j++;
/* find `i' and `j' such that i is present and j is not */
@ -579,8 +555,7 @@ static int unbound_search(Table *t, unsigned int j)
** Try to find a boundary in table `t'. A `boundary' is an integer index
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
*/
int luaH_getn(Table *t)
{
int luaH_getn(Table *t) {
unsigned int j = t->sizearray;
if (j > 0 && ttisnil(&t->array[j - 1])) {
/* there is a boundary in the array part: (binary) search for it */
@ -602,8 +577,7 @@ int luaH_getn(Table *t)
#if defined(LUA_DEBUG)
Node *luaH_mainposition(const Table *t, const TValue *key)
{
Node *luaH_mainposition(const Table *t, const TValue *key) {
return mainposition(t, key);
}