1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

formatting.c cleanup: Remove dashes in comments

This saves some vertical space and makes the comments style more
consistent with the rest of the code.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-10-28 19:20:02 +01:00
parent d5845aa8ad
commit 95924672d5

View File

@@ -1,4 +1,4 @@
/* ----------------------------------------------------------------------- /*-------------------------------------------------------------------------
* formatting.c * formatting.c
* *
* src/backend/utils/adt/formatting.c * src/backend/utils/adt/formatting.c
@@ -54,7 +54,7 @@
* than Oracle :-), * than Oracle :-),
* to_char('Hello', 'X X X X X') -> 'H e l l o' * to_char('Hello', 'X X X X X') -> 'H e l l o'
* *
* ----------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifdef DEBUG_TO_FROM_CHAR #ifdef DEBUG_TO_FROM_CHAR
@@ -92,32 +92,28 @@
#include "varatt.h" #include "varatt.h"
/* ---------- /*
* Routines flags * Routines flags
* ----------
*/ */
#define DCH_FLAG 0x1 /* DATE-TIME flag */ #define DCH_FLAG 0x1 /* DATE-TIME flag */
#define NUM_FLAG 0x2 /* NUMBER flag */ #define NUM_FLAG 0x2 /* NUMBER flag */
#define STD_FLAG 0x4 /* STANDARD flag */ #define STD_FLAG 0x4 /* STANDARD flag */
/* ---------- /*
* KeyWord Index (ascii from position 32 (' ') to 126 (~)) * KeyWord Index (ascii from position 32 (' ') to 126 (~))
* ----------
*/ */
#define KeyWord_INDEX_SIZE ('~' - ' ') #define KeyWord_INDEX_SIZE ('~' - ' ')
#define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1) #define KeyWord_INDEX_FILTER(_c) ((_c) <= ' ' || (_c) >= '~' ? 0 : 1)
/* ---------- /*
* Maximal length of one node * Maximal length of one node
* ----------
*/ */
#define DCH_MAX_ITEM_SIZ 12 /* max localized day name */ #define DCH_MAX_ITEM_SIZ 12 /* max localized day name */
#define NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */ #define NUM_MAX_ITEM_SIZ 8 /* roman number (RN has 15 chars) */
/* ---------- /*
* Format parser structs * Format parser structs
* ----------
*/ */
typedef struct typedef struct
{ {
@@ -127,9 +123,8 @@ typedef struct
type; /* prefix / postfix */ type; /* prefix / postfix */
} KeySuffix; } KeySuffix;
/* ---------- /*
* FromCharDateMode * FromCharDateMode
* ----------
* *
* This value is used to nominate one of several distinct (and mutually * This value is used to nominate one of several distinct (and mutually
* exclusive) date conventions that a keyword can belong to. * exclusive) date conventions that a keyword can belong to.
@@ -171,9 +166,8 @@ typedef struct
#define CLOCK_12_HOUR 1 #define CLOCK_12_HOUR 1
/* ---------- /*
* Full months * Full months
* ----------
*/ */
static const char *const months_full[] = { static const char *const months_full[] = {
"January", "February", "March", "April", "May", "June", "July", "January", "February", "March", "April", "May", "June", "July",
@@ -184,9 +178,9 @@ static const char *const days_short[] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
}; };
/* ---------- /*
* AD / BC * AD / BC
* ---------- *
* There is no 0 AD. Years go from 1 BC to 1 AD, so we make it * There is no 0 AD. Years go from 1 BC to 1 AD, so we make it
* positive and map year == -1 to year zero, and shift all negative * positive and map year == -1 to year zero, and shift all negative
* years up one. For interval years, we just return the year. * years up one. For interval years, we just return the year.
@@ -216,9 +210,8 @@ static const char *const days_short[] = {
static const char *const adbc_strings[] = {ad_STR, bc_STR, AD_STR, BC_STR, NULL}; static const char *const adbc_strings[] = {ad_STR, bc_STR, AD_STR, BC_STR, NULL};
static const char *const adbc_strings_long[] = {a_d_STR, b_c_STR, A_D_STR, B_C_STR, NULL}; static const char *const adbc_strings_long[] = {a_d_STR, b_c_STR, A_D_STR, B_C_STR, NULL};
/* ---------- /*
* AM / PM * AM / PM
* ----------
*/ */
#define A_M_STR "A.M." #define A_M_STR "A.M."
#define a_m_STR "a.m." #define a_m_STR "a.m."
@@ -243,11 +236,10 @@ static const char *const adbc_strings_long[] = {a_d_STR, b_c_STR, A_D_STR, B_C_S
static const char *const ampm_strings[] = {am_STR, pm_STR, AM_STR, PM_STR, NULL}; static const char *const ampm_strings[] = {am_STR, pm_STR, AM_STR, PM_STR, NULL};
static const char *const ampm_strings_long[] = {a_m_STR, p_m_STR, A_M_STR, P_M_STR, NULL}; static const char *const ampm_strings_long[] = {a_m_STR, p_m_STR, A_M_STR, P_M_STR, NULL};
/* ---------- /*
* Months in roman-numeral * Months in roman-numeral
* (Must be in reverse order for seq_search (in FROM_CHAR), because * (Must be in reverse order for seq_search (in FROM_CHAR), because
* 'VIII' must have higher precedence than 'V') * 'VIII' must have higher precedence than 'V')
* ----------
*/ */
static const char *const rm_months_upper[] = static const char *const rm_months_upper[] =
{"XII", "XI", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I", NULL}; {"XII", "XI", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I", NULL};
@@ -255,9 +247,8 @@ static const char *const rm_months_upper[] =
static const char *const rm_months_lower[] = static const char *const rm_months_lower[] =
{"xii", "xi", "x", "ix", "viii", "vii", "vi", "v", "iv", "iii", "ii", "i", NULL}; {"xii", "xi", "x", "ix", "viii", "vii", "vi", "v", "iv", "iii", "ii", "i", NULL};
/* ---------- /*
* Roman numerals * Roman numerals
* ----------
*/ */
static const char *const rm1[] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL}; static const char *const rm1[] = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", NULL};
static const char *const rm10[] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL}; static const char *const rm10[] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", NULL};
@@ -289,23 +280,20 @@ static const char *const rm100[] = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "D
*/ */
#define MAX_ROMAN_LEN 15 #define MAX_ROMAN_LEN 15
/* ---------- /*
* Ordinal postfixes * Ordinal postfixes
* ----------
*/ */
static const char *const numTH[] = {"ST", "ND", "RD", "TH", NULL}; static const char *const numTH[] = {"ST", "ND", "RD", "TH", NULL};
static const char *const numth[] = {"st", "nd", "rd", "th", NULL}; static const char *const numth[] = {"st", "nd", "rd", "th", NULL};
/* ---------- /*
* Flags & Options: * Flags & Options:
* ----------
*/ */
#define TH_UPPER 1 #define TH_UPPER 1
#define TH_LOWER 2 #define TH_LOWER 2
/* ---------- /*
* Number description struct * Number description struct
* ----------
*/ */
typedef struct typedef struct
{ {
@@ -320,9 +308,8 @@ typedef struct
need_locale; /* needs it locale */ need_locale; /* needs it locale */
} NUMDesc; } NUMDesc;
/* ---------- /*
* Flags for NUMBER version * Flags for NUMBER version
* ----------
*/ */
#define NUM_F_DECIMAL (1 << 1) #define NUM_F_DECIMAL (1 << 1)
#define NUM_F_LDECIMAL (1 << 2) #define NUM_F_LDECIMAL (1 << 2)
@@ -343,9 +330,8 @@ typedef struct
#define NUM_LSIGN_POST 1 #define NUM_LSIGN_POST 1
#define NUM_LSIGN_NONE 0 #define NUM_LSIGN_NONE 0
/* ---------- /*
* Tests * Tests
* ----------
*/ */
#define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL) #define IS_DECIMAL(_f) ((_f)->flag & NUM_F_DECIMAL)
#define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL) #define IS_LDECIMAL(_f) ((_f)->flag & NUM_F_LDECIMAL)
@@ -360,7 +346,7 @@ typedef struct
#define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI) #define IS_MULTI(_f) ((_f)->flag & NUM_F_MULTI)
#define IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE) #define IS_EEEE(_f) ((_f)->flag & NUM_F_EEEE)
/* ---------- /*
* Format picture cache * Format picture cache
* *
* We will cache datetime format pictures up to DCH_CACHE_SIZE bytes long; * We will cache datetime format pictures up to DCH_CACHE_SIZE bytes long;
@@ -376,7 +362,6 @@ typedef struct
* *
* The max number of entries in each cache is DCH_CACHE_ENTRIES * The max number of entries in each cache is DCH_CACHE_ENTRIES
* resp. NUM_CACHE_ENTRIES. * resp. NUM_CACHE_ENTRIES.
* ----------
*/ */
#define DCH_CACHE_OVERHEAD \ #define DCH_CACHE_OVERHEAD \
MAXALIGN(sizeof(bool) + sizeof(int)) MAXALIGN(sizeof(bool) + sizeof(int))
@@ -419,9 +404,8 @@ static NUMCacheEntry *NUMCache[NUM_CACHE_ENTRIES];
static int n_NUMCache = 0; /* current number of entries */ static int n_NUMCache = 0; /* current number of entries */
static int NUMCounter = 0; /* aging-event counter */ static int NUMCounter = 0; /* aging-event counter */
/* ---------- /*
* For char->date/time conversion * For char->date/time conversion
* ----------
*/ */
typedef struct typedef struct
{ {
@@ -463,9 +447,8 @@ struct fmt_tz /* do_to_timestamp's timezone info output */
int gmtoffset; /* GMT offset in seconds */ int gmtoffset; /* GMT offset in seconds */
}; };
/* ---------- /*
* Debug * Debug
* ----------
*/ */
#ifdef DEBUG_TO_FROM_CHAR #ifdef DEBUG_TO_FROM_CHAR
#define DEBUG_TMFC(_X) \ #define DEBUG_TMFC(_X) \
@@ -484,13 +467,12 @@ struct fmt_tz /* do_to_timestamp's timezone info output */
#define DEBUG_TM(_X) #define DEBUG_TM(_X)
#endif #endif
/* ---------- /*
* Datetime to char conversion * Datetime to char conversion
* *
* To support intervals as well as timestamps, we use a custom "tm" struct * To support intervals as well as timestamps, we use a custom "tm" struct
* that is almost like struct pg_tm, but has a 64-bit tm_hour field. * that is almost like struct pg_tm, but has a 64-bit tm_hour field.
* We omit the tm_isdst and tm_zone fields, which are not used here. * We omit the tm_isdst and tm_zone fields, which are not used here.
* ----------
*/ */
struct fmt_tm struct fmt_tm
{ {
@@ -561,9 +543,8 @@ do { \
* KeyWord definitions * KeyWord definitions
*****************************************************************************/ *****************************************************************************/
/* ---------- /*
* Suffixes (FormatNode.suffix is an OR of these codes) * Suffixes (FormatNode.suffix is an OR of these codes)
* ----------
*/ */
#define DCH_S_FM 0x01 #define DCH_S_FM 0x01
#define DCH_S_TH 0x02 #define DCH_S_TH 0x02
@@ -571,9 +552,8 @@ do { \
#define DCH_S_SP 0x08 #define DCH_S_SP 0x08
#define DCH_S_TM 0x10 #define DCH_S_TM 0x10
/* ---------- /*
* Suffix tests * Suffix tests
* ----------
*/ */
#define S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0) #define S_THth(_s) ((((_s) & DCH_S_TH) || ((_s) & DCH_S_th)) ? 1 : 0)
#define S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0) #define S_TH(_s) (((_s) & DCH_S_TH) ? 1 : 0)
@@ -585,9 +565,8 @@ do { \
#define S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0) #define S_SP(_s) (((_s) & DCH_S_SP) ? 1 : 0)
#define S_TM(_s) (((_s) & DCH_S_TM) ? 1 : 0) #define S_TM(_s) (((_s) & DCH_S_TM) ? 1 : 0)
/* ---------- /*
* Suffixes definition for DATE-TIME TO/FROM CHAR * Suffixes definition for DATE-TIME TO/FROM CHAR
* ----------
*/ */
#define TM_SUFFIX_LEN 2 #define TM_SUFFIX_LEN 2
@@ -604,7 +583,7 @@ static const KeySuffix DCH_suff[] = {
}; };
/* ---------- /*
* Format-pictures (KeyWord). * Format-pictures (KeyWord).
* *
* The KeyWord field; alphabetic sorted, *BUT* strings alike is sorted * The KeyWord field; alphabetic sorted, *BUT* strings alike is sorted
@@ -628,8 +607,6 @@ static const KeySuffix DCH_suff[] = {
* 1) see in index to index['M' - 32], * 1) see in index to index['M' - 32],
* 2) take keywords position (enum DCH_MI) from index * 2) take keywords position (enum DCH_MI) from index
* 3) run sequential search in keywords[] from this position * 3) run sequential search in keywords[] from this position
*
* ----------
*/ */
typedef enum typedef enum
@@ -794,9 +771,8 @@ typedef enum
_NUM_last_ _NUM_last_
} NUM_poz; } NUM_poz;
/* ---------- /*
* KeyWords for DATE-TIME version * KeyWords for DATE-TIME version
* ----------
*/ */
static const KeyWord DCH_keywords[] = { static const KeyWord DCH_keywords[] = {
/* name, len, id, is_digit, date_mode */ /* name, len, id, is_digit, date_mode */
@@ -917,11 +893,10 @@ static const KeyWord DCH_keywords[] = {
{NULL, 0, 0, 0, 0} {NULL, 0, 0, 0, 0}
}; };
/* ---------- /*
* KeyWords for NUMBER version * KeyWords for NUMBER version
* *
* The is_digit and date_mode fields are not relevant here. * The is_digit and date_mode fields are not relevant here.
* ----------
*/ */
static const KeyWord NUM_keywords[] = { static const KeyWord NUM_keywords[] = {
/* name, len, id is in Index */ /* name, len, id is in Index */
@@ -967,9 +942,8 @@ static const KeyWord NUM_keywords[] = {
}; };
/* ---------- /*
* KeyWords index for DATE-TIME version * KeyWords index for DATE-TIME version
* ----------
*/ */
static const int DCH_index[KeyWord_INDEX_SIZE] = { static const int DCH_index[KeyWord_INDEX_SIZE] = {
/* /*
@@ -991,9 +965,8 @@ static const int DCH_index[KeyWord_INDEX_SIZE] = {
/*---- chars over 126 are skipped ----*/ /*---- chars over 126 are skipped ----*/
}; };
/* ---------- /*
* KeyWords index for NUMBER version * KeyWords index for NUMBER version
* ----------
*/ */
static const int NUM_index[KeyWord_INDEX_SIZE] = { static const int NUM_index[KeyWord_INDEX_SIZE] = {
/* /*
@@ -1015,9 +988,8 @@ static const int NUM_index[KeyWord_INDEX_SIZE] = {
/*---- chars over 126 are skipped ----*/ /*---- chars over 126 are skipped ----*/
}; };
/* ---------- /*
* Number processor struct * Number processor struct
* ----------
*/ */
typedef struct NUMProc typedef struct NUMProc
{ {
@@ -1062,9 +1034,8 @@ typedef struct NUMProc
#define AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s))) #define AMOUNT_TEST(s) (Np->inout_p <= Np->inout + (input_len - (s)))
/* ---------- /*
* Functions * Functions
* ----------
*/ */
static const KeyWord *index_seq_search(const char *str, const KeyWord *kw, static const KeyWord *index_seq_search(const char *str, const KeyWord *kw,
const int *index); const int *index);
@@ -1125,11 +1096,10 @@ static NUMCacheEntry *NUM_cache_search(const char *str);
static NUMCacheEntry *NUM_cache_fetch(const char *str); static NUMCacheEntry *NUM_cache_fetch(const char *str);
/* ---------- /*
* Fast sequential search, use index for data selection which * Fast sequential search, use index for data selection which
* go to seq. cycle (it is very fast for unwanted strings) * go to seq. cycle (it is very fast for unwanted strings)
* (can't be used binary search in format parsing) * (can't be used binary search in format parsing)
* ----------
*/ */
static const KeyWord * static const KeyWord *
index_seq_search(const char *str, const KeyWord *kw, const int *index) index_seq_search(const char *str, const KeyWord *kw, const int *index)
@@ -1181,9 +1151,8 @@ is_separator_char(const char *str)
!(*str >= '0' && *str <= '9')); !(*str >= '0' && *str <= '9'));
} }
/* ---------- /*
* Prepare NUMDesc (number description struct) via FormatNode struct * Prepare NUMDesc (number description struct) via FormatNode struct
* ----------
*/ */
static void static void
NUMDesc_prepare(NUMDesc *num, FormatNode *n) NUMDesc_prepare(NUMDesc *num, FormatNode *n)
@@ -1364,12 +1333,11 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
errdetail("\"RN\" may only be used together with \"FM\"."))); errdetail("\"RN\" may only be used together with \"FM\".")));
} }
/* ---------- /*
* Format parser, search small keywords and keyword's suffixes, and make * Format parser, search small keywords and keyword's suffixes, and make
* format-node tree. * format-node tree.
* *
* for DATE-TIME & NUMBER version * for DATE-TIME & NUMBER version
* ----------
*/ */
static void static void
parse_format(FormatNode *node, const char *str, const KeyWord *kw, parse_format(FormatNode *node, const char *str, const KeyWord *kw,
@@ -1514,9 +1482,8 @@ parse_format(FormatNode *node, const char *str, const KeyWord *kw,
n->suffix = 0; n->suffix = 0;
} }
/* ---------- /*
* DEBUG: Dump the FormatNode Tree (debug) * DEBUG: Dump the FormatNode Tree (debug)
* ----------
*/ */
#ifdef DEBUG_TO_FROM_CHAR #ifdef DEBUG_TO_FROM_CHAR
@@ -1554,10 +1521,9 @@ dump_node(FormatNode *node, int max)
* Private utils * Private utils
*****************************************************************************/ *****************************************************************************/
/* ---------- /*
* Return ST/ND/RD/TH for simple (1..9) numbers * Return ST/ND/RD/TH for simple (1..9) numbers
* type --> 0 upper, 1 lower * type --> 0 upper, 1 lower
* ----------
*/ */
static const char * static const char *
get_th(char *num, int type) get_th(char *num, int type)
@@ -1601,10 +1567,9 @@ get_th(char *num, int type)
} }
} }
/* ---------- /*
* Convert string-number to ordinal string-number * Convert string-number to ordinal string-number
* type --> 0 upper, 1 lower * type --> 0 upper, 1 lower
* ----------
*/ */
static char * static char *
str_numth(char *dest, char *num, int type) str_numth(char *dest, char *num, int type)
@@ -2006,11 +1971,10 @@ asc_toupper_z(const char *buff)
/* asc_initcap_z is not currently needed */ /* asc_initcap_z is not currently needed */
/* ---------- /*
* Skip TM / th in FROM_CHAR * Skip TM / th in FROM_CHAR
* *
* If S_THth is on, skip two chars, assuming there are two available * If S_THth is on, skip two chars, assuming there are two available
* ----------
*/ */
#define SKIP_THth(ptr, _suf) \ #define SKIP_THth(ptr, _suf) \
do { \ do { \
@@ -2023,10 +1987,9 @@ asc_toupper_z(const char *buff)
#ifdef DEBUG_TO_FROM_CHAR #ifdef DEBUG_TO_FROM_CHAR
/* ----------- /*
* DEBUG: Call for debug and for index checking; (Show ASCII char * DEBUG: Call for debug and for index checking; (Show ASCII char
* and defined keyword for each used position * and defined keyword for each used position
* ----------
*/ */
static void static void
dump_index(const KeyWord *k, const int *index) dump_index(const KeyWord *k, const int *index)
@@ -2055,9 +2018,8 @@ dump_index(const KeyWord *k, const int *index)
} }
#endif /* DEBUG */ #endif /* DEBUG */
/* ---------- /*
* Return true if next format picture is not digit value * Return true if next format picture is not digit value
* ----------
*/ */
static bool static bool
is_next_separator(FormatNode *n) is_next_separator(FormatNode *n)
@@ -2498,10 +2460,9 @@ from_char_seq_search(int *dest, const char **src, const char *const *array,
return true; return true;
} }
/* ---------- /*
* Process a TmToChar struct as denoted by a list of FormatNodes. * Process a TmToChar struct as denoted by a list of FormatNodes.
* The formatted data is written to the string pointed to by 'out'. * The formatted data is written to the string pointed to by 'out'.
* ----------
*/ */
static void static void
DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid collid) DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid collid)
@@ -3992,9 +3953,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval, Oid collid)
* Public routines * Public routines
***************************************************************************/ ***************************************************************************/
/* ------------------- /*
* TIMESTAMP to_char() * TIMESTAMP to_char()
* -------------------
*/ */
Datum Datum
timestamp_to_char(PG_FUNCTION_ARGS) timestamp_to_char(PG_FUNCTION_ARGS)
@@ -4068,9 +4028,8 @@ timestamptz_to_char(PG_FUNCTION_ARGS)
} }
/* ------------------- /*
* INTERVAL to_char() * INTERVAL to_char()
* -------------------
*/ */
Datum Datum
interval_to_char(PG_FUNCTION_ARGS) interval_to_char(PG_FUNCTION_ARGS)
@@ -4107,12 +4066,11 @@ interval_to_char(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(res); PG_RETURN_TEXT_P(res);
} }
/* --------------------- /*
* TO_TIMESTAMP() * TO_TIMESTAMP()
* *
* Make Timestamp from date_str which is formatted at argument 'fmt' * Make Timestamp from date_str which is formatted at argument 'fmt'
* ( to_timestamp is reverse to_char() ) * ( to_timestamp is reverse to_char() )
* ---------------------
*/ */
Datum Datum
to_timestamp(PG_FUNCTION_ARGS) to_timestamp(PG_FUNCTION_ARGS)
@@ -4148,10 +4106,9 @@ to_timestamp(PG_FUNCTION_ARGS)
PG_RETURN_TIMESTAMP(result); PG_RETURN_TIMESTAMP(result);
} }
/* ---------- /*
* TO_DATE * TO_DATE
* Make Date from date_str which is formatted at argument 'fmt' * Make Date from date_str which is formatted at argument 'fmt'
* ----------
*/ */
Datum Datum
to_date(PG_FUNCTION_ARGS) to_date(PG_FUNCTION_ARGS)
@@ -4998,9 +4955,8 @@ NUM_cache_fetch(const char *str)
return ent; return ent;
} }
/* ---------- /*
* Cache routine for NUM to_char version * Cache routine for NUM to_char version
* ----------
*/ */
static FormatNode * static FormatNode *
NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree) NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree)
@@ -5271,9 +5227,8 @@ roman_to_int(NUMProc *Np, int input_len)
} }
/* ---------- /*
* Locale * Locale
* ----------
*/ */
static void static void
NUM_prepare_locale(NUMProc *Np) NUM_prepare_locale(NUMProc *Np)
@@ -5349,13 +5304,12 @@ NUM_prepare_locale(NUMProc *Np)
} }
} }
/* ---------- /*
* Return pointer of last relevant number after decimal point * Return pointer of last relevant number after decimal point
* 12.0500 --> last relevant is '5' * 12.0500 --> last relevant is '5'
* 12.0000 --> last relevant is '.' * 12.0000 --> last relevant is '.'
* If there is no decimal point, return NULL (which will result in same * If there is no decimal point, return NULL (which will result in same
* behavior as if FM hadn't been specified). * behavior as if FM hadn't been specified).
* ----------
*/ */
static char * static char *
get_last_relevant_decnum(char *num) get_last_relevant_decnum(char *num)
@@ -5381,9 +5335,8 @@ get_last_relevant_decnum(char *num)
return result; return result;
} }
/* ---------- /*
* Number extraction for TO_NUMBER() * Number extraction for TO_NUMBER()
* ----------
*/ */
static void static void
NUM_numpart_from_char(NUMProc *Np, int id, int input_len) NUM_numpart_from_char(NUMProc *Np, int id, int input_len)
@@ -5596,9 +5549,8 @@ NUM_numpart_from_char(NUMProc *Np, int id, int input_len)
*(_n)->number == '0' && \ *(_n)->number == '0' && \
(_n)->Num->post != 0) (_n)->Num->post != 0)
/* ---------- /*
* Add digit or sign to number-string * Add digit or sign to number-string
* ----------
*/ */
static void static void
NUM_numpart_to_char(NUMProc *Np, int id) NUM_numpart_to_char(NUMProc *Np, int id)
@@ -6267,10 +6219,9 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout,
} }
} }
/* ---------- /*
* MACRO: Start part of NUM - for all NUM's to_char variants * MACRO: Start part of NUM - for all NUM's to_char variants
* (sorry, but I hate copy same code - macro is better..) * (sorry, but I hate copy same code - macro is better..)
* ----------
*/ */
#define NUM_TOCHAR_prepare \ #define NUM_TOCHAR_prepare \
do { \ do { \
@@ -6281,9 +6232,8 @@ do { \
format = NUM_cache(len, &Num, fmt, &shouldFree); \ format = NUM_cache(len, &Num, fmt, &shouldFree); \
} while (0) } while (0)
/* ---------- /*
* MACRO: Finish part of NUM * MACRO: Finish part of NUM
* ----------
*/ */
#define NUM_TOCHAR_finish \ #define NUM_TOCHAR_finish \
do { \ do { \
@@ -6303,9 +6253,8 @@ do { \
SET_VARSIZE(result, len + VARHDRSZ); \ SET_VARSIZE(result, len + VARHDRSZ); \
} while (0) } while (0)
/* ------------------- /*
* NUMERIC to_number() (convert string to numeric) * NUMERIC to_number() (convert string to numeric)
* -------------------
*/ */
Datum Datum
numeric_to_number(PG_FUNCTION_ARGS) numeric_to_number(PG_FUNCTION_ARGS)
@@ -6362,9 +6311,8 @@ numeric_to_number(PG_FUNCTION_ARGS)
return result; return result;
} }
/* ------------------ /*
* NUMERIC to_char() * NUMERIC to_char()
* ------------------
*/ */
Datum Datum
numeric_to_char(PG_FUNCTION_ARGS) numeric_to_char(PG_FUNCTION_ARGS)
@@ -6490,9 +6438,8 @@ numeric_to_char(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(result); PG_RETURN_TEXT_P(result);
} }
/* --------------- /*
* INT4 to_char() * INT4 to_char()
* ---------------
*/ */
Datum Datum
int4_to_char(PG_FUNCTION_ARGS) int4_to_char(PG_FUNCTION_ARGS)
@@ -6584,9 +6531,8 @@ int4_to_char(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(result); PG_RETURN_TEXT_P(result);
} }
/* --------------- /*
* INT8 to_char() * INT8 to_char()
* ---------------
*/ */
Datum Datum
int8_to_char(PG_FUNCTION_ARGS) int8_to_char(PG_FUNCTION_ARGS)
@@ -6696,9 +6642,8 @@ int8_to_char(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(result); PG_RETURN_TEXT_P(result);
} }
/* ----------------- /*
* FLOAT4 to_char() * FLOAT4 to_char()
* -----------------
*/ */
Datum Datum
float4_to_char(PG_FUNCTION_ARGS) float4_to_char(PG_FUNCTION_ARGS)
@@ -6809,9 +6754,8 @@ float4_to_char(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(result); PG_RETURN_TEXT_P(result);
} }
/* ----------------- /*
* FLOAT8 to_char() * FLOAT8 to_char()
* -----------------
*/ */
Datum Datum
float8_to_char(PG_FUNCTION_ARGS) float8_to_char(PG_FUNCTION_ARGS)