Hi Daniel, > * With this, a *lot* more things are working now.
Good to hear; if the problems were sounding insurmountable you would be entirely on your own. > In fact, the only > breakage still in gllib is strcoll(), due to this platform's odd > three-argument form of it. (Could you point me to where this sort of quirk > should be worked around?) The files m4/strcoll.m4, lib/strcoll.c, modules/strcoll, m4/string_h.m4, lib/string.in.h, modules/string, doc/posix-functions/strcoll.texi are probably the ones that need to be modified. We generally use the same idiom for replacing (= overriding) a system function. You find dozens of examples of this technique. > * Changed all uses of __STRICT_ANSI__ to "defined __STRICT_ANSI__". This > is how both NeXT and current glibc headers use the symbol; IMO, this > is really how it should be done. Applied. > A bit of clarification: There is actually no difference in how this > ancient version of GCC handles cpp symbols versus newer ones. An > undefined cpp symbol is silently replaced with 0 (thus none of the > missing HAVE_* symbols broke). Good. > * New and improved absolute-header matching code. I rewrote that to handle all characters that might need to be escaped, not only '.' and '/' but also '^', '[', and others. > * Make use of setrlimit() if available to escape from the infinite > frexp() trap. Here I prefer to use alarm() instead of setrlimit(), 1. because it's easier to use, 2. because some platforms probably define RLIMIT_CPU but don't implement it. > * Many of the tests still fail to build, not because the functions for > them are not available, but because said declarations for these > functions either disappear with -posix->_POSIX_SOURCE->__STRICT_ANSI__ > (which we can't do anything about), or don't exist in any standard > headers at all. This needs to be worked around on a case-by-case basis. But out of laziness, I would not do anything for functions that return 'int' (because 'int' is the default return type that the compiler assumes for functions without a declaration). > Providing the declarations should get all of these going again. Is > there any precedent for doing this in gnulib? There are many. Look for HAVE_DECL_ in m4/*.m4. > Patch against current git master is attached. Thanks, I've applied the following patches. I'll get back to the other issues later. 2011-10-18 Daniel Richard G. <sk...@iskunk.org> (tiny change) Support for old NeXTstep 3.3 gcc. * lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Write 'defined __STRICT_ANSI__', not '__STRICT_ANSI__'. * lib/math.in.h (_GL_NUM_UINT_WORDS etc.): Likewise. * lib/spawn.in.h (_Restrict_arr_): Likewise. * lib/regex.h (_Restrict_arr_): Likewise. * lib/regex_internal.h (re_token_t): Likewise. * lib/regexec.c (check_node_accept_bytes): Likewise. * tests/test-printf-posix.c (func1, func2, func3, func4): Likewise. --- lib/gettext.h.orig Tue Oct 18 20:28:01 2011 +++ lib/gettext.h Tue Oct 18 20:24:15 2011 @@ -185,7 +185,7 @@ #include <string.h> #define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ - (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ /* || __STDC_VERSION__ >= 199901L */ ) #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS --- lib/math.in.h.orig Tue Oct 18 20:28:01 2011 +++ lib/math.in.h Tue Oct 18 20:24:35 2011 @@ -1188,7 +1188,7 @@ _GL_EXTERN_C int gl_signbitf (float arg); _GL_EXTERN_C int gl_signbitd (double arg); _GL_EXTERN_C int gl_signbitl (long double arg); -# if __GNUC__ >= 2 && !__STRICT_ANSI__ +# if __GNUC__ >= 2 && !defined __STRICT_ANSI__ # define _GL_NUM_UINT_WORDS(type) \ ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf --- lib/regex.h.orig Tue Oct 18 20:28:01 2011 +++ lib/regex.h Tue Oct 18 20:25:07 2011 @@ -644,7 +644,7 @@ #ifndef _Restrict_arr_ # if ((199901L <= __STDC_VERSION__ \ || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ - && !__STRICT_ANSI__)) \ + && !defined __STRICT_ANSI__)) \ && !defined __GNUG__) # define _Restrict_arr_ _Restrict_ # else --- lib/regex_internal.h.orig Tue Oct 18 20:28:01 2011 +++ lib/regex_internal.h Tue Oct 18 20:25:18 2011 @@ -334,7 +334,7 @@ Idx idx; /* for BACK_REF */ re_context_type ctx_type; /* for ANCHOR */ } opr; -#if __GNUC__ >= 2 && !__STRICT_ANSI__ +#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ re_token_type_t type : 8; #else re_token_type_t type; --- lib/regexec.c.orig Tue Oct 18 20:28:01 2011 +++ lib/regexec.c Tue Oct 18 20:24:51 2011 @@ -3985,7 +3985,7 @@ # endif /* _LIBC */ { /* match with range expression? */ -#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && __STRICT_ANSI__) +#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined __STRICT_ANSI__) wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'}; #else wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; --- lib/spawn.in.h.orig Tue Oct 18 20:28:01 2011 +++ lib/spawn.in.h Tue Oct 18 20:25:29 2011 @@ -63,7 +63,7 @@ #ifndef _Restrict_arr_ # if ((199901L <= __STDC_VERSION__ \ || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ - && !__STRICT_ANSI__)) \ + && !defined __STRICT_ANSI__)) \ && !defined __GNUG__) # define _Restrict_arr_ _Restrict_ # else --- tests/test-printf-posix.c.orig Tue Oct 18 20:28:01 2011 +++ tests/test-printf-posix.c Tue Oct 18 20:25:44 2011 @@ -39,7 +39,7 @@ } /* Test whether __attribute__ (__format__ (...)) still works. */ -#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !__STRICT_ANSI__ +#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !defined __STRICT_ANSI__ extern int func1 (char *, size_t, const char *, ...) __attribute__ ((__format__ (__printf__, 3, 4))); extern int func2 (char *, size_t, const char *, ...) 2011-10-19 Bruno Haible <br...@clisp.org> Support for old NeXTstep 3.3 sed. * m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): In the sed address part, use /.../, not \|...|. Escape periods in the header file name. * m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Likewise. Reported by Daniel Richard G. <sk...@iskunk.org>. --- m4/absolute-header.m4.orig Wed Oct 19 10:34:15 2011 +++ m4/absolute-header.m4 Wed Oct 19 02:40:09 2011 @@ -1,4 +1,4 @@ -# absolute-header.m4 serial 15 +# absolute-header.m4 serial 16 dnl Copyright (C) 2006-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, @@ -78,11 +78,16 @@ gl_dirsep_regex='[/\\]' ;; *) - gl_dirsep_regex='/' + gl_dirsep_regex='\/' ;; esac - gl_absolute_header_sed='\|'"${gl_dirsep_regex}"'$1|{ - s|.*"\(.*'"${gl_dirsep_regex}"'$1\)".*|\1| + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' + gl_header_literal_regex=`echo '$1' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ s|^/[^/]|//&| p q --- m4/include_next.m4.orig Wed Oct 19 10:34:15 2011 +++ m4/include_next.m4 Wed Oct 19 02:43:07 2011 @@ -1,4 +1,4 @@ -# include_next.m4 serial 22 +# include_next.m4 serial 23 dnl Copyright (C) 2006-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, @@ -219,12 +219,17 @@ gl_dirsep_regex='[/\\]' ;; *) - gl_dirsep_regex='/' + gl_dirsep_regex='\/' ;; esac + dnl A sed expression that turns a string into a basic regular + dnl expression, for use within "/.../". + gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g' changequote([,]) - gl_absolute_header_sed='\|'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[|{ - s|.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*|\1| + gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \ + | sed -e "$gl_make_literal_regex_sed"` + gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{ + s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/ changequote(,)dnl s|^/[^/]|//&| changequote([,])dnl 2011-10-19 Bruno Haible <br...@clisp.org> Support for old NeXTstep 3.3 frexp(). * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Check for alarm. Limit the execution time of the test to 5 seconds. Reported by Daniel Richard G. <sk...@iskunk.org>. --- m4/frexp.m4.orig Wed Oct 19 11:08:53 2011 +++ m4/frexp.m4 Wed Oct 19 11:07:15 2011 @@ -1,4 +1,4 @@ -# frexp.m4 serial 12 +# frexp.m4 serial 13 dnl Copyright (C) 2007-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, @@ -93,6 +93,7 @@ AC_DEFUN([gl_FUNC_FREXP_WORKS], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([alarm]) AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works], [ AC_RUN_IFELSE( @@ -100,6 +101,9 @@ AC_DEFUN([gl_FUNC_FREXP_WORKS], #include <float.h> #include <math.h> #include <string.h> +#if HAVE_ALARM +# include <unistd.h> +#endif /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. ICC 10.0 has a bug when optimizing the expression -zero. The expression -DBL_MIN * DBL_MIN does not work when cross-compiling @@ -120,6 +124,11 @@ int main() int i; volatile double x; double zero = 0.0; +#if HAVE_ALARM + /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite + number. Let the test fail in this case. */ + alarm (5); +#endif /* Test on denormalized numbers. */ for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) ; -- In memoriam Hanns-Martin Schleyer <http://en.wikipedia.org/wiki/Hanns-Martin_Schleyer>