[gs-devel] Re: Werner Fink's patches on ESP Ghostscript
Till Kamppeter
till.kamppeter at gmail.com
Mon Jul 2 03:08:22 PDT 2007
Dr. Werner Fink wrote:
> On Fri, Jun 29, 2007 at 07:06:28PM +0100, Till Kamppeter wrote:
>> Attached.
>>
>> Till
>
> JFYI, I've found this in my SPAM waste. Seems that the numbers
> of attachments has increased the SPAM cound a lot ;)
>
Then you have the patches now? Would be great if you port them to the
current Ghostscript. Please post the new patches here, or better in the
form of bug reports on bugs.ghostscript.com.
> For ghostscript-8.57 and above I've two patches as well.
> One required to be able to make pdf visible with X11R7,
> see https://bugzilla.novell.com/show_bug.cgi?id=203287 .
> an other is a crash within sgirdb driver, see
> https://bugzilla.novell.com/show_bug.cgi?id=209879
>
Thank you very much for the new patches. Please post them as bugs on
bugs.ghostscript.com.
Till
> ------------------------------------------------------------------------
>
> --- lib/pdf_main.ps
> +++ lib/pdf_main.ps 2007-06-14 14:55:29.570377299 +0000
> @@ -1159,10 +1159,14 @@ end readonly def
> % Determine the number of spot colors used on the page. Note: This searches
> % the pages resources. It may be high if a spot color is in a resource but
> % is not actually used on the page.
> - << /PageSpotColors 3 index countspotcolors >> setpagedevice
> + currentpagedevice /PageSpotColors known {
> + << /PageSpotColors 3 index countspotcolors >> setpagedevice
> + } if
> % Let the device know if we will be using PDF 1.4 transparency.
> % The clist logic may need to adjust the size of bands.
> - 1 index pageusestransparency /PageUsesTransparency exch def
> + currentpagedevice /PageUsesTransparency known {
> + 1 index pageusestransparency /PageUsesTransparency exch def
> + } if
> dup /Install .knownget {
> % Don't let the Install procedure get more deeply
> % nested after every page.
> @@ -1289,7 +1293,9 @@ end readonly def
> end % scratch dict
> % Indicate that the number of spot colors is unknown in case the next page
> % imaged is a PS file.
> - << /PageSpotColors -1 >> setpagedevice
> + currentpagedevice /PageSpotColors known {
> + << /PageSpotColors -1 >> setpagedevice
> + } if
> % Some PDF files don't have matching q/Q (gsave/grestore) so we need
> % to clean up any left over dicts from the dictstack
> countdictstack PDFdictstackcount sub dup 0 ne {
> --- src/gdevbbox.c
> +++ src/gdevbbox.c 2007-06-14 14:25:08.827985873 +0000
> @@ -1167,6 +1167,17 @@ bbox_create_compositor(gx_device * dev,
> {
> gx_device_bbox *const bdev = (gx_device_bbox *) dev;
> gx_device *target = bdev->target;
> + const gs_state *ps = (const gs_state *)pis;
> +
> + /*
> + * Do not create a compositor for the target if overprint is active,
> + * this because then it is possible that the current page is erased
> + * for a bbox which equals the current page.
> + */
> + if (gs_currentoverprint(ps) || gs_currentoverprintmode(ps)) {
> + *pcdev = dev;
> + return 0;
> + }
>
> /*
> * If there isn't a target, all we care about is the bounding box,
>
>
> ------------------------------------------------------------------------
>
> --- src/gdevsgi.c
> +++ src/gdevsgi.c 2007-06-14 17:32:26.811161244 +0200
> @@ -69,12 +69,20 @@ private int
> sgi_begin_page(gx_device_printer *bdev, FILE *pstream, sgi_cursor *pcur)
> {
> uint line_size = gdev_mem_bytes_per_scan_line((gx_device_printer*)bdev);
> - byte *data = (byte*)gs_malloc(bdev->memory, line_size, 1, "sgi_begin_page");
> - IMAGE *header= (IMAGE*)gs_malloc(bdev->memory, sizeof(IMAGE),1,"sgi_begin_page");
> + byte *data;
> + IMAGE *header;
> char filler= '\0';
> int i;
>
> - if ((data == (byte*)0)||(header == (IMAGE*)0)) return -1;
> + data = (byte*)gs_malloc(bdev->memory, line_size, 1, "sgi_begin_page");
> + if (data == (byte*)0) return -1;
> +
> + header= (IMAGE*)gs_malloc(bdev->memory, sizeof(IMAGE),1,"sgi_begin_page");
> + if (header == (IMAGE*)0)
> + {
> + gs_free(bdev->memory,data,line_size,1,"sgi_begin_page(failed)");
> + return -1;
> + }
>
> bzero(header,sizeof(IMAGE));
> header->imagic = IMAGIC;
> @@ -95,6 +103,7 @@ sgi_begin_page(gx_device_printer *bdev,
> pcur->bpp = bdev->color_info.depth;
> pcur->line_size = line_size;
> pcur->data = data;
> + gs_free(bdev->memory,header,sizeof(IMAGE),1,"sgi_begin_page");
> return 0;
> }
>
> @@ -115,12 +124,21 @@ sgi_print_page(gx_device_printer *pdev,
> int code = sgi_begin_page(bdev, pstream, &cur);
> uint bpe, mask;
> int separation;
> - long *rowsizes=(long*)gs_malloc(pdev->memory, 4,3*bdev->height,"sgi_print_page");
> + long *rowsizes;
> byte *edata ;
> long lastval;
> int rownumber;
> -#define aref2(a,b) a*bdev->height+b
> - edata = (byte*)gs_malloc(pdev->memory, cur.line_size, 1, "sgi_begin_page");
> +#define aref2(a,b) ((a)*bdev->height)+(b)
> + if(code<0) return(-1);
> + rowsizes = (long*)gs_malloc(pdev->memory,sizeof(long),3*bdev->height,"sgi_print_page");
> + if(rowsizes==(long*)NULL) return(-1);
> + bzero(rowsizes,sizeof(long)*3*bdev->height);
> + edata = (byte*)gs_malloc(pdev->memory, cur.line_size, 1, "sgi_begin_page");
> + if(edata==(byte*)NULL)
> + {
> + gs_free(pdev->memory,rowsizes,sizeof(long),3*bdev->height,"sgi_print_page");
> + return(-1);
> + }
> if((code<0)||(rowsizes==(long*)NULL)||(edata==(byte*)NULL)) return(-1);
> fwrite(rowsizes,sizeof(long),3*bdev->height,pstream); /* rowstarts */
> fwrite(rowsizes,sizeof(long),3*bdev->height,pstream); /* rowsizes */
> @@ -215,9 +233,8 @@ sgi_print_page(gx_device_printer *pdev,
> fputc((char)(lastval>>16),pstream);
> fputc((char)(lastval>>8),pstream);
> fputc((char)(lastval),pstream);}
> - gs_free(pdev->memory, (char*)cur.data, cur.line_size, 1,
> - "sgi_print_page(done)");
> - gs_free(pdev->memory, (char*)edata, cur.line_size, 1, "sgi_print_page(done)");
> - gs_free(pdev->memory, (char*)rowsizes,4,3*bdev->height,"sgi_print_page(done)");
> + gs_free(pdev->memory, cur.data, cur.line_size, 1, "sgi_print_page(done)");
> + gs_free(pdev->memory, edata, cur.line_size, 1, "sgi_print_page(done)");
> + gs_free(pdev->memory, rowsizes,4,3*bdev->height,"sgi_print_page(done)");
> return (code < 0 ? code : 0);
> }
More information about the gs-devel
mailing list