File: 36_arrowhead.patch

package info (click to toggle)
fig2dev 1%3A3.2.8b-3%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,008 kB
  • sloc: ansic: 37,618; sh: 7,021; makefile: 175; csh: 12
file content (79 lines) | stat: -rw-r--r-- 2,937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From: Thomas Loimer <thomas.loimer@tuwien.ac.at>
Date: Thu, 11 Aug 2022 23:36:53 +0200
Origin: upstream, https://sourceforge.net/p/mcj/fig2dev/ci/a45dbb6
Bug: https://sourceforge.net/p/mcj/tickets/146/
Subject: Accept arrowheads without any points, ticket #146
 If an arrowhead does not contain any point, fig2dev only crashes for the
 pict2e output language. Nevertheless, check the number of points in an
 arrowhead also for the mp and ps output languages.

--- a/fig2dev/dev/genmp.c
+++ b/fig2dev/dev/genmp.c
@@ -3,7 +3,7 @@
  * Copyright (c) 1991 by Micah Beck
  * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul
  * Parts Copyright (c) 1989-2015 by Brian V. Smith
- * Parts Copyright (c) 2015-2019 by Thomas Loimer
+ * Parts Copyright (c) 2015-2022 by Thomas Loimer
  *
  * Any party obtaining a copy of these files is granted, free of charge, a
  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
@@ -493,6 +493,8 @@ genmp_drawarrow(int from_x, int from_y,
        Information on clipping is discarded */
     calc_arrow(from_x, from_y, to_x, to_y,
 	       obj->thickness, arr, points, &numpoints, fillpoints, &nfillpoints, clippoints, &nclippoints);
+    if (numpoints < 3)
+	return;
 
     fprintf(tfp,"%% Draw arrowhead type %d\n",type);
     fprintf(tfp,"  linecap:=0;\n");	/* butt line cap for arrowheads */
--- a/fig2dev/dev/genpict2e.c
+++ b/fig2dev/dev/genpict2e.c
@@ -1169,6 +1169,8 @@ put_arrow(F_point *p, F_point *q, F_arro
 	calc_arrow(p->x, p->y, q->x, q->y, linethick, a, points, &npoints,
 		   fillpoints, &nfillpoints, clippts, &nclippts);
 	/* reset line-style outside of put_arrow */
+	if (npoints < 2)
+		return;
 
 	/* fill filled arrows */
 	if ((a->style || nfillpoints) && a->type < 13) {
--- a/fig2dev/dev/genps.c
+++ b/fig2dev/dev/genps.c
@@ -3,7 +3,7 @@
  * Copyright (c) 1991 by Micah Beck
  * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul
  * Parts Copyright (c) 1989-2015 by Brian V. Smith
- * Parts Copyright (c) 2015-2020 by Thomas Loimer
+ * Parts Copyright (c) 2015-2022 by Thomas Loimer
  *
  * Any party obtaining a copy of these files is granted, free of charge, a
  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
@@ -2489,6 +2489,9 @@ draw_arrow(F_arrow *arrow, F_pos *points
 {
 	int i, type;
 
+	if (npoints < 2)
+		return;
+
 	fprintf(tfp,"%% arrowhead\n");
 	set_linecap(0);			/* butt line cap for arrowheads */
 	set_linejoin(0);		/* miter join for sharp points */
--- a/fig2dev/tests/output.at
+++ b/fig2dev/tests/output.at
@@ -228,6 +228,15 @@ FIG_FILE_TOP
 EOF], 0, ignore)
 AT_CLEANUP
 
+AT_SETUP([arrows without any points, ticket #146])
+AT_KEYWORDS(pict2e arrows)
+AT_CHECK([fig2dev -L pict2e <<EOF
+FIG_FILE_TOP
+5 1 2 4 7 2 0 -1 0.0 0 0 1 0 7956 3420 6029 3765 5984 3270 6254 2085
+	1 1 2. 120. 240.
+EOF], 0, ignore)
+AT_CLEANUP
+
 
 AT_BANNER([Test svg output language.])
 AT_SETUP([compare patterns with template])