Add ptp fix from #1261
[openwrt/svn-archive/archive.git] / libs / libgphoto2 / patches / 01-ptp_iconv_fix.patch
1 diff -urN libgphoto2-2.3.1/camlibs/ptp2/ptp-pack.c libgphoto2-2.3.1.new/camlibs/ptp2/ptp-pack.c
2 --- libgphoto2-2.3.1/camlibs/ptp2/ptp-pack.c 2006-12-24 16:16:20.000000000 +0100
3 +++ libgphoto2-2.3.1.new/camlibs/ptp2/ptp-pack.c 2007-02-28 00:17:17.000000000 +0100
4 @@ -116,8 +116,17 @@
5 nconv = iconv (params->cd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax);
6 /* FIXME: handle size errors */
7 loclstr[PTP_MAXSTRLEN*3] = '\0';
8 - if (nconv == (size_t) -1)
9 - return NULL;
10 + if (nconv == (size_t) -1) {
11 + int i;
12 + /* try the old way, in case iconv is broken */
13 + for (i=0;i<loclen;i++) {
14 + if (string[i]>127)
15 + loclstr[i] = '?';
16 + else
17 + loclstr[i] = string[i];
18 + }
19 + string[loclen] = 0;
20 + }
21 return strdup(loclstr);
22 }
23 return NULL;