diff options
author | sborrill <sborrill@pkgsrc.org> | 2007-04-25 13:36:18 +0000 |
---|---|---|
committer | sborrill <sborrill@pkgsrc.org> | 2007-04-25 13:36:18 +0000 |
commit | 81dd481da9a2868ba3c45f607055724abd5d5e06 (patch) | |
tree | 96dcecdf62a87827c13503e93e31b792a7ae5f60 | |
parent | b6cd3ca075285b0b5d176c2e6cd1fc6435ec8c8c (diff) | |
download | pkgsrc-81dd481da9a2868ba3c45f607055724abd5d5e06.tar.gz |
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
-rw-r--r-- | devel/libgphoto2/Makefile | 4 | ||||
-rw-r--r-- | devel/libgphoto2/distinfo | 5 | ||||
-rw-r--r-- | devel/libgphoto2/patches/patch-aa | 68 | ||||
-rw-r--r-- | devel/libgphoto2/patches/patch-ag | 115 |
4 files changed, 166 insertions, 26 deletions
diff --git a/devel/libgphoto2/Makefile b/devel/libgphoto2/Makefile index 160fa4e85a0..2ff4f78b621 100644 --- a/devel/libgphoto2/Makefile +++ b/devel/libgphoto2/Makefile @@ -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 --git a/devel/libgphoto2/distinfo b/devel/libgphoto2/distinfo index 8e4fc673c21..a5538ebeb95 100644 --- a/devel/libgphoto2/distinfo +++ b/devel/libgphoto2/distinfo @@ -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 --git a/devel/libgphoto2/patches/patch-aa b/devel/libgphoto2/patches/patch-aa index aa1a7b80c2c..f84a9e91467 100644 --- a/devel/libgphoto2/patches/patch-aa +++ b/devel/libgphoto2/patches/patch-aa @@ -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 @@ - #endif - #define UCS_2_INTERNAL "UCS-2" +--- 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 + +-/* +- * 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 --git a/devel/libgphoto2/patches/patch-ag b/devel/libgphoto2/patches/patch-ag new file mode 100644 index 00000000000..c84651906da --- /dev/null +++ b/devel/libgphoto2/patches/patch-ag @@ -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; |