diff options
author | nyamatongwe <devnull@localhost> | 2003-10-04 01:02:13 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2003-10-04 01:02:13 +0000 |
commit | 76ee73d75b953a6e5dbb4a3269502884dd2050a5 (patch) | |
tree | c8d2ddb26abc4c08b39b04f0dd10c654dc22c5c4 | |
parent | dc7601539e9d80c0c9a1f80dc877cc0f579c89fb (diff) | |
download | scintilla-mirror-76ee73d75b953a6e5dbb4a3269502884dd2050a5.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.
-rw-r--r-- | gtk/PlatGTK.cxx | 12 | ||||
-rw-r--r-- | gtk/ScintillaGTK.cxx | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 8df0e06ac..5367a6227 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -39,6 +39,14 @@ #define USE_PANGO 1 #include <iconv.h> const iconv_t iconvhBad = (iconv_t)(-1); +// 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 @@ -1038,7 +1046,7 @@ static char *UTF8FromIconv(iconv_t iconvh, const char *s, int len) { size_t inLeft = len; char *pout = utfForm; 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))) { *pout = '\0'; return utfForm; @@ -1055,7 +1063,7 @@ static size_t MultiByteLenFromIconv(iconv_t iconvh, const char *s, size_t len) { size_t inLeft = lenMB; char *pout = wcForm; size_t outLeft = 2; - 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))) { return lenMB; } 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; |