Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf37983

Browse files
committed
Back out unintended change to pg_locale.c.
1 parent9295eea commitbf37983

File tree

1 file changed

+15
-135
lines changed

1 file changed

+15
-135
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 15 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2010, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.52 2010/02/27 20:16:17 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.53 2010/02/27 20:20:44 momjian Exp $
88
*
99
*-----------------------------------------------------------------------
1010
*/
@@ -386,70 +386,6 @@ free_struct_lconv(struct lconv * s)
386386
free(s->positive_sign);
387387
}
388388

389-
#ifdefWIN32
390-
staticchar*db_strdup(constchar*item,constchar*str)
391-
{
392-
intdb_encoding=GetDatabaseEncoding();
393-
size_twchars,ilen,wclen,dstlen;
394-
intutflen,bytes_per_char;
395-
wchar_t*wbuf;
396-
char*dst;
397-
398-
if (!str[0])
399-
returnstrdup(str);
400-
ilen=strlen(str)+1;
401-
wclen=ilen*sizeof(wchar_t);
402-
wbuf= (wchar_t*)palloc(wclen);
403-
404-
/* convert multi-byte string to a wide-character string */
405-
wchars=mbstowcs(wbuf,str,ilen);
406-
if (wchars== (size_t)-1)
407-
elog(ERROR,
408-
"could not convert string to wide characters: error %lu",GetLastError());
409-
410-
/* allocate target string */
411-
bytes_per_char=pg_encoding_max_length(PG_UTF8);
412-
if (pg_encoding_max_length(db_encoding)>bytes_per_char)
413-
bytes_per_char=pg_encoding_max_length(db_encoding);
414-
dstlen=wchars*bytes_per_char+1;
415-
if ((dst=malloc(dstlen))==NULL)
416-
elog(ERROR,"could not allocate a destination buffer");
417-
418-
/* Convert wide string to UTF8 */
419-
utflen=WideCharToMultiByte(CP_UTF8,0,wbuf,wchars,dst,dstlen,NULL,NULL);
420-
if (utflen==0)
421-
elog(ERROR,
422-
"could not convert string %04x to UTF-8: error %lu",wbuf[0],GetLastError());
423-
pfree(wbuf);
424-
425-
dst[utflen]='\0';
426-
if (db_encoding!=PG_UTF8)
427-
{
428-
PG_TRY();
429-
{
430-
char*convstr=pg_do_encoding_conversion(dst,utflen,PG_UTF8,db_encoding);
431-
if (dst!=convstr)
432-
{
433-
strlcpy(dst,convstr,dstlen);
434-
pfree(convstr);
435-
}
436-
}
437-
PG_CATCH();
438-
{
439-
FlushErrorState();
440-
dst[0]='\0';
441-
}
442-
PG_END_TRY();
443-
}
444-
445-
returndst;
446-
}
447-
#else
448-
staticchar*db_strdup(constchar*item,constchar*str)
449-
{
450-
returnstrdup(str);
451-
}
452-
#endif/* WIN32 */
453389

454390
/*
455391
* Return the POSIX lconv struct (contains number/money formatting
@@ -462,9 +398,6 @@ PGLC_localeconv(void)
462398
structlconv*extlconv;
463399
char*save_lc_monetary;
464400
char*save_lc_numeric;
465-
#ifdefWIN32
466-
char*save_lc_ctype=NULL;
467-
#endif
468401

469402
/* Did we do it already? */
470403
if (CurrentLocaleConvValid)
@@ -480,83 +413,30 @@ PGLC_localeconv(void)
480413
if (save_lc_numeric)
481414
save_lc_numeric=pstrdup(save_lc_numeric);
482415

483-
#ifdefWIN32
484-
/*
485-
*WIN32 returns an inaccurately encoded symbol, e.g. Euro,
486-
*when the LC_CTYPE does not match the numeric or monetary
487-
*lc types, so we switch to matching LC_CTYPEs as we access them.
488-
*/
489-
490-
if ((save_lc_ctype=setlocale(LC_CTYPE,NULL))!=NULL)
491-
{
492-
/* Save for later restore */
493-
save_lc_ctype=pstrdup(save_lc_ctype);
494-
495-
/* Set LC_CTYPE to match LC_MONETARY? */
496-
if (pg_strcasecmp(save_lc_ctype,locale_monetary)!=0)
497-
setlocale(LC_CTYPE,locale_monetary);
498-
}
499-
else
500-
/* LC_CTYPE not set, unconditionally set it */
501-
setlocale(LC_CTYPE,locale_monetary);
502-
503-
/*
504-
*If LC_NUMERIC and LC_MONETARY match, we can set it now and
505-
*avoid a second localeconv() call.
506-
*/
507-
if (pg_strcasecmp(locale_numeric,locale_monetary)==0)
508-
#else
509-
setlocale(LC_NUMERIC,locale_numeric);
510-
#endif
511-
512416
setlocale(LC_MONETARY,locale_monetary);
513-
/*
514-
*Get formatting information for LC_MONETARY, and LC_NUMERIC if they
515-
*are the same.
516-
*/
417+
setlocale(LC_NUMERIC,locale_numeric);
418+
419+
/* Get formatting information */
517420
extlconv=localeconv();
518421

519422
/*
520-
* Must copy all values since restoring internal settingsmight overwrite
423+
* Must copy all values since restoring internal settingsmay overwrite
521424
* localeconv()'s results.
522425
*/
523426
CurrentLocaleConv=*extlconv;
524-
525-
/* The first argument of db_strdup() is only used on WIN32 */
526-
CurrentLocaleConv.currency_symbol=db_strdup("currency_symbol",extlconv->currency_symbol);
527-
CurrentLocaleConv.int_curr_symbol=db_strdup("int_curr_symbol",extlconv->int_curr_symbol);
528-
CurrentLocaleConv.mon_decimal_point=db_strdup("mon_decimal_point",extlconv->mon_decimal_point);
427+
CurrentLocaleConv.currency_symbol=strdup(extlconv->currency_symbol);
428+
CurrentLocaleConv.decimal_point=strdup(extlconv->decimal_point);
429+
CurrentLocaleConv.grouping=strdup(extlconv->grouping);
430+
CurrentLocaleConv.thousands_sep=strdup(extlconv->thousands_sep);
431+
CurrentLocaleConv.int_curr_symbol=strdup(extlconv->int_curr_symbol);
432+
CurrentLocaleConv.mon_decimal_point=strdup(extlconv->mon_decimal_point);
529433
CurrentLocaleConv.mon_grouping=strdup(extlconv->mon_grouping);
530-
CurrentLocaleConv.mon_thousands_sep=db_strdup("mon_thousands_sep",extlconv->mon_thousands_sep);
531-
CurrentLocaleConv.negative_sign=db_strdup("negative_sign",extlconv->negative_sign);
532-
CurrentLocaleConv.positive_sign=db_strdup("positive_sign",extlconv->positive_sign);
434+
CurrentLocaleConv.mon_thousands_sep=strdup(extlconv->mon_thousands_sep);
435+
CurrentLocaleConv.negative_sign=strdup(extlconv->negative_sign);
436+
CurrentLocaleConv.positive_sign=strdup(extlconv->positive_sign);
533437
CurrentLocaleConv.n_sign_posn=extlconv->n_sign_posn;
534438

535-
#ifdefWIN32
536-
/* Do we need to change LC_CTYPE to match LC_NUMERIC? */
537-
if (pg_strcasecmp(locale_numeric,locale_monetary)!=0)
538-
{
539-
setlocale(LC_CTYPE,locale_numeric);
540-
setlocale(LC_NUMERIC,locale_numeric);
541-
/* Get formatting information for LC_NUMERIC */
542-
extlconv=localeconv();
543-
}
544-
#endif
545-
546-
CurrentLocaleConv.decimal_point=db_strdup("decimal_point",extlconv->decimal_point);
547-
CurrentLocaleConv.grouping=strdup(extlconv->grouping);
548-
CurrentLocaleConv.thousands_sep=db_strdup("thousands_sep",extlconv->thousands_sep);
549-
550-
/*
551-
*Restore internal settings
552-
*/
553-
#ifdefWIN32
554-
if (save_lc_ctype)
555-
{
556-
setlocale(LC_CTYPE,save_lc_ctype);
557-
pfree(save_lc_ctype);
558-
}
559-
#endif
439+
/* Try to restore internal settings */
560440
if (save_lc_monetary)
561441
{
562442
setlocale(LC_MONETARY,save_lc_monetary);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp