aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2008-05-20 01:41:02 +0000
committerBruce Momjian <bruce@momjian.us>2008-05-20 01:41:02 +0000
commit9f194709665e1f7d7e5064ee4e78134eb0a6b125 (patch)
tree709f7270e77280e02c127fe36104893c2c683503 /src/backend/utils/adt/formatting.c
parentabb5fd8604117f89941fdb484457f70a599801d4 (diff)
downloadpostgresql-9f194709665e1f7d7e5064ee4e78134eb0a6b125.tar.gz
postgresql-9f194709665e1f7d7e5064ee4e78134eb0a6b125.zip
Simplify code in formatting.c now that to upper/lower/initcase do not
modify the passed string.
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c80
1 files changed, 15 insertions, 65 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index a8d63180dc4..37b0844ab18 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.140 2008/05/19 18:08:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.141 2008/05/20 01:41:02 momjian Exp $
*
*
* Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group
@@ -1894,10 +1894,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ strcpy(s, str_toupper(localized_full_months[tm->tm_mon - 1]));
else
{
strcpy(workbuff, months_full[tm->tm_mon - 1]);
@@ -1910,14 +1907,9 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ 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,10 +1917,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ 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,15 +1930,9 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ strcpy(s, str_toupper(localized_abbrev_months[tm->tm_mon - 1]));
else
- {
- strcpy(workbuff, months[tm->tm_mon - 1]);
- sprintf(s, "%*s", 0, str_toupper(workbuff));
- }
+ strcpy(s, str_toupper(months[tm->tm_mon - 1]));
s += strlen(s);
break;
case DCH_Mon:
@@ -1957,14 +1940,9 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ 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,10 +1950,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ strcpy(s, str_tolower(localized_abbrev_months[tm->tm_mon - 1]));
else
{
strcpy(s, months[tm->tm_mon - 1]);
@@ -1992,10 +1967,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ strcpy(s, str_toupper(localized_full_days[tm->tm_wday]));
else
{
strcpy(workbuff, days[tm->tm_wday]);
@@ -2006,23 +1978,15 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ 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(workbuff, localized_full_days[tm->tm_wday]);
- sprintf(s, "%*s", 0, str_tolower(workbuff));
- }
+ 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,37 +1997,23 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
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));
- }
+ strcpy(s, str_toupper(localized_abbrev_days[tm->tm_wday]));
else
- {
- strcpy(workbuff, days_short[tm->tm_wday]);
- sprintf(s, "%*s", 0, str_toupper(workbuff));
- }
+ 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(workbuff, localized_abbrev_days[tm->tm_wday]);
- sprintf(s, "%*s", 0, str_initcap(workbuff));
- }
+ 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(workbuff, localized_abbrev_days[tm->tm_wday]);
- sprintf(s, "%*s", 0, str_tolower(workbuff));
- }
+ strcpy(s, str_tolower(localized_abbrev_days[tm->tm_wday]));
else
{
strcpy(s, days_short[tm->tm_wday]);