Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Expression parsing and evaluation for plural form selection.
  2. Copyright (C) 2000-2003 Free Software Foundation, Inc.
  3. Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU Library General Public License as published
  6. by the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  15. USA. */
  16. #ifndef _PLURAL_EXP_H
  17. #define _PLURAL_EXP_H
  18. #ifndef internal_function
  19. # define internal_function
  20. #endif
  21. #ifndef attribute_hidden
  22. # define attribute_hidden
  23. #endif
  24. /* This is the representation of the expressions to determine the
  25. plural form. */
  26. struct expression
  27. {
  28. int nargs; /* Number of arguments. */
  29. enum operator
  30. {
  31. /* Without arguments: */
  32. var, /* The variable "n". */
  33. num, /* Decimal number. */
  34. /* Unary operators: */
  35. lnot, /* Logical NOT. */
  36. /* Binary operators: */
  37. mult, /* Multiplication. */
  38. divide, /* Division. */
  39. module, /* Modulo operation. */
  40. plus, /* Addition. */
  41. minus, /* Subtraction. */
  42. less_than, /* Comparison. */
  43. greater_than, /* Comparison. */
  44. less_or_equal, /* Comparison. */
  45. greater_or_equal, /* Comparison. */
  46. equal, /* Comparison for equality. */
  47. not_equal, /* Comparison for inequality. */
  48. land, /* Logical AND. */
  49. lor, /* Logical OR. */
  50. /* Ternary operators: */
  51. qmop /* Question mark operator. */
  52. } operation;
  53. union
  54. {
  55. unsigned long int num; /* Number value for `num'. */
  56. struct expression *args[3]; /* Up to three arguments. */
  57. } val;
  58. };
  59. /* This is the data structure to pass information to the parser and get
  60. the result in a thread-safe way. */
  61. struct parse_args
  62. {
  63. const char *cp;
  64. struct expression *res;
  65. };
  66. /* Names for the libintl functions are a problem. This source code is used
  67. 1. in the GNU C Library library,
  68. 2. in the GNU libintl library,
  69. 3. in the GNU gettext tools.
  70. The function names in each situation must be different, to allow for
  71. binary incompatible changes in 'struct expression'. Furthermore,
  72. 1. in the GNU C Library library, the names have a __ prefix,
  73. 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
  74. must follow ANSI C and not start with __.
  75. So we have to distinguish the three cases. */
  76. #ifdef _LIBC
  77. # define FREE_EXPRESSION __gettext_free_exp
  78. # define PLURAL_PARSE __gettextparse
  79. # define GERMANIC_PLURAL __gettext_germanic_plural
  80. # define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
  81. #elif defined (IN_LIBINTL)
  82. # define FREE_EXPRESSION libintl_gettext_free_exp
  83. # define PLURAL_PARSE libintl_gettextparse
  84. # define GERMANIC_PLURAL libintl_gettext_germanic_plural
  85. # define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
  86. #else
  87. # define FREE_EXPRESSION free_plural_expression
  88. # define PLURAL_PARSE parse_plural_expression
  89. # define GERMANIC_PLURAL germanic_plural
  90. # define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
  91. #endif
  92. extern void FREE_EXPRESSION (struct expression *exp)
  93. internal_function;
  94. extern int PLURAL_PARSE (void *arg);
  95. extern struct expression GERMANIC_PLURAL attribute_hidden;
  96. extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
  97. struct expression **pluralp,
  98. unsigned long int *npluralsp)
  99. internal_function;
  100. #if !defined (_LIBC) && !defined (IN_LIBINTL)
  101. extern unsigned long int plural_eval (struct expression *pexp,
  102. unsigned long int n);
  103. #endif
  104. #endif /* _PLURAL_EXP_H */