static const KeySuffix *
suff_search(const char *str, const KeySuffix *suf, int type)
{
- const KeySuffix *s;
-
- for (s = suf; s->name != NULL; s++)
+ for (const KeySuffix *s = suf; s->name != NULL; s++)
{
if (s->type != type)
continue;
asc_tolower(const char *buff, size_t nbytes)
{
char *result;
- char *p;
if (!buff)
return NULL;
result = pnstrdup(buff, nbytes);
- for (p = result; *p; p++)
+ for (char *p = result; *p; p++)
*p = pg_ascii_tolower((unsigned char) *p);
return result;
asc_toupper(const char *buff, size_t nbytes)
{
char *result;
- char *p;
if (!buff)
return NULL;
result = pnstrdup(buff, nbytes);
- for (p = result; *p; p++)
+ for (char *p = result; *p; p++)
*p = pg_ascii_toupper((unsigned char) *p);
return result;
asc_initcap(const char *buff, size_t nbytes)
{
char *result;
- char *p;
int wasalnum = false;
if (!buff)
result = pnstrdup(buff, nbytes);
- for (p = result; *p; p++)
+ for (char *p = result; *p; p++)
{
char c;
static void
dump_index(const KeyWord *k, const int *index)
{
- int i,
- count = 0,
+ int count = 0,
free_i = 0;
elog(DEBUG_elog_output, "TO-FROM_CHAR: Dump KeyWord Index:");
- for (i = 0; i < KeyWord_INDEX_SIZE; i++)
+ for (int i = 0; i < KeyWord_INDEX_SIZE; i++)
{
if (index[i] != -1)
{
seq_search_ascii(const char *name, const char *const *array, int *len)
{
unsigned char firstc;
- const char *const *a;
*len = 0;
/* we handle first char specially to gain some speed */
firstc = pg_ascii_tolower((unsigned char) *name);
- for (a = array; *a != NULL; a++)
+ for (const char *const *a = array; *a != NULL; a++)
{
- const char *p;
- const char *n;
-
/* compare first chars */
if (pg_ascii_tolower((unsigned char) **a) != firstc)
continue;
/* compare rest of string */
- for (p = *a + 1, n = name + 1;; p++, n++)
+ for (const char *p = *a + 1, *n = name + 1;; p++, n++)
{
/* return success if we matched whole array entry */
if (*p == '\0')
static int
seq_search_localized(const char *name, char **array, int *len, Oid collid)
{
- char **a;
char *upper_name;
char *lower_name;
* The case-folding processing done below is fairly expensive, so before
* doing that, make a quick pass to see if there is an exact match.
*/
- for (a = array; *a != NULL; a++)
+ for (char **a = array; *a != NULL; a++)
{
int element_len = strlen(*a);
lower_name = str_tolower(upper_name, strlen(upper_name), collid);
pfree(upper_name);
- for (a = array; *a != NULL; a++)
+ for (char **a = array; *a != NULL; a++)
{
char *upper_element;
char *lower_element;
* any) to avoid including irrelevant data.
*/
char *copy = pstrdup(*src);
- char *c;
- for (c = copy; *c; c++)
+ for (char *c = copy; *c; c++)
{
if (scanner_isspace(*c))
{
static void
DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid collid)
{
- FormatNode *n;
char *s;
struct fmt_tm *tm = &in->tm;
int i;
cache_locale_time();
s = out;
- for (n = node; n->type != NODE_TYPE_END; n++)
+ for (FormatNode *n = node; n->type != NODE_TYPE_END; n++)
{
if (n->type != NODE_TYPE_ACTION)
{
static int
DCH_datetime_type(FormatNode *node)
{
- FormatNode *n;
int flags = 0;
- for (n = node; n->type != NODE_TYPE_END; n++)
+ for (FormatNode *n = node; n->type != NODE_TYPE_END; n++)
{
if (n->type != NODE_TYPE_ACTION)
continue;
{
int len,
num;
- char *p,
- *result,
+ char *result,
numstr[12];
result = (char *) palloc(MAX_ROMAN_LEN + 1);
len = snprintf(numstr, sizeof(numstr), "%d", number);
Assert(len > 0 && len <= 4);
- for (p = numstr; *p != '\0'; p++, --len)
+ for (char *p = numstr; *p != '\0'; p++, --len)
{
num = *p - ('0' + 1);
if (num < 0)