112{
115
116 /* Check if the locale name matches any of the problematic ones. */
118 {
122 char *match;
123 char *match_start = NULL;
124 char *match_end = NULL;
125
126 match = strstr(
locale, needle_start);
127 if (match)
128 {
129 /*
130 * Found a match for the first part. If this was a two-part
131 * replacement, find the second part.
132 */
133 match_start = match;
134 if (needle_end)
135 {
136 match = strstr(match_start + strlen(needle_start), needle_end);
137 if (match)
138 match_end = match + strlen(needle_end);
139 else
140 match_start = NULL;
141 }
142 else
143 match_end = match_start + strlen(needle_start);
144 }
145
146 if (match_start)
147 {
148 /* Found a match. Replace the matched string. */
149 int matchpos = match_start -
locale;
150 int replacementlen = strlen(replacement);
151 char *rest = match_end;
152 int restlen = strlen(rest);
153
154 /* check that the result fits in the static buffer */
156 return NULL;
157
158 memcpy(&aliasbuf[0], &
locale[0], matchpos);
159 memcpy(&aliasbuf[matchpos], replacement, replacementlen);
160 /* includes null terminator */
161 memcpy(&aliasbuf[matchpos + replacementlen], rest, restlen + 1);
162
163 return aliasbuf;
164 }
165 }
166
167 /* no match, just return the original string */
169}
const char * locale_name_end
const char * locale_name_start
#define MAX_LOCALE_NAME_LEN