pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/libgphoto2 Use improved patch for UCS-2/iconv pr...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e6af8670c910
branches:  trunk
changeset: 528236:e6af8670c910
user:      sborrill <sborrill%pkgsrc.org@localhost>
date:      Wed Apr 25 13:36:18 2007 +0000

description:
Use improved patch for UCS-2/iconv problems.
Based on: https://sourceforge.net/tracker/?func=detail&atid=108874&aid=1648398&group_id=8874
Bump PKGREVISION to 3

diffstat:

 devel/libgphoto2/Makefile         |    4 +-
 devel/libgphoto2/distinfo         |    5 +-
 devel/libgphoto2/patches/patch-aa |   68 +++++++++++++++-------
 devel/libgphoto2/patches/patch-ag |  115 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 166 insertions(+), 26 deletions(-)

diffs (236 lines):

diff -r 2ad53c8c084a -r e6af8670c910 devel/libgphoto2/Makefile
--- a/devel/libgphoto2/Makefile Wed Apr 25 13:29:11 2007 +0000
+++ b/devel/libgphoto2/Makefile Wed Apr 25 13:36:18 2007 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.36 2007/03/20 10:22:31 abs Exp $
+# $NetBSD: Makefile,v 1.37 2007/04/25 13:36:18 sborrill Exp $
 
 DISTNAME=      libgphoto2-2.3.1
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    devel graphics
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=gphoto/}
 EXTRACT_SUFX=  .tar.bz2
diff -r 2ad53c8c084a -r e6af8670c910 devel/libgphoto2/distinfo
--- a/devel/libgphoto2/distinfo Wed Apr 25 13:29:11 2007 +0000
+++ b/devel/libgphoto2/distinfo Wed Apr 25 13:36:18 2007 +0000
@@ -1,11 +1,12 @@
-$NetBSD: distinfo,v 1.12 2007/03/20 10:25:16 abs Exp $
+$NetBSD: distinfo,v 1.13 2007/04/25 13:36:18 sborrill Exp $
 
 SHA1 (libgphoto2-2.3.1.tar.bz2) = 13cc3f05ee298b33cd03ba4b772ef05a3aa49b97
 RMD160 (libgphoto2-2.3.1.tar.bz2) = ab678a5006a89ef1fe9f052dac1f9738961cc3a8
 Size (libgphoto2-2.3.1.tar.bz2) = 3230934 bytes
-SHA1 (patch-aa) = 172651a01bc8e940e49c729b731e34cf321b0d6d
+SHA1 (patch-aa) = c1620348beddd102b2515987670786a54f9fcf08
 SHA1 (patch-ab) = 921eea83471110dd85197a7171278c7d0556536b
 SHA1 (patch-ac) = f5d3e72163f6de85c4e5a9b5f4b32d8d628e7b30
 SHA1 (patch-ad) = 270c6f9a655631bc8d43a8d66851e902ea5ea8a5
 SHA1 (patch-ae) = 782807e35b748d80ad4bb8306eb576742d9e6f69
 SHA1 (patch-af) = b0dccb67bf51ad7570438ba8f65d0187f5fd4b17
+SHA1 (patch-ag) = 2c50b33a70dd9c4b41eb8fabc1f7fd03959660f3
diff -r 2ad53c8c084a -r e6af8670c910 devel/libgphoto2/patches/patch-aa
--- a/devel/libgphoto2/patches/patch-aa Wed Apr 25 13:29:11 2007 +0000
+++ b/devel/libgphoto2/patches/patch-aa Wed Apr 25 13:36:18 2007 +0000
@@ -1,36 +1,60 @@
-$NetBSD: patch-aa,v 1.6 2007/03/20 10:22:31 abs Exp $
+$NetBSD: patch-aa,v 1.7 2007/04/25 13:36:18 sborrill Exp $
 
---- camlibs/ptp2/library.c.orig        2006-12-24 15:16:20.000000000 +0000
-+++ camlibs/ptp2/library.c
-@@ -58,6 +58,7 @@
-  * is always bigendian though, we would need to work around that
-  * too...
-  */
-+/*
- #ifndef __GLIBC__
- #define UCS_2_INTERNAL "UCS-2-INTERNAL"
- #else
-@@ -66,7 +67,7 @@
+--- camlibs/ptp2/library.c.orig        2007-01-30 20:06:58.000000000 -0500
++++ camlibs/ptp2/library.c     2007-01-30 20:13:25.000000000 -0500
+@@ -50,23 +50,6 @@
+ #  define N_(String) (String)
  #endif
- #define UCS_2_INTERNAL "UCS-2"
- #endif
+ 
+-/*
+- * On MacOS (Darwin) and *BSD we're not using glibc, but libiconv.
+- * glibc knows that UCS-2 is to be in the local machine endianness,
+- * whereas libiconv does not. So we construct this macro to get
+- * things right. Reportedly, glibc 2.1.3 has a bug so that UCS-2
+- * is always bigendian though, we would need to work around that
+- * too...
+- */
+-#ifndef __GLIBC__
+-#define UCS_2_INTERNAL "UCS-2-INTERNAL"
+-#else
+-#if (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1 )
+-#error "Too old glibc. This versions iconv() implementation cannot be trusted."
+-#endif
+-#define UCS_2_INTERNAL "UCS-2"
+-#endif
 -
-+*/
  #include "ptp.h"
  #include "ptp-bugs.h"
  #include "ptp-private.h"
-@@ -3696,8 +3697,12 @@ camera_init (Camera *camera, GPContext *
+@@ -3619,7 +3602,7 @@
+       CameraAbilities a;
+       int ret, i, retried = 0;
+       PTPParams *params;
+-      char *curloc;
++      char *camloc, *curloc;
+ 
+       /* Make sure our port is either USB or PTP/IP. */
+       if ((camera->port->type != GP_PORT_USB) && (camera->port->type != GP_PORT_PTPIP)) {
+@@ -3649,6 +3632,11 @@
+       memset (camera->pl->params.data, 0, sizeof (PTPData));
+       ((PTPData *) camera->pl->params.data)->camera = camera;
+       camera->pl->params.byteorder = PTP_DL_LE;
++    if (camera->pl->params.byteorder == PTP_DL_LE) {
++        camloc = "UCS-2LE";
++    } else {
++        camloc = "UCS-2BE";
++    }
+ 
+       switch (camera->port->type) {
+       case GP_PORT_USB:
+@@ -3696,8 +3684,8 @@
  
        curloc = nl_langinfo (CODESET);
        if (!curloc) curloc="UTF-8";
 -      camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, UCS_2_INTERNAL);
 -      camera->pl->params.cd_locale_to_ucs2 = iconv_open(UCS_2_INTERNAL, curloc);
-+      camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, "UCS-2-INTERNAL");
-+      if(camera->pl->params.cd_ucs2_to_locale == (iconv_t) -1)
-+              camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, "UCS-2");             
-+      camera->pl->params.cd_locale_to_ucs2 = iconv_open("UCS-2-INTERNAL", curloc);
-+      if(camera->pl->params.cd_locale_to_ucs2 == (iconv_t) -1)
-+              camera->pl->params.cd_locale_to_ucs2 = iconv_open("UCS-2", curloc);     
++      camera->pl->params.cd_ucs2_to_locale = iconv_open(curloc, camloc);
++      camera->pl->params.cd_locale_to_ucs2 = iconv_open(camloc, curloc);
        if ((camera->pl->params.cd_ucs2_to_locale == (iconv_t) -1) ||
            (camera->pl->params.cd_locale_to_ucs2 == (iconv_t) -1)) {
                gp_log (GP_LOG_ERROR, "iconv", "Failed to create iconv converter.\n");
diff -r 2ad53c8c084a -r e6af8670c910 devel/libgphoto2/patches/patch-ag
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libgphoto2/patches/patch-ag Wed Apr 25 13:36:18 2007 +0000
@@ -0,0 +1,115 @@
+$NetBSD: patch-ag,v 1.1 2007/04/25 13:36:18 sborrill Exp $
+
+--- camlibs/ptp2/ptp-pack.c.orig       2007-01-30 20:06:47.000000000 -0500
++++ camlibs/ptp2/ptp-pack.c    2007-01-30 21:32:05.000000000 -0500
+@@ -89,41 +89,38 @@
+ static inline char*
+ ptp_unpack_string(PTPParams *params, unsigned char* data, uint16_t offset, uint8_t *len)
+ {
+-      int i;
+-      uint8_t loclen;
++      uint8_t length;
++      uint16_t string[PTP_MAXSTRLEN+1];
++      /* allow for UTF-8: max of 3 bytes per UCS-2 char, plus final null */
++      char loclstr[PTP_MAXSTRLEN*3+1]; 
++      size_t nconv, srclen, destlen;
++      char *src, *dest;
++
++      length = dtoh8a(&data[offset]); /* PTP_MAXSTRLEN == 255, 8 bit len */
++      *len = length;
++      if (length == 0)                /* nothing to do? */
++              return(NULL);
++
++      /* copy to string[] to ensure correct alignment for iconv(3) */
++      memcpy(string, &data[offset+1], length * sizeof(string[0]));
++      string[length] = 0x0000U;   /* be paranoid!  add a terminator. */
++      loclstr[0] = '\0';
++    
++      /* convert from camera UCS-2 to our locale */
++      src = (char *)string;
++      srclen = length * sizeof(string[0]);
++      dest = loclstr;
++      destlen = sizeof(loclstr)-1;
++      nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, 
++                      &dest, &destlen);
++      if (nconv == (size_t) -1)
++              return(NULL);
+ 
+-      /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */
+-      loclen = dtoh8a(&data[offset]);
+-      /* This len is used to advance the buffer pointer */
+-      *len = loclen;
+-      if (loclen) {
+-              uint16_t string[PTP_MAXSTRLEN+1];
+-              char *stringp = (char *) string;
+-              char loclstr[PTP_MAXSTRLEN*3+1]; /* UTF-8 encoding is max 3 bytes per UCS2 char. */
+-              char *locp = loclstr;
+-              size_t nconv;
+-              size_t convlen = loclen * 2; /* UCS-2 is 16 bit wide */
+-              size_t convmax = PTP_MAXSTRLEN*3;
+-              
+-              for (i=0;i<loclen;i++) {
+-                      string[i]=dtoh16a(&data[offset+i*2+1]);
+-              }
+-              /* be paranoid! Add a terminator. :( */
+-              string[loclen]=0x0000U;
+-              loclstr[0]='\0';
+-              /* loclstr=ucs2_to_utf8(string); */
+-              /* Do the conversion.  */
+-              nconv = iconv (params->cd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax);
+-              /* FIXME: handle size errors */
+-              loclstr[PTP_MAXSTRLEN*3] = '\0';
+-              if (nconv == (size_t) -1)
+-                      return NULL;
+-              return strdup(loclstr);
+-      }
+-      return NULL;
++      *dest = '\0';
++      loclstr[sizeof(loclstr)-1] = '\0';   /* be safe? */
++      return(strdup(loclstr));
+ }
+ 
+-
+ static inline int
+ ucs2strlen(uint16_t const * const unicstr)
+ {
+@@ -138,7 +135,6 @@
+ static inline void
+ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t offset, uint8_t *len)
+ {
+-      int i;
+       int packedlen;
+       uint16_t ucs2str[PTP_MAXSTRLEN+1];
+       char *ucs2strp = (char *) ucs2str;
+@@ -148,11 +144,15 @@
+       size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */
+ 
+       /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */
+-      ucs2str[0] = 0x0000U;
+-      memset(ucs2strp, 0, PTP_MAXSTRLEN*2+2);
+-      nconv = iconv (params->cd_locale_to_ucs2, &stringp, &convlen, &ucs2strp, &convmax);
++      memset(ucs2strp, 0, sizeof(ucs2str));  /* XXX: necessary? */
++      nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen,
++              &ucs2strp, &convmax);
+       if (nconv == (size_t) -1)
+               ucs2str[0] = 0x0000U;
++      /*
++       * XXX: isn't packedlen just ( (uint16_t *)ucs2strp - ucs2str )?
++       *      why do we need ucs2strlen()?
++       */
+       packedlen = ucs2strlen(ucs2str);
+       if (packedlen > PTP_MAXSTRLEN-1) {
+               *len=0;
+@@ -161,10 +161,8 @@
+       
+       /* number of characters including terminating 0 (PTP standard confirmed) */
+       htod8a(&data[offset],packedlen+1);
+-      for (i=0;i<packedlen && i< PTP_MAXSTRLEN; i++) {
+-              htod16a(&data[offset+i*2+1],ucs2str[i]);
+-      }
+-      htod16a(&data[offset+i*2+1],0x0000);
++      memcpy(&data[offset+1], &ucs2str[0], packedlen * sizeof(ucs2str[0]));
++      htod16a(&data[offset+packedlen*2+1], 0x0000);  /* terminate 0 */
+ 
+       /* The returned length is in number of characters */
+       *len = (uint8_t) packedlen+1;



Home | Main Index | Thread Index | Old Index