From d6f25baf36fba05e3d8b2fa6d3cd4c026e2e6d33 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 Nov 2011 23:00:52 +0100 Subject: Sync core PTP files from gphoto2 Signed-off-by: Linus Walleij --- src/ptp-pack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ptp-pack.c') diff --git a/src/ptp-pack.c b/src/ptp-pack.c index 15b294e..18c4513 100644 --- a/src/ptp-pack.c +++ b/src/ptp-pack.c @@ -123,8 +123,8 @@ ptp_unpack_string(PTPParams *params, unsigned char* data, uint16_t offset, uint8 destlen = sizeof(loclstr)-1; nconv = (size_t)-1; #ifdef HAVE_ICONV - nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, - &dest, &destlen); + if (params->cd_ucs2_to_locale != (iconv_t)-1) + nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, &dest, &destlen); #endif if (nconv == (size_t) -1) { /* do it the hard way */ int i; @@ -164,7 +164,7 @@ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t o /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */ memset(ucs2strp, 0, sizeof(ucs2str)); /* XXX: necessary? */ #ifdef HAVE_ICONV - { + if (params->cd_locale_to_ucs2 == (iconv_t)-1) { size_t nconv; size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */ char *stringp = string; @@ -173,7 +173,7 @@ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t o &ucs2strp, &convmax); if (nconv == (size_t) -1) ucs2str[0] = 0x0000U; - } + } else #else { int i; -- cgit v1.2.1