Mercurial > hg > nginx
comparison src/os/win32/ngx_errno.c @ 2770:e70ac6e13f31
fallback to neutral language in FormatMessage()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 28 Apr 2009 15:06:29 +0000 |
parents | 234ddbff1b2e |
children | e294f37401c0 |
comparison
equal
deleted
inserted
replaced
2769:9d986c4e796f | 2770:e70ac6e13f31 |
---|---|
9 | 9 |
10 | 10 |
11 u_char * | 11 u_char * |
12 ngx_strerror_r(ngx_err_t err, u_char *errstr, size_t size) | 12 ngx_strerror_r(ngx_err_t err, u_char *errstr, size_t size) |
13 { | 13 { |
14 u_int len; | 14 u_int len; |
15 static u_long lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); | |
15 | 16 |
16 if (size == 0) { | 17 if (size == 0) { |
17 return errstr; | 18 return errstr; |
18 } | 19 } |
19 | 20 |
20 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | 21 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
21 |FORMAT_MESSAGE_IGNORE_INSERTS, | 22 NULL, err, lang, (char *) errstr, size, NULL); |
22 NULL, err, | 23 |
23 MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), | 24 if (len == 0 && lang && GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND) { |
24 (char *) errstr, size, NULL); | 25 |
26 /* | |
27 * Try to use English messages first and fallback to a language, | |
28 * based on locale: non-English Windows have no English messages | |
29 * at all. This way allows to use English messages at least on | |
30 * Windows with MUI. | |
31 */ | |
32 | |
33 lang = 0; | |
34 | |
35 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, | |
36 NULL, err, lang, (char *) errstr, size, NULL); | |
37 } | |
25 | 38 |
26 if (len == 0) { | 39 if (len == 0) { |
27 return ngx_snprintf(errstr, size, | 40 return ngx_snprintf(errstr, size, |
28 "FormatMessage() error:(%d)", GetLastError()); | 41 "FormatMessage() error:(%d)", GetLastError()); |
29 } | 42 } |