diff options
author | nyamatongwe <unknown> | 2003-10-04 01:02:13 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2003-10-04 01:02:13 +0000 |
commit | db1a5df81887b1b96cfee9f42ed8e7248655537d (patch) | |
tree | c8d2ddb26abc4c08b39b04f0dd10c654dc22c5c4 /gtk/ScintillaGTK.cxx | |
parent | 69c10177465e5209829f74c7ab3cd6aaf92c9bbe (diff) | |
download | scintilla-mirror-db1a5df81887b1b96cfee9f42ed8e7248655537d.tar.gz |
Adaptor template to allow use of versions of iconv that use a const
source parameter as well as versions that use non-const.
Diffstat (limited to 'gtk/ScintillaGTK.cxx')
-rw-r--r-- | gtk/ScintillaGTK.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index e10aee5f2..d421d5326 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -58,6 +58,14 @@ #if !PLAT_GTK_WIN32 #include <iconv.h> +// Since various versions of iconv can not agree on whether the src argument +// is char ** or const char ** provide a templatised adaptor. +template<typename T> +size_t iconv_adaptor(size_t(*f_iconv)(iconv_t, T, size_t *, char **, size_t *), + iconv_t cd, char** src, size_t *srcleft, + char **dst, size_t *dstleft) { + return f_iconv(cd, (T)src, srcleft, dst, dstleft); +} #endif #ifdef _MSC_VER @@ -969,7 +977,7 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) { size_t inLeft = strlen(utfVal); char *pout = localeVal; size_t outLeft = sizeof(localeVal); - size_t conversions = iconv(iconvh, &pin, &inLeft, &pout, &outLeft); + size_t conversions = iconv_adaptor(iconv, iconvh, &pin, &inLeft, &pout, &outLeft); iconv_close(iconvh); if (conversions != ((size_t)(-1))) { *pout = '\0'; @@ -1107,7 +1115,7 @@ static char *ConvertText(size_t *lenResult, char *s, size_t len, const char *cha size_t inLeft = len; char *pout = destForm; size_t outLeft = len*3+1; - size_t conversions = iconv(iconvh, &pin, &inLeft, &pout, &outLeft); + size_t conversions = iconv_adaptor(iconv, iconvh, &pin, &inLeft, &pout, &outLeft); if (conversions == ((size_t)(-1))) { fprintf(stderr, "iconv failed for %s\n", static_cast<char *>(s)); delete []destForm; |