Comparison

util-src/strbitop.c @ 12469:2b3adaa6d38e

util.strbitop: Reduce scope of functions Equivalent to 'local' in Lua, these functions are exported via the luaopen_ function, which is the only one needing to be visible outside of the file. Pointed out by Link Mauve at some point, but there wasn't really any rush here.
author Kim Alvefur <zash@zash.se>
date Sat, 23 Apr 2022 14:29:43 +0200
parent 11175:235537247aa3
child 12575:1f6f05a98fcd
comparison
equal deleted inserted replaced
12468:353836684009 12469:2b3adaa6d38e
12 #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R) 12 #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
13 #endif 13 #endif
14 14
15 /* TODO Deduplicate code somehow */ 15 /* TODO Deduplicate code somehow */
16 16
17 int strop_and(lua_State *L) { 17 static int strop_and(lua_State *L) {
18 luaL_Buffer buf; 18 luaL_Buffer buf;
19 size_t a, b, i; 19 size_t a, b, i;
20 const char *str_a = luaL_checklstring(L, 1, &a); 20 const char *str_a = luaL_checklstring(L, 1, &a);
21 const char *str_b = luaL_checklstring(L, 2, &b); 21 const char *str_b = luaL_checklstring(L, 2, &b);
22 22
33 33
34 luaL_pushresult(&buf); 34 luaL_pushresult(&buf);
35 return 1; 35 return 1;
36 } 36 }
37 37
38 int strop_or(lua_State *L) { 38 static int strop_or(lua_State *L) {
39 luaL_Buffer buf; 39 luaL_Buffer buf;
40 size_t a, b, i; 40 size_t a, b, i;
41 const char *str_a = luaL_checklstring(L, 1, &a); 41 const char *str_a = luaL_checklstring(L, 1, &a);
42 const char *str_b = luaL_checklstring(L, 2, &b); 42 const char *str_b = luaL_checklstring(L, 2, &b);
43 43
54 54
55 luaL_pushresult(&buf); 55 luaL_pushresult(&buf);
56 return 1; 56 return 1;
57 } 57 }
58 58
59 int strop_xor(lua_State *L) { 59 static int strop_xor(lua_State *L) {
60 luaL_Buffer buf; 60 luaL_Buffer buf;
61 size_t a, b, i; 61 size_t a, b, i;
62 const char *str_a = luaL_checklstring(L, 1, &a); 62 const char *str_a = luaL_checklstring(L, 1, &a);
63 const char *str_b = luaL_checklstring(L, 2, &b); 63 const char *str_b = luaL_checklstring(L, 2, &b);
64 64