Mercurial > gnulib
annotate lib/mbswidth.h @ 40057:b06060465f09
maint: Run 'make update-copyright'
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 01 Jan 2019 00:25:11 +0100 |
parents | 10eb9086bea0 |
children |
rev | line source |
---|---|
2757 | 1 /* Determine the number of screen columns needed for a string. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2000-2004, 2007, 2009-2019 Free Software Foundation, Inc. |
2757 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8386
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
2757 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8386
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8386
diff
changeset
|
7 (at your option) any later version. |
2757 | 8 |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
2757 | 16 |
3979
7627246c7a83
Standard specification idiom. Make mbswidth.h self contained.
Bruno Haible <bruno@clisp.org>
parents:
3978
diff
changeset
|
17 #include <stddef.h> |
7627246c7a83
Standard specification idiom. Make mbswidth.h self contained.
Bruno Haible <bruno@clisp.org>
parents:
3978
diff
changeset
|
18 |
4246 | 19 /* Avoid a clash of our mbswidth() with a function of the same name defined |
20 in UnixWare 7.1.1 <wchar.h>. We need this #include before the #define | |
4976
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
21 below. |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
22 However, we don't want to #include <wchar.h> on all platforms because |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
23 - Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
24 <wchar.h>. |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
25 - BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
26 <wchar.h>. */ |
4df6aeb9a5c5
Fix portability problem with Tru64 and BSD/OS.
Bruno Haible <bruno@clisp.org>
parents:
4246
diff
changeset
|
27 #if HAVE_DECL_MBSWIDTH_IN_WCHAR_H |
4246 | 28 # include <wchar.h> |
29 #endif | |
30 | |
31 | |
8386
4ec84f742938
Convert tabs in the middle of preprocessor directives.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
32 #ifdef __cplusplus |
5104
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
33 extern "C" { |
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
34 #endif |
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
35 |
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
36 |
2778
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
37 /* Optional flags to influence mbswidth/mbsnwidth behavior. */ |
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
38 |
3325
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
39 /* If this bit is set, return -1 upon finding an invalid or incomplete |
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
40 character. Otherwise, assume invalid characters have width 1. */ |
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
41 #define MBSW_REJECT_INVALID 1 |
2778
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
42 |
3325
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
43 /* If this bit is set, return -1 upon finding a non-printable character. |
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
44 Otherwise, assume unprintable characters have width 0 if they are |
55d1cb769050
(MBSW_REJECT_UNPRINTABLE, MBSW_REJECT_INVALID):
Jim Meyering <jim@meyering.net>
parents:
3176
diff
changeset
|
45 control characters and 1 otherwise. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
46 #define MBSW_REJECT_UNPRINTABLE 2 |
2778
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
47 |
4246 | 48 |
2778
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
49 /* Returns the number of screen columns needed for STRING. */ |
3176
1057602c3299
(mbswidth): Also define as macro, to avoid prototype clash.
Jim Meyering <jim@meyering.net>
parents:
2798
diff
changeset
|
50 #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */ |
3978 | 51 extern int mbswidth (const char *string, int flags); |
2778
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
52 |
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
53 /* Returns the number of screen columns needed for the NBYTES bytes |
ae01c32493fb
(mbswidth): Add a flags argument.
Jim Meyering <jim@meyering.net>
parents:
2757
diff
changeset
|
54 starting at BUF. */ |
3978 | 55 extern int mbsnwidth (const char *buf, size_t nbytes, int flags); |
5104
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
56 |
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
57 |
8386
4ec84f742938
Convert tabs in the middle of preprocessor directives.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
58 #ifdef __cplusplus |
5104
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
59 } |
73f9a98a273f
Allow use in C++ environment.
Bruno Haible <bruno@clisp.org>
parents:
4976
diff
changeset
|
60 #endif |