diff options
author | Jeremy Allison <jra@samba.org> | 2004-08-10 02:05:38 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:18 -0500 |
commit | 16de9d9711d5de8b2877b367e1d86ad3844d5d09 (patch) | |
tree | 1ff28dab96427275fa95795ea7ae2286d5f2c43d /source3 | |
parent | 532431d49357334febb45bc07524f28052752f9a (diff) | |
download | samba-16de9d9711d5de8b2877b367e1d86ad3844d5d09.tar.gz samba-16de9d9711d5de8b2877b367e1d86ad3844d5d09.tar.bz2 samba-16de9d9711d5de8b2877b367e1d86ad3844d5d09.zip |
r1684: Patch for bug #1578 based on fix from Alexander E. Patrakov,
<patrakov@ums.usu.ru>. Main change, hardcode replacement char
to '_' as I really don't want a new parameter.
Jeremy.
(This used to be commit db3dde026b84aa28c2d7a32249488f203e362497)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/charcnv.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 3d7678c34c..6cbf7562b0 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -23,6 +23,13 @@ */ #include "includes.h" +/* We can parameterize this if someone complains.... JRA. */ + +char lp_failed_convert_char(void) +{ + return '_'; +} + /** * @file * @@ -259,11 +266,11 @@ static size_t convert_string_internal(charset_t from, charset_t to, return destlen - o_len; if (from == CH_UCS2 && to != CH_UCS2) { - /* Can't convert from ucs2 to multibyte. Just truncate this char to ascii. */ + /* Can't convert from ucs2 to multibyte. Replace with the default fail char. */ if (i_len < 2) return destlen - o_len; if (i_len >= 2) { - *outbuf = inbuf[0]; + *outbuf = lp_failed_convert_char(); outbuf++; o_len--; @@ -279,11 +286,11 @@ static size_t convert_string_internal(charset_t from, charset_t to, goto again; } else if (from != CH_UCS2 && to == CH_UCS2) { - /* Can't convert to ucs2 - just widen by adding zero. */ + /* Can't convert to ucs2 - just widen by adding the default fail char then zero. */ if (o_len < 2) return destlen - o_len; - outbuf[0] = inbuf[0]; + outbuf[0] = lp_failed_convert_char(); outbuf[1] = '\0'; inbuf++; @@ -299,9 +306,9 @@ static size_t convert_string_internal(charset_t from, charset_t to, goto again; } else if (from != CH_UCS2 && to != CH_UCS2) { - /* Failed multibyte to multibyte. Just copy 1 char and + /* Failed multibyte to multibyte. Just copy the default fail char and try again. */ - outbuf[0] = inbuf[0]; + outbuf[0] = lp_failed_convert_char(); inbuf++; i_len--; @@ -581,12 +588,12 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to, goto out; if (from == CH_UCS2 && to != CH_UCS2) { - /* Can't convert from ucs2 to multibyte. Just truncate this char to ascii. */ + /* Can't convert from ucs2 to multibyte. Just use the default fail char. */ if (i_len < 2) goto out; if (i_len >= 2) { - *outbuf = inbuf[0]; + *outbuf = lp_failed_convert_char(); outbuf++; o_len--; @@ -602,11 +609,11 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to, goto again; } else if (from != CH_UCS2 && to == CH_UCS2) { - /* Can't convert to ucs2 - just widen by adding zero. */ + /* Can't convert to ucs2 - just widen by adding the default fail char then zero. */ if (o_len < 2) goto out; - outbuf[0] = inbuf[0]; + outbuf[0] = lp_failed_convert_char(); outbuf[1] = '\0'; inbuf++; @@ -622,9 +629,9 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to, goto again; } else if (from != CH_UCS2 && to != CH_UCS2) { - /* Failed multibyte to multibyte. Just copy 1 char and + /* Failed multibyte to multibyte. Just copy the default fail char and try again. */ - outbuf[0] = inbuf[0]; + outbuf[0] = lp_failed_convert_char(); inbuf++; i_len--; |