2 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License. As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
9 AC_DEFUN([gl_FUNC_STPNCPY],
11 dnl Persuade glibc <string.h> to declare stpncpy().
12 AC_REQUIRE([AC_GNU_SOURCE])
14 AC_CACHE_CHECK([for working stpncpy], gl_cv_func_stpncpy, [
17 extern char *stpncpy (char *dest, const char *src, size_t n);
19 const char *src = "Hello";
21 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+1 here. */
22 strcpy (dest, "\377\377\377\377\377\377");
23 if (stpncpy (dest, src, 2) != dest + 2) exit(1);
24 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+4 here. */
25 strcpy (dest, "\377\377\377\377\377\377");
26 if (stpncpy (dest, src, 5) != dest + 5) exit(1);
27 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+6 here. */
28 strcpy (dest, "\377\377\377\377\377\377");
29 if (stpncpy (dest, src, 7) != dest + 5) exit(1);
32 ], gl_cv_func_stpncpy=yes, gl_cv_func_stpncpy=no,
33 [AC_EGREP_CPP([Thanks for using GNU], [
35 #ifdef __GNU_LIBRARY__
38 ], gl_cv_func_stpncpy=yes, gl_cv_func_stpncpy=no)])])
40 if test $gl_cv_func_stpncpy = yes; then
41 AC_DEFINE(HAVE_STPNCPY, 1,
42 [Define if you have the stpncpy() function and it works.])
45 AC_DEFINE(stpncpy, rpl_stpncpy,
46 [Define to rpl_stpncpy if the replacement function should be used.])
51 # Prerequisites of lib/stpncpy.c.
52 AC_DEFUN([gl_PREREQ_STPNCPY], [