r1648 - in dev/concept/moongoo: . libalfs syntax test

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Mon Dec 13 06:12:57 PST 2004


Author: neocool
Date: 2004-12-13 07:12:57 -0700 (Mon, 13 Dec 2004)
New Revision: 1648

Added:
   dev/concept/moongoo/test/
   dev/concept/moongoo/test/Makefile
   dev/concept/moongoo/test/tst.c
   dev/concept/moongoo/test/tst.h
   dev/concept/moongoo/test/tst_squeeze.c
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/build.c
   dev/concept/moongoo/inc.mak
   dev/concept/moongoo/libalfs/parse.c
   dev/concept/moongoo/libalfs/parse.h
   dev/concept/moongoo/libalfs/util.c
   dev/concept/moongoo/libalfs/util.h
   dev/concept/moongoo/syntax/blfs.c
   dev/concept/moongoo/syntax/book.c
   dev/concept/moongoo/syntax/nalfs.c
   dev/concept/moongoo/url.c
Log:
Update.


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/Makefile	2004-12-13 14:12:57 UTC (rev 1648)
@@ -4,17 +4,17 @@
 OBJS=build.o moongoo.o plugin.o url.o
 
 ifeq ($(OPTS),)
-OPTS=-s syn
+OPTS=-q -s blfs
 #OPTS+=~/projects/alfs/book/index.xml
 #OPTS+=~/projects/alfs/lfs-profile/LFS.xml
 #OPTS+=~/projects/alfs/ass/index.xml
-OPTS+=~/projects/hive/unstable/profile.xml
-#OPTS+=~/projects/alfs/blfs/index.xml
+#OPTS+=~/projects/hive/unstable/profile.xml
+OPTS+=~/projects/alfs/blfs/index.xml
 #OPTS+=~/projects/alfs/hlfs/index.xml
 #OPTS+=~/projects/alfs/book-rng/index.xml
 endif
 
-SUBDIRS=libalfs syntax
+SUBDIRS=libalfs syntax test
 
 .PHONY: all
 
@@ -24,7 +24,7 @@
 
 $(BIN): $(OBJS) libalfs/libalfs.a
 
-check: $(BIN)
+memcheck: $(BIN)
 	valgrind --tool=memcheck ./$(BIN) $(OPTS)
 
 run: $(BIN)

Modified: dev/concept/moongoo/build.c
===================================================================
--- dev/concept/moongoo/build.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/build.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -53,7 +53,6 @@
 	return 0;
 }
 
-// TODO: Write shorter code for sed_paralell()
 void sed_paralell (profile *prof, char **filter, char **p1, char **p2)
 {
 	int i, j, k;

Modified: dev/concept/moongoo/inc.mak
===================================================================
--- dev/concept/moongoo/inc.mak	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/inc.mak	2004-12-13 14:12:57 UTC (rev 1648)
@@ -18,7 +18,7 @@
 	done
 
 clean: clean-subdirs
-	rm -f $(BIN) $(LIB) $(LIBS) *.o
+	rm -f $(BIN) $(LIB) $(LIBS) *.o $(TESTS)
 	
 todo:
 	@find -name '*.c'|xargs grep "TODO:"|cut -d" " -f3-|sort

Modified: dev/concept/moongoo/libalfs/parse.c
===================================================================
--- dev/concept/moongoo/libalfs/parse.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/libalfs/parse.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -15,6 +15,12 @@
 	return &prof->ch[i].pkg[j];
 }
 
+dep *cur_dep (profile *prof)
+{
+	package *pkg = cur_pkg(prof);
+	return &pkg->dep[pkg->o-1];
+}	
+
 chapter *next_chpt (profile *prof)
 {
 	chapter *ch;
@@ -50,6 +56,7 @@
 	return cmd;
 }
 
+// TODO: Crashes when used in syntax/blfs.c, need to investigate further
 dep *next_dep (profile *prof)
 {
 	dep *dep;
@@ -57,10 +64,13 @@
 	
 	i = prof->n-1;
 	j = prof->ch[i].n-1;
+
+	printf("%s\n", cur_pkg(prof)->name);
+
 	prof->ch[i].pkg[j].dep = realloc(prof->ch[i].pkg[j].dep,
 			(++prof->ch[i].pkg[j].o)*sizeof(dep));
 	k = prof->ch[i].pkg[j].o-1;
-
+	
 	dep = &prof->ch[i].pkg[j].dep[k];
 	dep->type = DEP_NONE;
 	dep->name = NULL;
@@ -226,7 +236,7 @@
 	
 	if (!ret)
 	{
-		// XXX: Add support for missing archive types
+		// TODO: Add support for missing archive types
 		//fprintf(stderr, "Archive extension '%s' is unknown.\n", ext);
 		return;
 	}

Modified: dev/concept/moongoo/libalfs/parse.h
===================================================================
--- dev/concept/moongoo/libalfs/parse.h	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/libalfs/parse.h	2004-12-13 14:12:57 UTC (rev 1648)
@@ -3,6 +3,7 @@
 
 #include <alfs.h>
 
+dep *cur_dep (profile *prof);
 package *cur_pkg (profile *prof);
 
 chapter *next_chpt (profile *prof);

Modified: dev/concept/moongoo/libalfs/util.c
===================================================================
--- dev/concept/moongoo/libalfs/util.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/libalfs/util.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -254,7 +254,7 @@
 	return ret;
 }
 
-char *squeeze (char *str)
+char *squeeze_all (char *str)
 {
 	bool blank=false;
 	int i, len=0;
@@ -284,6 +284,32 @@
 	return ret;
 }
 
+char *squeeze (char *str)
+{
+	int i, begin=0, end=strlen(str);
+
+	if (!str)
+		return NULL;
+
+	for (i=0;i<strlen(str);i++)
+	{
+		if (isblank(str[i]))
+			begin++;
+		else
+			break;
+	}
+
+	for (i=strlen(str)-1;i>=0;i--)
+	{
+		if (isblank(str[i]))
+			end--;
+		else
+			break;
+	}
+
+	return strcut(str, begin, end-begin);
+}
+
 char *strkill (char *str, char *tokill)
 {
 	char *cpy;
@@ -318,7 +344,9 @@
 	for (i=0;i<n;i++)
 	{
 		ret = strstr(ret, needle);
-		if ((ret) && (strcmp(haystack, ret)))
+		if (!ret)
+			break;
+		if (strcmp(haystack, ret))
 			ret++;
 	}
 

Modified: dev/concept/moongoo/libalfs/util.h
===================================================================
--- dev/concept/moongoo/libalfs/util.h	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/libalfs/util.h	2004-12-13 14:12:57 UTC (rev 1648)
@@ -38,6 +38,7 @@
 int whereis (char *str, char ch);
 char *notrail (char *str, char *token);
 char *squeeze (char *str);
+char *squeeze_all (char *str);
 char *strkill (char *str, char *tokill);
 char *strnstr (char *haystack, char *needle, int n);
 char *strnrchr (char *haystack, char needle, int n);

Modified: dev/concept/moongoo/syntax/blfs.c
===================================================================
--- dev/concept/moongoo/syntax/blfs.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/syntax/blfs.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -5,7 +5,6 @@
 
 profile *prof;
 
-// TODO: Removed a <command> block because of parsing problems (postlfs/config/bootdisk.xml)
 profile *parse_blfs (xmlNodePtr node, replaceable *r);
 
 static t_plug sample_plugin =
@@ -27,24 +26,24 @@
 
 static void t_userinput (xmlNodePtr node, void *data)
 {
-	// XXX: Add all possible replaceables to moo.xml
-	/*replaceable *r = (replaceable *)data;
-	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);*/
+	// TODO: Add all possible replaceables to moo.xml
+	replaceable *r = (replaceable *)data;
+	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);
 	foreach(node->children, "command", (xml_handler_t)t_command, NULL);
 }
 
 static void t_xref (xmlNodePtr node, void *data)
 {
-	dtype *type = (dtype *)data;
 	char *role = xmlGetProp(node, "role");
-	dep *dep;
+	dtype *type = (dtype *)data;
+	package *pkg = cur_pkg(prof);
 
-	if ((role)&&(!strcmp(role, "no")))
+	if ((role) && (!strcmp(role, "no")))
 		return;
 
-	dep = next_dep(prof);
-	dep->name = xmlGetProp(node, "linkend");
-	dep->type = *type;
+	pkg->dep = realloc(pkg->dep, (++pkg->o)*sizeof(dep));
+	pkg->dep[pkg->o-1].name = xmlGetProp(node, "linkend");
+	pkg->dep[pkg->o-1].type = *type;
 }
 
 static void t_sect4 (xmlNodePtr node, void *data)
@@ -61,10 +60,7 @@
 	if (!strcmp(title, "Recommended"))
 		type = RECOM;
 	else
-	{
 		fprintf(stderr, "Unknown dependency type '%s'\n", title);
-		type = DEP_NONE;
-	}
 	
 	foreach(node->children, "xref", (xml_handler_t)t_xref, &type);
 }
@@ -73,9 +69,6 @@
 {
 	char *title = strstr(find_value(node->children, "title"), " ");
 	
-	// TODO: Dependency parsing is broken
-	return;
-	
 	if ((title)&&(!strncmp(lower_case(title), " dependencies", 13)))
 		foreach(node->children, "sect4", (xml_handler_t)t_sect4, NULL);
 }

Modified: dev/concept/moongoo/syntax/book.c
===================================================================
--- dev/concept/moongoo/syntax/book.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/syntax/book.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -25,7 +25,7 @@
 
 static void t_userinput (xmlNodePtr node, void *data)
 {
-	// XXX: <replaceable> problems w/ the RNG book
+	// TODO: <replaceable> problems w/ the RNG book
 	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);
 	parse_cmdblock(prof, node); 
 }

Modified: dev/concept/moongoo/syntax/nalfs.c
===================================================================
--- dev/concept/moongoo/syntax/nalfs.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/syntax/nalfs.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -30,7 +30,7 @@
 {
 	char *archive = find_value(node->children, "archive");
 	node=node->children;
-	// TODO: squeeze() squeezes too much
+	// TODO: tokenize() problem
 	snprintf(commando, BUF_LEN, "tar -C %s %s\necho \"%s  %s\"|md5sum -c -\n", 
 		find_value(node, "destination"), archive, find_value(node, "digest"),
 		archive);

Added: dev/concept/moongoo/test/Makefile
===================================================================
--- dev/concept/moongoo/test/Makefile	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/test/Makefile	2004-12-13 14:12:57 UTC (rev 1648)
@@ -0,0 +1,18 @@
+CC=gcc
+
+CFLAGS=-I. -I../libalfs
+
+TESTS=tst_squeeze
+
+.PHONY: all
+
+all: run
+
+run: $(TESTS)
+	@for test in $(TESTS); do \
+		(echo "Running $$test..." && exec ./$$test) || exit $$?; \
+	done
+
+include ../inc.mak
+
+tst_squeeze: tst.o ../libalfs/libalfs.a

Added: dev/concept/moongoo/test/tst.c
===================================================================
--- dev/concept/moongoo/test/tst.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/test/tst.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <tst.h>
+
+static int __tst_harness (char *result, char *reference, bool dbg)
+{
+	int ret;
+
+	if (dbg)
+		printf("_%s_\n_%s_\n", result, reference);
+	ret=strcmp(result, reference);
+	free(result);
+
+	return ret;
+}
+
+int tst_harness (char *result, char *reference)
+{
+	return __tst_harness(result, reference, false);
+}
+
+int tst_harness_dbg (char *result, char *reference)
+{
+	return __tst_harness(result, reference, true);
+}

Added: dev/concept/moongoo/test/tst.h
===================================================================
--- dev/concept/moongoo/test/tst.h	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/test/tst.h	2004-12-13 14:12:57 UTC (rev 1648)
@@ -0,0 +1,9 @@
+#ifndef __TST_H__
+#define __TST_H__
+
+#include <stdbool.h>
+
+int tst_harness_dbg (char *result, char *reference);
+int tst_harness (char *result, char *reference);
+
+#endif

Added: dev/concept/moongoo/test/tst_squeeze.c
===================================================================
--- dev/concept/moongoo/test/tst_squeeze.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/test/tst_squeeze.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -0,0 +1,7 @@
+#include <util.h>
+#include <tst.h>
+
+int main (int argc, char **argv)
+{
+	return tst_harness(squeeze("   moo  moongoo   "), "moo  moongoo");
+}

Modified: dev/concept/moongoo/url.c
===================================================================
--- dev/concept/moongoo/url.c	2004-12-13 01:01:23 UTC (rev 1647)
+++ dev/concept/moongoo/url.c	2004-12-13 14:12:57 UTC (rev 1648)
@@ -2,8 +2,8 @@
 
 #include <url.h>
 
-// XXX: Tcl URL is not yet found (tcl8.4.7-src.tar.gz)
-// XXX: Vim-lang will not be downloaded atm.
+// TODO: Tcl URL is not yet found (tcl8.4.7-src.tar.gz)
+// TODO: Vim-lang will not be downloaded atm.
 static void t_url (xmlNodePtr cur, void *data)
 {
 	profile *prof = (profile *)data;




More information about the alfs-log mailing list