summaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-05-25 12:33:24 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-05-25 12:33:24 (GMT)
commit5fd2550d4c96318b2de4a4a44e15e3c50c268e79 (patch)
treeb712838611281a444a9b603949352bc4003de657 /m4
parent80e155c9cf826d977393ee130a07be599401335e (diff)
downloadmonitoring-plugins-5fd2550d4c96318b2de4a4a44e15e3c50c268e79.tar.gz
Use coreutils' regexp libraries, so regexp always available now
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1403 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'm4')
-rw-r--r--m4/.cvsignore1
-rw-r--r--m4/np_coreutils.m41
-rw-r--r--m4/regex.m4187
-rw-r--r--m4/restrict.m438
4 files changed, 227 insertions, 0 deletions
diff --git a/m4/.cvsignore b/m4/.cvsignore
index 282522d..a324157 100644
--- a/m4/.cvsignore
+++ b/m4/.cvsignore
@@ -1,2 +1,3 @@
1Makefile 1Makefile
2Makefile.in 2Makefile.in
3Makefile.am
diff --git a/m4/np_coreutils.m4 b/m4/np_coreutils.m4
index e6627a2..44aa3b8 100644
--- a/m4/np_coreutils.m4
+++ b/m4/np_coreutils.m4
@@ -18,4 +18,5 @@ AC_DEFUN([np_COREUTILS],
18 AC_REQUIRE([gl_MOUNTLIST]) 18 AC_REQUIRE([gl_MOUNTLIST])
19 AC_REQUIRE([gl_FSUSAGE]) 19 AC_REQUIRE([gl_FSUSAGE])
20 AC_REQUIRE([gl_FUNC_GLIBC_UNLOCKED_IO]) 20 AC_REQUIRE([gl_FUNC_GLIBC_UNLOCKED_IO])
21 AC_REQUIRE([gl_REGEX])
21]) 22])
diff --git a/m4/regex.m4 b/m4/regex.m4
new file mode 100644
index 0000000..8ea4fe9
--- /dev/null
+++ b/m4/regex.m4
@@ -0,0 +1,187 @@
1#serial 31
2
3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
4# Software Foundation, Inc.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl Initially derived from code in GNU grep.
11dnl Mostly written by Jim Meyering.
12
13AC_PREREQ([2.50])
14
15AC_DEFUN([gl_REGEX],
16[
17 AC_REQUIRE([AC_SYS_LARGEFILE]) dnl for a sufficently-wide off_t
18
19 AC_CACHE_CHECK([whether off_t can be used in a switch statement],
20 [gl_cv_type_off_t_switch],
21 [AC_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [AC_INCLUDES_DEFAULT],
24 [[off_t o = -1;
25 switch (o)
26 {
27 case -2:
28 return 1;
29 case -1:
30 return 2;
31 default:
32 return 0;
33 }
34 ]])],
35 [gl_cv_type_off_t_switch=yes],
36 [gl_cv_type_off_t_switch=no])])
37 if test $gl_cv_type_off_t_switch = yes; then
38 AC_DEFINE([_REGEX_LARGE_OFFSETS], 1,
39 [Define if you want regoff_t to be at least as wide POSIX requires.])
40 fi
41
42 AC_LIBSOURCES(
43 [regcomp.c, regex.c, regex.h,
44 regex_internal.c, regex_internal.h, regexec.c])
45
46 AC_ARG_WITH([included-regex],
47 [AC_HELP_STRING([--without-included-regex],
48 [don't compile regex; this is the default on
49 systems with recent-enough versions of the GNU C
50 Library (use with caution on other systems)])])
51
52 case $with_included_regex in
53 yes|no) ac_use_included_regex=$with_included_regex
54 ;;
55 '')
56 # If the system regex support is good enough that it passes the the
57 # following run test, then default to *not* using the included regex.c.
58 # If cross compiling, assume the test would fail and use the included
59 # regex.c. The first failing regular expression is from `Spencer ere
60 # test #75' in grep-2.3.
61 AC_CACHE_CHECK([for working re_compile_pattern],
62 [gl_cv_func_re_compile_pattern_broken],
63 [AC_RUN_IFELSE(
64 [AC_LANG_PROGRAM(
65 [AC_INCLUDES_DEFAULT
66 #include <regex.h>],
67 [[static struct re_pattern_buffer regex;
68 const char *s;
69 struct re_registers regs;
70 /* Use the POSIX-compliant spelling with leading REG_,
71 rather than the traditional GNU spelling with leading RE_,
72 so that we reject older libc implementations. */
73 re_set_syntax (REG_SYNTAX_POSIX_EGREP);
74 memset (&regex, 0, sizeof (regex));
75 s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);
76 /* This should fail with _Invalid character class name_ error. */
77 if (!s)
78 exit (1);
79
80 /* This should succeed, but does not for e.g. glibc-2.1.3. */
81 memset (&regex, 0, sizeof (regex));
82 s = re_compile_pattern ("{1", 2, &regex);
83
84 if (s)
85 exit (1);
86
87 /* The following example is derived from a problem report
88 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
89 memset (&regex, 0, sizeof (regex));
90 s = re_compile_pattern ("[an\371]*n", 7, &regex);
91 if (s)
92 exit (1);
93
94 /* This should match, but does not for e.g. glibc-2.2.1. */
95 if (re_match (&regex, "an", 2, 0, &regs) != 2)
96 exit (1);
97
98 memset (&regex, 0, sizeof (regex));
99 s = re_compile_pattern ("x", 1, &regex);
100 if (s)
101 exit (1);
102
103 /* The version of regex.c in e.g. GNU libc-2.2.93 did not
104 work with a negative RANGE argument. */
105 if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
106 exit (1);
107
108 /* The version of regex.c in older versions of gnulib
109 ignored REG_IGNORE_CASE (which was then called RE_ICASE).
110 Detect that problem too. */
111 memset (&regex, 0, sizeof (regex));
112 re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE);
113 s = re_compile_pattern ("x", 1, &regex);
114 if (s)
115 exit (1);
116
117 if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
118 exit (1);
119
120 /* REG_STARTEND was added to glibc on 2004-01-15.
121 Reject older versions. */
122 if (! REG_STARTEND)
123 exit (1);
124
125 /* Reject hosts whose regoff_t values are too narrow.
126 These include glibc 2.3.5 on hosts with 64-bit off_t
127 and 32-bit int, and Solaris 10 on hosts with 32-bit int
128 and _FILE_OFFSET_BITS=64. */
129 if (sizeof (regoff_t) < sizeof (off_t))
130 exit (1);
131
132 exit (0);]])],
133 [gl_cv_func_re_compile_pattern_broken=no],
134 [gl_cv_func_re_compile_pattern_broken=yes],
135 dnl When crosscompiling, assume it is broken.
136 [gl_cv_func_re_compile_pattern_broken=yes])])
137 ac_use_included_regex=$gl_cv_func_re_compile_pattern_broken
138 ;;
139 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
140 ;;
141 esac
142
143 if test $ac_use_included_regex = yes; then
144 AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
145 [Define to rpl_re_syntax_options if the replacement should be used.])
146 AC_DEFINE([re_set_syntax], [rpl_re_set_syntax],
147 [Define to rpl_re_set_syntax if the replacement should be used.])
148 AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern],
149 [Define to rpl_re_compile_pattern if the replacement should be used.])
150 AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap],
151 [Define to rpl_re_compile_fastmap if the replacement should be used.])
152 AC_DEFINE([re_search], [rpl_re_search],
153 [Define to rpl_re_search if the replacement should be used.])
154 AC_DEFINE([re_search_2], [rpl_re_search_2],
155 [Define to rpl_re_search_2 if the replacement should be used.])
156 AC_DEFINE([re_match], [rpl_re_match],
157 [Define to rpl_re_match if the replacement should be used.])
158 AC_DEFINE([re_match_2], [rpl_re_match_2],
159 [Define to rpl_re_match_2 if the replacement should be used.])
160 AC_DEFINE([re_set_registers], [rpl_re_set_registers],
161 [Define to rpl_re_set_registers if the replacement should be used.])
162 AC_DEFINE([re_comp], [rpl_re_comp],
163 [Define to rpl_re_comp if the replacement should be used.])
164 AC_DEFINE([re_exec], [rpl_re_exec],
165 [Define to rpl_re_exec if the replacement should be used.])
166 AC_DEFINE([regcomp], [rpl_regcomp],
167 [Define to rpl_regcomp if the replacement should be used.])
168 AC_DEFINE([regexec], [rpl_regexec],
169 [Define to rpl_regexec if the replacement should be used.])
170 AC_DEFINE([regerror], [rpl_regerror],
171 [Define to rpl_regerror if the replacement should be used.])
172 AC_DEFINE([regfree], [rpl_regfree],
173 [Define to rpl_regfree if the replacement should be used.])
174 AC_LIBOBJ([regex])
175 gl_PREREQ_REGEX
176 fi
177])
178
179# Prerequisites of lib/regex.c and lib/regex_internal.c.
180AC_DEFUN([gl_PREREQ_REGEX],
181[
182 AC_REQUIRE([AC_GNU_SOURCE])
183 AC_REQUIRE([gl_C_RESTRICT])
184 AC_REQUIRE([AM_LANGINFO_CODESET])
185 AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])
186 AC_CHECK_FUNCS_ONCE([isblank mbrtowc mempcpy wcrtomb wcscoll])
187])
diff --git a/m4/restrict.m4 b/m4/restrict.m4
new file mode 100644
index 0000000..1f3bbb9
--- /dev/null
+++ b/m4/restrict.m4
@@ -0,0 +1,38 @@
1#serial 1003
2dnl Copyright (C) 2003 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# This macro can be removed once we can rely on Autoconf 2.57a or later,
8# since we can then use its AC_C_RESTRICT.
9
10# gl_C_RESTRICT
11# --------------
12# Determine whether the C/C++ compiler supports the "restrict" keyword
13# introduced in ANSI C99, or an equivalent. Do nothing if the compiler
14# accepts it. Otherwise, if the compiler supports an equivalent,
15# define "restrict" to be that. Here are some variants:
16# - GCC supports both __restrict and __restrict__
17# - older DEC Alpha C compilers support only __restrict
18# - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
19# Otherwise, define "restrict" to be empty.
20AC_DEFUN([gl_C_RESTRICT],
21[AC_CACHE_CHECK([for C/C++ restrict keyword], gl_cv_c_restrict,
22 [gl_cv_c_restrict=no
23 # Try the official restrict keyword, then gcc's __restrict, and
24 # the less common variants.
25 for ac_kw in restrict __restrict __restrict__ _Restrict; do
26 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
27 [float * $ac_kw x;])],
28 [gl_cv_c_restrict=$ac_kw; break])
29 done
30 ])
31 case $gl_cv_c_restrict in
32 restrict) ;;
33 no) AC_DEFINE(restrict,,
34 [Define to equivalent of C99 restrict keyword, or to nothing if this
35 is not supported. Do not define if restrict is supported directly.]) ;;
36 *) AC_DEFINE_UNQUOTED(restrict, $gl_cv_c_restrict) ;;
37 esac
38])