Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

1.3.9 hpgltops breaks some previously working HPGL files #2966

Closed

Description

@michaelrsweet

Version: 1.3.9
CUPS.org User: martin.pitt.canonical

I tested ftp://ftp.ornl.gov/pub/ortep/examples/ahelix.hp before and after the patch in STR #1911:

filter/hpgltops 1 martin test 1 '' /tmp/ahelix.hp > /tmp/x.ps
evince /tmp/x.ps

and with the patch I just get a blank page. I suspect it is due to the shifted pen enumeration, which now starts counting at 0 instead of 1.

Activity

  1. michaelrsweet commented on Oct 10, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: martin.pitt.canonical

    The second random example I found is at http://en.wikipedia.org/wiki/HPGL, which does not work any more either.

  2. michaelrsweet commented on Oct 10, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: martin.pitt.canonical

    There also seem to be a couple of places left which were not adapted to the "shifted by 1" pen enumeration, like filter/hpgl-vector.c:396

    PenNumber = (int)decode_number(&s, base_bits, 1.0);

    or filter/hpgl-attr.c:217

    for (i = 0; i <= PenCount; i ++)

    Those were the two places I found after a cursory inspection.

    As for the regression, it seems that pen 1 does not work any more. If I replace "SP1;" with "SP2", it works. I think the reason for that is PC_pen_color(). Pens[0] has always been white (before and after the patch), Pens[1] has always been black. However, "SP1" in the past was Pens[1], while it is now Pens[0], and "SP0" (which was valid before) isn't any more. Therefore I think the fix is to revert the "-1" in SP and just make sure that the array does not overflow by 1.

  3. michaelrsweet commented on Oct 10, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: martin.pitt.canonical

    I think I got it right now. I reverted the SP_select_pen() enumeration change to not break the color map, and fixed the remaining loop. The "PenNumber = " in hpgl-vector.c is correct then, too.

  4. michaelrsweet commented on Oct 22, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: martin.pitt.canonical

    This is a contentless ping to avoid this mercyless auto-timeout of bug reports.

  5. michaelrsweet commented on Oct 22, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Martin,

    I only close stale bugs that I am waiting for information from the reporter, so as long as the status is "pending" the bug is safe...

    Also, I'll have you know that my index finger always mercifully clicks the mouse button when closing inactive bugs! :)

  6. michaelrsweet commented on Nov 13, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  7. michaelrsweet commented on Nov 13, 2008

    @michaelrsweet
    ContributorAuthor

    "str2966.patch":

    Index: filter/hpgl-attr.c

    --- filter/hpgl-attr.c (revision 8118)
    +++ filter/hpgl-attr.c (working copy)
    @@ -3,7 +3,7 @@
    *

    • HP-GL/2 attribute processing for the Common UNIX Printing System (CUPS).
    • * Copyright 2007 by Apple Inc.
    • * Copyright 2007-2008 by Apple Inc.
    • Copyright 1993-2007 by Easy Software Products.
    • These coded instructions, statements, and computer programs are the
      @@ -214,7 +214,7 @@
      "DEBUG: HP-GL/2 'NP' command with invalid number of "
      "parameters (%d)!\n", num_params);
    • for (i = 0; i <= PenCount; i ++)
    • for (i = 0; i < PenCount; i ++)
      Pens[i].width = PenWidth;

    PC_pen_color(0, NULL);
    @@ -232,14 +232,14 @@
    int i; /* Looping var /
    static float standard_colors[8][3] = /
    Standard colors for first 8 pens */
    {

    •     { 1.0, 1.0, 1.0 },    /\* White _/
        { 0.0, 0.0, 0.0 },    /_ Black _/
        { 1.0, 0.0, 0.0 },    /_ Red _/
        { 0.0, 1.0, 0.0 },    /_ Green _/
        { 1.0, 1.0, 0.0 },    /_ Yellow _/
        { 0.0, 0.0, 1.0 },    /_ Blue _/
        { 1.0, 0.0, 1.0 },    /_ Magenta */
      
    •     { 0.0, 1.0, 1.0 } /\* Cyan */
      
    •     { 0.0, 1.0, 1.0 },    /\* Cyan */
      
    •     { 1.0, 1.0, 1.0 } /\* White */
      };
      

    Index: filter/hpgl-vector.c

    --- filter/hpgl-vector.c (revision 8118)
    +++ filter/hpgl-vector.c (working copy)
    @@ -3,7 +3,7 @@
    *

    • HP-GL/2 vector routines for the Common UNIX Printing System (CUPS).
    • * Copyright 2007 by Apple Inc.
    • * Copyright 2007-2008 by Apple Inc.
    • Copyright 1993-2007 by Easy Software Products.
    • These coded instructions, statements, and computer programs are the
      @@ -393,13 +393,20 @@
      break;
      case ':' : /* Select pen */
      s ++;

    •      PenNumber = (int)decode_number(&s, base_bits, 1.0);
      
    •      temp = (int)decode_number(&s, base_bits, 1.0) - 1;
      
    • if (temp < 0 || temp >= PenCount)
      
    • {
      
    •   fprintf(stderr, "DEBUG: Bad pen number %d in PE\n", temp + 1);
      
    •   return;
      
    • }
      
    •      PenNumber = temp;
      

      #ifdef DEBUG

    •      fprintf(stderr, "DEBUG:     set pen #%d\n", PenNumber);
      
    •      fprintf(stderr, "DEBUG:     set pen #%d\n", PenNumber + 1);
      

      #endif /* DEBUG */

    •      Outputf("%% PE: set pen #%d\n", PenNumber);
      
    •      Outputf("%% PE: set pen #%d\n", PenNumber + 1);
      

      if (PageDirty)
      printf("%.3f %.3f %.3f %.2f SP\n", Pens[PenNumber].rgb[0],

  8. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions