+2005-10-09 Bruno Haible <bruno@clisp.org>
+
+ * 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 <bruno@clisp.org>
* msgl-check.c: Include c-ctype.h instead of ctype.h.
plural-exp.c
Parsing plural expressions.
+plural-eval.h
plural-eval.c
Evaluating plural expressions.
msgl-check.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 \
#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"
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
-/* Some platforms don't have the sigjmp_buf type in <setjmp.h>. */
-#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.
/* 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 <drepper@cygnus.com>, 2000.
This program is free software; you can redistribute it and/or modify
# include <config.h>
#endif
-#if !INTDIV0_RAISES_SIGFPE
-# include <signal.h>
-#endif
+/* Specification. */
+#include "plural-eval.h"
+
+#include <stddef.h>
+#include <signal.h>
#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
+}