From mjl@luckie.org.nz  Mon Jun  4 03:48:35 2012
Return-Path: <mjl@luckie.org.nz>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 87A3B106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  4 Jun 2012 03:48:35 +0000 (UTC)
	(envelope-from mjl@luckie.org.nz)
Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.120])
	by mx1.freebsd.org (Postfix) with ESMTP id 475158FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  4 Jun 2012 03:48:35 +0000 (UTC)
Received: from [76.88.32.44] ([76.88.32.44:28691] helo=spandex.luckie.org.nz)
	by cdptpa-oedge03.mail.rr.com (envelope-from <mjl@luckie.org.nz>)
	(ecelerity 2.2.3.46 r()) with ESMTP
	id B7/86-00524-2103CCF4; Mon, 04 Jun 2012 03:48:34 +0000
Received: from mylar.luckie.org.nz ([192.168.2.20])
	by spandex.luckie.org.nz with esmtps (TLSv1:AES256-SHA:256)
	(Exim 4.77 (FreeBSD))
	(envelope-from <mjl@luckie.org.nz>)
	id 1SbOHR-000Jaf-OM; Sun, 03 Jun 2012 20:48:33 -0700
Received: from mjl by mylar.luckie.org.nz with local (Exim 4.77 (FreeBSD))
	(envelope-from <mjl@mylar.luckie.org.nz>)
	id 1SbOHb-0000qc-GB; Sun, 03 Jun 2012 20:48:43 -0700
Message-Id: <E1SbOHb-0000qc-GB@mylar.luckie.org.nz>
Date: Sun, 03 Jun 2012 20:48:43 -0700
From: Matthew Luckie <mjl@luckie.org.nz>
Sender: Matthew Luckie <mjl@luckie.org.nz>
Reply-To: Matthew Luckie <mjl@luckie.org.nz>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Helge Oldach <ports-xfig@oldach.net>
Subject: [patch] fix graphics/xfig after png update
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         168651
>Category:       ports
>Synopsis:       [patch] fix graphics/xfig after png update
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dinoex
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 04 03:50:12 UTC 2012
>Closed-Date:    Mon Jun 04 06:32:23 CEST 2012
>Last-Modified:  Mon Jun 04 06:32:23 CEST 2012
>Originator:     Matthew Luckie
>Release:        FreeBSD 9.0-RELEASE i386
>Organization:
>Environment:
System: FreeBSD mylar.luckie.org.nz 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Mar 13 20:42:13 PDT 2012 root@mylar.luckie.org.nz:/usr/src/sys/i386/compile/GENERIC i386


	
>Description:

With the recent png update, xfig no longer works.

>How-To-Repeat:

>Fix:

Patch obtained from 

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/media-gfx/xfig/files/xfig-3.2.5b-libpng-1.5.patch?diff_format=s&view=log

Thanks to Helge Oldach for pointing me at the above fix.

--- patch-xfig begins here ---
diff -uNr xfig/files/patch-png xfig-new/files/patch-png
--- xfig/files/patch-png	1969-12-31 16:00:00.000000000 -0800
+++ xfig-new/files/patch-png	2012-06-03 20:42:48.000000000 -0700
@@ -0,0 +1,68 @@
+diff -u xfig.3.2.5b.orig/f_readpng.c xfig.3.2.5b/f_readpng.c
+--- f_readpng.c.orig	2007-03-28 17:23:14.000000000 -0700
++++ f_readpng.c	2012-06-03 20:35:48.000000000 -0700
+@@ -73,7 +73,7 @@
+     }
+ 
+     /* set long jump recovery here */
+-    if (setjmp(png_ptr->jmpbuf)) {
++    if (setjmp(png_jmpbuf(png_ptr))) {
+ 	/* if we get here there was a problem reading the file */
+ 	png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
+ 	close_picfile(file,filetype);
+@@ -90,15 +90,17 @@
+     png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type,
+ 	&interlace_type, &compression_type, &filter_type);
+ 
+-    if (info_ptr->valid & PNG_INFO_gAMA)
+-	png_set_gamma(png_ptr, 2.2, info_ptr->gamma);
+-    else
+-	png_set_gamma(png_ptr, 2.2, 0.45);
++    png_fixed_point gamma = 0.45;
++    png_get_gAMA_fixed(png_ptr,info_ptr,&gamma);
++    png_set_gamma(png_ptr, 2.2, gamma);
+ 
+-    if (info_ptr->valid & PNG_INFO_bKGD)
++    if (png_get_valid(png_ptr,info_ptr,PNG_INFO_bKGD)) {
+ 	/* set the background to the one supplied */
+-	png_set_background(png_ptr, &info_ptr->background,
++	png_color_16p background;
++	png_get_bKGD(png_ptr,info_ptr,&background);
++	png_set_background(png_ptr, background,
+ 		PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
++    }
+     else {
+ 	/* blend the canvas background using the alpha channel */
+ 	background.red   = x_bg_color.red >> 8;
+@@ -136,7 +138,11 @@
+ 
+ 	if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) {
+ 	    png_get_hIST(png_ptr, info_ptr, &histogram);
++#if PNG_LIBPNG_VER_MAJOR <= 1 && PNG_LIBPNG_VER_MINOR < 5
+ 	    png_set_dither(png_ptr, palette, num_palette, 256, histogram, 0);
++#else
++	    png_set_quantize(png_ptr, palette, num_palette, 256, histogram, 0);
++#endif
+ 	}
+     }
+     if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+diff -u xfig.3.2.5b.orig/f_wrpng.c xfig.3.2.5b/f_wrpng.c
+--- f_wrpng.c.orig	2007-03-28 17:23:14.000000000 -0700
++++ f_wrpng.c	2012-06-03 20:41:11.000000000 -0700
+@@ -20,6 +20,7 @@
+ #include "w_msgpanel.h"
+ #include "w_setup.h"
+ #include <png.h>
++#include <zlib.h>
+ 
+ /*
+  * Write PNG file from rgb data
+@@ -59,7 +60,7 @@
+     }
+ 
+     /* set long jump recovery here */
+-    if (setjmp(png_ptr->jmpbuf)) {
++    if (setjmp(png_jmpbuf(png_ptr))) {
+ 	/* if we get here there was a problem reading the file */
+ 	png_destroy_write_struct(&png_ptr, &info_ptr);
+ 	return False;
--- patch-xfig ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: dinoex 
State-Changed-When: Mon Jun 4 06:31:27 CEST 2012 
State-Changed-Why:  
the patch is already committed, thanks. 


Responsible-Changed-From-To: freebsd-ports-bugs->dinoex 
Responsible-Changed-By: dinoex 
Responsible-Changed-When: Mon Jun 4 06:31:27 CEST 2012 
Responsible-Changed-Why:  
I will take care of followups. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168651 
>Unformatted:
