r1621 - dev/concept/moongoo

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Thu Dec 2 14:15:51 PST 2004


Author: neocool
Date: 2004-12-02 15:15:50 -0700 (Thu, 02 Dec 2004)
New Revision: 1621

Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/nalfs.c
   dev/concept/moongoo/util.c
Log:
Semi-decent nALFS syntax support done.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-02 20:43:57 UTC (rev 1620)
+++ dev/concept/moongoo/Makefile	2004-12-02 22:15:50 UTC (rev 1621)
@@ -9,8 +9,8 @@
 BIN=moongoo
 OBJS=alfs.o book.o util.o repl.o syn.o nalfs.o ass.o devel.o
 
-BOOK=~/projects/alfs/book/index.xml
-#BOOK=~/projects/alfs/lfs-profile/LFS.xml
+#BOOK=~/projects/alfs/book/index.xml
+BOOK=~/projects/alfs/lfs-profile/LFS.xml
 #BOOK=~/projects/alfs/ass/index.xml
 #BOOK=~/projects/hive/unstable/profile.xml
 
@@ -24,7 +24,7 @@
 compile: $(BIN)
 
 run: compile
-	./$(BIN) $(BOOK)
+	./$(BIN) -s nalfs -q $(BOOK)
 
 memcheck: compile
 	valgrind -q --tool=memcheck $(BIN) $(BOOK)

Modified: dev/concept/moongoo/nalfs.c
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-02 20:43:57 UTC (rev 1620)
+++ dev/concept/moongoo/nalfs.c	2004-12-02 22:15:50 UTC (rev 1621)
@@ -4,13 +4,16 @@
 #include <util.h>
 #include <devel.h>
 
+// TODO: Having a big static buffer sucks
+#define BUF_LEN		3000
+
 profile *prof;
-char commando[512];
+char commando[BUF_LEN];
 
 void parse_unpack (xmlNodePtr node)
 {
 	node=node->children;
-	snprintf(commando, 512, "tar -C %s %s\n", find_value(node, 
+	snprintf(commando, BUF_LEN, "tar -C %s %s\n", find_value(node, 
 		"destination"), find_value(node, "archive"));
 	
 	// TODO: Handle <digest>
@@ -19,20 +22,20 @@
 
 void parse_remove (xmlNodePtr node)
 {
-	snprintf(commando, 512, "rm -rf %s\n", xmlNodeGetContent(node));
+	snprintf(commando, BUF_LEN, "rm -rf %s\n", xmlNodeGetContent(node));
 }
 
 void parse_make (xmlNodePtr node)
 {
 	node=node->children;
-	snprintf(commando, 512, "%s make %s\n", find_value(node, "prefix"), 
+	snprintf(commando, BUF_LEN, "%s make %s\n", find_value(node, "prefix"), 
 		find_values(node, "param"));
 }
 
 void parse_configure (xmlNodePtr node)
 {
 	node = node->children;
-	snprintf(commando, 512, "%s ./configure %s\n", find_value(node, 
+	snprintf(commando, BUF_LEN, "%s ./configure %s\n", find_value(node, 
 		"prefix"), find_values(node, "param"));
 }
 
@@ -41,14 +44,14 @@
 	char *orig[4] = { "force", "archive", "recursive", NULL };
 	char *repl[4] = { "-f", "-a", "-r", NULL };
 	node = node->children;
-	snprintf(commando, 512, "cp %s %s %s\n", find_values_repl(node, "option",
+	snprintf(commando, BUF_LEN, "cp %s %s %s\n", find_values_repl(node, "option",
 		orig, repl), find_value(node, "source"), find_value(node, 
 		"destination"));
 }
 
 void __parse_env (xmlNodePtr node, void *data)
 {
-	snprintf(commando, 512, "export %s=\"%s\"\n", xmlGetProp(node, "name"), 
+	snprintf(commando, BUF_LEN, "export %s=\"%s\"\n", xmlGetProp(node, "name"), 
 			xmlNodeGetContent(node));
 }
 
@@ -59,7 +62,7 @@
 
 void parse_base (xmlNodePtr node, void *data)
 {
-	snprintf(commando, 512, "cd %s\n", xmlNodeGetContent(node));
+	snprintf(commando, BUF_LEN, "cd %s\n", xmlNodeGetContent(node));
 }
 
 void parse_stageinfo (xmlNodePtr node)
@@ -72,13 +75,13 @@
 void parse_textdump (xmlNodePtr node)
 {
 	node=node->children;
-	snprintf(commando, 512, "cat >%s << EOF\n%s\nEOF\n", find_value(node,
+	snprintf(commando, BUF_LEN, "cat >%s << EOF\n%s\nEOF\n", find_value(node,
 		"file"), cut_trail(find_value(node, "content"), "="));
 }
 
 void parse_execute (xmlNodePtr node)
 {
-	snprintf(commando, 512, "%s %s\n", xmlGetProp(node, "command"), 
+	snprintf(commando, BUF_LEN, "%s %s\n", xmlGetProp(node, "command"), 
 		find_values(node->children, "param"));
 }
 
@@ -87,14 +90,14 @@
 	char *orig[2] = { "parents", NULL };
 	char *repl[2] = { "-p", NULL };
 	node=node->children;
-	snprintf(commando, 512, "mkdir %s %s\n", find_values_repl(node, "option",
+	snprintf(commando, BUF_LEN, "mkdir %s %s\n", find_values_repl(node, "option",
 		orig, repl), find_value(node, "name"));
 }
 
 void parse_search_replace (xmlNodePtr node)
 {
 	node = node->children;
-	snprintf(commando, 512, "sed -i 's%%%s%%%s%%g' %s\n", find_value(node,
+	snprintf(commando, BUF_LEN, "sed -i 's%%%s%%%s%%g' %s\n", find_value(node,
 		"find"), find_value(node, "replace"), find_value(node, "file"));
 }
 
@@ -102,7 +105,7 @@
 {
 	char *orig[2] = { "recursive", NULL };
 	char *repl[2] = { "-R", NULL };
-	snprintf(commando, 512, "chmod %s %s %s\n", find_values_repl(node->children,
+	snprintf(commando, BUF_LEN, "chmod %s %s %s\n", find_values_repl(node->children,
 		"option", orig, repl), xmlGetProp(node, "mode"), 
 		find_value(node->children, "name"));
 }
@@ -111,7 +114,7 @@
 {
 	char *orig[2] = { "recursive", NULL };
 	char *repl[2] = { "-R", NULL };
-	snprintf(commando, 512, "chown %s %s:%s %s\n", 
+	snprintf(commando, BUF_LEN, "chown %s %s:%s %s\n", 
 		find_values_repl(node->children, "option", orig, repl), 
 		xmlGetProp(node, "user"), xmlGetProp(node, "group"),
 		find_value(node->children, "name"));
@@ -119,12 +122,12 @@
 
 void parse_patch (xmlNodePtr node)
 {
-	snprintf(commando, 512, "patch %s\n", find_values(node->children, "param"));
+	snprintf(commando, BUF_LEN, "patch %s\n", find_values(node->children, "param"));
 }
 
 void parse_move (xmlNodePtr node)
 {
-	snprintf(commando, 512, "mv %s %s\n", find_value(node->children, "source"), 
+	snprintf(commando, BUF_LEN, "mv %s %s\n", find_value(node->children, "source"), 
 		find_value(node->children, "destination"));
 }
 
@@ -132,7 +135,7 @@
 {
 	char *orig[2] = { "force", NULL };
 	char *repl[2] = { "f", NULL };
-	snprintf(commando, 512, "ln -s%s %s %s\n", find_values_repl(node->children,
+	snprintf(commando, BUF_LEN, "ln -s%s %s %s\n", find_values_repl(node->children,
 		"option", orig, repl), find_value(node->children, "target"),
 		find_value(node->children, "name"));
 }

Modified: dev/concept/moongoo/util.c
===================================================================
--- dev/concept/moongoo/util.c	2004-12-02 20:43:57 UTC (rev 1620)
+++ dev/concept/moongoo/util.c	2004-12-02 22:15:50 UTC (rev 1621)
@@ -302,7 +302,7 @@
 	for (i=0;i<n;i++)
 	{
 		ret = strstr(ret, needle);
-		if (strcmp(haystack, ret))
+		if ((ret) && (strcmp(haystack, ret)))
 			ret++;
 	}
 




More information about the alfs-log mailing list