gettext.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Implementation of gettext(3) function.
  2. Copyright (C) 1995-2019 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #ifdef HAVE_CONFIG_H
  14. # include <config.h>
  15. #endif
  16. #ifdef _LIBC
  17. # define __need_NULL
  18. # include <stddef.h>
  19. #else
  20. # include <stdlib.h> /* Just for NULL. */
  21. #endif
  22. #include "gettextP.h"
  23. #ifdef _LIBC
  24. # include <libintl.h>
  25. #else
  26. # include "libgnuintl.h"
  27. #endif
  28. /* @@ end of prolog @@ */
  29. /* Names for the libintl functions are a problem. They must not clash
  30. with existing names and they should follow ANSI C. But this source
  31. code is also used in GNU C Library where the names have a __
  32. prefix. So we have to make a difference here. */
  33. #ifdef _LIBC
  34. # define GETTEXT __gettext
  35. # define DCGETTEXT __dcgettext
  36. #else
  37. # define GETTEXT libintl_gettext
  38. # define DCGETTEXT libintl_dcgettext
  39. #endif
  40. /* Look up MSGID in the current default message catalog for the current
  41. LC_MESSAGES locale. If not found, returns MSGID itself (the default
  42. text). */
  43. char *
  44. GETTEXT (const char *msgid)
  45. {
  46. return DCGETTEXT (NULL, msgid, LC_MESSAGES);
  47. }
  48. #ifdef _LIBC
  49. /* Alias for function name in GNU C Library. */
  50. weak_alias (__gettext, gettext);
  51. #endif