annotate m4/stpncpy.m4 @ 17252:7a29ec33d6c5

missing @item
author Karl Berry <karl@freefriends.org>
date Tue, 01 Jan 2013 09:17:08 -0800
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16810
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
1 # stpncpy.m4 serial 16
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16810
diff changeset
2 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 11007
diff changeset
3 dnl Inc.
5585
adff74659d81 Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents: 5584
diff changeset
4 dnl This file is free software; the Free Software Foundation
adff74659d81 Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents: 5584
diff changeset
5 dnl gives unlimited permission to copy and/or distribute it,
adff74659d81 Use an all-permissive copyright notice, recommended by RMS.
Bruno Haible <bruno@clisp.org>
parents: 5584
diff changeset
6 dnl with or without modifications, as long as this notice is preserved.
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 AC_DEFUN([gl_FUNC_STPNCPY],
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 [
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 dnl Persuade glibc <string.h> to declare stpncpy().
9209
5a0294ce5372 Track CVS Autoconf on AC_USE_SYSTEM_EXTENSIONS.
Eric Blake <ebb9@byu.net>
parents: 8814
diff changeset
11 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12
9264
a1355710e330 Rename string_.h to string.in.h.
Bruno Haible <bruno@clisp.org>
parents: 9209
diff changeset
13 dnl The stpncpy() declaration in lib/string.in.h uses 'restrict'.
8814
04b21457982b Ensure AC_C_RESTRICT is invoked.
Bruno Haible <bruno@clisp.org>
parents: 7982
diff changeset
14 AC_REQUIRE([AC_C_RESTRICT])
04b21457982b Ensure AC_C_RESTRICT is invoked.
Bruno Haible <bruno@clisp.org>
parents: 7982
diff changeset
15
7982
6b61aba76343 Enforce ordering constraints between gl_HEADER_STRING_H_DEFAULTS and the
Bruno Haible <bruno@clisp.org>
parents: 7944
diff changeset
16 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
6b61aba76343 Enforce ordering constraints between gl_HEADER_STRING_H_DEFAULTS and the
Bruno Haible <bruno@clisp.org>
parents: 7944
diff changeset
17
4746
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
18 dnl Both glibc and AIX (4.3.3, 5.1) have an stpncpy() function
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
19 dnl declared in <string.h>. Its side effects are the same as those
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
20 dnl of strncpy():
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
21 dnl stpncpy (dest, src, n)
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
22 dnl overwrites dest[0..n-1], min(strlen(src),n) bytes coming from src,
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
23 dnl and the remaining bytes being NULs. However, the return value is
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
24 dnl in glibc: dest + min(strlen(src),n)
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
25 dnl in AIX: dest + max(0,n-1)
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
26 dnl Only the glibc return value is useful in practice.
7f0802de0710 Better handling of collision with AIX stpncpy() function.
Bruno Haible <bruno@clisp.org>
parents: 4221
diff changeset
27
13558
263949fe34ae stpncpy: Allow stpncpy to be defined as a macro.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
28 AC_CHECK_DECLS_ONCE([stpncpy])
13119
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
29 AC_CHECK_FUNCS_ONCE([stpncpy])
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
30 if test $ac_cv_func_stpncpy = yes; then
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
31 AC_CACHE_CHECK([for working stpncpy], [gl_cv_func_stpncpy], [
13579
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
32 AC_RUN_IFELSE(
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
33 [AC_LANG_SOURCE([[
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #include <stdlib.h>
7363
d2d55a61866f Ensure stpncpy() is declared.
Bruno Haible <bruno@clisp.org>
parents: 5672
diff changeset
35 #include <string.h> /* for strcpy */
d2d55a61866f Ensure stpncpy() is declared.
Bruno Haible <bruno@clisp.org>
parents: 5672
diff changeset
36 /* The stpncpy prototype is missing in <string.h> on AIX 4. */
13558
263949fe34ae stpncpy: Allow stpncpy to be defined as a macro.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
37 #if !HAVE_DECL_STPNCPY
15438
591ddd1ddd1a Declare system functions in a way that works with C++.
Bruno Haible <bruno@clisp.org>
parents: 15099
diff changeset
38 extern
591ddd1ddd1a Declare system functions in a way that works with C++.
Bruno Haible <bruno@clisp.org>
parents: 15099
diff changeset
39 # ifdef __cplusplus
591ddd1ddd1a Declare system functions in a way that works with C++.
Bruno Haible <bruno@clisp.org>
parents: 15099
diff changeset
40 "C"
591ddd1ddd1a Declare system functions in a way that works with C++.
Bruno Haible <bruno@clisp.org>
parents: 15099
diff changeset
41 # endif
591ddd1ddd1a Declare system functions in a way that works with C++.
Bruno Haible <bruno@clisp.org>
parents: 15099
diff changeset
42 char *stpncpy (char *dest, const char *src, size_t n);
13558
263949fe34ae stpncpy: Allow stpncpy to be defined as a macro.
Bruno Haible <bruno@clisp.org>
parents: 13119
diff changeset
43 #endif
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
44 int main ()
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
45 {
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
46 int result = 0;
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 const char *src = "Hello";
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 char dest[10];
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+1 here. */
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
50 {
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
51 strcpy (dest, "\377\377\377\377\377\377");
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
52 if (stpncpy (dest, src, 2) != dest + 2)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
53 result |= 1;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
54 }
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+4 here. */
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
56 {
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
57 strcpy (dest, "\377\377\377\377\377\377");
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
58 if (stpncpy (dest, src, 5) != dest + 5)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
59 result |= 2;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
60 }
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 /* AIX 4.3.3 and AIX 5.1 stpncpy() returns dest+6 here. */
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
62 {
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
63 strcpy (dest, "\377\377\377\377\377\377");
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
64 if (stpncpy (dest, src, 7) != dest + 5)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
65 result |= 4;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
66 }
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13579
diff changeset
67 return result;
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 }
13579
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
69 ]])],
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
70 [gl_cv_func_stpncpy=yes],
da9779900713 Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents: 13558
diff changeset
71 [gl_cv_func_stpncpy=no],
13119
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
72 [AC_EGREP_CPP([Thanks for using GNU], [
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 #include <features.h>
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 #ifdef __GNU_LIBRARY__
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 Thanks for using GNU
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 #endif
16810
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
77 ], [gl_cv_func_stpncpy="guessing yes"], [gl_cv_func_stpncpy="guessing no"])
13119
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
78 ])
5fa4ec4a6e8b stpncpy: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
79 ])
16810
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
80 case "$gl_cv_func_stpncpy" in
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
81 *yes)
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
82 AC_DEFINE([HAVE_STPNCPY], [1],
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
83 [Define if you have the stpncpy() function and it works.])
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
84 ;;
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
85 *)
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
86 REPLACE_STPNCPY=1
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
87 ;;
ca49e9a6643d Say "guessing yes" or "guessing no" when cross-compiling.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
88 esac
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 else
7944
a1d177cd9523 * doc/gnulib-tool.texi (Initial import): Update to match current
Paul Eggert <eggert@cs.ucla.edu>
parents: 7363
diff changeset
90 HAVE_STPNCPY=0
4221
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 fi
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 ])
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 # Prerequisites of lib/stpncpy.c.
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 AC_DEFUN([gl_PREREQ_STPNCPY], [
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 :
06a92cabf1fc New module stpncpy.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 ])