r1609 - dev/concept/moongoo

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Tue Nov 30 16:40:19 PST 2004


Author: neocool
Date: 2004-11-30 17:40:19 -0700 (Tue, 30 Nov 2004)
New Revision: 1609

Modified:
   dev/concept/moongoo/alfs.c
   dev/concept/moongoo/alfs.h
   dev/concept/moongoo/book.c
   dev/concept/moongoo/moongoo.c
Log:
Update.


Modified: dev/concept/moongoo/alfs.c
===================================================================
--- dev/concept/moongoo/alfs.c	2004-12-01 00:02:07 UTC (rev 1608)
+++ dev/concept/moongoo/alfs.c	2004-12-01 00:40:19 UTC (rev 1609)
@@ -5,11 +5,15 @@
 #include <util.h>
 
 xmlDocPtr doc;
+role *filter = NULL;
 
 void print_cmd (command cmd)
 {
 	int i=0;
 
+	if (filtered(cmd.role))
+		return;
+	
 	printf("%s ", cmd.cmd);
 	for (i=0;i<cmd.n;i++)
 		printf("%s ", cmd.arg[i]);
@@ -22,10 +26,12 @@
 {
 	int i;
 	
+	term_set(RESET, GREEN, BLACK);
 	if (!pkg.vers)
 		printf("%s\n\n", pkg.name);
 	else
 		printf("%s-%s\n\n", pkg.name, pkg.vers);
+	term_reset();
 	
 	for (i=0;i<pkg.n;i++)
 		print_cmd(pkg.build[i]);
@@ -36,6 +42,9 @@
 {
 	int i;
 
+	if (!ch.n)
+		return;
+
 	term_set(RESET, RED, BLACK);
 	printf("%s\n", ch.name);
 	term_reset();
@@ -225,10 +234,38 @@
 			if ((node->prev) && (node->prev->type==XML_TEXT_NODE) &&
 				(strcmp(node->prev->parent->name, "title")))
 			{
-				xmlNodeAddContent(node->prev, entity_val((char *)node->name));
+				char *text = entity_val((char *)node->name);
+				if (text)
+					xmlNodeAddContent(node->prev, text);
 			}
 		}
 		resolve_entities(node->children);
 		node=node->next;
 	}
 }
+
+void set_filter (role *role)
+{
+	filter = role;
+}
+
+void unset_filter ()
+{
+	filter = NULL;
+}
+
+bool filtered (role role)
+{
+	int i=0;
+
+	if (!filter)
+		return false;
+
+	while (filter[i])
+	{
+		if (role==filter[i])
+			return true;
+		i++;
+	}
+	return false;
+}

Modified: dev/concept/moongoo/alfs.h
===================================================================
--- dev/concept/moongoo/alfs.h	2004-12-01 00:02:07 UTC (rev 1608)
+++ dev/concept/moongoo/alfs.h	2004-12-01 00:40:19 UTC (rev 1609)
@@ -9,7 +9,7 @@
 
 typedef enum
 {
-	NONE,
+	NONE = 1,
 	NOEXECUTE,
 	INTERACTIVE,
 	TESTSUITE,
@@ -59,6 +59,9 @@
 void print_cmd (command cmd);
 void print_chapter (chapter ch);
 void print_profile (profile prof);
+void set_filter (role *role);
+void unset_filter ();
+bool filtered (role role);
 
 void resolve_entities (xmlNodePtr node);
 void foreach (xmlNodePtr node, char *str, xml_handler_t func, void *data);

Modified: dev/concept/moongoo/book.c
===================================================================
--- dev/concept/moongoo/book.c	2004-12-01 00:02:07 UTC (rev 1608)
+++ dev/concept/moongoo/book.c	2004-12-01 00:40:19 UTC (rev 1609)
@@ -42,7 +42,7 @@
 		&prof->ch[i].pkg[j].n);
 	free(tmp);
 
-	if (!prof->ch[i].pkg[i].n)
+	if (!prof->ch[i].pkg[j].n)
 		prof->ch[i].n--;
 }
 

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-01 00:02:07 UTC (rev 1608)
+++ dev/concept/moongoo/moongoo.c	2004-12-01 00:40:19 UTC (rev 1609)
@@ -6,9 +6,10 @@
 #include <repl.h>
 #include <util.h>
 
+role default_filter[4] = { NOEXECUTE, INTERACTIVE, TESTSUITE, 0 };
+
 int main (int argc, char **argv)
 {
-	//int i;
 	xmlNodePtr cur;
 	profile *prof;
 
@@ -18,6 +19,7 @@
 		return 1;
 	}
 	
+	xmlSubstituteEntitiesDefault(1);
 	doc=xmlParseFile(argv[1]);
 	if (!doc)
 		return 2;
@@ -26,6 +28,7 @@
 	resolve_entities(cur);
 	
 	prof=bookasprofile(cur);
+	set_filter(default_filter);
 	print_profile(*prof);
 	
 	xmlFreeDoc(doc);




More information about the alfs-log mailing list