]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Move some code from msgl-check.c to plural-eval.c.
authorBruno Haible <bruno@clisp.org>
Mon, 24 Oct 2005 11:58:57 +0000 (11:58 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:56 +0000 (12:12 +0200)
gettext-tools/src/ChangeLog
gettext-tools/src/FILES
gettext-tools/src/Makefile.am
gettext-tools/src/msgl-check.c
gettext-tools/src/plural-eval.c

index 5c5fe2ed9a606159d3352cd087a1f6f3269cedac..a9304c61c9989383e79455991b8136a5be6050a0 100644 (file)
@@ -1,3 +1,16 @@
+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.
index 99a1e997eeb9b6f1bd2b03046dad4f5208c7ce8a..3781aef392c2f9c69be4c5da06925d2ca133e26f 100644 (file)
@@ -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
index 42d2f17a1a980eae1ef4f5e4b17ea937a7bd6f00..c25e91a5f55641af5aaa2009c6d7b487107656df 100644 (file)
@@ -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 \
index e585377130d049dcb3ebe46983a7a1fcc0cf9ce4..9d010f367a719f0855cd216ad00b0dc05b9b197c 100644 (file)
@@ -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"
 
 #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.
index 584770648cc54a76389ee155156cb1389aa1188d..bfd7032c41ae85687f93efce6da4ef8ca1554e32 100644 (file)
@@ -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 <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
+}