Blame intl/plural-exp.h

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