chiark / gitweb /
Put the charstring cursor in a local variable
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 2 Nov 2024 19:32:17 +0000 (19:32 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 14 Nov 2024 22:27:18 +0000 (22:27 +0000)
bedstead.c

index 2b80a3b401ceff1c10ed645cd722c79a1cbdeff6..75bb3351808c7ecce4781d8af1f836b543684567 100644 (file)
@@ -3564,10 +3564,8 @@ clean_path(void)
        } while (done_anything);
 }
 
-static vec cur;
-
 static void
-emit_contour(point *p0)
+emit_contour(point *p0, vec *cur)
 {
        point *p = p0, *p1;
        int stacksize = 0;
@@ -3576,11 +3574,11 @@ emit_contour(point *p0)
        do {
                stacksize += 2;
                printf(" %g %g %s\n",
-                      (double)(p->v.x - cur.x) / XSCALE,
-                      (double)(p->v.y - cur.y) / YSCALE,
+                      (double)(p->v.x - cur->x) / XSCALE,
+                      (double)(p->v.y - cur->y) / YSCALE,
                       p == p0 ? "rmoveto" : stacksize >= 48 ? "rlineto" : "");
                stacksize %= 48;
-               cur = p->v;
+               *cur = p->v;
                p1 = p->next;
                p->prev = p->next = NULL;
                p = p1;
@@ -3593,9 +3591,8 @@ emit_path(void)
 {
        int i, pass;
        point *p;
+       struct vec cur = { 0, DESCENT * YPIX };
 
-       cur.x = 0;
-       cur.y = DESCENT * YPIX;
        /*
         * On the first pass, emit open contours (if there are any).
         * On the second pass, emit all remaining contours.
@@ -3604,7 +3601,7 @@ emit_path(void)
                for (i = 0; i < nextpoint; i++) {
                        p = &points[i];
                        if (p->next && (!p->prev || pass == 1))
-                               emit_contour(p);
+                               emit_contour(p, &cur);
                }
        }
        printf("endchar\n");