openbsd-ports/cad/chipmunk/patches/patch-psys_src_plot_c

34 lines
855 B
Plaintext
Raw Normal View History

$OpenBSD: patch-psys_src_plot_c,v 1.1.1.1 2003/10/25 18:33:27 pvalchev Exp $
--- psys/src/plot.c.orig 2003-03-12 15:47:36.000000000 -0700
+++ psys/src/plot.c 2003-10-25 10:50:56.000000000 -0600
@@ -2633,6 +2633,9 @@ long *which_;
Char STR4[256];
point *pp1;
chardesc *cd1;
+ int fd = -1;
+ char tmpf[25] = "/tmp/chipmunk.XXXXXXXXXX";
+ FILE *tmpp;
P_setcpy(which, which_);
f = NULL;
@@ -2664,8 +2667,17 @@ long *which_;
if (f != NULL) {
/* p2c: plot.text, line 2335: Note: OPEN does not specify a name [181] */
rewind(f);
- } else
- f = tmpfile();
+ } else {
+ if ((fd == mkstemp(tmpf)) == -1 ||
+ (tmpp = fdopen(fd, "w+")) == NULL) {
+ if (fd != -1) {
+ unlink(tmpf);
+ close(fd);
+ }
+ f = NULL;
+ } else
+ f = tmpp;
+ }
if (f == NULL) {
P_escapecode = -10;
P_ioresult = FileNotFound;