Re: clue on sparky

2002-12-23 Thread Emil Styrke
Jack Howarth <[EMAIL PROTECTED]> writes:

> I believe I may have a clue as to why sparky is segfaulting in
> when run as a python extension. The upstream maintainer is using
> python 2.1.1 and tcl 8.3.4 so I built against our python 2.1.3 and
> tck 8.3.3. However I just noticed that sid's python2.1 is in
> fact built against tcl-8.4 now. Could this case problems if one
> builds a python2.1 module against tcl8.3 instead and try to import it?

Yes, I believe it could.  I got the same problem when I tried to use
python-opengl linked against tk8.3, in my tk8.4 system.

> I tried building sparky against tcl8.4 but got errors of the form...
> 
> g++-2.95 -O2 -fPIC -I/usr/include/tcl8.4 -c 
> /usr/local/src/sparky/c++/winsystem-unix.cc
> In file included from /usr/local/src/sparky/c++/winsystem-unix.cc:9:
> /usr/local/src/sparky/c++/winsystem-all.cc: In function `void 
> update_argv(WinSysP *, int *, char **)':
> /usr/local/src/sparky/c++/winsystem-all.cc:354: initialization to `char *' 
> from `const char *' discards qualifiers
> /usr/local/src/sparky/c++/winsystem-all.cc:360: passing `char ***' as 
> argument 4 of `Tcl_SplitList(Tcl_Interp *, const char *, int *, const char 
> ***)' adds cv-quals without intervening `const'
> /usr/local/src/sparky/c++/winsystem-all.cc: In method 
> `Command_Callback::Command_Callback(WinSysP *, void *, void (*)(void *, void 
> *, void *), void *, bool = true)':
> /usr/local/src/sparky/c++/winsystem-all.cc:1717: passing `int (*)(void *, 
> Tcl_Interp *, int, char **)' as argument 3 of `add_tcl_command(WinSysP *, 
> const Stringy &, int (*)(void *, Tcl_Interp *, int, const char **), void *)'
> 
> ..etc. Anyone have any idea how to properly handle those?

Maybe some variables have been declared constant in tcl8.4 that were
previously non-const?  Then the variables in your code needs to be
const as well.

/Emil




Re: clue on sparky

2002-12-23 Thread Jack Howarth
Emil,
   Actually it is probably something else. I had a user with YellowDog
Linux 2.3 try sparky against python 2.1.1 and tcl 8.3.3 and he segfaults
as well. Are you on i386 or ppc debian? If i386, I would be very interested
if sparky segfaults on that arch as well. It has been built on redhat
linux for i386 by the author so it shouldn't segfault on that arch.
  Jack



Re: clue on sparky

2002-12-23 Thread Emil Styrke
Jack Howarth <[EMAIL PROTECTED]> writes:

> Emil,
>Actually it is probably something else. I had a user with YellowDog
> Linux 2.3 try sparky against python 2.1.1 and tcl 8.3.3 and he segfaults
> as well. Are you on i386 or ppc debian? If i386, I would be very interested
> if sparky segfaults on that arch as well. It has been built on redhat
> linux for i386 by the author so it shouldn't segfault on that arch.

Ok.  I'm on ppc, though.

/Emil



sparky problems resolved

2002-12-23 Thread Jack Howarth
Just in case anyone is interested, I have resolved the problems
of building a usable python version of sparky with debian ppc sid by
patching it to build under gcc 3.2.2. Interestingly the gcc 2.95.4
build segfaults but a gcc 3.2.2 build works fine. Since sparky uses
its own __tkinter.so with threads disabled I am able to build against
tcl8.3 even though sid's python 2.1 is built against tcl8.4. The
attached patch has been sent upstream.
  Jack
diff -uNr sparky/c++/assignguess.cc sparky.works/c++/assignguess.cc
--- sparky/c++/assignguess.cc	1999-11-09 11:38:31.0 -0500
+++ sparky.works/c++/assignguess.cc	2002-12-23 18:20:01.0 -0500
@@ -144,7 +144,7 @@
 	{
 	  double pos = interval_mod(r->frequency(),
 	alias_onto.min[a], alias_onto.max[a]);
-	  dev += abs(pos - center[a]) / threshold;
+	  dev += myabs(pos - center[a]) / threshold;
 	}
 	}
   }
diff -uNr sparky/c++/brukerfile.cc sparky.works/c++/brukerfile.cc
--- sparky/c++/brukerfile.cc	2000-05-26 23:10:55.0 -0400
+++ sparky.works/c++/brukerfile.cc	2002-12-23 18:20:01.0 -0500
@@ -30,7 +30,11 @@
 // SW_h = sweep width in Hz = SFO1 * SW (4587.155342)
 //
 
+#if __GNUC__ >= 3
+#include 
+#else
 #include 		// Use ifstream
+#endif
 #include 		// Use FILE *
 #include 		// Use atoi()
 #include 		// Use strchr()
diff -uNr sparky/c++/contour.cc sparky.works/c++/contour.cc
--- sparky/c++/contour.cc	1999-12-14 12:36:12.0 -0500
+++ sparky.works/c++/contour.cc	2002-12-23 18:20:01.0 -0500
@@ -127,12 +127,12 @@
 	// Should really use floor() and ceil() here but it creates
 	// off by one rounding problems.
 
-	index_region.min[a] = round(sp->map(r.max[a], a, PPM, INDEX));
-	index_region.max[a] = round(sp->map(r.min[a], a, PPM, INDEX));
+	index_region.min[a] = myround(sp->map(r.max[a], a, PPM, INDEX));
+	index_region.max[a] = myround(sp->map(r.min[a], a, PPM, INDEX));
   }
 else
   {
-	int center = round(sp->map(r.center(a), a, PPM, INDEX));
+	int center = myround(sp->map(r.center(a), a, PPM, INDEX));
 	index_region.min[a] = center;
 	index_region.max[a] = center;
   }
diff -uNr sparky/c++/format.cc sparky.works/c++/format.cc
--- sparky/c++/format.cc	2001-11-13 16:46:31.0 -0500
+++ sparky.works/c++/format.cc	2002-12-23 18:20:01.0 -0500
@@ -1,6 +1,10 @@
 // 
 //
+#if __GNUC__ >= 3
+#include 
+#else
 #include 		// Use ostream, istream
+#endif
 #include 		// Use sprintf(), fputc(), ...
 #include 		// Use strchr(), strcmp()
 #include 		// Use isspace(), isalpha()
@@ -3530,7 +3534,7 @@
 		fprintf(fp, "extraPeakPlanes");
 		for (i = 0; i < sp->dimension(); i++) {
 		  double d = sp->scale(v->visible_depth(i), i, PPM, INDEX);
-		  fprintf(fp, " %d", max(0, round(d-1)));
+		  fprintf(fp, " %d", max(0, myround(d-1)));
 		}
 		fputc('\n', fp);
 		}
diff -uNr sparky/c++/format.h sparky.works/c++/format.h
--- sparky/c++/format.h	1999-11-24 15:43:07.0 -0500
+++ sparky.works/c++/format.h	2002-12-23 18:20:01.0 -0500
@@ -4,8 +4,13 @@
 #ifndef FORMAT_HEADER_INCLUDED
 #define FORMAT_HEADER_INCLUDED
 
+#if __GNUC__ >= 3
+#include 
+using namespace std;
+#else
 class istream;
 class ostream;
+#endif
 
 class Condition;
 class Object_Table;
diff -uNr sparky/c++/integrate.cc sparky.works/c++/integrate.cc
--- sparky/c++/integrate.cc	1999-12-10 16:59:54.0 -0500
+++ sparky.works/c++/integrate.cc	2002-12-23 18:20:01.0 -0500
@@ -309,7 +309,7 @@
 	for (int row = 0; row < h; row++) {
 		for (int col = 0; col < w; col++) {
 			double weighted_height = (*dp++) * (*wp++);
-			double abs_height = abs(weighted_height);
+			double abs_height = myabs(weighted_height);
 			integral += weighted_height;
 			abs_integral += abs_height;
 			comx += col * abs_height;
@@ -542,7 +542,7 @@
 		Peak *pk2 = (Peak *) overlapped[pi2];
 		bool close = true;
 		for (int a = 0 ; a < sp->dimension() ; ++a)
-		  if (abs(pk1->position()[a] - pk2->position()[a])
+		  if (myabs(pk1->position()[a] - pk2->position()[a])
 		  > sp->mIntegrate.grouping_dist[a])
 		close = false;
 		if (close)
diff -uNr sparky/c++/label.cc sparky.works/c++/label.cc
--- sparky/c++/label.cc	2001-12-06 19:28:36.0 -0500
+++ sparky.works/c++/label.cc	2002-12-23 18:20:01.0 -0500
@@ -15,6 +15,7 @@
 #include "mathconst.h"		// use MC_PI
 #include "memalloc.h"		// use new()
 #include "notifier.h"	// use Notifier
+#include 
 #include "num.h"
 #include "peakgp.h"
 #include "peak.h"
@@ -602,12 +603,12 @@
 		pointerLab1Y = labelCenterY + deltaY - labelYDelta * factor;
 		pointerLab2Y = labelCenterY - deltaY - labelYDelta * factor;
 	}
-	else if (is_between(abs(aOL), 135, 180)
-		 && is_between(abs(aOR), 135, 180)) {
+	else if (is_between(myabs(aOL), 135, 180)
+		 && is_between(myabs(aOR), 135, 180)) {
 		/*
 		 * case C, label left of peak
 		 */
-		factor = (aOR