201 |
*/ |
*/ |
202 |
const char *get_source_encoding (const char *lang) |
const char *get_source_encoding (const char *lang) |
203 |
{ |
{ |
204 |
int i; |
const struct directory_entry *entry; |
205 |
const char *dot; |
const char *dot; |
206 |
|
|
207 |
if (!lang) |
if (!lang) |
232 |
/* TODO: I should probably drop any ,<version> components. */ |
/* TODO: I should probably drop any ,<version> components. */ |
233 |
return dot + 1; |
return dot + 1; |
234 |
|
|
235 |
for (i = 0; directory_table[i].lang_dir; ++i) { |
for (entry = directory_table; entry->lang_dir; ++entry) |
236 |
if (STRNEQ (directory_table[i].lang_dir, lang, |
if (STRNEQ (entry->lang_dir, lang, strlen (entry->lang_dir))) |
237 |
strlen (directory_table[i].lang_dir))) |
return entry->source_encoding; |
|
return directory_table[i].source_encoding; |
|
|
} |
|
238 |
|
|
239 |
return NULL; |
return NULL; |
240 |
} |
} |
245 |
*/ |
*/ |
246 |
const char *get_standard_output_encoding (const char *lang) |
const char *get_standard_output_encoding (const char *lang) |
247 |
{ |
{ |
248 |
int i; |
const struct directory_entry *entry; |
249 |
const char *dot; |
const char *dot; |
250 |
|
|
251 |
if (!lang) |
if (!lang) |
260 |
/* TODO: I should probably drop any ,<version> components. */ |
/* TODO: I should probably drop any ,<version> components. */ |
261 |
return dot + 1; |
return dot + 1; |
262 |
|
|
263 |
for (i = 0; directory_table[i].lang_dir; ++i) { |
for (entry = directory_table; entry->lang_dir; ++entry) |
264 |
if (STRNEQ (directory_table[i].lang_dir, lang, |
if (STRNEQ (entry->lang_dir, lang, strlen (entry->lang_dir))) |
265 |
strlen (directory_table[i].lang_dir))) |
return entry->standard_output_encoding; |
|
return directory_table[i].standard_output_encoding; |
|
|
} |
|
266 |
|
|
267 |
return NULL; |
return NULL; |
268 |
} |
} |
347 |
const char *get_default_device (const char *locale_charset, |
const char *get_default_device (const char *locale_charset, |
348 |
const char *source_encoding) |
const char *source_encoding) |
349 |
{ |
{ |
350 |
int i; |
const struct charset_entry *entry; |
351 |
|
|
352 |
if (!locale_charset || !source_encoding) |
if (!locale_charset || !source_encoding) |
353 |
return fallback_default_device; |
return fallback_default_device; |
354 |
|
|
355 |
for (i = 0; charset_table[i].locale_charset; ++i) { |
for (entry = charset_table; entry->locale_charset; ++entry) { |
|
const struct charset_entry *entry = &charset_table[i]; |
|
356 |
if (STREQ (entry->locale_charset, locale_charset)) { |
if (STREQ (entry->locale_charset, locale_charset)) { |
357 |
const char *roff_encoding = |
const char *roff_encoding = |
358 |
get_roff_encoding (entry->default_device); |
get_roff_encoding (entry->default_device); |
371 |
*/ |
*/ |
372 |
const char *get_roff_encoding (const char *device) |
const char *get_roff_encoding (const char *device) |
373 |
{ |
{ |
374 |
int i; |
const struct device_entry *entry; |
375 |
int found = 0; |
int found = 0; |
376 |
const char *roff_encoding = NULL; |
const char *roff_encoding = NULL; |
377 |
|
|
378 |
for (i = 0; device_table[i].roff_device; ++i) { |
for (entry = device_table; entry->roff_device; ++entry) { |
379 |
if (STREQ (device_table[i].roff_device, device)) { |
if (STREQ (entry->roff_device, device)) { |
380 |
found = 1; |
found = 1; |
381 |
roff_encoding = device_table[i].roff_encoding; |
roff_encoding = entry->roff_encoding; |
382 |
break; |
break; |
383 |
} |
} |
384 |
} |
} |
408 |
*/ |
*/ |
409 |
const char *get_output_encoding (const char *device) |
const char *get_output_encoding (const char *device) |
410 |
{ |
{ |
411 |
int i; |
const struct device_entry *entry; |
412 |
|
|
413 |
for (i = 0; device_table[i].roff_device; ++i) |
for (entry = device_table; entry->roff_device; ++entry) |
414 |
if (STREQ (device_table[i].roff_device, device)) |
if (STREQ (entry->roff_device, device)) |
415 |
return device_table[i].output_encoding; |
return entry->output_encoding; |
416 |
|
|
417 |
return NULL; |
return NULL; |
418 |
} |
} |
420 |
/* Return the value of LESSCHARSET appropriate for this locale. */ |
/* Return the value of LESSCHARSET appropriate for this locale. */ |
421 |
const char *get_less_charset (const char *locale_charset) |
const char *get_less_charset (const char *locale_charset) |
422 |
{ |
{ |
423 |
int i; |
const struct less_charset_entry *entry; |
424 |
|
|
425 |
for (i = 0; less_charset_table[i].locale_charset; ++i) { |
for (entry = less_charset_table; entry->locale_charset; ++entry) |
|
const struct less_charset_entry *entry = |
|
|
&less_charset_table[i]; |
|
426 |
if (STREQ (entry->locale_charset, locale_charset)) |
if (STREQ (entry->locale_charset, locale_charset)) |
427 |
return entry->less_charset; |
return entry->less_charset; |
|
} |
|
428 |
|
|
429 |
return fallback_less_charset; |
return fallback_less_charset; |
430 |
} |
} |