/*
* check if given string is a valid locale detecting
* whether contains a ' symbol by Wwashington @ Smth
* (I will take responsibility for it
*/
static bool
cfglocale(const char *locale)
{
bool ret;
char loc_temp[128];
int len, i, j;
ret = false; j=0;
len = strlen(locale);
for (i=0;i<len;i++)
{
if (locale=='\'')
{ ret=true;
loc_temp[j++]='\\';
}
loc_temp[j++]=locale;
}
/* should we exit here? */
if (ret)
sprintf(locale,"%s", loc_temp);
return ret;
}
------->;
if (cfglocale(lc_messages))
fprintf(stderr, _("checking\npostgresql.conf: parameter updated -->; lc_messages\n");
if (cfglocale(lc_monetary))
fprintf(stderr, _("postgresql.conf: parameter updated -->; lc_monetary\n");
if (cfglocale(lc_numeric))
fprintf(stderr, _("postgresql.conf: parameter updated -->; lc_numeric\n");
if (cfglocale(lc_time))
fprintf(stderr, _("postgresql.conf: parameter updated -->; lc_time\n");
/*
* check if given Windows timezone is a valid locale
* to meet the English catalog by Wwashington @ Smth
* (I will take responsibility for it
*/
static bool
scanzone(const char *locale)
{
bool ret;
ret = false;
if (strcmp(locale, "中国标准时间"==0 )
{
ret=true;
sprintf((char *)locale, "China Standard Time"
}
1) set TZ=PRC
2) initdb --locale=C作者: wwashington 时间: 2004-09-04 13:09 标题: PostgreSQL 8.0 beta working patch(下载) 向大家报告一个好消息,已经把补丁发给 PostgreSQL 开发组了。
希望老外不嫌弃咱们中国人的土智慧,在正式版里集成这个补丁。作者: wwashington 时间: 2004-10-08 11:43 标题: PostgreSQL 8.0 beta working patch(下载) 发件人 : Bruce Momjian <pgman@xxx>;
发送 : 2004年10月8日 0:52:37
收件人 : Zhong Jacky <jackyzhongxp@xxx>;
抄送 : pgsql-bugs@postgresql.org
主题 : Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone
| | | 收件箱
I have reviewed your patch. I found that the first patch was definitely
needed. Your code adds escapes for single quotes in locale names placed
in postgresql.conf. I also added code to escape a literal backslash as
well. I re-factored your code and applied the attached patch.
Your second patch to pgtz.c is not needed anymore because we have a more
general solution added on September 1:
/*
* Localized Windows versions return localized names for the
* timezone. Scan the registry to find the English name,
* and then try matching against our table again.
*/
memset(localtzname, 0, sizeof(localtzname));
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time
Zones",
0,
KEY_READ,
&rootKey) != ERROR_SUCCESS)
Zhong Jacky wrote:
>; Hi pgsql-bugs,
>;
>; I'm a Chinese and I am using WinXp Chs to compile pgsql 8.0 beta 1
>; in the MinGW environment. I found 2 bugs and fix them, maybe you can
>; merge the patch into the offical release, thanks.
>;
>; Part A) Below is the two bugs occur when we run initdb under WinXp Chs.
>;
>; 1) FATAL: syntax error in file "E:/Unix/Sys/Pgsql/data/postgresql.conf"
>;
>; line 261, near token "s"
>;
>; Reason: the string 'Chinese_People's Republic of China.936' should be
>; 'Chinese_People\'s Republic of China.936', otherwise token mismatch. Plese
>; remember the regular expression like sed and awk under Unix.
>;
>; Patch: I wrote a function to detect ' in string and insert a \ symbol
>;
>; 2) WARNING: could not find a match for Windows timezone "??????"
>;
>; Reason: "??????" is the string stands for "China Standard
>; Time",
>; which shows in Chinese language.
>;
>; Patch: use a scanzone() function to find and convert timezone to the
>; English string in win32_tzmap[]. I can fix only Chinese because I only have
>; WinXp Chs operating system, people can fix others in similar way.
>;
>; Part B) You can visit these 2 websites for more detail and get patch.
>; 1) http://blog.csdn.net/chaoyuebetter/archive/2004/08/13/73785.aspx
>; 2) http://www.smth.edu.cn/bbsgcon.php?board=NewSoftware&num=2547
>;
>; Part C) The patch is based on snap0812, but can work on snap0825, etc.
>;
>; Regards,
>; Jacky作者: wwashington 时间: 2004-10-08 11:45 标题: PostgreSQL 8.0 beta working patch(下载) 发件人 : Tom Lane <tgl@xxx>;
发送 : 2004年10月8日 1:17:56
收件人 : Bruce Momjian <pgman@xxx>;
抄送 : Zhong Jacky <jackyzhongxp@xxx>;, pgsql-bugs@postgresql.org
主题 : Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone
| | | 收件箱
Bruce Momjian <pgman@candle.pha.pa.us>; writes:
>; + /*
>; + * Escape any single quotes or backslashes in locale
>; + */
>; + static void
>; + escape_locale(char **locale)
>; + {
>; + int len = strlen(*locale),
>; + i, j;
>; + char *loc_temp = xmalloc(len * 2);
>; +
>; + for (i = 0, j = 0; i < len; i++)
>; + {
>; + if ((*locale) == '\'' || (*locale) == '\\')
>; + loc_temp[j++] = '\\';
>; + loc_temp[j++] = (*locale);
>; + }
>; + *locale = loc_temp;
>; + }
Surely this is quite broken. You need to xmalloc one more byte and
add a '\0'.
regards, tom lane作者: wwashington 时间: 2004-10-08 11:46 标题: PostgreSQL 8.0 beta working patch(下载) 发件人 : Bruce Momjian <pgman@xxx>;
发送 : 2004年10月8日 1:29:11
收件人 : Tom Lane <tgl@xxx>;
抄送 : Zhong Jacky <jackyzhongxp@xxx>;, pgsql-bugs@postgresql.org
主题 : Re: [BUGS] pgsql 8.0 beta1 patch for token and timezone