shithub: lu9-p9

Download patch

ref: 5d34be6a2478a81cb196cc889a1d9a8dc09f581a
parent: 926048e140de090693c7d1699432881657c93e7b
author: kvik <kvik@a-b.xyz>
date: Thu Apr 22 18:59:40 EDT 2021

all: remove unused data, clarify naming

--- a/base/base.c
+++ b/base/base.c
@@ -14,61 +14,7 @@
 #include "proc.c"
 #include "misc.c"
 
-typedef struct Data {
-	char *key;
-	lua_Integer val;
-} Data;
-
-static Data p9data[] = {
-	{"OREAD", OREAD},
-	{"OWRITE", OWRITE},
-	{"ORDWR", ORDWR},
-	{"OEXEC", OEXEC},
-	{"OTRUNC", OTRUNC},
-	{"OCEXEC", OCEXEC},
-	{"ORCLOSE", ORCLOSE},
-	{"OEXCL", OEXCL},
-	
-	{"DMDIR", DMDIR},
-	{"DMAPPEND", DMAPPEND},
-	{"DMEXCL", DMEXCL},
-	{"DMMOUNT", DMMOUNT},
-	{"DMAUTH", DMAUTH},
-	{"DMTMP", DMTMP},
-	{"DMREAD", DMREAD},
-	{"DMWRITE", DMWRITE},
-	{"DMEXEC", DMEXEC},
-	{"QTDIR", QTDIR},
-	{"QTAPPEND", QTAPPEND},
-	{"QTEXCL", QTEXCL},
-	{"QTMOUNT", QTMOUNT},
-	{"QTAUTH", QTAUTH},
-	{"QTTMP", QTTMP},
-	{"QTFILE", QTFILE},
-	
-	{"MREPL", MREPL},
-	{"MBEFORE", MBEFORE},
-	{"MAFTER", MAFTER},
-	{"MCREATE", MCREATE},
-	{"MCACHE", MCACHE},
-
-	{"RFPROC", RFPROC},
-	{"RFNOWAIT", RFNOWAIT},
-	{"RFNAMEG", RFNAMEG},
-	{"RFCNAMEG", RFCNAMEG},
-	{"RFNOMNT", RFNOMNT},
-	{"RFENVG", RFENVG},
-	{"RFCENVG", RFCENVG},
-	{"RFNOTEG", RFNOTEG},
-	{"RFFDG", RFFDG},
-	{"RFCFDG", RFCFDG},
-	{"RFREND", RFREND},
-	{"RFMEM", RFMEM},
-	
-	{nil, 0}
-};
-
-static luaL_Reg p9func[] = {
+static luaL_Reg p9_module[] = {
 	{"open", p9_open},
 	{"create", p9_create},
 	{"file", p9_file},
@@ -111,7 +57,6 @@
 {
 	int lib;
 	Buf *buf;
-	Data *d;
 	
 	buf = resizebuffer(L, nil, Iosize);
 	lua_pushlightuserdata(L, buf);
@@ -140,12 +85,8 @@
 	luaL_setfuncs(L, walkmt, 0);
 	lua_pop(L, 1);
 	
-	luaL_newlib(L, p9func);
+	luaL_newlib(L, p9_module);
 	lib = lua_gettop(L);
-	for(d = p9data; d->key != nil; d++){
-		lua_pushinteger(L, d->val);
-		lua_setfield(L, -2, d->key);
-	}
 	
 	static luaL_Reg envmt[] = {
 		{"__index", p9_getenv_index},
--- a/note/note.c
+++ b/note/note.c
@@ -182,7 +182,7 @@
 	return 1;
 }
 
-static luaL_Reg p9_note_funcs[] = {
+static luaL_Reg p9_note_module[] = {
 	{"post", p9_note_post},
 	{"catch", p9_note_catch},
 	{nil, nil},
@@ -199,7 +199,7 @@
 	lua_createtable(L, 1, 0);
 	lua_setfield(L, LUA_REGISTRYINDEX, "p9-note-handlers");
 	
-	luaL_newlib(L, p9_note_funcs);
+	luaL_newlib(L, p9_note_module);
 	
 	atnotify(notecatcher, 1);
 	return 1;