n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
127 stars 23 forks source link

pic: "chop" does not work. #76

Closed reffort closed 5 years ago

reffort commented 5 years ago

To replicate:

.PS
circle "1"
move right 1i
circle "2"
line <-> from 1st circle to 2nd circle "normal" above
move down from 1st circle
circle "3"
move down from 2nd circle
circle "4"
line <-> from 3rd circle to 4th circle chop "chopped" above
.PE

Then run: pic testfile | troff | dpost | ps2pdf - > testfile.pdf

There should be four circles: two on top with a line connecting their centers, and two below with a line connecting the circles (the line should not be drawn within the circles). However, the two lower circles are instead connected at their centers because "chop" is not working.

In commit c6c12d9660b0... dated 04 Nov 2014, "Some gcc warnings removed," the line

chop_ap[chop++] = ap;

was deleted from file pic/linegen.c.

gcc -Wall does flag this line with the message that chop_ap is an unused variable. It is right about that. However, the variable chop is used, and if it is not incremented, it remains at 0 and the "chop" attribute won't work.

Solution: Add chop++ back in.


diff --git a/pic/linegen.c b/pic/linegen.c
index f80b64a..a90e627 100644
@@ -145,6 +145,7 @@ obj *linegen(int type)
                else
                    chop2 = ap->a_val.f;
            }
+           chop++;
            break;
        case FILL:
            battr |= FILLBIT;
n-t-roff commented 5 years ago

Applied. Thank you for analyzing and reporting this!