1.3.9 hpgltops breaks some previously working HPGL files #2966

Closed
michaelrsweet opened this Issue Oct 8, 2008 · 7 comments

Projects

None yet

1 participant

@michaelrsweet
Collaborator

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.

@michaelrsweet
Collaborator

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.

@michaelrsweet
Collaborator

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.

@michaelrsweet
Collaborator

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.

@michaelrsweet
Collaborator

CUPS.org User: martin.pitt.canonical

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

@michaelrsweet
Collaborator

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! :)

@michaelrsweet
Collaborator

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Collaborator

"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],

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