glibcompat.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. GLIB - Library of useful routines for C programming
  3. Copyright (C) 2009, 2011
  4. The Free Software Foundation, Inc.
  5. Written by:
  6. Slava Zanko <slavazanko@gmail.com>, 2009.
  7. This file is part of the Midnight Commander.
  8. The Midnight Commander is free software: you can redistribute it
  9. and/or modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation, either version 3 of the License,
  11. or (at your option) any later version.
  12. The Midnight Commander is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /** \file glibcompat.c
  20. * \brief Source: compatibility with older versions of glib
  21. *
  22. * Following code was copied from glib to GNU Midnight Commander to
  23. * provide compatibility with older versions of glib.
  24. */
  25. #include <config.h>
  26. #include "global.h"
  27. #include "glibcompat.h"
  28. /*** global variables ****************************************************************************/
  29. /*** file scope macro definitions ****************************************************************/
  30. /*** file scope type declarations ****************************************************************/
  31. /*** file scope variables ************************************************************************/
  32. /*** file scope functions ************************************************************************/
  33. /*** public functions ****************************************************************************/
  34. /* --------------------------------------------------------------------------------------------- */
  35. #if ! GLIB_CHECK_VERSION (2, 13, 0)
  36. /*
  37. This is incomplete copy of same glib-function.
  38. For older glib (less than 2.13) functional is enought.
  39. For full version of glib welcome to glib update.
  40. */
  41. gboolean
  42. g_unichar_iszerowidth (gunichar c)
  43. {
  44. if (G_UNLIKELY (c == 0x00AD))
  45. return FALSE;
  46. if (G_UNLIKELY ((c >= 0x1160 && c < 0x1200) || c == 0x200B))
  47. return TRUE;
  48. return FALSE;
  49. }
  50. #endif /* ! GLIB_CHECK_VERSION (2, 13, 0) */
  51. /* --------------------------------------------------------------------------------------------- */
  52. #if ! GLIB_CHECK_VERSION (2, 7, 0)
  53. gboolean
  54. g_file_set_contents (const gchar * filename, const gchar * contents, gssize length, GError ** error)
  55. {
  56. return g_file_replace (filename, contents, length, error);
  57. }
  58. #endif /* ! GLIB_CHECK_VERSION (2, 7, 0) */