diff options
| author | Andrew Dunstan <andrew@dunslane.net> | 2013-02-06 14:52:29 -0500 |
|---|---|---|
| committer | Andrew Dunstan <andrew@dunslane.net> | 2013-02-06 14:52:29 -0500 |
| commit | e1c1e2173248f39c1b15fca7b2a31ad7b5199ce7 (patch) | |
| tree | db58fc5d34d7812a88b144ce4f573fe74406e402 /src/port | |
| parent | 5a1cd89f8f4a0bc13c85810de47d48bb6386ea89 (diff) | |
| download | postgresql-e1c1e2173248f39c1b15fca7b2a31ad7b5199ce7.tar.gz | |
Enable building with Microsoft Visual Studio 2012.
Backpatch to release 9.2
Brar Piening and Noah Misch, reviewed by Craig Ringer.
Diffstat (limited to 'src/port')
| -rw-r--r-- | src/port/chklocale.c | 43 | ||||
| -rw-r--r-- | src/port/win32env.c | 6 |
2 files changed, 39 insertions, 10 deletions
diff --git a/src/port/chklocale.c b/src/port/chklocale.c index 7e2062c6bb..9e889383f2 100644 --- a/src/port/chklocale.c +++ b/src/port/chklocale.c @@ -189,26 +189,49 @@ static const struct encoding_match encoding_match_list[] = { #ifdef WIN32 /* - * On Windows, use CP<codepage number> instead of the nl_langinfo() result + * On Windows, use CP<code page number> instead of the nl_langinfo() result + * + * Visual Studio 2012 expanded the set of valid LC_CTYPE values, so have its + * locale machinery determine the code page. See comments at IsoLocaleName(). + * For other compilers, follow the locale's predictable format. + * + * Returns a malloc()'d string for the caller to free. */ static char * win32_langinfo(const char *ctype) { - char *r; + char *r = NULL; + +#if (_MSC_VER >= 1700) + _locale_t loct = NULL; + + loct = _create_locale(LC_CTYPE, ctype); + if (loct != NULL) + { + r = malloc(16); /* excess */ + if (r != NULL) + sprintf(r, "CP%u", loct->locinfo->lc_codepage); + _free_locale(loct); + } +#else char *codepage; - int ln; /* * Locale format on Win32 is <Language>_<Country>.<CodePage> . For - * example, English_USA.1252. + * example, English_United States.1252. */ codepage = strrchr(ctype, '.'); - if (!codepage) - return NULL; - codepage++; - ln = strlen(codepage); - r = malloc(ln + 3); - sprintf(r, "CP%s", codepage); + if (codepage != NULL) + { + int ln; + + codepage++; + ln = strlen(codepage); + r = malloc(ln + 3); + if (r != NULL) + sprintf(r, "CP%s", codepage); + } +#endif return r; } diff --git a/src/port/win32env.c b/src/port/win32env.c index 5f0f6f9859..b5f4e8e6d6 100644 --- a/src/port/win32env.c +++ b/src/port/win32env.c @@ -61,6 +61,12 @@ pgwin32_putenv(const char *envval) "msvcr90", 0, NULL }, /* Visual Studio 2008 */ { + "msvcr100", 0, NULL + }, /* Visual Studio 2010 */ + { + "msvcr110", 0, NULL + }, /* Visual Studio 2012 */ + { NULL, 0, NULL } }; |
