summaryrefslogtreecommitdiff
path: root/src/ptp-pack.c
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2011-11-14 23:00:52 +0100
committerLinus Walleij <triad@df.lth.se>2011-11-14 23:00:52 +0100
commitd6f25baf36fba05e3d8b2fa6d3cd4c026e2e6d33 (patch)
tree9e482e0adbf47233a016669bd2563746653bd6d4 /src/ptp-pack.c
parent1d9b1ec778465b3dc17ff1b5c41b3a8e111fd22b (diff)
downloadlibmtp-d6f25baf36fba05e3d8b2fa6d3cd4c026e2e6d33.tar.gz
Sync core PTP files from gphoto2
Signed-off-by: Linus Walleij <triad@df.lth.se>
Diffstat (limited to 'src/ptp-pack.c')
-rw-r--r--src/ptp-pack.c8
1 files changed, 4 insertions, 4 deletions
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;