shithub: lu9-p9

Download patch

ref: 3fc6d7a0f87a487c5d33b838ff5b5b9968b7b1cc
parent: ee5dbf6528365a9dd306665f85c707571b974e5c
author: kvik <[email protected]>
date: Sun Apr 18 21:39:57 EDT 2021

misc: implement p9.cleanname()

--- a/mkfile
+++ b/mkfile
@@ -17,4 +17,4 @@
 %.$O: %.c
 	$CC $CFLAGS $stem.c
 
-p9.$O: p9.c fs.c walk.c env.c ns.c proc.c
+p9.$O: p9.c fs.c walk.c env.c ns.c proc.c misc.c
--- a/p9.c
+++ b/p9.c
@@ -95,6 +95,7 @@
 #include "env.c"
 #include "ns.c"
 #include "proc.c"
+#include "misc.c"
 
 typedef struct Data {
 	char *key;
@@ -174,6 +175,8 @@
 	{"sleep", p9_sleep},
 	{"alarm", p9_alarm},
 	{"rfork", p9_rfork},
+	
+	{"cleanname", p9_cleanname},
 	
 	{nil, nil}
 };
--- a/test.lua
+++ b/test.lua
@@ -256,3 +256,13 @@
 		and #e == 3 and e[1] == "d" and e[2] == "e" and e[3] == "f")
 	p9.env.test = nil
 end
+
+
+
+
+-- Misc.
+
+-- cleanname
+do
+	assert(p9.cleanname("/usr///./glenda/.") == "/usr/glenda")
+end