Mercurial > hg > octave-jordi > gnulib-hg
annotate m4/wcwidth.m4 @ 15009:2917eb19f982
truncl: Move AC_LIBOBJ invocations to module description.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Move AC_LIBOBJ invocation from here...
* modules/truncl (configure.ac): ... to here.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 21 May 2011 11:32:55 +0200 |
parents | f7f11056a86e |
children | 570b3db43160 |
rev | line source |
---|---|
14685
f7f11056a86e
maint: remove useless REPLACE_*_H macros
Eric Blake <eblake@redhat.com>
parents:
14079
diff
changeset
|
1 # wcwidth.m4 serial 19 |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
13918
diff
changeset
|
2 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. |
6876
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
3 dnl This file is free software; the Free Software Foundation |
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
4 dnl gives unlimited permission to copy and/or distribute it, |
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
5 dnl with or without modifications, as long as this notice is preserved. |
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
6 |
6882
6f91a91ac710
Fixes after wcwidth module creation.
Bruno Haible <bruno@clisp.org>
parents:
6876
diff
changeset
|
7 AC_DEFUN([gl_FUNC_WCWIDTH], |
6f91a91ac710
Fixes after wcwidth module creation.
Bruno Haible <bruno@clisp.org>
parents:
6876
diff
changeset
|
8 [ |
9073
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
11711
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
9073
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
11 |
6882
6f91a91ac710
Fixes after wcwidth module creation.
Bruno Haible <bruno@clisp.org>
parents:
6876
diff
changeset
|
12 dnl Persuade glibc <wchar.h> to declare wcwidth(). |
9209
5a0294ce5372
Track CVS Autoconf on AC_USE_SYSTEM_EXTENSIONS.
Eric Blake <ebb9@byu.net>
parents:
9075
diff
changeset
|
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
6876
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
14 |
6882
6f91a91ac710
Fixes after wcwidth module creation.
Bruno Haible <bruno@clisp.org>
parents:
6876
diff
changeset
|
15 AC_REQUIRE([gt_TYPE_WCHAR_T]) |
7560
046e511d4faf
Fix compilation error on platforms without 'wint_t' type.
Bruno Haible <bruno@clisp.org>
parents:
7115
diff
changeset
|
16 AC_REQUIRE([gt_TYPE_WINT_T]) |
6882
6f91a91ac710
Fixes after wcwidth module creation.
Bruno Haible <bruno@clisp.org>
parents:
6876
diff
changeset
|
17 |
7758
ea1da95d3579
* lib/mbchar.h: Just include <wctype.h>; the wctype module
Paul Eggert <eggert@cs.ucla.edu>
parents:
7560
diff
changeset
|
18 AC_CHECK_HEADERS_ONCE([wchar.h]) |
ea1da95d3579
* lib/mbchar.h: Just include <wctype.h>; the wctype module
Paul Eggert <eggert@cs.ucla.edu>
parents:
7560
diff
changeset
|
19 AC_CHECK_FUNCS_ONCE([wcwidth]) |
6876
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
20 |
6911
8e002ebcf4b6
* wcwidth.m4 (gl_FUNC_WCWIDTH): Simplify by using AC_CHECK_DECLS.
Eric Blake <ebb9@byu.net>
parents:
6882
diff
changeset
|
21 AC_CHECK_DECLS([wcwidth], [], [], [ |
6876
edba9bd2b197
* mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
Eric Blake <ebb9@byu.net>
parents:
diff
changeset
|
22 /* AIX 3.2.5 declares wcwidth in <string.h>. */ |
7083 | 23 #include <string.h> |
7115
7c420c567087
Work around the __VA_LIST__ in <wchar.h> problem on Tru64 with DTK compiler.
Bruno Haible <bruno@clisp.org>
parents:
7083
diff
changeset
|
24 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
7c420c567087
Work around the __VA_LIST__ in <wchar.h> problem on Tru64 with DTK compiler.
Bruno Haible <bruno@clisp.org>
parents:
7083
diff
changeset
|
25 <wchar.h>. |
7852
72bd6a3bf181
* lib/wctype_.h [HAVE_WINT_T]: Include <stddef.h> before
Eric Blake <ebb9@byu.net>
parents:
7758
diff
changeset
|
26 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included |
72bd6a3bf181
* lib/wctype_.h [HAVE_WINT_T]: Include <stddef.h> before
Eric Blake <ebb9@byu.net>
parents:
7758
diff
changeset
|
27 before <wchar.h>. */ |
7888
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7852
diff
changeset
|
28 #include <stddef.h> |
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7852
diff
changeset
|
29 #include <stdio.h> |
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7852
diff
changeset
|
30 #include <time.h> |
b6376840b47b
* modules/fnmatch (Depends-on): Depend on wchar.
Eric Blake <ebb9@byu.net>
parents:
7852
diff
changeset
|
31 #include <wchar.h> |
9071
ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
Bruno Haible <bruno@clisp.org>
parents:
7888
diff
changeset
|
32 ]) |
9073
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
33 if test $ac_cv_have_decl_wcwidth != yes; then |
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
34 HAVE_DECL_WCWIDTH=0 |
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
35 fi |
9071
ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
Bruno Haible <bruno@clisp.org>
parents:
7888
diff
changeset
|
36 |
13135
3500e68d2a04
wcwidth: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
37 if test $ac_cv_func_wcwidth = yes; then |
9075
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
38 dnl On MacOS X 10.3, wcwidth(0x0301) (COMBINING ACUTE ACCENT) returns 1. |
9382
f31fd684022b
Replace wcwidth also if it fails on U+200B (ZERO WIDTH SPACE).
Bruno Haible <bruno@clisp.org>
parents:
9209
diff
changeset
|
39 dnl On OSF/1 5.1, wcwidth(0x200B) (ZERO WIDTH SPACE) returns 1. |
9075
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
40 dnl This leads to bugs in 'ls' (coreutils). |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
41 AC_CACHE_CHECK([whether wcwidth works reasonably in UTF-8 locales], |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
42 [gl_cv_func_wcwidth_works], |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
43 [ |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13504
diff
changeset
|
44 AC_RUN_IFELSE( |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13504
diff
changeset
|
45 [AC_LANG_SOURCE([[ |
9075
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
46 #include <locale.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
47 /* AIX 3.2.5 declares wcwidth in <string.h>. */ |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
48 #include <string.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
49 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
50 <wchar.h>. |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
51 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
52 before <wchar.h>. */ |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
53 #include <stddef.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
54 #include <stdio.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
55 #include <time.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
56 #include <wchar.h> |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
57 #if !HAVE_DECL_WCWIDTH |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
58 extern |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
59 # ifdef __cplusplus |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
60 "C" |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
61 # endif |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
62 int wcwidth (int); |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
63 #endif |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
64 int main () |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
65 { |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
66 int result = 0; |
9075
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
67 if (setlocale (LC_ALL, "fr_FR.UTF-8") != NULL) |
13918
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
68 { |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
69 if (wcwidth (0x0301) > 0) |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
70 result |= 1; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
71 if (wcwidth (0x200B) > 0) |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
72 result |= 2; |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
73 } |
d5a74c6ec06b
Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents:
13579
diff
changeset
|
74 return result; |
13579
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13504
diff
changeset
|
75 }]])], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13504
diff
changeset
|
76 [gl_cv_func_wcwidth_works=yes], |
da9779900713
Modernize AC_TRY_RUN invocations.
Bruno Haible <bruno@clisp.org>
parents:
13504
diff
changeset
|
77 [gl_cv_func_wcwidth_works=no], |
11711
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
78 [ |
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
79 changequote(,)dnl |
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
80 case "$host_os" in |
13504
43d4c2eaeda9
wcwidth: Drop replacement on AIX 7.
Bruno Haible <bruno@clisp.org>
parents:
13135
diff
changeset
|
81 # Guess yes on glibc and AIX 7 systems. |
43d4c2eaeda9
wcwidth: Drop replacement on AIX 7.
Bruno Haible <bruno@clisp.org>
parents:
13135
diff
changeset
|
82 *-gnu* | aix[7-9]*) gl_cv_func_wcwidth_works="guessing yes";; |
43d4c2eaeda9
wcwidth: Drop replacement on AIX 7.
Bruno Haible <bruno@clisp.org>
parents:
13135
diff
changeset
|
83 *) gl_cv_func_wcwidth_works="guessing no";; |
11711
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
84 esac |
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
85 changequote([,])dnl |
0448ef50894e
Guess that wcwidth works on glibc systems.
Bruno Haible <bruno@clisp.org>
parents:
10499
diff
changeset
|
86 ]) |
9075
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
87 ]) |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
88 case "$gl_cv_func_wcwidth_works" in |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
89 *yes) ;; |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
90 *no) REPLACE_WCWIDTH=1 ;; |
4d262fc1845c
Work around MacOS X wcwidth(0x0301) bug.
Bruno Haible <bruno@clisp.org>
parents:
9073
diff
changeset
|
91 esac |
9073
eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
Bruno Haible <bruno@clisp.org>
parents:
9072
diff
changeset
|
92 fi |
13135
3500e68d2a04
wcwidth: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
93 if test $ac_cv_func_wcwidth != yes || test $REPLACE_WCWIDTH = 1; then |
9071
ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
Bruno Haible <bruno@clisp.org>
parents:
7888
diff
changeset
|
94 AC_LIBOBJ([wcwidth]) |
ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
Bruno Haible <bruno@clisp.org>
parents:
7888
diff
changeset
|
95 fi |
13135
3500e68d2a04
wcwidth: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
96 dnl We don't substitute HAVE_WCWIDTH. We assume that if the system does not |
3500e68d2a04
wcwidth: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents:
12559
diff
changeset
|
97 dnl have the wcwidth function, then it does not declare it. |
9071
ee2dc6c88b11
Provide wcwidth replacement in separate file wcwidth.c.
Bruno Haible <bruno@clisp.org>
parents:
7888
diff
changeset
|
98 ]) |