mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
This commit is contained in:
@ -4,14 +4,14 @@
|
||||
*
|
||||
* Portions Copyright (c) 2002-2009, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.49 2009/04/01 09:17:32 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.50 2009/06/11 14:49:03 momjian Exp $
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*----------
|
||||
* Here is how the locale stuff is handled: LC_COLLATE and LC_CTYPE
|
||||
* are fixed at CREATE DATABASE time, stored in pg_database, and cannot
|
||||
* are fixed at CREATE DATABASE time, stored in pg_database, and cannot
|
||||
* be changed. Thus, the effects of strcoll(), strxfrm(), isupper(),
|
||||
* toupper(), etc. are always in the same fixed locale.
|
||||
*
|
||||
@ -93,7 +93,7 @@ static char lc_numeric_envbuf[LC_ENV_BUFSIZE];
|
||||
static char lc_time_envbuf[LC_ENV_BUFSIZE];
|
||||
|
||||
#if defined(WIN32) && defined(LC_MESSAGES)
|
||||
static char *IsoLocaleName(const char *); /* MSVC specific */
|
||||
static char *IsoLocaleName(const char *); /* MSVC specific */
|
||||
#endif
|
||||
|
||||
|
||||
@ -159,9 +159,9 @@ pg_perm_setlocale(int category, const char *locale)
|
||||
result = IsoLocaleName(locale);
|
||||
if (result == NULL)
|
||||
result = (char *) locale;
|
||||
#endif /* WIN32 */
|
||||
#endif /* WIN32 */
|
||||
break;
|
||||
#endif /* LC_MESSAGES */
|
||||
#endif /* LC_MESSAGES */
|
||||
case LC_MONETARY:
|
||||
envvar = "LC_MONETARY";
|
||||
envbuf = lc_monetary_envbuf;
|
||||
@ -468,28 +468,33 @@ PGLC_localeconv(void)
|
||||
* pg_strftime(), which isn't locale-aware and does not need to be replaced.
|
||||
*/
|
||||
static size_t
|
||||
strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm *tm)
|
||||
strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm * tm)
|
||||
{
|
||||
size_t len;
|
||||
wchar_t wbuf[MAX_L10N_DATA];
|
||||
int encoding;
|
||||
size_t len;
|
||||
wchar_t wbuf[MAX_L10N_DATA];
|
||||
int encoding;
|
||||
|
||||
encoding = GetDatabaseEncoding();
|
||||
|
||||
len = wcsftime(wbuf, MAX_L10N_DATA, format, tm);
|
||||
if (len == 0)
|
||||
/* strftime call failed - return 0 with the contents of dst unspecified */
|
||||
|
||||
/*
|
||||
* strftime call failed - return 0 with the contents of dst
|
||||
* unspecified
|
||||
*/
|
||||
return 0;
|
||||
|
||||
len = WideCharToMultiByte(CP_UTF8, 0, wbuf, len, dst, dstlen, NULL, NULL);
|
||||
if (len == 0)
|
||||
elog(ERROR,
|
||||
"could not convert string to UTF-8:error %lu", GetLastError());
|
||||
"could not convert string to UTF-8:error %lu", GetLastError());
|
||||
|
||||
dst[len] = '\0';
|
||||
if (encoding != PG_UTF8)
|
||||
{
|
||||
char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding);
|
||||
char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding);
|
||||
|
||||
if (dst != convstr)
|
||||
{
|
||||
strlcpy(dst, convstr, dstlen);
|
||||
@ -501,8 +506,7 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
|
||||
}
|
||||
|
||||
#define strftime(a,b,c,d) strftime_win32(a,b,L##c,d)
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
/*
|
||||
@ -511,12 +515,13 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
|
||||
void
|
||||
cache_locale_time(void)
|
||||
{
|
||||
char *save_lc_time;
|
||||
char *save_lc_time;
|
||||
time_t timenow;
|
||||
struct tm *timeinfo;
|
||||
struct tm *timeinfo;
|
||||
char buf[MAX_L10N_DATA];
|
||||
char *ptr;
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
char *save_lc_ctype;
|
||||
#endif
|
||||
@ -611,10 +616,11 @@ cache_locale_time(void)
|
||||
* contains the iso formatted locale name.
|
||||
*/
|
||||
static
|
||||
char *IsoLocaleName(const char *winlocname)
|
||||
char *
|
||||
IsoLocaleName(const char *winlocname)
|
||||
{
|
||||
#if (_MSC_VER >= 1400) /* VC8.0 or later */
|
||||
static char iso_lc_messages[32];
|
||||
#if (_MSC_VER >= 1400) /* VC8.0 or later */
|
||||
static char iso_lc_messages[32];
|
||||
_locale_t loct = NULL;
|
||||
|
||||
if (pg_strcasecmp("c", winlocname) == 0 ||
|
||||
@ -627,8 +633,9 @@ char *IsoLocaleName(const char *winlocname)
|
||||
loct = _create_locale(LC_CTYPE, winlocname);
|
||||
if (loct != NULL)
|
||||
{
|
||||
char isolang[32], isocrty[32];
|
||||
LCID lcid;
|
||||
char isolang[32],
|
||||
isocrty[32];
|
||||
LCID lcid;
|
||||
|
||||
lcid = loct->locinfo->lc_handle[LC_CTYPE];
|
||||
if (lcid == 0)
|
||||
@ -644,8 +651,8 @@ char *IsoLocaleName(const char *winlocname)
|
||||
}
|
||||
return NULL;
|
||||
#else
|
||||
return NULL; /* Not supported on this version of msvc/mingw */
|
||||
#endif /* _MSC_VER >= 1400 */
|
||||
return NULL; /* Not supported on this version of msvc/mingw */
|
||||
#endif /* _MSC_VER >= 1400 */
|
||||
}
|
||||
#endif /* WIN32 && LC_MESSAGES */
|
||||
|
||||
#endif /* WIN32 && LC_MESSAGES */
|
||||
|
Reference in New Issue
Block a user