annotate lib/propername.c @ 17160:72f4bab621be

fts: introduce FTS_VERBATIM This gives clients the option to disable stripping of trailing slashes from input path names during fts_open initialization. The recent change v0.0-7611-g3a9002d that made fts_open strip trailing slashes from input path names had a negative impact on findutils that relies on the old fts_open behavior to implement POSIX requirement that each path operand of the find utility shall be evaluated unaltered as it was provided, including all trailing slash characters. * lib/fts_.h (FTS_VERBATIM): New bit flag. (FTS_OPTIONMASK, FTS_NAMEONLY, FTS_STOP): Adjust. * lib/fts.c (fts_open): Honor it.
author Dmitry V. Levin <ldv@altlinux.org>
date Sun, 18 Nov 2012 04:40:18 +0400
parents 8250f2777afc
children e542fd46ad6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Localization of proper names.
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 16131
diff changeset
2 Copyright (C) 2006-2012 Free Software Foundation, Inc.
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2006.
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 (at your option) any later version.
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
16130
376ca4146b05 propername: do not mark proper_name with the const attribute
Jim Meyering <meyering@redhat.com>
parents: 14612
diff changeset
18 /* Without this pragma, gcc 4.7.0 20111124 mistakenly suggests that
376ca4146b05 propername: do not mark proper_name with the const attribute
Jim Meyering <meyering@redhat.com>
parents: 14612
diff changeset
19 the proper_name function might be candidate for attribute 'const' */
16131
732c22001112 quotearg, propername: correct pragma guard expression
Jim Meyering <meyering@redhat.com>
parents: 16130
diff changeset
20 #if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
16130
376ca4146b05 propername: do not mark proper_name with the const attribute
Jim Meyering <meyering@redhat.com>
parents: 14612
diff changeset
21 # pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
376ca4146b05 propername: do not mark proper_name with the const attribute
Jim Meyering <meyering@redhat.com>
parents: 14612
diff changeset
22 #endif
376ca4146b05 propername: do not mark proper_name with the const attribute
Jim Meyering <meyering@redhat.com>
parents: 14612
diff changeset
23
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <config.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 /* Specification. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include "propername.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include <ctype.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #include <stdbool.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 #include <stdio.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #include <stdlib.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #include <string.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #if HAVE_ICONV
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 # include <iconv.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #endif
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #include "trim.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 #include "mbchar.h"
10954
a0bbe1a6f787 Remove HAVE_MBRTOWC conditionals. Use mbrtowc unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 10225
diff changeset
40 #include "mbuiter.h"
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 #include "localcharset.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #include "c-strcase.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 #include "xstriconv.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 #include "xalloc.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 #include "gettext.h"
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 /* Tests whether STRING contains trim (SUB), starting and ending at word
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 boundaries.
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 Here, instead of implementing Unicode Standard Annex #29 for determining
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 word boundaries, we assume that trim (SUB) starts and ends with words and
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 only test whether the part before it ends with a non-word and the part
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 after it starts with a non-word. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 static bool
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 mbsstr_trimmed_wordbounded (const char *string, const char *sub)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 char *tsub = trim (sub);
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 bool found = false;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 for (; *string != '\0';)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 const char *tsub_in_string = mbsstr (string, tsub);
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 if (tsub_in_string == NULL)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
64 break;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
66 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
67 if (MB_CUR_MAX > 1)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
68 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
69 mbui_iterator_t string_iter;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
70 bool word_boundary_before;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
71 bool word_boundary_after;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
73 mbui_init (string_iter, string);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
74 word_boundary_before = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
75 if (mbui_cur_ptr (string_iter) < tsub_in_string)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
76 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
77 mbchar_t last_char_before_tsub;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
78 do
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
79 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
80 if (!mbui_avail (string_iter))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
81 abort ();
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
82 last_char_before_tsub = mbui_cur (string_iter);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
83 mbui_advance (string_iter);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
84 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
85 while (mbui_cur_ptr (string_iter) < tsub_in_string);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
86 if (mb_isalnum (last_char_before_tsub))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
87 word_boundary_before = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
88 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
90 mbui_init (string_iter, tsub_in_string);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
91 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
92 mbui_iterator_t tsub_iter;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
94 for (mbui_init (tsub_iter, tsub);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
95 mbui_avail (tsub_iter);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
96 mbui_advance (tsub_iter))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
97 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
98 if (!mbui_avail (string_iter))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
99 abort ();
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
100 mbui_advance (string_iter);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
101 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
102 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
103 word_boundary_after = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
104 if (mbui_avail (string_iter))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
105 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
106 mbchar_t first_char_after_tsub = mbui_cur (string_iter);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
107 if (mb_isalnum (first_char_after_tsub))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
108 word_boundary_after = false;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
109 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
111 if (word_boundary_before && word_boundary_after)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
112 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
113 found = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
114 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
115 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
117 mbui_init (string_iter, tsub_in_string);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
118 if (!mbui_avail (string_iter))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
119 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
120 string = tsub_in_string + mb_len (mbui_cur (string_iter));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
121 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
122 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
123 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
124 bool word_boundary_before;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
125 const char *p;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
126 bool word_boundary_after;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
128 word_boundary_before = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
129 if (string < tsub_in_string)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
130 if (isalnum ((unsigned char) tsub_in_string[-1]))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
131 word_boundary_before = false;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
133 p = tsub_in_string + strlen (tsub);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
134 word_boundary_after = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
135 if (*p != '\0')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
136 if (isalnum ((unsigned char) *p))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
137 word_boundary_after = false;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
139 if (word_boundary_before && word_boundary_after)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
140 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
141 found = true;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
142 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
143 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
145 if (*tsub_in_string == '\0')
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
146 break;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
147 string = tsub_in_string + 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
148 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
149 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 free (tsub);
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 return found;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 /* Return the localization of NAME. NAME is written in ASCII. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156
14612
6ef4f1f39105 Revert "use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE"
Jim Meyering <meyering@redhat.com>
parents: 14610
diff changeset
157 const char *
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 proper_name (const char *name)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 /* See whether there is a translation. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 const char *translation = gettext (name);
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 if (translation != name)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 /* See whether the translation contains the original name. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 if (mbsstr_trimmed_wordbounded (translation, name))
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
167 return translation;
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
169 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
170 /* Return "TRANSLATION (NAME)". */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
171 char *result =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
172 XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
174 sprintf (result, "%s (%s)", translation, name);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
175 return result;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
176 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 else
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 return name;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 /* Return the localization of a name whose original writing is not ASCII.
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184 escape sequences. NAME_ASCII is a fallback written only with ASCII
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 characters. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 const char *
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 proper_name_utf8 (const char *name_ascii, const char *name_utf8)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 /* See whether there is a translation. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 const char *translation = gettext (name_ascii);
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 /* Try to convert NAME_UTF8 to the locale encoding. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 const char *locale_code = locale_charset ();
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 char *alloc_name_converted = NULL;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 char *alloc_name_converted_translit = NULL;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 const char *name_converted = NULL;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 const char *name_converted_translit = NULL;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 const char *name;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 if (c_strcasecmp (locale_code, "UTF-8") != 0)
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 #if HAVE_ICONV
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 name_converted = alloc_name_converted =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
205 xstr_iconv (name_utf8, "UTF-8", locale_code);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206
13885
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
207 # if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) \
87a95303747f Port to uClibc.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
208 && !defined __UCLIBC__) \
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 || _LIBICONV_VERSION >= 0x0105
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
211 char *converted_translit;
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
212
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
213 size_t len = strlen (locale_code);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
214 char *locale_code_translit = XNMALLOC (len + 10 + 1, char);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
215 memcpy (locale_code_translit, locale_code, len);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
216 memcpy (locale_code_translit + len, "//TRANSLIT", 10 + 1);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
218 converted_translit =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
219 xstr_iconv (name_utf8, "UTF-8", locale_code_translit);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
221 free (locale_code_translit);
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
222
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
223 if (converted_translit != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
224 {
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
225 # if !_LIBICONV_VERSION
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
226 /* Don't use the transliteration if it added question marks.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
227 glibc's transliteration falls back to question marks; libiconv's
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
228 transliteration does not.
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
229 mbschr is equivalent to strchr in this case. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
230 if (strchr (converted_translit, '?') != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
231 free (converted_translit);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
232 else
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
233 # endif
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
234 name_converted_translit = alloc_name_converted_translit =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
235 converted_translit;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
236 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 # endif
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 #endif
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 else
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 name_converted = name_utf8;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 name_converted_translit = name_utf8;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247 /* The name in locale encoding. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 name = (name_converted != NULL ? name_converted :
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
249 name_converted_translit != NULL ? name_converted_translit :
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
250 name_ascii);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251
11537
0ec84326efef Ignore no-op translations.
Jim Meyering <meyering@redhat.com>
parents: 10954
diff changeset
252 /* See whether we have a translation. Some translators have not understood
0ec84326efef Ignore no-op translations.
Jim Meyering <meyering@redhat.com>
parents: 10954
diff changeset
253 that they should use the UTF-8 form of the name, if possible. So if the
0ec84326efef Ignore no-op translations.
Jim Meyering <meyering@redhat.com>
parents: 10954
diff changeset
254 translator provided a no-op translation, we ignore it. */
0ec84326efef Ignore no-op translations.
Jim Meyering <meyering@redhat.com>
parents: 10954
diff changeset
255 if (strcmp (translation, name_ascii) != 0)
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 /* See whether the translation contains the original name. */
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 if (mbsstr_trimmed_wordbounded (translation, name_ascii)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
259 || (name_converted != NULL
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
260 && mbsstr_trimmed_wordbounded (translation, name_converted))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
261 || (name_converted_translit != NULL
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
262 && mbsstr_trimmed_wordbounded (translation, name_converted_translit)))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
263 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
264 if (alloc_name_converted != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
265 free (alloc_name_converted);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
266 if (alloc_name_converted_translit != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
267 free (alloc_name_converted_translit);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
268 return translation;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
269 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 else
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
271 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
272 /* Return "TRANSLATION (NAME)". */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
273 char *result =
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
274 XNMALLOC (strlen (translation) + 2 + strlen (name) + 1 + 1, char);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
276 sprintf (result, "%s (%s)", translation, name);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
278 if (alloc_name_converted != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
279 free (alloc_name_converted);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
280 if (alloc_name_converted_translit != NULL)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
281 free (alloc_name_converted_translit);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
282 return result;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
283 }
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 else
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 if (alloc_name_converted != NULL && alloc_name_converted != name)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
288 free (alloc_name_converted);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 if (alloc_name_converted_translit != NULL
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
290 && alloc_name_converted_translit != name)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11537
diff changeset
291 free (alloc_name_converted_translit);
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 return name;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
296 #ifdef TEST1
10085
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 # include <locale.h>
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298 int
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 main (int argc, char *argv[])
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300 {
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 setlocale (LC_ALL, "");
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 if (mbsstr_trimmed_wordbounded (argv[1], argv[2]))
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 printf("found\n");
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304 return 0;
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305 }
6eeccac8ebca New module 'propername', moved here from GNU gettext.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306 #endif
10225
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
307
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
308 #ifdef TEST2
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
309 # include <locale.h>
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
310 # include <stdio.h>
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
311 int
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
312 main (int argc, char *argv[])
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
313 {
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
314 setlocale (LC_ALL, "");
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
315 printf ("%s\n", proper_name_utf8 ("Franc,ois Pinard", "Fran\303\247ois Pinard"));
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
316 return 0;
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
317 }
263c02b12cef Avoid question marks in proper_name_utf8 result.
Bruno Haible <bruno@clisp.org>
parents: 10085
diff changeset
318 #endif