Revision: 42318
http://brlcad.svn.sourceforge.net/brlcad/?rev=42318&view=rev
Author: brlcad
Date: 2011-01-16 08:25:33 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
seems over-complicated, simplify. just compare the first to the second, and
the second to the first since all we do is print both if there's a difference.
fix two bugs in the process, one that caught colortable changes with g2asc +
asc2g of ktank when there were none due to resetting the wrong found1 var to
zero in the found2's loop. the second was printing color commands if we're v4.
Modified Paths:
--------------
brlcad/trunk/src/gtools/g_diff.c
Modified: brlcad/trunk/src/gtools/g_diff.c
===================================================================
--- brlcad/trunk/src/gtools/g_diff.c 2011-01-16 07:48:05 UTC (rev 42317)
+++ brlcad/trunk/src/gtools/g_diff.c 2011-01-16 08:25:33 UTC (rev 42318)
@@ -86,101 +86,79 @@
int found1 = 0, found2 = 0;
int is_diff = 0;
- for (mp1 = mater_hd1; mp1 != MATER_NULL; mp1 = mp1->mt_forw) {
+ /* find a match for all color table entries of file1 in file2 */
+ for (mp1 = mater_hd1; is_diff == 0 && mp1 != MATER_NULL; mp1 =
mp1->mt_forw) {
found1 = 0;
mp2 = mater_hd2;
while (mp2 != MATER_NULL) {
- if (mp1->mt_low == mp2->mt_low &&
- mp1->mt_high == mp2->mt_high &&
- mp1->mt_r == mp2->mt_r &&
- mp1->mt_g == mp2->mt_g &&
- mp1->mt_b == mp2->mt_b) {
+ if (mp1->mt_low == mp2->mt_low
+ && mp1->mt_high == mp2->mt_high
+ && mp1->mt_r == mp2->mt_r
+ && mp1->mt_g == mp2->mt_g
+ && mp1->mt_b == mp2->mt_b)
+ {
found1 = 1;
break;
- } else {
- mp2 = mp2->mt_forw;
}
+ mp2 = mp2->mt_forw;
}
- if (!found1)
- break;
+ if (!found1) {
+ /* bu_log("could not find %d..%d: %d %d %d\n", mp1->mt_low,
mp1->mt_high, mp1->mt_r, mp1->mt_g, mp1->mt_b); */
+ is_diff = 1;
+ }
}
- for (mp2 = mater_hd2; mp2 != MATER_NULL; mp2 = mp2->mt_forw) {
- found1 = 0;
+
+ /* find a match for all color tabl eentries of file2 in file1 */
+ for (mp2 = mater_hd2; is_diff == 0 && mp2 != MATER_NULL; mp2 =
mp2->mt_forw) {
+ found2 = 0;
mp1 = mater_hd1;
while (mp1 != MATER_NULL) {
- if (mp1->mt_low == mp2->mt_low &&
- mp1->mt_high == mp2->mt_high &&
- mp1->mt_r == mp2->mt_r &&
- mp1->mt_g == mp2->mt_g &&
- mp1->mt_b == mp2->mt_b) {
+ if (mp1->mt_low == mp2->mt_low
+ && mp1->mt_high == mp2->mt_high
+ && mp1->mt_r == mp2->mt_r
+ && mp1->mt_g == mp2->mt_g
+ && mp1->mt_b == mp2->mt_b)
+ {
found2 = 1;
break;
- } else {
- mp1 = mp1->mt_forw;
}
+ mp1 = mp1->mt_forw;
}
- if (!found2)
- break;
+ if (!found2) {
+ /* bu_log("could not find %d..%d: %d %d %d\n", mp1->mt_low,
mp1->mt_high, mp1->mt_r, mp1->mt_g, mp1->mt_b); */
+ is_diff = 1;
+ }
}
- if (!found1 && !found2) {
+
+ if (is_diff == 0) {
return 0;
- } else if (!found1 || !found2) {
- is_diff = 1;
- } else {
- /* actually compare two color tables */
- mp1 = mater_hd1;
- mp2 = mater_hd2;
- while (mp1 != MATER_NULL && mp2 != MATER_NULL) {
- if (mp1->mt_low != mp2->mt_low) {
- is_diff = 1;
- break;
- }
- if (mp1->mt_high != mp2->mt_high) {
- is_diff = 1;
- break;
- }
- if (mp1->mt_r != mp2->mt_r) {
- is_diff = 1;
- break;
- }
- if (mp1->mt_g != mp2->mt_g) {
- is_diff = 1;
- break;
- }
- if (mp1->mt_b != mp2->mt_b) {
- is_diff = 1;
- break;
- }
- mp1 = mp1->mt_forw;
- mp2 = mp2->mt_forw;
- }
}
- if (is_diff) {
- if (mode == HUMAN) {
- printf("Color table has changed from:\n");
- for (mp1 = mater_hd1; mp1 != MATER_NULL; mp1 = mp1->mt_forw) {
- printf("\t%d..%d %d %d %d\n", mp1->mt_low, mp1->mt_high,
- mp1->mt_r, mp1->mt_g, mp1->mt_b);
- }
- printf("\t\tto:\n");
+ if (mode == HUMAN) {
+ printf("Color table has changed from:\n");
+ for (mp1 = mater_hd1; mp1 != MATER_NULL; mp1 = mp1->mt_forw) {
+ printf("\t%d..%d %d %d %d\n", mp1->mt_low, mp1->mt_high,
+ mp1->mt_r, mp1->mt_g, mp1->mt_b);
+ }
+ printf("\t\tto:\n");
+ for (mp2 = mater_hd2; mp2 != MATER_NULL; mp2 = mp2->mt_forw) {
+ printf("\t%d..%d %d %d %d\n", mp2->mt_low, mp2->mt_high,
+ mp2->mt_r, mp2->mt_g, mp2->mt_b);
+ }
+ } else {
+ if (version2 > 4) {
+ /* punt, just delete the existing colortable and print a new one */
+ printf("attr rm _GLOBAL regionid_colortable\n");
for (mp2 = mater_hd2; mp2 != MATER_NULL; mp2 = mp2->mt_forw) {
- printf("\t%d..%d %d %d %d\n", mp2->mt_low, mp2->mt_high,
- mp2->mt_r, mp2->mt_g, mp2->mt_b);
- }
- } else {
- if (version2 > 4)
- printf("attr rm _GLOBAL regionid_colortable\n");
- for (mp2 = mater_hd2; mp2 != MATER_NULL; mp2 = mp2->mt_forw) {
printf("color %d %d %d %d %d\n", mp2->mt_low, mp2->mt_high,
mp2->mt_r, mp2->mt_g, mp2->mt_b);
}
}
- return 1;
}
- return 0;
+ return 1;
}
+
void
kill_obj(char *name)
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits