Now that upper/lower/initcase do not modify the passed string, I have simplified formatting.c with the attached patch.
-- Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Index: src/backend/utils/adt/formatting.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v retrieving revision 1.140 diff -c -c -r1.140 formatting.c *** src/backend/utils/adt/formatting.c 19 May 2008 18:08:15 -0000 1.140 --- src/backend/utils/adt/formatting.c 20 May 2008 01:37:23 -0000 *************** *** 1894,1903 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } else { strcpy(workbuff, months_full[tm->tm_mon - 1]); --- 1894,1900 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_toupper(localized_full_months[tm->tm_mon - 1])); else { strcpy(workbuff, months_full[tm->tm_mon - 1]); *************** *** 1910,1923 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_initcap(workbuff)); ! } else - { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]); - } s += strlen(s); break; case DCH_month: --- 1907,1915 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_initcap(localized_full_months[tm->tm_mon - 1])); else sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]); s += strlen(s); break; case DCH_month: *************** *** 1925,1934 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_tolower(workbuff)); ! } else { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]); --- 1917,1923 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_tolower(localized_full_months[tm->tm_mon - 1])); else { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]); *************** *** 1941,1955 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } else ! { ! strcpy(workbuff, months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } s += strlen(s); break; case DCH_Mon: --- 1930,1938 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_toupper(localized_abbrev_months[tm->tm_mon - 1])); else ! strcpy(s, str_toupper(months[tm->tm_mon - 1])); s += strlen(s); break; case DCH_Mon: *************** *** 1957,1970 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_initcap(workbuff)); ! } else - { strcpy(s, months[tm->tm_mon - 1]); - } s += strlen(s); break; case DCH_mon: --- 1940,1948 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_initcap(localized_abbrev_months[tm->tm_mon - 1])); else strcpy(s, months[tm->tm_mon - 1]); s += strlen(s); break; case DCH_mon: *************** *** 1972,1981 **** if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_months[tm->tm_mon - 1]); ! sprintf(s, "%*s", 0, str_tolower(workbuff)); ! } else { strcpy(s, months[tm->tm_mon - 1]); --- 1950,1956 ---- if (!tm->tm_mon) break; if (S_TM(n->suffix)) ! strcpy(s, str_tolower(localized_abbrev_months[tm->tm_mon - 1])); else { strcpy(s, months[tm->tm_mon - 1]); *************** *** 1992,2001 **** case DCH_DAY: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } else { strcpy(workbuff, days[tm->tm_wday]); --- 1967,1973 ---- case DCH_DAY: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_toupper(localized_full_days[tm->tm_wday])); else { strcpy(workbuff, days[tm->tm_wday]); *************** *** 2006,2028 **** case DCH_Day: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_initcap(workbuff)); ! } else - { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]); - } s += strlen(s); break; case DCH_day: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_full_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_tolower(workbuff)); ! } else { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]); --- 1978,1992 ---- case DCH_Day: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_initcap(localized_full_days[tm->tm_wday])); else sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]); s += strlen(s); break; case DCH_day: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_tolower(localized_full_days[tm->tm_wday])); else { sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]); *************** *** 2033,2069 **** case DCH_DY: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } else ! { ! strcpy(workbuff, days_short[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_toupper(workbuff)); ! } s += strlen(s); break; case DCH_Dy: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_initcap(workbuff)); ! } else - { strcpy(s, days_short[tm->tm_wday]); - } s += strlen(s); break; case DCH_dy: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! { ! strcpy(workbuff, localized_abbrev_days[tm->tm_wday]); ! sprintf(s, "%*s", 0, str_tolower(workbuff)); ! } else { strcpy(s, days_short[tm->tm_wday]); --- 1997,2019 ---- case DCH_DY: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_toupper(localized_abbrev_days[tm->tm_wday])); else ! strcpy(s, str_toupper(days_short[tm->tm_wday])); s += strlen(s); break; case DCH_Dy: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_initcap(localized_abbrev_days[tm->tm_wday])); else strcpy(s, days_short[tm->tm_wday]); s += strlen(s); break; case DCH_dy: INVALID_FOR_INTERVAL; if (S_TM(n->suffix)) ! strcpy(s, str_tolower(localized_abbrev_days[tm->tm_wday])); else { strcpy(s, days_short[tm->tm_wday]);
-- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches