Skip to content

Commit 6abe366

Browse files
author
sfeam
committed
do not call term->arrow() if the entire arrow is out of range
1 parent 4c7fccf commit 6abe366

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/gadgets.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.140 2017-08-01 01:19:37 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: gadgets.c,v 1.141 2017-10-31 18:51:23 sfeam Exp $"); }
33
#endif
44

55
/* GNUPLOT - gadgets.c */
@@ -253,8 +253,7 @@ draw_clip_line(int x1, int y1, int x2, int y2)
253253
struct termentry *t = term;
254254

255255
if (!clip_line(&x1, &y1, &x2, &y2))
256-
/* clip_line() returns zero --> segment completely outside
257-
* bounding box */
256+
/* clip_line() returns zero if segment completely outside bounding box */
258257
return;
259258

260259
(*t->move) (x1, y1);
@@ -318,11 +317,11 @@ draw_clip_arrow( int sx, int sy, int ex, int ey, int head)
318317
head &= ~BACKHEAD;
319318
if (clip_point(ex,ey))
320319
head &= ~END_HEAD;
321-
clip_line(&sx, &sy, &ex, &ey);
322320

323-
/* Call terminal routine to draw the clipped arrow */
324-
(*t->arrow)((unsigned int)sx, (unsigned int)sy,
325-
(unsigned int)ex, (unsigned int)ey, head);
321+
/* clip_line returns 0 if the whole thing is out of range */
322+
if (clip_line(&sx, &sy, &ex, &ey))
323+
(*t->arrow)((unsigned int)sx, (unsigned int)sy,
324+
(unsigned int)ex, (unsigned int)ey, head);
326325
}
327326

328327
/* Clip the given line to drawing coords defined by BoundingBox.
@@ -428,11 +427,6 @@ clip_line(int *x1, int *y1, int *x2, int *y2)
428427
*y2 = y_intr[1];
429428
}
430429
} else if (pos1) { /* Only x1/y1 was out - update only it */
431-
/* Nov 2010: When clip_line() and draw_clip_line() were consolidated in */
432-
/* 2000, the test below was the only point of difference between them. */
433-
/* Unfortunately, the wrong version was kept. Now I change it back. */
434-
/* The effect of the wrong version (>= rather than >) was that a line */
435-
/* from ymin to ymax+eps was clipped to ymin,ymin rather than ymin,ymax */
436430
if (dx * (*x2 - x_intr[0]) + dy * (*y2 - y_intr[0]) > 0) {
437431
*x1 = x_intr[0];
438432
*y1 = y_intr[0];

0 commit comments

Comments
 (0)