ref: e76d34a16eec236618daed706029093ce2a91440
parent: 9ab99ec017481375b87617ba167609f613adace8
author: phil9 <[email protected]>
date: Thu Dec 1 01:04:24 EST 2022
refactoring
--- a/slug.c
+++ b/slug.c
@@ -59,6 +59,13 @@
}
void
+lset(lua_State *L, const char *name, int value)
+{
+ lua_pushnumber(L, value);
+ lua_setglobal(L, name);
+}
+
+void
resize(lua_State *L, int w, int h)
{
int fd, n;
@@ -71,10 +78,8 @@
if(write(fd, buf, n) != n)
fprint(2, "write error: %r\n");
close(fd);
- lua_pushnumber(L, w);
- lua_setglobal(L, "width");
- lua_pushnumber(L, h);
- lua_setglobal(L, "height");
+ lset(L, "width", w);
+ lset(L, "height", h);
}
void