Blame intl/plural-exp.h

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