11/* -----------------------------------------------------------------------
22 * formatting.c
33 *
4- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.108 2006/03/05 15:58:42 momjian Exp $
4+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.109 2006/04/19 14:48:06 momjian Exp $
55 *
66 *
77 * Portions Copyright (c) 1999-2006, PostgreSQL Global Development Group
@@ -1096,7 +1096,6 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
10961096num -> pre_lsign_num = num -> pre ;
10971097num -> need_locale = TRUE;
10981098num -> flag |=NUM_F_LSIGN ;
1099-
11001099}
11011100else if (num -> lsign == NUM_LSIGN_NONE )
11021101{
@@ -1228,7 +1227,6 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
12281227 */
12291228if (* str && (n -> key = index_seq_search (str ,kw ,index ))!= NULL )
12301229{
1231-
12321230n -> type = NODE_TYPE_ACTION ;
12331231n -> suffix = 0 ;
12341232node_set = 1 ;
@@ -1250,7 +1248,6 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
12501248if (s -> len )
12511249str += s -> len ;
12521250}
1253-
12541251}
12551252else if (* str )
12561253{
@@ -1259,7 +1256,6 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
12591256 */
12601257if (* str == '"' && last != '\\' )
12611258{
1262-
12631259int x = 0 ;
12641260
12651261while (* (++ str ))
@@ -1284,13 +1280,11 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
12841280node_set = 0 ;
12851281suffix = 0 ;
12861282last = 0 ;
1287-
12881283}
12891284else if (* str && * str == '\\' && last != '\\' && * (str + 1 )== '"' )
12901285{
12911286last = * str ;
12921287str ++ ;
1293-
12941288}
12951289else if (* str )
12961290{
@@ -1301,7 +1295,6 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
13011295last = 0 ;
13021296str ++ ;
13031297}
1304-
13051298}
13061299
13071300/* end */
@@ -1314,7 +1307,6 @@ parse_format(FormatNode *node, char *str, const KeyWord *kw,
13141307n -> suffix = 0 ;
13151308node_set = 0 ;
13161309}
1317-
13181310}
13191311
13201312n -> type = NODE_TYPE_END ;
@@ -1422,7 +1414,6 @@ dump_node(FormatNode *node, int max)
14221414}
14231415else
14241416elog (DEBUG_elog_output ,"%d:\t unknown NODE!" ,a );
1425-
14261417}
14271418}
14281419#endif /* DEBUG */
@@ -1558,14 +1549,12 @@ seq_search(char *name, char **array, int type, int max, int *len)
15581549
15591550for (last = 0 ,a = array ;* a != NULL ;a ++ )
15601551{
1561-
15621552/* comperate first chars */
15631553if (* name != * * a )
15641554continue ;
15651555
15661556for (i = 1 ,p = * a + 1 ,n = name + 1 ;;n ++ ,p ++ ,i ++ )
15671557{
1568-
15691558/* search fragment (max) only */
15701559if (max && i == max )
15711560{
@@ -2703,7 +2692,6 @@ DCH_cache_getnew(char *str)
27032692 */
27042693if (n_DCHCache > DCH_CACHE_FIELDS )
27052694{
2706-
27072695DCHCacheEntry * old = DCHCache + 0 ;
27082696
27092697#ifdef DEBUG_TO_FROM_CHAR
@@ -3226,7 +3214,6 @@ do_to_timestamp(text *date_txt, text *fmt,
32263214
32273215if ((ent = DCH_cache_search (fmt_str ))== NULL )
32283216{
3229-
32303217ent = DCH_cache_getnew (fmt_str );
32313218
32323219/*
@@ -3475,7 +3462,6 @@ NUM_cache_getnew(char *str)
34753462 */
34763463if (n_NUMCache > NUM_CACHE_FIELDS )
34773464{
3478-
34793465NUMCacheEntry * old = NUMCache + 0 ;
34803466
34813467#ifdef DEBUG_TO_FROM_CHAR
@@ -3503,7 +3489,6 @@ NUM_cache_getnew(char *str)
35033489old -> age = (++ NUMCounter );
35043490
35053491ent = old ;
3506-
35073492}
35083493else
35093494{
@@ -3598,7 +3583,6 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree)
35983583NULL ,NUM_index ,NUM_TYPE ,Num );
35993584
36003585(format + len )-> type = NODE_TYPE_END ;/* Paranoia? */
3601-
36023586}
36033587else
36043588{
@@ -3611,7 +3595,6 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree)
36113595
36123596if ((ent = NUM_cache_search (str ))== NULL )
36133597{
3614-
36153598ent = NUM_cache_getnew (str );
36163599
36173600/*
@@ -3622,7 +3605,6 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree)
36223605NULL ,NUM_index ,NUM_TYPE ,& ent -> Num );
36233606
36243607(ent -> format + len )-> type = NODE_TYPE_END ;/* Paranoia? */
3625-
36263608}
36273609
36283610format = ent -> format ;
@@ -3705,7 +3687,6 @@ NUM_prepare_locale(NUMProc *Np)
37053687{
37063688if (Np -> Num -> need_locale )
37073689{
3708-
37093690struct lconv * lconv ;
37103691
37113692/*
@@ -3829,7 +3810,6 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
38293810if (* Np -> number == ' ' && (id == NUM_0 || id == NUM_9 )&&
38303811(Np -> read_pre + Np -> read_post )== 0 )
38313812{
3832-
38333813#ifdef DEBUG_TO_FROM_CHAR
38343814elog (DEBUG_elog_output ,"Try read sign (%c), locale positive: %s, negative: %s" ,
38353815* Np -> inout_p ,Np -> L_positive_sign ,Np -> L_negative_sign );
@@ -3872,14 +3852,11 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
38723852if (* Np -> inout_p == '-' || (IS_BRACKET (Np -> Num )&&
38733853* Np -> inout_p == '<' ))
38743854{
3875-
38763855* Np -> number = '-' ;/* set - */
38773856Np -> inout_p ++ ;
3878-
38793857}
38803858else if (* Np -> inout_p == '+' )
38813859{
3882-
38833860* Np -> number = '+' ;/* set + */
38843861Np -> inout_p ++ ;
38853862}
@@ -3898,7 +3875,6 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
38983875 */
38993876if (isdigit ((unsignedchar )* Np -> inout_p ))
39003877{
3901-
39023878if (Np -> read_dec && Np -> read_post == Np -> Num -> post )
39033879return ;
39043880
@@ -3922,13 +3898,11 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
39223898}
39233899else if (IS_DECIMAL (Np -> Num )&& Np -> read_dec == FALSE)
39243900{
3925-
39263901#ifdef DEBUG_TO_FROM_CHAR
39273902elog (DEBUG_elog_output ,"Try read decimal point (%c)" ,* Np -> inout_p );
39283903#endif
39293904if (* Np -> inout_p == '.' )
39303905{
3931-
39323906* Np -> number_p = '.' ;
39333907Np -> number_p ++ ;
39343908Np -> read_dec = TRUE;
@@ -4123,7 +4097,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
41234097* Np -> inout_p = ' ' ;/* Write ' ' */
41244098++ Np -> inout_p ;
41254099}
4126-
41274100}
41284101else if (IS_ZERO (Np -> Num )&&
41294102Np -> num_curr < Np -> num_pre &&
@@ -4135,7 +4108,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
41354108* Np -> inout_p = '0' ;/* Write '0' */
41364109++ Np -> inout_p ;
41374110Np -> num_in = TRUE;
4138-
41394111}
41404112else
41414113{
@@ -4144,7 +4116,6 @@ NUM_numpart_to_char(NUMProc *Np, int id)
41444116 */
41454117if (* Np -> number_p == '.' )
41464118{
4147-
41484119if (!Np -> last_relevant || * Np -> last_relevant != '.' )
41494120{
41504121strcpy (Np -> inout_p ,Np -> decimal );/* Write DEC/D */
@@ -4157,11 +4128,9 @@ NUM_numpart_to_char(NUMProc *Np, int id)
41574128else if (IS_FILLMODE (Np -> Num )&&
41584129Np -> last_relevant && * Np -> last_relevant == '.' )
41594130{
4160-
41614131strcpy (Np -> inout_p ,Np -> decimal );/* Write DEC/D */
41624132Np -> inout_p += strlen (Np -> inout_p );
41634133}
4164-
41654134}
41664135else
41674136{
@@ -4408,7 +4377,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
44084377 */
44094378switch (n -> key -> id )
44104379{
4411-
44124380case NUM_9 :
44134381case NUM_0 :
44144382case NUM_DEC :
@@ -4467,7 +4435,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
44674435strcpy (Np -> inout_p ,Np -> L_thousands_sep );
44684436Np -> inout_p += strlen (Np -> inout_p )- 1 ;
44694437}
4470-
44714438}
44724439else
44734440{
@@ -4485,7 +4452,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
44854452{
44864453strcpy (Np -> inout_p ,Np -> L_currency_symbol );
44874454Np -> inout_p += strlen (Np -> inout_p )- 1 ;
4488-
44894455}
44904456else
44914457Np -> inout_p += strlen (Np -> L_currency_symbol )- 1 ;
@@ -4546,7 +4512,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
45464512continue ;
45474513else
45484514* Np -> inout_p = ' ' ;
4549-
45504515}
45514516else
45524517{
@@ -4564,7 +4529,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
45644529continue ;
45654530else
45664531* Np -> inout_p = ' ' ;
4567-
45684532}
45694533else
45704534{
@@ -4591,7 +4555,6 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
45914555continue ;
45924556break ;
45934557}
4594-
45954558}
45964559else
45974560{