summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorAlain Magloire <alainm@rcsm.ee.mcgill.ca>2001-02-08 05:56:49 +0000
committerAlain Magloire <alainm@rcsm.ee.mcgill.ca>2001-02-08 05:56:49 +0000
commit5d6c5528ceaf61a916d667af1a54562c9caa7789 (patch)
tree6906a2870408eb7a4b62f70b01a70c034e430f97 /m4
parentf850847ef85d69bbebb7bac5490ebccbec7ee8e2 (diff)
downloadgrep-5d6c5528ceaf61a916d667af1a54562c9caa7789.tar.gz
Patch provided by Paul Eggert.
* Makefile.am (ACINCLUDE_INPUTS): Add decl.m4, inttypes_h.m4, uintmax_t.m4, ulonglong.m4, xstrtoumax.m4. * m4/Makefile.am (EXTRA_DIST): Likewise. * src/Makefile.am (base_sources): Add xstrtol.c, xstrtol.h, xstrtoumax.c. (EXTRA_DIST): Add strtol.c. * configure.in (jm_AC_TYPE_UINTMAX_T, jm_AC_PREREQ_XSTRTOUMAX, HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): Add. (AC_REPLACE_FUNCS): Add strtoul. * src/grep.c: Include xstrtol.h. (ck_atio): Use xstrtoumax and do proper overflow checking. (max_count, outleft): Now off_t, not int. (main): Likewise. Use xstrtoumax to convert max_count from string. * acconfig.h (HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): New #undefs. (HAVE_STPCPY, ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, HAVE_LC_MESSAGES): Remove. * m4/decl.m4, m4/inttypes_h.m4, m4/uintmax_t.m4, m4/ulonglong.m4, m4/xstrtoumax.m4, src/strtol.c, src/strtoul.c, src/strtoull.c, src/strtoumax.c, src/xstrtol.c, src/xstrtol.h, src/xstrtoumax.c: New files, taken unchanged from textutils, fileutils, sh-utils and/or tar.
Diffstat (limited to 'm4')
-rw-r--r--m4/Makefile.am11
-rw-r--r--m4/decl.m437
-rw-r--r--m4/inttypes_h.m422
-rw-r--r--m4/uintmax_t.m422
-rw-r--r--m4/ulonglong.m417
-rw-r--r--m4/xstrtoumax.m434
6 files changed, 140 insertions, 3 deletions
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 3be5753c..21cd7d19 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,7 +1,8 @@
## Process this file with automake to create Makefile.in
AUTOMAKE_OPTIONS = no-dependencies
-EXTRA_DIST = djgpp.m4 \
+EXTRA_DIST = decl.m4 \
+ djgpp.m4 \
dosfile.m4 \
envsep.m4 \
gettext.m4 \
@@ -9,10 +10,14 @@ EXTRA_DIST = djgpp.m4 \
header.m4 \
init.m4 \
install.m4 \
+ inttypes_h.m4 \
isc-posix.m4 \
- lcmessage.m4 \
largefile.m4 \
+ lcmessage.m4 \
missing.m4 \
progtest.m4 \
regex.m4 \
- sanity.m4
+ sanity.m4 \
+ uintmax_t.m4 \
+ ulonglong.m4 \
+ xstrtoumax.m4
diff --git a/m4/decl.m4 b/m4/decl.m4
new file mode 100644
index 00000000..4dd7e0d6
--- /dev/null
+++ b/m4/decl.m4
@@ -0,0 +1,37 @@
+#serial 5
+
+AC_DEFUN(jm_CHECK_DECLARATION,
+[
+ AC_MSG_CHECKING([whether $1 is declared])
+ AC_CACHE_VAL(jm_cv_func_decl_$1,
+ [AC_TRY_COMPILE([$2],
+ [
+#ifndef $1
+char *(*pfn) = (char *(*)) $1
+#endif
+ ],
+ eval "jm_cv_func_decl_$1=yes",
+ eval "jm_cv_func_decl_$1=no")])
+
+ if eval "test \"`echo '$jm_cv_func_decl_'$1`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ ifelse([$3], , :, [$3])
+ else
+ AC_MSG_RESULT(no)
+ ifelse([$4], , , [$4
+])dnl
+ fi
+])dnl
+
+dnl jm_CHECK_DECLARATIONS(INCLUDES, FUNCTION... [, ACTION-IF-DECLARED
+dnl [, ACTION-IF-NOT-DECLARED]])
+AC_DEFUN(jm_CHECK_DECLARATIONS,
+[
+ for jm_func in $2
+ do
+ jm_CHECK_DECLARATION($jm_func, [$1],
+ [
+ jm_tr_func=HAVE_DECL_`echo $jm_func | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
+ AC_DEFINE_UNQUOTED($jm_tr_func) $3], [$4])dnl
+ done
+])
diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4
new file mode 100644
index 00000000..750639d6
--- /dev/null
+++ b/m4/inttypes_h.m4
@@ -0,0 +1,22 @@
+#serial 3
+
+dnl From Paul Eggert.
+
+# Define HAVE_INTTYPES_H if <inttypes.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+
+AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
+[
+ AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
+ [AC_TRY_COMPILE(
+ [#include <sys/types.h>
+#include <inttypes.h>],
+ [uintmax_t i = (uintmax_t) -1;],
+ jm_ac_cv_header_inttypes_h=yes,
+ jm_ac_cv_header_inttypes_h=no)])
+ if test $jm_ac_cv_header_inttypes_h = yes; then
+ AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
+[Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
+ and declares uintmax_t. ])
+ fi
+])
diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4
new file mode 100644
index 00000000..222beffa
--- /dev/null
+++ b/m4/uintmax_t.m4
@@ -0,0 +1,22 @@
+#serial 5
+
+dnl From Paul Eggert.
+
+AC_PREREQ(2.13)
+
+# Define uintmax_t to `unsigned long' or `unsigned long long'
+# if <inttypes.h> does not exist.
+
+AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
+[
+ AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
+ if test $jm_ac_cv_header_inttypes_h = no; then
+ AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
+ test $ac_cv_type_unsigned_long_long = yes \
+ && ac_type='unsigned long long' \
+ || ac_type='unsigned long'
+ AC_DEFINE_UNQUOTED(uintmax_t, $ac_type,
+[ Define to unsigned long or unsigned long long
+ if <inttypes.h> doesn't define.])
+ fi
+])
diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4
new file mode 100644
index 00000000..e2fbb552
--- /dev/null
+++ b/m4/ulonglong.m4
@@ -0,0 +1,17 @@
+#serial 2
+
+dnl From Paul Eggert.
+
+AC_DEFUN(jm_AC_TYPE_UNSIGNED_LONG_LONG,
+[
+ AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
+ [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
+ [unsigned long long ullmax = (unsigned long long) -1;
+ return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
+ ac_cv_type_unsigned_long_long=yes,
+ ac_cv_type_unsigned_long_long=no)])
+ if test $ac_cv_type_unsigned_long_long = yes; then
+ AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1,
+ [Define if you have the unsigned long long type.])
+ fi
+])
diff --git a/m4/xstrtoumax.m4 b/m4/xstrtoumax.m4
new file mode 100644
index 00000000..f6e31996
--- /dev/null
+++ b/m4/xstrtoumax.m4
@@ -0,0 +1,34 @@
+#serial 2
+
+# autoconf tests required for use of xstrtoumax.c
+
+AC_DEFUN(jm_AC_PREREQ_XSTRTOUMAX,
+[
+ AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
+ AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
+ AC_CHECK_HEADERS(stdlib.h)
+
+ AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
+ jm_cv_func_strtoumax_macro,
+ AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
+#ifdef strtoumax
+ inttypes_h_defines_strtoumax
+#endif],
+ jm_cv_func_strtoumax_macro=yes,
+ jm_cv_func_strtoumax_macro=no))
+
+ if test "$jm_cv_func_strtoumax_macro" != yes; then
+ AC_REPLACE_FUNCS(strtoumax)
+ fi
+
+ dnl We don't need (and can't compile) the replacement strtoull
+ dnl unless the type `unsigned long long' exists.
+ dnl Also, only the replacement strtoumax invokes strtoull,
+ dnl so we need the replacement strtoull only if strtoumax does not exist.
+ case "$ac_cv_type_unsigned_long_long,$jm_cv_func_strtoumax_macro,$ac_cv_func_strtoumax" in
+ yes,no,no)
+ AC_REPLACE_FUNCS(strtoull)
+ ;;
+ esac
+
+])