git » fp-git.git » commit f0b9250

new tree working features

author ecalot
2005-12-29 10:46:40 UTC
committer ecalot
2005-12-29 10:46:40 UTC
parent 8facebcde79050b9d2a45e07da352edd106c2767

new tree working features

PR/src/lib/xml/tree.c +33 -1
PR/src/lib/xml/unknown.c +33 -1

diff --git a/PR/src/lib/xml/tree.c b/PR/src/lib/xml/tree.c
index 0924329..74bf5cf 100644
--- a/PR/src/lib/xml/tree.c
+++ b/PR/src/lib/xml/tree.c
@@ -90,7 +90,7 @@ static struct {
 	           value,       index,       path,       type,       flags,          typedesc, count)
 
 
-/* tree module */
+/* tree module, TODO send to other module */
 #define outputStream stdout
 
 void showTag(int n,tTag* t) {
@@ -133,6 +133,7 @@ void showTag(int n,tTag* t) {
 	}
 }
 
+/* file deletion */
 
 void rec_tree(tTag* *t,const char* file) {
 	tTag* aux=*t;
@@ -171,6 +172,36 @@ void unknown_deletetreefile(const char* file) {
 
 }
 
+/* inheritance fixing */
+#define TotalInheritance(a) if (equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;}
+
+void rec_tree_fix(tTag* parent,tTag* child) {
+	if (parent) {
+		TotalInheritance(palette);
+		TotalInheritance(paletteindex);
+		TotalInheritance(paletteorder);
+		TotalInheritance(type);
+		TotalInheritance(file);
+		TotalInheritance(index);
+		TotalInheritance(order);
+		TotalInheritance(flags);
+		printf("t='%s' child='%s'\n",parent->path,child->path);
+	}
+	
+	if (child->next) rec_tree_fix(parent,child->next);
+	if (child->child) rec_tree_fix(child,child->child);
+}
+
+void unknown_fixtreeinheritances() {
+	printf("fixind inheritances in tree\n");
+	if (unknownFile.tree) {
+		rec_tree_fix(NULL,unknownFile.tree);
+		
+		freeAllocation(unknownFile.tree->path);
+		unknownFile.tree->path=NULL;		
+	}
+}
+
 /***************************************************************\
 |                          Semantic Layer                       |
 \***************************************************************/
@@ -242,6 +273,7 @@ int unknownLogAppend(const char* vFiledat,tResourceId id,const char* ext,tResour
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 		/* TODO: move here the read-parsing-loading and write-opening */
 		unknown_deletetreefile(vFiledat);
+		unknown_fixtreeinheritances();
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		int i;
 		unknown_folderclose(); 
diff --git a/PR/src/lib/xml/unknown.c b/PR/src/lib/xml/unknown.c
index 0924329..74bf5cf 100644
--- a/PR/src/lib/xml/unknown.c
+++ b/PR/src/lib/xml/unknown.c
@@ -90,7 +90,7 @@ static struct {
 	           value,       index,       path,       type,       flags,          typedesc, count)
 
 
-/* tree module */
+/* tree module, TODO send to other module */
 #define outputStream stdout
 
 void showTag(int n,tTag* t) {
@@ -133,6 +133,7 @@ void showTag(int n,tTag* t) {
 	}
 }
 
+/* file deletion */
 
 void rec_tree(tTag* *t,const char* file) {
 	tTag* aux=*t;
@@ -171,6 +172,36 @@ void unknown_deletetreefile(const char* file) {
 
 }
 
+/* inheritance fixing */
+#define TotalInheritance(a) if (equalsIgnoreCase(parent->a,child->a)) {freeAllocation(child->a);child->a=NULL;}
+
+void rec_tree_fix(tTag* parent,tTag* child) {
+	if (parent) {
+		TotalInheritance(palette);
+		TotalInheritance(paletteindex);
+		TotalInheritance(paletteorder);
+		TotalInheritance(type);
+		TotalInheritance(file);
+		TotalInheritance(index);
+		TotalInheritance(order);
+		TotalInheritance(flags);
+		printf("t='%s' child='%s'\n",parent->path,child->path);
+	}
+	
+	if (child->next) rec_tree_fix(parent,child->next);
+	if (child->child) rec_tree_fix(child,child->child);
+}
+
+void unknown_fixtreeinheritances() {
+	printf("fixind inheritances in tree\n");
+	if (unknownFile.tree) {
+		rec_tree_fix(NULL,unknownFile.tree);
+		
+		freeAllocation(unknownFile.tree->path);
+		unknownFile.tree->path=NULL;		
+	}
+}
+
 /***************************************************************\
 |                          Semantic Layer                       |
 \***************************************************************/
@@ -242,6 +273,7 @@ int unknownLogAppend(const char* vFiledat,tResourceId id,const char* ext,tResour
 		unknownFile.currentDat=strallocandcopy(vFiledat);
 		/* TODO: move here the read-parsing-loading and write-opening */
 		unknown_deletetreefile(vFiledat);
+		unknown_fixtreeinheritances();
 	} else if (!equalsIgnoreCase(unknownFile.currentDat,vFiledat)) {
 		int i;
 		unknown_folderclose();