1
1
/* -----------------------------------------------------------------------
2
2
* formatting.c
3
3
*
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 $
5
5
*
6
6
*
7
7
* 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)
1894
1894
if (!tm -> tm_mon )
1895
1895
break ;
1896
1896
if (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 ]));
1901
1898
else
1902
1899
{
1903
1900
strcpy (workbuff , months_full [tm -> tm_mon - 1 ]);
@@ -1910,25 +1907,17 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
1910
1907
if (!tm -> tm_mon )
1911
1908
break ;
1912
1909
if (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 ]));
1917
1911
else
1918
- {
1919
1912
sprintf (s , "%*s" , S_FM (n -> suffix ) ? 0 : -9 , months_full [tm -> tm_mon - 1 ]);
1920
- }
1921
1913
s += strlen (s );
1922
1914
break ;
1923
1915
case DCH_month :
1924
1916
INVALID_FOR_INTERVAL ;
1925
1917
if (!tm -> tm_mon )
1926
1918
break ;
1927
1919
if (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 ]));
1932
1921
else
1933
1922
{
1934
1923
sprintf (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)
1941
1930
if (!tm -> tm_mon )
1942
1931
break ;
1943
1932
if (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 ]));
1948
1934
else
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 ]));
1953
1936
s += strlen (s );
1954
1937
break ;
1955
1938
case DCH_Mon :
1956
1939
INVALID_FOR_INTERVAL ;
1957
1940
if (!tm -> tm_mon )
1958
1941
break ;
1959
1942
if (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 ]));
1964
1944
else
1965
- {
1966
1945
strcpy (s , months [tm -> tm_mon - 1 ]);
1967
- }
1968
1946
s += strlen (s );
1969
1947
break ;
1970
1948
case DCH_mon :
1971
1949
INVALID_FOR_INTERVAL ;
1972
1950
if (!tm -> tm_mon )
1973
1951
break ;
1974
1952
if (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 ]));
1979
1954
else
1980
1955
{
1981
1956
strcpy (s , months [tm -> tm_mon - 1 ]);
@@ -1992,10 +1967,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
1992
1967
case DCH_DAY :
1993
1968
INVALID_FOR_INTERVAL ;
1994
1969
if (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 ]));
1999
1971
else
2000
1972
{
2001
1973
strcpy (workbuff , days [tm -> tm_wday ]);
@@ -2006,23 +1978,15 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out)
2006
1978
case DCH_Day :
2007
1979
INVALID_FOR_INTERVAL ;
2008
1980
if (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 ]));
2013
1982
else
2014
- {
2015
1983
sprintf (s , "%*s" , S_FM (n -> suffix ) ? 0 : -9 , days [tm -> tm_wday ]);
2016
- }
2017
1984
s += strlen (s );
2018
1985
break ;
2019
1986
case DCH_day :
2020
1987
INVALID_FOR_INTERVAL ;
2021
1988
if (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 ]));
2026
1990
else
2027
1991
{
2028
1992
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)
2033
1997
case DCH_DY :
2034
1998
INVALID_FOR_INTERVAL ;
2035
1999
if (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 ]));
2040
2001
else
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 ]));
2045
2003
s += strlen (s );
2046
2004
break ;
2047
2005
case DCH_Dy :
2048
2006
INVALID_FOR_INTERVAL ;
2049
2007
if (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 ]));
2054
2009
else
2055
- {
2056
2010
strcpy (s , days_short [tm -> tm_wday ]);
2057
- }
2058
2011
s += strlen (s );
2059
2012
break ;
2060
2013
case DCH_dy :
2061
2014
INVALID_FOR_INTERVAL ;
2062
2015
if (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 ]));
2067
2017
else
2068
2018
{
2069
2019
strcpy (s , days_short [tm -> tm_wday ]);
0 commit comments