glibcompat.c 2.7 KB

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