|
|
|
@ -457,7 +457,7 @@ strlower_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
/* Output workspace cannot have more codes than input bytes */ |
|
|
|
|
workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t)); |
|
|
|
|
|
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, locale); |
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, loc); |
|
|
|
|
|
|
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++) |
|
|
|
|
workspace[curr_char] = towlower_l(workspace[curr_char], loc); |
|
|
|
@ -468,7 +468,7 @@ strlower_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
max_size = curr_char * pg_database_encoding_max_length(); |
|
|
|
|
result = palloc(max_size + 1); |
|
|
|
|
|
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, locale); |
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, loc); |
|
|
|
|
|
|
|
|
|
if (result_size + 1 > destsize) |
|
|
|
|
return result_size; |
|
|
|
@ -552,7 +552,7 @@ strtitle_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
/* Output workspace cannot have more codes than input bytes */ |
|
|
|
|
workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t)); |
|
|
|
|
|
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, locale); |
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, loc); |
|
|
|
|
|
|
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++) |
|
|
|
|
{ |
|
|
|
@ -569,7 +569,7 @@ strtitle_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
max_size = curr_char * pg_database_encoding_max_length(); |
|
|
|
|
result = palloc(max_size + 1); |
|
|
|
|
|
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, locale); |
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, loc); |
|
|
|
|
|
|
|
|
|
if (result_size + 1 > destsize) |
|
|
|
|
return result_size; |
|
|
|
@ -640,7 +640,7 @@ strupper_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
/* Output workspace cannot have more codes than input bytes */ |
|
|
|
|
workspace = (wchar_t *) palloc((srclen + 1) * sizeof(wchar_t)); |
|
|
|
|
|
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, locale); |
|
|
|
|
char2wchar(workspace, srclen + 1, src, srclen, loc); |
|
|
|
|
|
|
|
|
|
for (curr_char = 0; workspace[curr_char] != 0; curr_char++) |
|
|
|
|
workspace[curr_char] = towupper_l(workspace[curr_char], loc); |
|
|
|
@ -651,7 +651,7 @@ strupper_libc_mb(char *dest, size_t destsize, const char *src, ssize_t srclen, |
|
|
|
|
max_size = curr_char * pg_database_encoding_max_length(); |
|
|
|
|
result = palloc(max_size + 1); |
|
|
|
|
|
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, locale); |
|
|
|
|
result_size = wchar2char(result, workspace, max_size + 1, loc); |
|
|
|
|
|
|
|
|
|
if (result_size + 1 > destsize) |
|
|
|
|
return result_size; |
|
|
|
@ -1130,7 +1130,7 @@ wcstombs_l(char *dest, const wchar_t *src, size_t n, locale_t loc) |
|
|
|
|
* zero-terminated. The output will be zero-terminated iff there is room. |
|
|
|
|
*/ |
|
|
|
|
size_t |
|
|
|
|
wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) |
|
|
|
|
wchar2char(char *to, const wchar_t *from, size_t tolen, locale_t loc) |
|
|
|
|
{ |
|
|
|
|
size_t result; |
|
|
|
|
|
|
|
|
@ -1160,7 +1160,7 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
#endif /* WIN32 */ |
|
|
|
|
if (locale == (pg_locale_t) 0) |
|
|
|
|
if (loc == (locale_t) 0) |
|
|
|
|
{ |
|
|
|
|
/* Use wcstombs directly for the default locale */ |
|
|
|
|
result = wcstombs(to, from, tolen); |
|
|
|
@ -1168,7 +1168,7 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* Use wcstombs_l for nondefault locales */ |
|
|
|
|
result = wcstombs_l(to, from, tolen, locale->info.lt); |
|
|
|
|
result = wcstombs_l(to, from, tolen, loc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
@ -1185,7 +1185,7 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) |
|
|
|
|
*/ |
|
|
|
|
size_t |
|
|
|
|
char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, |
|
|
|
|
pg_locale_t locale) |
|
|
|
|
locale_t loc) |
|
|
|
|
{ |
|
|
|
|
size_t result; |
|
|
|
|
|
|
|
|
@ -1220,7 +1220,7 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, |
|
|
|
|
/* mbstowcs requires ending '\0' */ |
|
|
|
|
char *str = pnstrdup(from, fromlen); |
|
|
|
|
|
|
|
|
|
if (locale == (pg_locale_t) 0) |
|
|
|
|
if (loc == (locale_t) 0) |
|
|
|
|
{ |
|
|
|
|
/* Use mbstowcs directly for the default locale */ |
|
|
|
|
result = mbstowcs(to, str, tolen); |
|
|
|
@ -1228,7 +1228,7 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
/* Use mbstowcs_l for nondefault locales */ |
|
|
|
|
result = mbstowcs_l(to, str, tolen, locale->info.lt); |
|
|
|
|
result = mbstowcs_l(to, str, tolen, loc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pfree(str); |
|
|
|
|