Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/uniwidth/u8-width.c @ 12518:b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
The files named by the following are exempted:
grep -v '^#' config/srclist.txt|grep -v '^$' \
| while read src dst; do
test -f "$dst" && { echo "$dst"; continue; }
test -d "$dst" || continue
echo "$dst"/$(basename "$src")
done > exempt
git ls-files tests/unictype >> exempt
In the remaining files, convert to all-interval notation if
- there is already at least one year interval like 2000-2003
- the file is maintained by me
- the file is in lib/uni*/, where that style already prevails
Otherwise, use update-copyright's default.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Mon, 28 Dec 2009 10:50:36 +0100 |
parents | e8d2c6fc33ad |
children | c2cbabec01dd |
rev | line source |
---|---|
9058 | 1 /* Determine display width of UTF-8 string. |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
2 Copyright (C) 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc. |
9058 | 3 Written by Bruno Haible <bruno@clisp.org>, 2002. |
4 | |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
6 under the terms of the GNU Lesser General Public License as published |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
7 by the Free Software Foundation; either version 3 of the License, or |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
8 (at your option) any later version. |
9058 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
13 Lesser General Public License for more details. |
9058 | 14 |
9307
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public License |
ad8a75a45dc9
Change copyright notice from LGPLv2.0+ to LGPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9058
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9058 | 17 |
18 #include <config.h> | |
19 | |
20 /* Specification. */ | |
21 #include "uniwidth.h" | |
22 | |
23 #include "unistr.h" | |
24 | |
25 int | |
26 u8_width (const uint8_t *s, size_t n, const char *encoding) | |
27 { | |
28 const uint8_t *s_end = s + n; | |
29 int width = 0; | |
30 | |
31 while (s < s_end) | |
32 { | |
33 ucs4_t uc; | |
34 int w; | |
35 | |
36 s += u8_mbtouc_unsafe (&uc, s, s_end - s); | |
37 | |
38 if (uc == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9307
diff
changeset
|
39 break; /* end of string reached */ |
9058 | 40 |
41 w = uc_width (uc, encoding); | |
42 if (w >= 0) /* ignore control characters in the string */ | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9307
diff
changeset
|
43 width += w; |
9058 | 44 } |
45 | |
46 return width; | |
47 } |