Commit 2284749c authored by Emden R. Gansner's avatar Emden R. Gansner

Various fixes provided by Robert Hart, with small changes.

Some of the absolute value tests aren't necessary; we just want
a test for being non-zero. In addition, freeing the result of parseSegs
is a little more delicate.
parent 149de55f
......@@ -146,7 +146,7 @@ static void computeBounds(ellipse_t * ep)
double bOnA = ep->b / ep->a;
double etaXMin, etaXMax, etaYMin, etaYMax;
if (abs(ep->sinTheta) < 0.1) {
if (fabs(ep->sinTheta) < 0.1) {
double tanTheta = ep->sinTheta / ep->cosTheta;
if (ep->cosTheta < 0) {
etaXMin = -atan(tanTheta * bOnA);
......@@ -365,7 +365,7 @@ estimateError(ellipse_t * ep, int degree, double etaA, double etaB)
double dx = xB - xA;
double dy = yB - yA;
return abs(x * dy - y * dx + xB * yA - xA * yB)
return fabs(x * dy - y * dx + xB * yA - xA * yB)
/ sqrt(dx * dx + dy * dy);
} else {
......
......@@ -397,6 +397,10 @@ static double getSegLen (char* s)
* 3 => warning message
* There is a last sentinel segment with color == NULL; it will always follow
* the last segment with t > 0.
*
* Note that psegs is only assigned to if the return value is 0 or 3.
* Otherwise, psegs is left unchanged and the allocated memory is
* freed before returning.
*/
static int
parseSegs (char* clrs, int nseg, colorsegs_t** psegs)
......@@ -2151,7 +2155,7 @@ static int multicolor (GVJ_t * job, edge_t * e, char** styles, char* colors, int
if ((ED_spl(e)->size>1) && (bz.sflag||bz.eflag) && styles)
gvrender_set_style(job, styles);
}
free (segs);
freeSegs (segs);
return 0;
}
......@@ -4129,12 +4133,13 @@ int gvRenderJobs (GVC_t * gvc, graph_t * g)
*/
boolean findStopColor (char* colorlist, char* clrs[2], float* frac)
{
colorsegs_t* segs;
colorsegs_t* segs = NULL;
int rv;
rv = parseSegs (colorlist, 0, &segs);
if (rv || (segs->numc < 2) || (segs->segs[0].color == NULL)) {
clrs[0] = NULL;
freeSegs (segs);
return FALSE;
}
......
......@@ -1873,7 +1873,7 @@ static void poly_init(node_t * n)
dimen = ND_label(n)->dimen;
/* minimal whitespace around label */
if (ROUND(abs(dimen.x)) || ROUND(abs(dimen.y))) {
if ((dimen.x > 0) || (dimen.y > 0)) {
/* padding */
if ((p = agget(n, "margin"))) {
marginx = marginy = 0;
......
......@@ -184,7 +184,8 @@ static PostscriptAlias* translate_postscript_fontname(char* fontname)
static PostscriptAlias *result;
if (key.name == NULL || strcasecmp(key.name, fontname)) {
key.name = fontname;
free(key.name);
key.name = strdup(fontname);
result = (PostscriptAlias *) bsearch((void *) &key,
(void *) postscript_alias,
sizeof(postscript_alias) / sizeof(PostscriptAlias),
......
......@@ -455,7 +455,7 @@ static void gvevent_motion(GVJ_t * job, pointf pointer)
double dx = (pointer.x - job->oldpointer.x) / job->devscale.x;
double dy = (pointer.y - job->oldpointer.y) / job->devscale.y;
if (abs(dx) < EPSILON && abs(dy) < EPSILON) /* ignore motion events with no motion */
if (fabs(dx) < EPSILON && fabs(dy) < EPSILON) /* ignore motion events with no motion */
return;
switch (job->button) {
......
......@@ -1007,7 +1007,7 @@ static boolean _neato_set_aspect(graph_t * g)
/* compute_bb(g); */
if (GD_drawing(g)->ratio_kind) {
if ((abs(GD_bb(g).LL.x)) || (abs(GD_bb(g).LL.y))) {
if (GD_bb(g).LL.x || GD_bb(g).LL.y) {
translated = TRUE;
neato_translate (g);
}
......
......@@ -756,7 +756,7 @@ float *mdsModel(vtx_data * graph, int nG)
j = graph[i].edges[e];
if (j < i)
continue;
delta += abs(Dij[i * nG + j - shift] - graph[i].ewgts[e]);
delta += fabsf(Dij[i * nG + j - shift] - graph[i].ewgts[e]);
Dij[i * nG + j - shift] = graph[i].ewgts[e];
}
}
......
......@@ -508,8 +508,8 @@ static void pov_begin_graph(GVJ_t * job)
x = job->view.x / 2.0 * job->scale.x;
y = job->view.y / 2.0 * job->scale.y;
d = -500;
px = atanf(x / abs(d)) * 180 / M_PI * 2;
py = atanf(y / abs(d)) * 180 / M_PI * 2;
px = atanf(x / fabsf(d)) * 180 / M_PI * 2;
py = atanf(y / fabsf(d)) * 180 / M_PI * 2;
gvprintf(job, POV_CAMERA, x, y, d, x, y, 0.0,
(px > py ? px : py) * 1.2);
gvputs(job, POV_SKY_AND_GND);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment