From: Bruno Haible Date: Mon, 24 Oct 2005 11:58:57 +0000 (+0000) Subject: Move some code from msgl-check.c to plural-eval.c. X-Git-Tag: v0.15~348 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da1d63fc946a16ee3081b1c72046eb0a623b153a;p=thirdparty%2Fgettext.git Move some code from msgl-check.c to plural-eval.c. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 5c5fe2ed9..a9304c61c 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,16 @@ +2005-10-09 Bruno Haible + + * plural-eval.h: New file. + * plural-eval.c: Include plural-eval.h. + (sigfpe_exit, sigfpe_code, sigfpe_handler, install_sigfpe_handler, + uninstall_sigfpe_handler): New definitions, moved here from + msgl-check.c. + * msgl-check.c: Include plural.eval.h. + (sigjmp_buf, sigsetjmp, siglongjmp, USE_SIGINFO): Move to plural-eval.h. + (sigfpe_exit, sigfpe_code, sigfpe_handler, install_sigfpe_handler, + uninstall_sigfpe_handler): Move to plural-eval.c. + * Makefile.am (noinst_HEADERS): Add plural-eval.h. + 2005-10-09 Bruno Haible * msgl-check.c: Include c-ctype.h instead of ctype.h. diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES index 99a1e997e..3781aef39 100644 --- a/gettext-tools/src/FILES +++ b/gettext-tools/src/FILES @@ -211,6 +211,7 @@ format.c Table of the language dependent format string handlers. plural-exp.c Parsing plural expressions. +plural-eval.h plural-eval.c Evaluating plural expressions. msgl-check.h diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index 42d2f17a1..c25e91a5f 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -41,7 +41,7 @@ str-list.h \ write-po.h write-properties.h write-stringtable.h \ dir-list.h file-list.h po-gram-gen.h po-gram-gen2.h \ msgl-charset.h msgl-equal.h msgl-iconv.h msgl-ascii.h msgl-cat.h \ -msgl-english.h msgl-check.h msgfmt.h msgunfmt.h plural-count.h \ +msgl-english.h msgl-check.h msgfmt.h msgunfmt.h plural-count.h plural-eval.h \ read-mo.h write-mo.h \ read-java.h write-java.h \ read-csharp.h write-csharp.h \ diff --git a/gettext-tools/src/msgl-check.c b/gettext-tools/src/msgl-check.c index e58537713..9d010f367 100644 --- a/gettext-tools/src/msgl-check.c +++ b/gettext-tools/src/msgl-check.c @@ -36,6 +36,7 @@ #include "po-xerror.h" #include "format.h" #include "plural-exp.h" +#include "plural-eval.h" #include "plural-table.h" #include "strstr.h" #include "vasprintf.h" @@ -47,75 +48,6 @@ #define SIZEOF(a) (sizeof(a) / sizeof(a[0])) -/* Some platforms don't have the sigjmp_buf type in . */ -#if defined _MSC_VER || defined __MINGW32__ -/* Native Woe32 API. */ -# define sigjmp_buf jmp_buf -# define sigsetjmp(env,savesigs) setjmp (env) -# define siglongjmp longjmp -#endif - -/* We use siginfo to get precise information about the signal. - But siginfo doesn't work on Irix 6.5. */ -#if HAVE_SIGINFO && !defined (__sgi) -# define USE_SIGINFO 1 -#endif - - -static sigjmp_buf sigfpe_exit; - -#if USE_SIGINFO - -static int sigfpe_code; - -/* Signal handler called in case of arithmetic exception (e.g. division - by zero) during plural_eval. */ -static void -sigfpe_handler (int sig, siginfo_t *sip, void *scp) -{ - sigfpe_code = sip->si_code; - siglongjmp (sigfpe_exit, 1); -} - -#else - -/* Signal handler called in case of arithmetic exception (e.g. division - by zero) during plural_eval. */ -static void -sigfpe_handler (int sig) -{ - siglongjmp (sigfpe_exit, 1); -} - -#endif - -static void -install_sigfpe_handler () -{ -#if USE_SIGINFO - struct sigaction action; - action.sa_sigaction = sigfpe_handler; - action.sa_flags = SA_SIGINFO; - sigemptyset (&action.sa_mask); - sigaction (SIGFPE, &action, (struct sigaction *) NULL); -#else - signal (SIGFPE, sigfpe_handler); -#endif -} - -static void -uninstall_sigfpe_handler () -{ -#if USE_SIGINFO - struct sigaction action; - action.sa_handler = SIG_DFL; - action.sa_flags = 0; - sigemptyset (&action.sa_mask); - sigaction (SIGFPE, &action, (struct sigaction *) NULL); -#else - signal (SIGFPE, SIG_DFL); -#endif -} /* Check the values returned by plural_eval. Return the number of errors that were seen. diff --git a/gettext-tools/src/plural-eval.c b/gettext-tools/src/plural-eval.c index 584770648..bfd7032c4 100644 --- a/gettext-tools/src/plural-eval.c +++ b/gettext-tools/src/plural-eval.c @@ -1,5 +1,5 @@ /* Expression evaluation for plural form selection. - Copyright (C) 2000-2003 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2005 Free Software Foundation, Inc. Written by Ulrich Drepper , 2000. This program is free software; you can redistribute it and/or modify @@ -20,14 +20,75 @@ # include #endif -#if !INTDIV0_RAISES_SIGFPE -# include -#endif +/* Specification. */ +#include "plural-eval.h" + +#include +#include #include "plural-exp.h" + #define STATIC /*extern*/ /* Include the expression evaluation code from libintl, this time with 'extern' linkage. */ #include "eval-plural.h" + + +/* Exit point. Must be set before calling install_sigfpe_handler(). */ +sigjmp_buf sigfpe_exit; + +#if USE_SIGINFO + +/* Additional information that is set before sigfpe_exit is invoked. */ +int sigfpe_code; + +/* Signal handler called in case of arithmetic exception (e.g. division + by zero) during plural_eval. */ +static void +sigfpe_handler (int sig, siginfo_t *sip, void *scp) +{ + sigfpe_code = sip->si_code; + siglongjmp (sigfpe_exit, 1); +} + +#else + +/* Signal handler called in case of arithmetic exception (e.g. division + by zero) during plural_eval. */ +static void +sigfpe_handler (int sig) +{ + siglongjmp (sigfpe_exit, 1); +} + +#endif + +void +install_sigfpe_handler (void) +{ +#if USE_SIGINFO + struct sigaction action; + action.sa_sigaction = sigfpe_handler; + action.sa_flags = SA_SIGINFO; + sigemptyset (&action.sa_mask); + sigaction (SIGFPE, &action, (struct sigaction *) NULL); +#else + signal (SIGFPE, sigfpe_handler); +#endif +} + +void +uninstall_sigfpe_handler (void) +{ +#if USE_SIGINFO + struct sigaction action; + action.sa_handler = SIG_DFL; + action.sa_flags = 0; + sigemptyset (&action.sa_mask); + sigaction (SIGFPE, &action, (struct sigaction *) NULL); +#else + signal (SIGFPE, SIG_DFL); +#endif +}