sparky problems resolved
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.000000000 -0500
+++ sparky.works/c++/assignguess.cc 2002-12-23 18:20:01.000000000 -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.000000000 -0400
+++ sparky.works/c++/brukerfile.cc 2002-12-23 18:20:01.000000000 -0500
@@ -30,7 +30,11 @@
// SW_h = sweep width in Hz = SFO1 * SW (4587.155342)
//
+#if __GNUC__ >= 3
+#include <fstream>
+#else
#include <fstream.h> // Use ifstream
+#endif
#include <stdio.h> // Use FILE *
#include <stdlib.h> // Use atoi()
#include <string.h> // Use strchr()
diff -uNr sparky/c++/contour.cc sparky.works/c++/contour.cc
--- sparky/c++/contour.cc 1999-12-14 12:36:12.000000000 -0500
+++ sparky.works/c++/contour.cc 2002-12-23 18:20:01.000000000 -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.000000000 -0500
+++ sparky.works/c++/format.cc 2002-12-23 18:20:01.000000000 -0500
@@ -1,6 +1,10 @@
// ----------------------------------------------------------------------------
//
+#if __GNUC__ >= 3
+#include <iostream>
+#else
#include <iostream.h> // Use ostream, istream
+#endif
#include <stdio.h> // Use sprintf(), fputc(), ...
#include <string.h> // Use strchr(), strcmp()
#include <ctype.h> // 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.000000000 -0500
+++ sparky.works/c++/format.h 2002-12-23 18:20:01.000000000 -0500
@@ -4,8 +4,13 @@
#ifndef FORMAT_HEADER_INCLUDED
#define FORMAT_HEADER_INCLUDED
+#if __GNUC__ >= 3
+#include <iosfwd>
+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.000000000 -0500
+++ sparky.works/c++/integrate.cc 2002-12-23 18:20:01.000000000 -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.000000000 -0500
+++ sparky.works/c++/label.cc 2002-12-23 18:20:01.000000000 -0500
@@ -15,6 +15,7 @@
#include "mathconst.h" // use MC_PI
#include "memalloc.h" // use new()
#include "notifier.h" // use Notifier
+#include <math.h>
#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 / abs(aOR)) * (180 - abs(aOR)) / 45;
+ factor = (aOR / myabs(aOR)) * (180 - myabs(aOR)) / 45;
factor = labelCenterY > peakCenterY
? max(factor, 0.0) : min(factor, 0.0);
diff -uNr sparky/c++/line.cc sparky.works/c++/line.cc
--- sparky/c++/line.cc 1999-12-01 13:08:59.000000000 -0500
+++ sparky.works/c++/line.cc 2002-12-23 18:20:01.000000000 -0500
@@ -29,7 +29,7 @@
SPoint delta = r1 - r2;
for (int a = 1 ; a < sp->dimension() ; ++a)
- if (abs(delta[a]) > abs(delta[long_axis]))
+ if (myabs(delta[a]) > myabs(delta[long_axis]))
long_axis = a;
SPoint center = (r1 + r2) * .5;
diff -uNr sparky/c++/linefit.cc sparky.works/c++/linefit.cc
--- sparky/c++/linefit.cc 2001-12-06 19:30:08.000000000 -0500
+++ sparky.works/c++/linefit.cc 2002-12-23 18:20:01.000000000 -0500
@@ -248,7 +248,7 @@
double vol = fit_volume();
double fe = (vol != 0 ?
- npoints * sqrt(residual / npoints) / abs(vol) :
+ npoints * sqrt(residual / npoints) / myabs(vol) :
0);
SPoint pos = sp->map(position(), INDEX, PPM);
diff -uNr sparky/c++/lusolve.cc sparky.works/c++/lusolve.cc
--- sparky/c++/lusolve.cc 2000-02-08 11:43:03.000000000 -0500
+++ sparky.works/c++/lusolve.cc 2002-12-23 18:20:01.000000000 -0500
@@ -19,7 +19,7 @@
for (i=1;i<=n;i++) {
big=0.0;
for (j=1;j<=n;j++)
- if ((temp=abs(a[i][j])) > big) big=temp;
+ if ((temp=myabs(a[i][j])) > big) big=temp;
if (big == 0.0)
return false;
vv[i]=1.0/big;
@@ -36,7 +36,7 @@
for (k=1;k<j;k++)
sum -= a[i][k]*a[k][j];
a[i][j]=sum;
- if ( (dum=vv[i]*abs(sum)) >= big) {
+ if ( (dum=vv[i]*myabs(sum)) >= big) {
big=dum;
imax=i;
}
diff -uNr sparky/c++/memalloc.cc sparky.works/c++/memalloc.cc
--- sparky/c++/memalloc.cc 2000-08-09 14:11:53.000000000 -0400
+++ sparky.works/c++/memalloc.cc 2002-12-23 18:20:01.000000000 -0500
@@ -2,7 +2,11 @@
// Replace new and delete with versions that keep track of all allocated
// blocks for debugging memory leaks.
//
+#if __GNUC__ >= 3
+#include <iostream>
+#else
#include <iostream.h> // use cerr
+#endif
#include <stdlib.h> // use malloc(), free()
#include <string.h> // use strcmp()
@@ -11,8 +15,10 @@
#include "table.h" // use Table
#include "utility.h" // use fatal_error()
+#if __GNUC__ < 3
#undef new
#undef delete
+#endif
// ----------------------------------------------------------------------------
//
@@ -40,6 +46,9 @@
// ----------------------------------------------------------------------------
//
void *operator new(size_t size)
+#if __GNUC__ >= 3
+ throw(std::bad_alloc)
+#endif
{
void *value = allocate(size);
if (tracking_memory)
@@ -73,6 +82,9 @@
// ----------------------------------------------------------------------------
//
void *operator new[](size_t size)
+#if __GNUC__ >= 3
+ throw(std::bad_alloc)
+#endif
{
void *value = allocate(size);
if (tracking_memory)
@@ -92,6 +104,9 @@
// ----------------------------------------------------------------------------
//
void operator delete(void *p)
+#if __GNUC__ >= 3
+ throw()
+#endif
{
if (tracking_memory)
forget(p);
@@ -101,6 +116,9 @@
// ----------------------------------------------------------------------------
//
void operator delete[](void *p)
+#if __GNUC__ >= 3
+ throw()
+#endif
{
if (tracking_memory)
forget(p);
diff -uNr sparky/c++/memalloc.h sparky.works/c++/memalloc.h
--- sparky/c++/memalloc.h 2000-02-07 21:34:12.000000000 -0500
+++ sparky.works/c++/memalloc.h 2002-12-23 18:20:01.000000000 -0500
@@ -19,11 +19,16 @@
#include <stddef.h> // use size_t
+#if __GNUC__ >= 3
+#include <new>
+using namespace std;
+#else
void *operator new(size_t size);
void operator delete(void *p);
void *operator new[](size_t size);
void operator delete[](void *p);
+#endif
// ----------------------------------------------------------------------------
// The lines below are for tracking all memory allocated with new.
diff -uNr sparky/c++/nmrdata.cc sparky.works/c++/nmrdata.cc
--- sparky/c++/nmrdata.cc 2001-11-15 17:04:04.000000000 -0500
+++ sparky.works/c++/nmrdata.cc 2002-12-23 18:20:01.000000000 -0500
@@ -2,7 +2,11 @@
// NMR data file reading and writing.
//
+#if __GNUC__ >= 3
+#include <iostream>
+#else
#include <iostream.h> // use ostream
+#endif
#include <math.h> // use fabs()
#include "blockfile.h" // Use Block_File, block_region()
diff -uNr sparky/c++/nmrdata.h sparky.works/c++/nmrdata.h
--- sparky/c++/nmrdata.h 2001-11-15 16:57:33.000000000 -0500
+++ sparky.works/c++/nmrdata.h 2002-12-23 18:20:01.000000000 -0500
@@ -9,7 +9,12 @@
#include "spoint.h" // Use SPoint, IPoint, IRegion
#include "stringc.h" // Use Stringy
+#if __GNUC__ >= 3
+#include <iosfwd>
+using namespace std;
+#else
class ostream;
+#endif
class Block_File;
diff -uNr sparky/c++/num.cc sparky.works/c++/num.cc
--- sparky/c++/num.cc 1999-01-29 05:07:03.000000000 -0500
+++ sparky.works/c++/num.cc 2002-12-23 18:20:01.000000000 -0500
@@ -27,9 +27,11 @@
// ----------------------------------------------------------------------------
//
-long abs(long a)
+int myabs(int a)
{ return a >= 0 ? a : -a; }
-double abs(double a)
+long myabs(long a)
+ { return a >= 0 ? a : -a; }
+double myabs(double a)
{ return a >= 0 ? a : -a; }
// ----------------------------------------------------------------------------
@@ -50,7 +52,7 @@
// ----------------------------------------------------------------------------
//
-int round(double x)
+int myround(double x)
{ return (int) (x >= 0 ? x + .5 : x - .5); }
// ----------------------------------------------------------------------------
@@ -58,7 +60,7 @@
//
double round_multiple(double x, double unit)
{
- return round(x / unit) * unit;
+ return myround(x / unit) * unit;
}
// ----------------------------------------------------------------------------
diff -uNr sparky/c++/num.h sparky.works/c++/num.h
--- sparky/c++/num.h 1999-01-29 05:07:13.000000000 -0500
+++ sparky.works/c++/num.h 2002-12-23 18:20:01.000000000 -0500
@@ -18,13 +18,14 @@
unsigned int max(unsigned int a, unsigned int b);
double max(double a, double b);
-long abs(long a);
-double abs(double a);
+int myabs(int a);
+long myabs(long a);
+double myabs(double a);
double floor(double x, double step);
double floor(double x, double a, double b);
double ceil(double x, double step);
-int round(double x);
+int myround(double x);
double round_multiple(double x, double unit);
double interval_mod(double x, double a, double b);
diff -uNr sparky/c++/peak.cc sparky.works/c++/peak.cc
--- sparky/c++/peak.cc 2001-12-06 19:31:04.000000000 -0500
+++ sparky.works/c++/peak.cc 2002-12-23 18:20:01.000000000 -0500
@@ -109,7 +109,7 @@
double Peak::SignalToNoise() const
{
- return abs(DataHeight()) / spectrum()->noise_level();
+ return myabs(DataHeight()) / spectrum()->noise_level();
}
//
diff -uNr sparky/c++/peakgp.cc sparky.works/c++/peakgp.cc
--- sparky/c++/peakgp.cc 1999-12-01 13:08:58.000000000 -0500
+++ sparky.works/c++/peakgp.cc 2002-12-23 18:20:01.000000000 -0500
@@ -196,7 +196,7 @@
double vol;
if (pk->volume(&vol))
{
- vol = abs(vol);
+ vol = myabs(vol);
volume_sum += vol;
freq += pk->frequency() * vol;
}
diff -uNr sparky/c++/peakpick.cc sparky.works/c++/peakpick.cc
--- sparky/c++/peakpick.cc 1999-11-24 16:08:36.000000000 -0500
+++ sparky.works/c++/peakpick.cc 2002-12-23 18:20:01.000000000 -0500
@@ -306,11 +306,11 @@
//
static int separation(const IPoint &p1, const IPoint &p2)
{
- int max = abs(p1[0] - p2[0]);
+ int max = myabs(p1[0] - p2[0]);
for (int i = 1; i < p1.dimension(); i++)
{
- int sep = abs(p1[i] - p2[i]);
+ int sep = myabs(p1[i] - p2[i]);
if (sep > max)
max = sep;
}
diff -uNr sparky/c++/print.cc sparky.works/c++/print.cc
--- sparky/c++/print.cc 2001-10-02 14:12:06.000000000 -0400
+++ sparky.works/c++/print.cc 2002-12-23 18:20:01.000000000 -0500
@@ -239,11 +239,11 @@
height = inch_to_cm(height);
double x_page_size = vp->scale(po.fixed_scales[0], X, PPM, u) * width;
- double x_size = abs(layout.start[0]-layout.end[0]);
+ double x_size = myabs(layout.start[0]-layout.end[0]);
layout.pages[0] = (x_page_size > 0 ? (int) ceil(x_size/x_page_size) : 1);
double y_page_size = vp->scale(po.fixed_scales[1], Y, PPM, u) * height;
- double y_size = abs(layout.start[1]-layout.end[1]);
+ double y_size = myabs(layout.start[1]-layout.end[1]);
layout.pages[1] = (y_page_size > 0 ? (int) ceil(y_size/y_page_size) : 1);
}
else
@@ -282,7 +282,7 @@
{
int ticks = 5; /* the default value */
- incr = abs(incr);
+ incr = myabs(incr);
if (incr == 0)
return ticks;
@@ -514,8 +514,8 @@
if (opt.fixed_scale) {
double scx = vp->scale(max(opt.fixed_scales[0], .001), X, PPM, u);
double scy = vp->scale(max(opt.fixed_scales[1], .001), Y, PPM, u);
- width = cm_to_inch(abs(bl_x - tr_x) / scx);
- height = cm_to_inch(abs(bl_y - tr_y) / scy);
+ width = cm_to_inch(myabs(bl_x - tr_x) / scx);
+ height = cm_to_inch(myabs(bl_y - tr_y) / scy);
}
//
@@ -788,7 +788,7 @@
/*
* Initialize the font
*/
- int font_size = round(72 * font_height * scale / dpi); // Point size
+ int font_size = myround(72 * font_height * scale / dpi); // Point size
fprintf(fp, "/XfR /%s bindFont XfR\n", RESFONTNAME);
fprintf(fp, "/resScale %d SC def\n", font_size);
// fprintf(fp, "/resScale %d SC def\n", RESFONTSIZE);
@@ -901,7 +901,7 @@
fprintf(to, "/SparkyMajorVersion %d def\n", SPARKY_VERSION);
fprintf(to, "/SparkyMinorVersion %d def\n", SPARKY_RELEASE);
fprintf(to, "/SCALE %f def\n", (double) UPI / DPI);
- fprintf(to, "/PEAKLINEWIDTH %d def\n", round(0.015 * DPI));
+ fprintf(to, "/PEAKLINEWIDTH %d def\n", myround(0.015 * DPI));
/*
* Set up the color array which maps pixels to colors.
@@ -1229,14 +1229,14 @@
* Print the moveto point. The "M" PostScript operator
* does a "moveto".
*/
- int px1 = round((x[0] - index_xoffset) * index_xscale);
- int py1 = round((y[0] - index_yoffset) * index_yscale);
+ int px1 = myround((x[0] - index_xoffset) * index_xscale);
+ int py1 = myround((y[0] - index_yoffset) * index_yscale);
fprintf(fp, "%d %d M\n", px1, py1);
for (int s = 1 ; s < len ; ++s)
{
- int px = round((x[2*s] - index_xoffset) * index_xscale);
- int py = round((y[2*s] - index_yoffset) * index_yscale);
+ int px = myround((x[2*s] - index_xoffset) * index_xscale);
+ int py = myround((y[2*s] - index_yoffset) * index_yscale);
fprintf(fp, "%d %d L\n", px, py);
}
@@ -1297,7 +1297,7 @@
static int decimals_after_point(double step)
{
int prec = 0;
- for (step = abs(step) ; step < .999 && prec <= 8 ; step *= 10)
+ for (step = myabs(step) ; step < .999 && prec <= 8 ; step *= 10)
prec += 1;
return prec;
diff -uNr sparky/c++/python.cc sparky.works/c++/python.cc
--- sparky/c++/python.cc 2001-11-15 17:04:29.000000000 -0500
+++ sparky.works/c++/python.cc 2002-12-23 18:20:01.000000000 -0500
@@ -26,7 +26,12 @@
//
#include <stdio.h> // use FILE
+
+#if __GNUC__ >= 3
+#include <fstream>
+#else
#include <fstream.h> // use ofstream, ifstream
+#endif
#include <Python.h> // Use PyObject
#include <tcl.h> // Use Tcl_Interp
diff -uNr sparky/c++/rectangle.cc sparky.works/c++/rectangle.cc
--- sparky/c++/rectangle.cc 1999-01-29 05:07:03.000000000 -0500
+++ sparky.works/c++/rectangle.cc 2002-12-23 18:20:01.000000000 -0500
@@ -2,7 +2,11 @@
// Rectangles in the plane.
//
+#if __GNUC__ >= 3
+#include <iostream>
+#else
#include <iostream.h>
+#endif
#include <math.h> // Use fabs()
#include "list.h" // use List
diff -uNr sparky/c++/rectangle.h sparky.works/c++/rectangle.h
--- sparky/c++/rectangle.h 1999-01-29 05:07:15.000000000 -0500
+++ sparky.works/c++/rectangle.h 2002-12-23 18:20:01.000000000 -0500
@@ -6,7 +6,12 @@
#define RECTANGLE_HEADER_INCLUDED
class List;
+#if __GNUC__ >= 3
+#include <iosfwd>
+using namespace std;
+#else
class ostream;
+#endif
enum Axis {X, Y, NOT_XY};
diff -uNr sparky/c++/resonance.cc sparky.works/c++/resonance.cc
--- sparky/c++/resonance.cc 2000-06-12 18:47:05.000000000 -0400
+++ sparky.works/c++/resonance.cc 2002-12-23 18:20:01.000000000 -0500
@@ -379,7 +379,7 @@
double pos1 = interval_mod(r1->frequency(), alias_min, alias_max);
double pos2 = interval_mod(r2->frequency(), alias_min, alias_max);
- return compare_doubles(abs(pos1 - center), abs(pos2 - center));
+ return compare_doubles(myabs(pos1 - center), myabs(pos2 - center));
}
// ----------------------------------------------------------------------------
diff -uNr sparky/c++/savefile.cc sparky.works/c++/savefile.cc
--- sparky/c++/savefile.cc 2000-03-03 13:27:33.000000000 -0500
+++ sparky.works/c++/savefile.cc 2002-12-23 18:20:01.000000000 -0500
@@ -7,7 +7,11 @@
* Resonance files.
*
*/
+#if __GNUC__ >= 3
+#include <fstream>
+#else
#include <fstream.h> // Use ofstream
+#endif
#include <string.h> // use strstr()
#include "memalloc.h" // use new()
diff -uNr sparky/c++/savefile.h sparky.works/c++/savefile.h
--- sparky/c++/savefile.h 1999-11-24 17:54:17.000000000 -0500
+++ sparky.works/c++/savefile.h 2002-12-23 18:20:01.000000000 -0500
@@ -9,7 +9,13 @@
#include "list.h" // Use List
#include "stringc.h" // Use Stringy
+#if __GNUC__ >= 3
+#include <iosfwd>
+using namespace std;
+#else
class ostream;
+#endif
+
class Session;
enum SAVEFILE_TYPE {
diff -uNr sparky/c++/session.cc sparky.works/c++/session.cc
--- sparky/c++/session.cc 2002-01-17 22:16:11.000000000 -0500
+++ sparky.works/c++/session.cc 2002-12-23 18:20:01.000000000 -0500
@@ -1,7 +1,11 @@
// ----------------------------------------------------------------------------
//
#include <stdlib.h> // Use exit()
+#if __GNUC__ >= 3
+#include <fstream>
+#else
#include <fstream.h> // use ifstream
+#endif
#include "command.h" // Use Command_Dispatcher
#include "contour.h" // close_contour_cache()
diff -uNr sparky/c++/simplex.cc sparky.works/c++/simplex.cc
--- sparky/c++/simplex.cc 1999-11-24 17:19:08.000000000 -0500
+++ sparky.works/c++/simplex.cc 2002-12-23 18:20:01.000000000 -0500
@@ -115,8 +115,8 @@
int lo, hi, nexthi;
get_high_low(y, mpts, &lo, &hi, &nexthi);
- double denom = abs(y[hi]) + abs(y[lo]);
- double rtol = (denom == 0 ? 0 : 2.0 * abs(y[hi] - y[lo]) / denom);
+ double denom = myabs(y[hi]) + myabs(y[lo]);
+ double rtol = (denom == 0 ? 0 : 2.0 * myabs(y[hi] - y[lo]) / denom);
if (rtol < ftol)
{
*best = lo;
diff -uNr sparky/c++/spectrumdata.cc sparky.works/c++/spectrumdata.cc
--- sparky/c++/spectrumdata.cc 2000-12-12 17:26:49.000000000 -0500
+++ sparky.works/c++/spectrumdata.cc 2002-12-23 18:20:01.000000000 -0500
@@ -699,7 +699,7 @@
float *values = new float[sample_count];
IRegion r = sp->index_range();
for (int k = 0 ; k < sample_count ; ++k)
- values[k] = abs(sp->height_at_index(r.random_point()));
+ values[k] = myabs(sp->height_at_index(r.random_point()));
sort_floats(values, sample_count);
double median = values[sample_count/2];
delete values;
diff -uNr sparky/c++/spoint.cc sparky.works/c++/spoint.cc
--- sparky/c++/spoint.cc 2000-01-18 18:27:59.000000000 -0500
+++ sparky.works/c++/spoint.cc 2002-12-23 18:20:01.000000000 -0500
@@ -58,7 +58,7 @@
{
int e[DIM];
for (int d = 0 ; d < dimension() ; ++d)
- e[d] = round((*this)[d]);
+ e[d] = myround((*this)[d]);
return IPoint(dimension(), e);
}
diff -uNr sparky/c++/stringc.cc sparky.works/c++/stringc.cc
--- sparky/c++/stringc.cc 2000-03-03 13:27:32.000000000 -0500
+++ sparky.works/c++/stringc.cc 2002-12-23 18:20:01.000000000 -0500
@@ -1,6 +1,10 @@
// ----------------------------------------------------------------------------
//
+#if __GNUC__ >= 3
+#include <iostream>
+#else
#include <iostream.h> // Use ostream, istream
+#endif
#include <stdarg.h> // use va_start()
#include <stdlib.h> // use atoi()
#include <stdio.h> // Use sprintf()
diff -uNr sparky/c++/stringc.h sparky.works/c++/stringc.h
--- sparky/c++/stringc.h 1999-11-24 16:53:21.000000000 -0500
+++ sparky.works/c++/stringc.h 2002-12-23 18:20:01.000000000 -0500
@@ -8,8 +8,14 @@
#undef NULL // Fix bad define in stddef.h gnu distribution.
#define NULL 0L
+#if __GNUC__ >= 3
+#include <iosfwd>
+using namespace std;
+#else
class istream;
class ostream;
+#endif
+
class List;
class Stringy
diff -uNr sparky/c++/ucsffile.cc sparky.works/c++/ucsffile.cc
--- sparky/c++/ucsffile.cc 2000-12-12 14:26:24.000000000 -0500
+++ sparky.works/c++/ucsffile.cc 2002-12-23 18:20:01.000000000 -0500
@@ -13,6 +13,7 @@
#include "blockfile.h" // Use Block_File
#include "memalloc.h" // use new()
#include "nmrdata.h" // Use NMR_Data
+#include <math.h>
#include "num.h" // Use round(), min(), max()
#include "spoint.h" // Use IPoint, IRegion
#include "system.h" // Use file_owner(), get_username()
@@ -693,22 +694,22 @@
hdr->date[24] = '\0';
hdr->axis = new NMR_AXIS [2];
memset(hdr->axis, 0, 2 * sizeof(NMR_AXIS));
- hdr->axis[T1].bsize = hdr->axis[T2].bsize = round(p.t1t2) - 1;
+ hdr->axis[T1].bsize = hdr->axis[T2].bsize = myround(p.t1t2) - 1;
if (p.t1t2 == 2.0) {
- hdr->axis[T1].npoints = round(p.nypoints);
- hdr->axis[T2].npoints = round(p.nxpoints);
+ hdr->axis[T1].npoints = myround(p.nypoints);
+ hdr->axis[T2].npoints = myround(p.nxpoints);
}
else {
- hdr->axis[T1].npoints = round(p.nxpoints);
- hdr->axis[T2].npoints = round(p.nypoints);
+ hdr->axis[T1].npoints = myround(p.nxpoints);
+ hdr->axis[T2].npoints = myround(p.nypoints);
}
/*
* fill in original axis sizes. May not be originally defined.
*/
- if ((hdr->axis[T1].size = round(p.w1.size)) == 0.0)
+ if ((hdr->axis[T1].size = myround(p.w1.size)) == 0.0)
hdr->axis[T1].size = hdr->axis[T1].npoints;
- if ((hdr->axis[T2].size = round(p.w2.size)) == 0.0)
+ if ((hdr->axis[T2].size = myround(p.w2.size)) == 0.0)
hdr->axis[T2].size = hdr->axis[T2].npoints;
@@ -726,15 +727,15 @@
b->apo.p1.shift = a->shift;
b->apo.p1.line_broad = a->lb;
b->apo.p2.gaussian = a->gn;
- b->flags.nfills = round(a->n_zero_fills);
+ b->flags.nfills = myround(a->n_zero_fills);
b->zero_order = a->zero_order;
b->first_order = a->first_order;
- b->flags.dc_offset = round(a->offset_correct);
- b->flags.ft_code = round(a->ft_code);
- b->flags.spectrum_reverse = round(a->spectrum_reverse);
- b->flags.absolute_value = round(a->abs_val_code);
- b->flags.baseline_fit = round(a->baseline_correct);
- b->flags.baseline_offset = round(a->ridge_subtract);
+ b->flags.dc_offset = myround(a->offset_correct);
+ b->flags.ft_code = myround(a->ft_code);
+ b->flags.spectrum_reverse = myround(a->spectrum_reverse);
+ b->flags.absolute_value = myround(a->abs_val_code);
+ b->flags.baseline_fit = myround(a->baseline_correct);
+ b->flags.baseline_offset = myround(a->ridge_subtract);
b->status.transformed = (unsigned) p.processed[i];
b->spectral_shift = (short) (p.xp.right_shift[i] -
p.xp.left_shift[i]);
diff -uNr sparky/c++/uicontour.cc sparky.works/c++/uicontour.cc
--- sparky/c++/uicontour.cc 2001-10-09 14:59:15.000000000 -0400
+++ sparky.works/c++/uicontour.cc 2002-12-23 18:20:01.000000000 -0500
@@ -4,6 +4,7 @@
#include "color.h" // use Color
#include "memalloc.h" // use new()
#include "notifier.h" // use Notifier
+#include <math.h>
#include "num.h" // Use round()
#include "session.h" // use Session
#include "stringc.h" // Use Stringy
@@ -179,13 +180,13 @@
{
Contour_Parameters pos(true);
pos.levels.lowest = ws.numeric_text_field(ws.table_element(table,1,1));
- pos.levels.levels = round(ws.numeric_text_field(ws.table_element(table,1,2)));
+ pos.levels.levels = myround(ws.numeric_text_field(ws.table_element(table,1,2)));
pos.levels.factor = ws.numeric_text_field(ws.table_element(table,1,3));
pos.set_color_scheme(ws.option_selected(ws.table_element(table,1,4)));
Contour_Parameters neg(false);
neg.levels.lowest = ws.numeric_text_field(ws.table_element(table,2,1));
- neg.levels.levels = round(ws.numeric_text_field(ws.table_element(table,2,2)));
+ neg.levels.levels = myround(ws.numeric_text_field(ws.table_element(table,2,2)));
neg.levels.factor = ws.numeric_text_field(ws.table_element(table,2,3));
neg.set_color_scheme(ws.option_selected(ws.table_element(table,2,4)));
diff -uNr sparky/c++/uidrawing.cc sparky.works/c++/uidrawing.cc
--- sparky/c++/uidrawing.cc 2001-12-11 19:20:33.000000000 -0500
+++ sparky.works/c++/uidrawing.cc 2002-12-23 18:20:01.000000000 -0500
@@ -393,7 +393,7 @@
//
void Drawing::update_font_height()
{
- int pixel_height = bounded(1, round(font_height / pixel_size(Y)), 100);
+ int pixel_height = bounded(1, myround(font_height / pixel_size(Y)), 100);
c->set_font_height(pixel_height);
}
@@ -459,8 +459,8 @@
//
void Drawing::paint_coordinates(double x, double y, int *px, int *py)
{
- *px = round(.5 * vw - (x - x_center) / x_pixel_size);
- *py = round(.5 * vh + (y - y_center) / y_pixel_size);
+ *px = myround(.5 * vw - (x - x_center) / x_pixel_size);
+ *py = myround(.5 * vh + (y - y_center) / y_pixel_size);
}
// ----------------------------------------------------------------------------
@@ -476,16 +476,16 @@
int Drawing::paint_coordinate(double d, Axis a)
{
return (a == X ?
- round(.5 * vw - (d - x_center) / x_pixel_size) :
- round(.5 * vh + (d - y_center) / y_pixel_size));
+ myround(.5 * vw - (d - x_center) / x_pixel_size) :
+ myround(.5 * vh + (d - y_center) / y_pixel_size));
}
// ----------------------------------------------------------------------------
//
void Drawing::translate_view(double delta_x, double delta_y)
{
- int dx = round(delta_x / pixel_size(X));
- int dy = round(delta_y / pixel_size(Y));
+ int dx = myround(delta_x / pixel_size(X));
+ int dy = myround(delta_y / pixel_size(Y));
// This is used before changing the mapping between X window coordinates
// and the image coordinates in translate_view(). If pretranslation exposure
diff -uNr sparky/c++/uiepanel.cc sparky.works/c++/uiepanel.cc
--- sparky/c++/uiepanel.cc 2000-02-09 21:00:09.000000000 -0500
+++ sparky.works/c++/uiepanel.cc 2002-12-23 18:20:01.000000000 -0500
@@ -141,7 +141,7 @@
//
void edge_panel::translate(double delta)
{
- int d = round(delta / pixel_size());
+ int d = myround(delta / pixel_size());
if (d != 0)
{
@@ -312,11 +312,11 @@
{
double h = thickness();
*px = paint_position(x);
- *py = round((h - y) / pixel_size());
+ *py = myround((h - y) / pixel_size());
}
else
{
- *px = round(x / pixel_size());
+ *px = myround(x / pixel_size());
*py = paint_position(y);
}
}
@@ -325,7 +325,7 @@
//
int edge_panel::paint_position(double x)
{
- return round((is_horizontal() ? b - x : x - a) / pixel_size());
+ return myround((is_horizontal() ? b - x : x - a) / pixel_size());
}
// ----------------------------------------------------------------------------
diff -uNr sparky/c++/uipreference.cc sparky.works/c++/uipreference.cc
--- sparky/c++/uipreference.cc 2000-05-30 14:55:26.000000000 -0400
+++ sparky.works/c++/uipreference.cc 2002-12-23 18:20:01.000000000 -0500
@@ -1,6 +1,7 @@
// ----------------------------------------------------------------------------
//
#include "memalloc.h" // use new()
+#include <math.h>
#include "num.h" // Use round()
#include "project.h" // use Project
#include "session.h" // use Session
@@ -127,11 +128,11 @@
((View *) vlist[vi])->set_contour_graying(pref.contour_graying);
double seconds = ws.numeric_edit_value(keytimeout);
- pref.key_timeout_interval = round(seconds * 1000);
+ pref.key_timeout_interval = myround(seconds * 1000);
double minutes = ws.numeric_edit_value(autobackup);
- proj.set_auto_backup(round(minutes * 60));
+ proj.set_auto_backup(myround(minutes * 60));
double mbytes = ws.numeric_edit_value(cachesize);
- proj.set_cache_size(round(mbytes));
+ proj.set_cache_size(myround(mbytes));
}
diff -uNr sparky/c++/uirpanel.cc sparky.works/c++/uirpanel.cc
--- sparky/c++/uirpanel.cc 2000-12-12 14:24:54.000000000 -0500
+++ sparky.works/c++/uirpanel.cc 2002-12-23 18:20:01.000000000 -0500
@@ -377,7 +377,7 @@
for (int psi = 0 ; psi < panel_strings.size() ; ++psi)
{
Panel_String *ps = (Panel_String *) panel_strings[psi];
- double sep = abs(ps->tick_position - freq_ppm);
+ double sep = myabs(ps->tick_position - freq_ppm);
if (closest == NULL || sep < min_sep)
{
min_sep = sep;
diff -uNr sparky/c++/uiscale.cc sparky.works/c++/uiscale.cc
--- sparky/c++/uiscale.cc 1999-12-02 19:29:39.000000000 -0500
+++ sparky.works/c++/uiscale.cc 2002-12-23 18:20:01.000000000 -0500
@@ -138,7 +138,7 @@
double x1 = scale_value(a);
double x2 = scale_value(b);
double minimum_spacing =
- 4 * abs(scale_value(label_spacing()) - scale_value(0));
+ 4 * myabs(scale_value(label_spacing()) - scale_value(0));
*spacing = graph_scale(minimum_spacing);
*first = round_multiple(min(x1, x2), *spacing);
diff -uNr sparky/c++/uislice.cc sparky.works/c++/uislice.cc
--- sparky/c++/uislice.cc 2001-01-04 20:51:11.000000000 -0500
+++ sparky.works/c++/uislice.cc 2002-12-23 18:20:01.000000000 -0500
@@ -73,7 +73,7 @@
int x, y;
if (s->dragging && s->ws.event_xy(event, &x, &y))
{
- int motion = (abs(x - s->last_x) >= abs(y - s->last_y) ?
+ int motion = (myabs(x - s->last_x) >= myabs(y - s->last_y) ?
x - s->last_x : y - s->last_y);
s->last_x = x;
s->last_y = y;
@@ -252,8 +252,8 @@
float **spectrum_data, float **peak_fit,
float **selected_peak, float **difference) const
{
- *d1 = round(view->map(p2, axis, PPM, INDEX));
- *d2 = round(view->map(p1, axis, PPM, INDEX));
+ *d1 = myround(view->map(p2, axis, PPM, INDEX));
+ *d2 = myround(view->map(p1, axis, PPM, INDEX));
IRegion region = slice_region(*d1, *d2);
int size = region.volume();
diff -uNr sparky/c++/uiview.cc sparky.works/c++/uiview.cc
--- sparky/c++/uiview.cc 2001-12-11 19:21:26.000000000 -0500
+++ sparky.works/c++/uiview.cc 2002-12-23 18:20:01.000000000 -0500
@@ -181,7 +181,7 @@
return *(Color *) colors[0];
double e = log(r) / log(levels.factor);
- int i = round(colors.size() * e / levels.levels);
+ int i = myround(colors.size() * e / levels.levels);
if (i < 0)
i = 0;
else if (i >= colors.size())
@@ -1077,8 +1077,8 @@
void View::drag(double x, double y)
{
if (!pick.down || // We didn't get button down event.
- (abs(x - pick.downX) < DRAGMIN * pixel_size(X) &&
- abs(y - pick.downY) < DRAGMIN * pixel_size(Y)))
+ (myabs(x - pick.downX) < DRAGMIN * pixel_size(X) &&
+ myabs(y - pick.downY) < DRAGMIN * pixel_size(Y)))
return;
if (pick.drag)
@@ -2113,7 +2113,7 @@
{
int zaxis = v->axis_order()[2];
double z = sp->map(p[zaxis], zaxis, PPM, INDEX);
- double z_display = round(sp->map(v->center(zaxis), zaxis, PPM, INDEX));
+ double z_display = myround(sp->map(v->center(zaxis), zaxis, PPM, INDEX));
if (z - z_display > .5)
plane = 1;
else if (z - z_display < -.5)
@@ -2470,8 +2470,8 @@
dxdata = pick.lastX - pick.downX;
dydata = pick.lastY - pick.downY;
- if (abs(dxdata) < MINMOVE * pixel_size(X) &&
- abs(dydata) < MINMOVE * pixel_size(Y))
+ if (myabs(dxdata) < MINMOVE * pixel_size(X) &&
+ myabs(dydata) < MINMOVE * pixel_size(Y))
return;
//
Reply to: