Blame intl/plural-exp.h

Packit Service a721b1
/* Expression parsing and evaluation for plural form selection.
Packit Service a721b1
   Copyright (C) 2000-2003, 2005-2007 Free Software Foundation, Inc.
Packit Service a721b1
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
Packit Service a721b1
Packit Service a721b1
   This program is free software; you can redistribute it and/or modify it
Packit Service a721b1
   under the terms of the GNU Library General Public License as published
Packit Service a721b1
   by the Free Software Foundation; either version 2, or (at your option)
Packit Service a721b1
   any later version.
Packit Service a721b1
Packit Service a721b1
   This program is distributed in the hope that it will be useful,
Packit Service a721b1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a721b1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service a721b1
   Library General Public License for more details.
Packit Service a721b1
Packit Service a721b1
   You should have received a copy of the GNU Library General Public
Packit Service a721b1
   License along with this program; if not, write to the Free Software
Packit Service a721b1
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
Packit Service a721b1
   USA.  */
Packit Service a721b1
Packit Service a721b1
#ifndef _PLURAL_EXP_H
Packit Service a721b1
#define _PLURAL_EXP_H
Packit Service a721b1
Packit Service a721b1
#ifndef internal_function
Packit Service a721b1
# define internal_function
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#ifndef attribute_hidden
Packit Service a721b1
# define attribute_hidden
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#ifdef __cplusplus
Packit Service a721b1
extern "C" {
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
Packit Service a721b1
enum expression_operator
Packit Service a721b1
{
Packit Service a721b1
  /* Without arguments:  */
Packit Service a721b1
  var,				/* The variable "n".  */
Packit Service a721b1
  num,				/* Decimal number.  */
Packit Service a721b1
  /* Unary operators:  */
Packit Service a721b1
  lnot,				/* Logical NOT.  */
Packit Service a721b1
  /* Binary operators:  */
Packit Service a721b1
  mult,				/* Multiplication.  */
Packit Service a721b1
  divide,			/* Division.  */
Packit Service a721b1
  module,			/* Modulo operation.  */
Packit Service a721b1
  plus,				/* Addition.  */
Packit Service a721b1
  minus,			/* Subtraction.  */
Packit Service a721b1
  less_than,			/* Comparison.  */
Packit Service a721b1
  greater_than,			/* Comparison.  */
Packit Service a721b1
  less_or_equal,		/* Comparison.  */
Packit Service a721b1
  greater_or_equal,		/* Comparison.  */
Packit Service a721b1
  equal,			/* Comparison for equality.  */
Packit Service a721b1
  not_equal,			/* Comparison for inequality.  */
Packit Service a721b1
  land,				/* Logical AND.  */
Packit Service a721b1
  lor,				/* Logical OR.  */
Packit Service a721b1
  /* Ternary operators:  */
Packit Service a721b1
  qmop				/* Question mark operator.  */
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
/* This is the representation of the expressions to determine the
Packit Service a721b1
   plural form.  */
Packit Service a721b1
struct expression
Packit Service a721b1
{
Packit Service a721b1
  int nargs;			/* Number of arguments.  */
Packit Service a721b1
  enum expression_operator operation;
Packit Service a721b1
  union
Packit Service a721b1
  {
Packit Service a721b1
    unsigned long int num;	/* Number value for `num'.  */
Packit Service a721b1
    struct expression *args[3];	/* Up to three arguments.  */
Packit Service a721b1
  } val;
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
/* This is the data structure to pass information to the parser and get
Packit Service a721b1
   the result in a thread-safe way.  */
Packit Service a721b1
struct parse_args
Packit Service a721b1
{
Packit Service a721b1
  const char *cp;
Packit Service a721b1
  struct expression *res;
Packit Service a721b1
};
Packit Service a721b1
Packit Service a721b1
Packit Service a721b1
/* Names for the libintl functions are a problem.  This source code is used
Packit Service a721b1
   1. in the GNU C Library library,
Packit Service a721b1
   2. in the GNU libintl library,
Packit Service a721b1
   3. in the GNU gettext tools.
Packit Service a721b1
   The function names in each situation must be different, to allow for
Packit Service a721b1
   binary incompatible changes in 'struct expression'.  Furthermore,
Packit Service a721b1
   1. in the GNU C Library library, the names have a __ prefix,
Packit Service a721b1
   2.+3. in the GNU libintl library and in the GNU gettext tools, the names
Packit Service a721b1
         must follow ANSI C and not start with __.
Packit Service a721b1
   So we have to distinguish the three cases.  */
Packit Service a721b1
#ifdef _LIBC
Packit Service a721b1
# define FREE_EXPRESSION __gettext_free_exp
Packit Service a721b1
# define PLURAL_PARSE __gettextparse
Packit Service a721b1
# define GERMANIC_PLURAL __gettext_germanic_plural
Packit Service a721b1
# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
Packit Service a721b1
#elif defined (IN_LIBINTL)
Packit Service a721b1
# define FREE_EXPRESSION libintl_gettext_free_exp
Packit Service a721b1
# define PLURAL_PARSE libintl_gettextparse
Packit Service a721b1
# define GERMANIC_PLURAL libintl_gettext_germanic_plural
Packit Service a721b1
# define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
Packit Service a721b1
#else
Packit Service a721b1
# define FREE_EXPRESSION free_plural_expression
Packit Service a721b1
# define PLURAL_PARSE parse_plural_expression
Packit Service a721b1
# define GERMANIC_PLURAL germanic_plural
Packit Service a721b1
# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
extern void FREE_EXPRESSION (struct expression *exp)
Packit Service a721b1
     internal_function;
Packit Service a721b1
extern int PLURAL_PARSE (void *arg);
Packit Service a721b1
extern struct expression GERMANIC_PLURAL attribute_hidden;
Packit Service a721b1
extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
Packit Service a721b1
				       const struct expression **pluralp,
Packit Service a721b1
				       unsigned long int *npluralsp)
Packit Service a721b1
     internal_function;
Packit Service a721b1
Packit Service a721b1
#if !defined (_LIBC) && !defined (IN_LIBINTL) && !defined (IN_LIBGLOCALE)
Packit Service a721b1
extern unsigned long int plural_eval (const struct expression *pexp,
Packit Service a721b1
				      unsigned long int n);
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
Packit Service a721b1
#ifdef __cplusplus
Packit Service a721b1
}
Packit Service a721b1
#endif
Packit Service a721b1
Packit Service a721b1
#endif /* _PLURAL_EXP_H */