You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

  1. From c2da1d47eeaf83d3683555b965a16654561f14b3 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Thu, 30 Jul 2020 16:27:02 -0700
  4. Subject: [PATCH] icu: fix compilation with const char iconv
  5. libiconv uses const char. Test for it and use it properly to fix
  6. compilation.
  7. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  8. ---
  9. src/lib/icu/Converter.cxx | 2 +-
  10. src/lib/icu/meson.build | 10 ++++++++++
  11. 2 files changed, 11 insertions(+), 1 deletion(-)
  12. diff --git a/src/lib/icu/Converter.cxx b/src/lib/icu/Converter.cxx
  13. index b03543a82..4c459e57e 100644
  14. --- a/src/lib/icu/Converter.cxx
  15. +++ b/src/lib/icu/Converter.cxx
  16. @@ -83,7 +83,7 @@ DoConvert(iconv_t conv, const char *src)
  17. {
  18. // TODO: dynamic buffer?
  19. char buffer[4096];
  20. - char *in = const_cast<char *>(src);
  21. + ICONV_CONST char *in = (ICONV_CONST char *)(src);
  22. char *out = buffer;
  23. size_t in_left = strlen(src);
  24. size_t out_left = sizeof(buffer);
  25. diff --git a/src/lib/icu/meson.build b/src/lib/icu/meson.build
  26. index 132e15b89..ac7d1b72a 100644
  27. --- a/src/lib/icu/meson.build
  28. +++ b/src/lib/icu/meson.build
  29. @@ -30,6 +30,16 @@ elif not get_option('iconv').disabled()
  30. have_iconv = true
  31. conf.set('HAVE_ICONV', have_iconv)
  32. endif
  33. + if have_iconv
  34. + iconvconsttest = '''#include <iconv.h>
  35. +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
  36. +'''
  37. + if c_compiler.compiles(iconvconsttest, dependencies : libiconv)
  38. + conf.set('ICONV_CONST', '')
  39. + else
  40. + conf.set('ICONV_CONST', 'const')
  41. + endif
  42. + endif
  43. if not have_iconv and get_option('iconv').enabled()
  44. error('iconv() not available')
  45. endif
  46. --
  47. 2.17.1