1 /* Expression evaluation for plural form selection.
2 Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "plural-eval.h"
28 #include "plural-exp.h"
31 #define STATIC /*extern*/
33 /* Include the expression evaluation code from libintl, this time with
35 #include "eval-plural.h"
38 /* Exit point. Must be set before calling install_sigfpe_handler(). */
39 sigjmp_buf sigfpe_exit;
43 /* Additional information that is set before sigfpe_exit is invoked. */
46 /* Signal handler called in case of arithmetic exception (e.g. division
47 by zero) during plural_eval. */
49 sigfpe_handler (int sig, siginfo_t *sip, void *scp)
51 sigfpe_code = sip->si_code;
52 siglongjmp (sigfpe_exit, 1);
57 /* Signal handler called in case of arithmetic exception (e.g. division
58 by zero) during plural_eval. */
60 sigfpe_handler (int sig)
62 siglongjmp (sigfpe_exit, 1);
68 install_sigfpe_handler (void)
71 struct sigaction action;
72 action.sa_sigaction = sigfpe_handler;
73 action.sa_flags = SA_SIGINFO;
74 sigemptyset (&action.sa_mask);
75 sigaction (SIGFPE, &action, (struct sigaction *) NULL);
77 signal (SIGFPE, sigfpe_handler);
82 uninstall_sigfpe_handler (void)
85 struct sigaction action;
86 action.sa_handler = SIG_DFL;
88 sigemptyset (&action.sa_mask);
89 sigaction (SIGFPE, &action, (struct sigaction *) NULL);
91 signal (SIGFPE, SIG_DFL);