Software / code / prosody
Comparison
util-src/table.c @ 7538:a3a4ed0d34f4
util.table: Move loop variable to top of function for C89 compatibility
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 07 Aug 2016 20:49:50 +0200 |
| parent | 7519:d278a770eddc |
| child | 7818:54669df178c2 |
comparison
equal
deleted
inserted
replaced
| 7537:a0813737c6fa | 7538:a3a4ed0d34f4 |
|---|---|
| 5 lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); | 5 lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); |
| 6 return 1; | 6 return 1; |
| 7 } | 7 } |
| 8 | 8 |
| 9 static int Lpack(lua_State* L) { | 9 static int Lpack(lua_State* L) { |
| 10 int arg; | |
| 10 unsigned int n_args = lua_gettop(L); | 11 unsigned int n_args = lua_gettop(L); |
| 11 lua_createtable(L, n_args, 1); | 12 lua_createtable(L, n_args, 1); |
| 12 lua_insert(L, 1); | 13 lua_insert(L, 1); |
| 13 for(int arg = n_args; arg >= 1; arg--) { | 14 for(arg = n_args; arg >= 1; arg--) { |
| 14 lua_rawseti(L, 1, arg); | 15 lua_rawseti(L, 1, arg); |
| 15 } | 16 } |
| 16 lua_pushinteger(L, n_args); | 17 lua_pushinteger(L, n_args); |
| 17 lua_setfield(L, -2, "n"); | 18 lua_setfield(L, -2, "n"); |
| 18 return 1; | 19 return 1; |