diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-30 15:34:18 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-01-30 15:34:18 -0800 |
commit | 16c3e636a68cf74386d3d4d582a3a189b84d700c (patch) | |
tree | 43ef51bef626bf3b4c4d578e8dce0ad9857e98df /m4 | |
parent | 4eec7f8b2b465c6fc2c09d37d4da2b540f607df0 (diff) | |
download | emacs-16c3e636a68cf74386d3d4d582a3a189b84d700c.tar.gz |
strftime: import from gnulib
Diffstat (limited to 'm4')
-rw-r--r-- | m4/gl-comp.m4 | 12 | ||||
-rw-r--r-- | m4/stdbool.m4 | 103 | ||||
-rw-r--r-- | m4/strftime.m4 | 30 | ||||
-rw-r--r-- | m4/tm_gmtoff.m4 | 14 |
4 files changed, 159 insertions, 0 deletions
diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4 index 32d3cce4307..e5121918903 100644 --- a/m4/gl-comp.m4 +++ b/m4/gl-comp.m4 @@ -38,7 +38,9 @@ AC_DEFUN([gl_EARLY], # Code from module intprops: # Code from module mktime: # Code from module multiarch: + # Code from module stdbool: # Code from module stddef: + # Code from module strftime: # Code from module time: # Code from module time_r: # Code from module unistd: @@ -81,8 +83,12 @@ AC_DEFUN([gl_INIT], gl_TIME_MODULE_INDICATOR([mktime]) # Code from module multiarch: gl_MULTIARCH + # Code from module stdbool: + AM_STDBOOL_H # Code from module stddef: gl_STDDEF_H + # Code from module strftime: + gl_FUNC_GNU_STRFTIME # Code from module time: gl_HEADER_TIME_H # Code from module time_r: @@ -245,7 +251,10 @@ AC_DEFUN([gl_FILE_LIST], [ lib/intprops.h lib/mktime-internal.h lib/mktime.c + lib/stdbool.in.h lib/stddef.in.h + lib/strftime.c + lib/strftime.h lib/time.in.h lib/time_r.c lib/unistd.in.h @@ -257,9 +266,12 @@ AC_DEFUN([gl_FILE_LIST], [ m4/include_next.m4 m4/mktime.m4 m4/multiarch.m4 + m4/stdbool.m4 m4/stddef_h.m4 + m4/strftime.m4 m4/time_h.m4 m4/time_r.m4 + m4/tm_gmtoff.m4 m4/unistd_h.m4 m4/warn-on-use.m4 m4/wchar_t.m4 diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 new file mode 100644 index 00000000000..df10486d0a8 --- /dev/null +++ b/m4/stdbool.m4 @@ -0,0 +1,103 @@ +# Check for stdbool.h that conforms to C99. + +dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +#serial 3 + +# Prepare for substituting <stdbool.h> if it is not supported. + +AC_DEFUN([AM_STDBOOL_H], +[ + AC_REQUIRE([AC_HEADER_STDBOOL]) + + # Define two additional variables used in the Makefile substitution. + + if test "$ac_cv_header_stdbool_h" = yes; then + STDBOOL_H='' + else + STDBOOL_H='stdbool.h' + fi + AC_SUBST([STDBOOL_H]) + + if test "$ac_cv_type__Bool" = yes; then + HAVE__BOOL=1 + else + HAVE__BOOL=0 + fi + AC_SUBST([HAVE__BOOL]) +]) + +# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. +AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) + +# This version of the macro is needed in autoconf <= 2.67. Autoconf has +# it built in since 2.60, but we want the tweaks from the 2.68 version +# to avoid rejecting xlc and clang due to relying on extensions. + +AC_DEFUN([AC_HEADER_STDBOOL], + [AC_CACHE_CHECK([for stdbool.h that conforms to C99], + [ac_cv_header_stdbool_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include <stdbool.h> + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + ]], + [[ + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + ]])], + [ac_cv_header_stdbool_h=yes], + [ac_cv_header_stdbool_h=no])]) + AC_CHECK_TYPES([_Bool]) + if test $ac_cv_header_stdbool_h = yes; then + AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.]) + fi]) diff --git a/m4/strftime.m4 b/m4/strftime.m4 new file mode 100644 index 00000000000..d9de341bf6d --- /dev/null +++ b/m4/strftime.m4 @@ -0,0 +1,30 @@ +# serial 32 + +# Copyright (C) 1996-1997, 1999-2007, 2009-2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering and Paul Eggert. + +AC_DEFUN([gl_FUNC_GNU_STRFTIME], +[ + gl_FUNC_STRFTIME +]) + +# These are the prerequisite macros for GNU's strftime.c replacement. +AC_DEFUN([gl_FUNC_STRFTIME], +[ + AC_LIBOBJ([strftime]) + + # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. + AC_REQUIRE([AC_STRUCT_TIMEZONE]) + + AC_REQUIRE([gl_TM_GMTOFF]) + + AC_CHECK_FUNCS_ONCE([tzset]) + + AC_DEFINE([my_strftime], [nstrftime], + [Define to the name of the strftime replacement function.]) +]) diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4 new file mode 100644 index 00000000000..d65ddc013be --- /dev/null +++ b/m4/tm_gmtoff.m4 @@ -0,0 +1,14 @@ +# tm_gmtoff.m4 serial 3 +dnl Copyright (C) 2002, 2009-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_TM_GMTOFF], +[ + AC_CHECK_MEMBER([struct tm.tm_gmtoff], + [AC_DEFINE([HAVE_TM_GMTOFF], [1], + [Define if struct tm has the tm_gmtoff member.])], + , + [#include <time.h>]) +]) |