Skip to content

Commit 03bc5ce

Browse files
committed
Try en_us.UTF-8 if en_us locale is not available.
Closes #28
1 parent 9fb18d2 commit 03bc5ce

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ HYPERMAIL VERSION 2.4.0:
88
* setup.c
99
PreConfig(): removed a 64-bit warning
1010

11+
* hypermail.c
12+
main(): if the en_US locale is not available, try en_US.UTF-8
13+
1114
2018-10-11 Jose Kahan
1215

1316
* string.c

src/hypermail.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,19 @@ int main(int argc, char **argv)
366366

367367
#ifdef HAVE_LOCALE_H
368368
if (!setlocale(LC_ALL, locale_code)) {
369-
snprintf(errmsg, sizeof(errmsg), "WARNING: locale \"%s\", not supported.\n", locale_code);
370-
fprintf(stderr, "%s", errmsg);/* AUDIT biege: avoid format-bug warning */
369+
char *rv;
370+
371+
if (!strcmp(locale_code, "en_US")) {
372+
/* many systems now install by defualt en_US.UTF-8.
373+
Here we assume that the mapping between en_US and en_US.UTF-8
374+
in system messages is identical.
375+
We cannot do the same for other languages, though */
376+
rv = setlocale(LC_ALL, "en_US.UTF-8");
377+
}
378+
if (!rv) {
379+
snprintf(errmsg, sizeof(errmsg), "WARNING: locale \"%s\", not supported.\n", locale_code);
380+
fprintf(stderr, "%s", errmsg);/* AUDIT biege: avoid format-bug warning */
381+
}
371382
}
372383
#endif
373384

0 commit comments

Comments
 (0)