11/* -----------------------------------------------------------------------
22 * formatting.c
33 *
4- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.140 2008/05/19 18:08:15 tgl Exp $
4+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.141 2008/05/20 01:41:02 momjian Exp $
55 *
66 *
77 * 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)
18941894if (!tm -> tm_mon )
18951895break ;
18961896if (S_TM (n -> suffix ))
1897- {
1898- strcpy (workbuff ,localized_full_months [tm -> tm_mon - 1 ]);
1899- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
1900- }
1897+ strcpy (s ,str_toupper (localized_full_months [tm -> tm_mon - 1 ]));
19011898else
19021899{
19031900strcpy (workbuff ,months_full [tm -> tm_mon - 1 ]);
@@ -1910,25 +1907,17 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
19101907if (!tm -> tm_mon )
19111908break ;
19121909if (S_TM (n -> suffix ))
1913- {
1914- strcpy (workbuff ,localized_full_months [tm -> tm_mon - 1 ]);
1915- sprintf (s ,"%*s" ,0 ,str_initcap (workbuff ));
1916- }
1910+ strcpy (s ,str_initcap (localized_full_months [tm -> tm_mon - 1 ]));
19171911else
1918- {
19191912sprintf (s ,"%*s" ,S_FM (n -> suffix ) ?0 :-9 ,months_full [tm -> tm_mon - 1 ]);
1920- }
19211913s += strlen (s );
19221914break ;
19231915case DCH_month :
19241916INVALID_FOR_INTERVAL ;
19251917if (!tm -> tm_mon )
19261918break ;
19271919if (S_TM (n -> suffix ))
1928- {
1929- strcpy (workbuff ,localized_full_months [tm -> tm_mon - 1 ]);
1930- sprintf (s ,"%*s" ,0 ,str_tolower (workbuff ));
1931- }
1920+ strcpy (s ,str_tolower (localized_full_months [tm -> tm_mon - 1 ]));
19321921else
19331922{
19341923sprintf (s ,"%*s" ,S_FM (n -> suffix ) ?0 :-9 ,months_full [tm -> tm_mon - 1 ]);
@@ -1941,41 +1930,27 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
19411930if (!tm -> tm_mon )
19421931break ;
19431932if (S_TM (n -> suffix ))
1944- {
1945- strcpy (workbuff ,localized_abbrev_months [tm -> tm_mon - 1 ]);
1946- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
1947- }
1933+ strcpy (s ,str_toupper (localized_abbrev_months [tm -> tm_mon - 1 ]));
19481934else
1949- {
1950- strcpy (workbuff ,months [tm -> tm_mon - 1 ]);
1951- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
1952- }
1935+ strcpy (s ,str_toupper (months [tm -> tm_mon - 1 ]));
19531936s += strlen (s );
19541937break ;
19551938case DCH_Mon :
19561939INVALID_FOR_INTERVAL ;
19571940if (!tm -> tm_mon )
19581941break ;
19591942if (S_TM (n -> suffix ))
1960- {
1961- strcpy (workbuff ,localized_abbrev_months [tm -> tm_mon - 1 ]);
1962- sprintf (s ,"%*s" ,0 ,str_initcap (workbuff ));
1963- }
1943+ strcpy (s ,str_initcap (localized_abbrev_months [tm -> tm_mon - 1 ]));
19641944else
1965- {
19661945strcpy (s ,months [tm -> tm_mon - 1 ]);
1967- }
19681946s += strlen (s );
19691947break ;
19701948case DCH_mon :
19711949INVALID_FOR_INTERVAL ;
19721950if (!tm -> tm_mon )
19731951break ;
19741952if (S_TM (n -> suffix ))
1975- {
1976- strcpy (workbuff ,localized_abbrev_months [tm -> tm_mon - 1 ]);
1977- sprintf (s ,"%*s" ,0 ,str_tolower (workbuff ));
1978- }
1953+ strcpy (s ,str_tolower (localized_abbrev_months [tm -> tm_mon - 1 ]));
19791954else
19801955{
19811956strcpy (s ,months [tm -> tm_mon - 1 ]);
@@ -1992,10 +1967,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
19921967case DCH_DAY :
19931968INVALID_FOR_INTERVAL ;
19941969if (S_TM (n -> suffix ))
1995- {
1996- strcpy (workbuff ,localized_full_days [tm -> tm_wday ]);
1997- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
1998- }
1970+ strcpy (s ,str_toupper (localized_full_days [tm -> tm_wday ]));
19991971else
20001972{
20011973strcpy (workbuff ,days [tm -> tm_wday ]);
@@ -2006,23 +1978,15 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
20061978case DCH_Day :
20071979INVALID_FOR_INTERVAL ;
20081980if (S_TM (n -> suffix ))
2009- {
2010- strcpy (workbuff ,localized_full_days [tm -> tm_wday ]);
2011- sprintf (s ,"%*s" ,0 ,str_initcap (workbuff ));
2012- }
1981+ strcpy (s ,str_initcap (localized_full_days [tm -> tm_wday ]));
20131982else
2014- {
20151983sprintf (s ,"%*s" ,S_FM (n -> suffix ) ?0 :-9 ,days [tm -> tm_wday ]);
2016- }
20171984s += strlen (s );
20181985break ;
20191986case DCH_day :
20201987INVALID_FOR_INTERVAL ;
20211988if (S_TM (n -> suffix ))
2022- {
2023- strcpy (workbuff ,localized_full_days [tm -> tm_wday ]);
2024- sprintf (s ,"%*s" ,0 ,str_tolower (workbuff ));
2025- }
1989+ strcpy (s ,str_tolower (localized_full_days [tm -> tm_wday ]));
20261990else
20271991{
20281992sprintf (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)
20331997case DCH_DY :
20341998INVALID_FOR_INTERVAL ;
20351999if (S_TM (n -> suffix ))
2036- {
2037- strcpy (workbuff ,localized_abbrev_days [tm -> tm_wday ]);
2038- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
2039- }
2000+ strcpy (s ,str_toupper (localized_abbrev_days [tm -> tm_wday ]));
20402001else
2041- {
2042- strcpy (workbuff ,days_short [tm -> tm_wday ]);
2043- sprintf (s ,"%*s" ,0 ,str_toupper (workbuff ));
2044- }
2002+ strcpy (s ,str_toupper (days_short [tm -> tm_wday ]));
20452003s += strlen (s );
20462004break ;
20472005case DCH_Dy :
20482006INVALID_FOR_INTERVAL ;
20492007if (S_TM (n -> suffix ))
2050- {
2051- strcpy (workbuff ,localized_abbrev_days [tm -> tm_wday ]);
2052- sprintf (s ,"%*s" ,0 ,str_initcap (workbuff ));
2053- }
2008+ strcpy (s ,str_initcap (localized_abbrev_days [tm -> tm_wday ]));
20542009else
2055- {
20562010strcpy (s ,days_short [tm -> tm_wday ]);
2057- }
20582011s += strlen (s );
20592012break ;
20602013case DCH_dy :
20612014INVALID_FOR_INTERVAL ;
20622015if (S_TM (n -> suffix ))
2063- {
2064- strcpy (workbuff ,localized_abbrev_days [tm -> tm_wday ]);
2065- sprintf (s ,"%*s" ,0 ,str_tolower (workbuff ));
2066- }
2016+ strcpy (s ,str_tolower (localized_abbrev_days [tm -> tm_wday ]));
20672017else
20682018{
20692019strcpy (s ,days_short [tm -> tm_wday ]);