mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4d
wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
@ -145,7 +145,7 @@ pg_reg_getcolor(struct colormap *cm, chr c)
|
||||
low = middle + 1;
|
||||
else
|
||||
{
|
||||
rownum = cmr->rownum; /* found a match */
|
||||
rownum = cmr->rownum; /* found a match */
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1040,8 +1040,7 @@ static void
|
||||
colorcomplement(struct nfa *nfa,
|
||||
struct colormap *cm,
|
||||
int type,
|
||||
struct state *of, /* complements of this guy's PLAIN
|
||||
* outarcs */
|
||||
struct state *of, /* complements of this guy's PLAIN outarcs */
|
||||
struct state *from,
|
||||
struct state *to)
|
||||
{
|
||||
@ -1138,4 +1137,4 @@ dumpchr(chr c,
|
||||
fprintf(f, "\\u%04lx", (long) c);
|
||||
}
|
||||
|
||||
#endif /* REG_DEBUG */
|
||||
#endif /* REG_DEBUG */
|
||||
|
@ -586,10 +586,10 @@ next(struct vars *v)
|
||||
FAILW(REG_BADRPT);
|
||||
switch (*v->now++)
|
||||
{
|
||||
case CHR(':'): /* non-capturing paren */
|
||||
case CHR(':'): /* non-capturing paren */
|
||||
RETV('(', 0);
|
||||
break;
|
||||
case CHR('#'): /* comment */
|
||||
case CHR('#'): /* comment */
|
||||
while (!ATEOS() && *v->now != CHR(')'))
|
||||
v->now++;
|
||||
if (!ATEOS())
|
||||
@ -597,11 +597,11 @@ next(struct vars *v)
|
||||
assert(v->nexttype == v->lasttype);
|
||||
return next(v);
|
||||
break;
|
||||
case CHR('='): /* positive lookahead */
|
||||
case CHR('='): /* positive lookahead */
|
||||
NOTE(REG_ULOOKAROUND);
|
||||
RETV(LACON, LATYPE_AHEAD_POS);
|
||||
break;
|
||||
case CHR('!'): /* negative lookahead */
|
||||
case CHR('!'): /* negative lookahead */
|
||||
NOTE(REG_ULOOKAROUND);
|
||||
RETV(LACON, LATYPE_AHEAD_NEG);
|
||||
break;
|
||||
@ -610,11 +610,11 @@ next(struct vars *v)
|
||||
FAILW(REG_BADRPT);
|
||||
switch (*v->now++)
|
||||
{
|
||||
case CHR('='): /* positive lookbehind */
|
||||
case CHR('='): /* positive lookbehind */
|
||||
NOTE(REG_ULOOKAROUND);
|
||||
RETV(LACON, LATYPE_BEHIND_POS);
|
||||
break;
|
||||
case CHR('!'): /* negative lookbehind */
|
||||
case CHR('!'): /* negative lookbehind */
|
||||
NOTE(REG_ULOOKAROUND);
|
||||
RETV(LACON, LATYPE_BEHIND_NEG);
|
||||
break;
|
||||
@ -836,7 +836,7 @@ lexescape(struct vars *v)
|
||||
break;
|
||||
case CHR('x'):
|
||||
NOTE(REG_UUNPORT);
|
||||
c = lexdigits(v, 16, 1, 255); /* REs >255 long outside spec */
|
||||
c = lexdigits(v, 16, 1, 255); /* REs >255 long outside spec */
|
||||
if (ISERR() || !CHR_IS_IN_RANGE(c))
|
||||
FAILW(REG_EESCAPE);
|
||||
RETV(PLAIN, c);
|
||||
@ -863,7 +863,7 @@ lexescape(struct vars *v)
|
||||
case CHR('9'):
|
||||
save = v->now;
|
||||
v->now--; /* put first digit back */
|
||||
c = lexdigits(v, 10, 1, 255); /* REs >255 long outside spec */
|
||||
c = lexdigits(v, 10, 1, 255); /* REs >255 long outside spec */
|
||||
if (ISERR())
|
||||
FAILW(REG_EESCAPE);
|
||||
/* ugly heuristic (first test is "exactly 1 digit?") */
|
||||
|
@ -754,7 +754,7 @@ cmp(const chr *x, const chr *y, /* strings to compare */
|
||||
* stop at embedded NULs!
|
||||
*/
|
||||
static int /* 0 for equal, nonzero for unequal */
|
||||
casecmp(const chr *x, const chr *y, /* strings to compare */
|
||||
casecmp(const chr *x, const chr *y, /* strings to compare */
|
||||
size_t len) /* exact length of comparison */
|
||||
{
|
||||
for (; len > 0; len--, x++, y++)
|
||||
|
@ -67,7 +67,7 @@ newnfa(struct vars *v,
|
||||
nfa->eos[0] = nfa->eos[1] = COLORLESS;
|
||||
nfa->parent = parent; /* Precedes newfstate so parent is valid. */
|
||||
nfa->post = newfstate(nfa, '@'); /* number 0 */
|
||||
nfa->pre = newfstate(nfa, '>'); /* number 1 */
|
||||
nfa->pre = newfstate(nfa, '>'); /* number 1 */
|
||||
|
||||
nfa->init = newstate(nfa); /* may become invalid later */
|
||||
nfa->final = newstate(nfa);
|
||||
@ -1253,7 +1253,7 @@ deltraverse(struct nfa *nfa,
|
||||
}
|
||||
|
||||
assert(s->no != FREESTATE); /* we're still here */
|
||||
assert(s == leftend || s->nins != 0); /* and still reachable */
|
||||
assert(s == leftend || s->nins != 0); /* and still reachable */
|
||||
assert(s->nouts == 0); /* but have no outarcs */
|
||||
|
||||
s->tmp = NULL; /* we're done here */
|
||||
@ -1751,7 +1751,7 @@ push(struct nfa *nfa,
|
||||
if (NISERR())
|
||||
return 0;
|
||||
copyouts(nfa, to, s); /* duplicate outarcs */
|
||||
cparc(nfa, con, from, s); /* move constraint arc */
|
||||
cparc(nfa, con, from, s); /* move constraint arc */
|
||||
freearc(nfa, con);
|
||||
if (NISERR())
|
||||
return 0;
|
||||
@ -1833,7 +1833,7 @@ combine(struct arc *con,
|
||||
case CA('$', '$'):
|
||||
case CA(AHEAD, AHEAD):
|
||||
case CA(BEHIND, BEHIND):
|
||||
if (con->co == a->co) /* true duplication */
|
||||
if (con->co == a->co) /* true duplication */
|
||||
return SATISFIED;
|
||||
return INCOMPATIBLE;
|
||||
break;
|
||||
@ -2763,8 +2763,8 @@ cleanup(struct nfa *nfa)
|
||||
static void
|
||||
markreachable(struct nfa *nfa,
|
||||
struct state *s,
|
||||
struct state *okay, /* consider only states with this mark */
|
||||
struct state *mark) /* the value to mark with */
|
||||
struct state *okay, /* consider only states with this mark */
|
||||
struct state *mark) /* the value to mark with */
|
||||
{
|
||||
struct arc *a;
|
||||
|
||||
@ -3114,7 +3114,7 @@ dumparc(struct arc *a,
|
||||
if (aa == NULL)
|
||||
fprintf(f, "?!?"); /* missing from in-chain */
|
||||
}
|
||||
#endif /* REG_DEBUG */
|
||||
#endif /* REG_DEBUG */
|
||||
|
||||
/*
|
||||
* dumpcnfa - dump a compacted NFA in human-readable form
|
||||
@ -3178,4 +3178,4 @@ dumpcstate(int st,
|
||||
fflush(f);
|
||||
}
|
||||
|
||||
#endif /* REG_DEBUG */
|
||||
#endif /* REG_DEBUG */
|
||||
|
@ -277,7 +277,7 @@ pg_set_regex_collation(Oid collation)
|
||||
pg_regex_strategy = PG_REGEX_LOCALE_WIDE;
|
||||
}
|
||||
else
|
||||
#endif /* USE_WIDE_UPPER_LOWER */
|
||||
#endif /* USE_WIDE_UPPER_LOWER */
|
||||
{
|
||||
if (pg_regex_locale)
|
||||
pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L;
|
||||
|
@ -257,7 +257,7 @@ struct vars
|
||||
/* parsing macros; most know that `v' is the struct vars pointer */
|
||||
#define NEXT() (next(v)) /* advance by one token */
|
||||
#define SEE(t) (v->nexttype == (t)) /* is next token this? */
|
||||
#define EAT(t) (SEE(t) && next(v)) /* if next is this, swallow it */
|
||||
#define EAT(t) (SEE(t) && next(v)) /* if next is this, swallow it */
|
||||
#define VISERR(vv) ((vv)->err != 0) /* have we seen an error yet? */
|
||||
#define ISERR() VISERR(v)
|
||||
#define VERR(vv,e) ((vv)->nexttype = EOS, \
|
||||
@ -942,7 +942,7 @@ parseqatom(struct vars *v,
|
||||
assert((size_t) subno < v->nsubs);
|
||||
}
|
||||
else
|
||||
atomtype = PLAIN; /* something that's not '(' */
|
||||
atomtype = PLAIN; /* something that's not '(' */
|
||||
NEXT();
|
||||
/* need new endpoints because tree will contain pointers */
|
||||
s = newstate(v->nfa);
|
||||
@ -1124,7 +1124,7 @@ parseqatom(struct vars *v,
|
||||
/* if it's a backref, now is the time to replicate the subNFA */
|
||||
if (atomtype == BACKREF)
|
||||
{
|
||||
assert(atom->begin->nouts == 1); /* just the EMPTY */
|
||||
assert(atom->begin->nouts == 1); /* just the EMPTY */
|
||||
delsub(v->nfa, atom->begin, atom->end);
|
||||
assert(v->subs[subno] != NULL);
|
||||
|
||||
@ -1145,7 +1145,7 @@ parseqatom(struct vars *v,
|
||||
if (atomtype == BACKREF)
|
||||
{
|
||||
/* special case: backrefs have internal quantifiers */
|
||||
EMPTYARC(s, atom->begin); /* empty prefix */
|
||||
EMPTYARC(s, atom->begin); /* empty prefix */
|
||||
/* just stuff everything into atom */
|
||||
repeat(v, atom->begin, atom->end, m, n);
|
||||
atom->min = (short) m;
|
||||
@ -1157,7 +1157,7 @@ parseqatom(struct vars *v,
|
||||
else if (m == 1 && n == 1)
|
||||
{
|
||||
/* no/vacuous quantifier: done */
|
||||
EMPTYARC(s, atom->begin); /* empty prefix */
|
||||
EMPTYARC(s, atom->begin); /* empty prefix */
|
||||
/* rest of branch can be strung starting from atom->end */
|
||||
s2 = atom->end;
|
||||
}
|
||||
@ -1175,7 +1175,7 @@ parseqatom(struct vars *v,
|
||||
assert(m >= 1 && m != DUPINF && n >= 1);
|
||||
repeat(v, s, atom->begin, m - 1, (n == DUPINF) ? n : n - 1);
|
||||
f = COMBINE(qprefer, atom->flags);
|
||||
t = subre(v, '.', f, s, atom->end); /* prefix and atom */
|
||||
t = subre(v, '.', f, s, atom->end); /* prefix and atom */
|
||||
NOERR();
|
||||
t->left = subre(v, '=', PREF(f), s, atom->begin);
|
||||
NOERR();
|
||||
@ -1618,7 +1618,7 @@ wordchrs(struct vars *v)
|
||||
*/
|
||||
static void
|
||||
processlacon(struct vars *v,
|
||||
struct state *begin, /* start of parsed LACON sub-re */
|
||||
struct state *begin, /* start of parsed LACON sub-re */
|
||||
struct state *end, /* end of parsed LACON sub-re */
|
||||
int latype,
|
||||
struct state *lp, /* left state to hang it on */
|
||||
@ -2180,7 +2180,7 @@ stid(struct subre *t,
|
||||
sprintf(buf, "%p", t);
|
||||
return buf;
|
||||
}
|
||||
#endif /* REG_DEBUG */
|
||||
#endif /* REG_DEBUG */
|
||||
|
||||
|
||||
#include "regc_lex.c"
|
||||
|
@ -303,7 +303,7 @@ static int
|
||||
matchuntil(struct vars *v,
|
||||
struct dfa *d,
|
||||
chr *probe, /* we want to know if a match ends here */
|
||||
struct sset **lastcss, /* state storage across calls */
|
||||
struct sset **lastcss, /* state storage across calls */
|
||||
chr **lastcp) /* state storage across calls */
|
||||
{
|
||||
chr *cp = *lastcp;
|
||||
@ -672,15 +672,15 @@ miss(struct vars *v,
|
||||
for (ca = cnfa->states[i]; ca->co != COLORLESS; ca++)
|
||||
{
|
||||
if (ca->co < cnfa->ncolors)
|
||||
continue; /* not a LACON arc */
|
||||
continue; /* not a LACON arc */
|
||||
if (ISBSET(d->work, ca->to))
|
||||
continue; /* arc would be a no-op anyway */
|
||||
sawlacons = 1; /* this LACON affects our result */
|
||||
continue; /* arc would be a no-op anyway */
|
||||
sawlacons = 1; /* this LACON affects our result */
|
||||
if (!lacon(v, cnfa, cp, ca->co))
|
||||
{
|
||||
if (ISERR())
|
||||
return NULL;
|
||||
continue; /* LACON arc cannot be traversed */
|
||||
continue; /* LACON arc cannot be traversed */
|
||||
}
|
||||
if (ISERR())
|
||||
return NULL;
|
||||
@ -821,7 +821,7 @@ getvacant(struct vars *v,
|
||||
FDEBUG(("zapping c%d's %ld outarc\n", (int) (p - d->ssets), (long) co));
|
||||
p->outs[co] = NULL;
|
||||
ap = p->inchain[co];
|
||||
p->inchain[co].ss = NULL; /* paranoia */
|
||||
p->inchain[co].ss = NULL; /* paranoia */
|
||||
}
|
||||
ss->ins.ss = NULL;
|
||||
|
||||
|
@ -64,7 +64,7 @@ pg_regerror(int errcode, /* error code, or REG_ATOI or REG_ITOA */
|
||||
{
|
||||
const struct rerr *r;
|
||||
const char *msg;
|
||||
char convbuf[sizeof(unk) + 50]; /* 50 = plenty for int */
|
||||
char convbuf[sizeof(unk) + 50]; /* 50 = plenty for int */
|
||||
size_t len;
|
||||
int icode;
|
||||
|
||||
@ -78,7 +78,7 @@ pg_regerror(int errcode, /* error code, or REG_ATOI or REG_ITOA */
|
||||
msg = convbuf;
|
||||
break;
|
||||
case REG_ITOA: /* convert number to name */
|
||||
icode = atoi(errbuf); /* not our problem if this fails */
|
||||
icode = atoi(errbuf); /* not our problem if this fails */
|
||||
for (r = rerrs; r->code >= 0; r++)
|
||||
if (r->code == icode)
|
||||
break;
|
||||
|
@ -403,7 +403,7 @@ find(struct vars *v,
|
||||
v->details->rm_extend.rm_so = OFF(cold);
|
||||
else
|
||||
v->details->rm_extend.rm_so = OFF(v->stop);
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
}
|
||||
if (close == NULL) /* not found */
|
||||
return REG_NOMATCH;
|
||||
@ -449,7 +449,7 @@ find(struct vars *v,
|
||||
v->details->rm_extend.rm_so = OFF(cold);
|
||||
else
|
||||
v->details->rm_extend.rm_so = OFF(v->stop);
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
}
|
||||
if (v->nmatch == 1) /* no need for submatches */
|
||||
return REG_OKAY;
|
||||
@ -494,7 +494,7 @@ cfind(struct vars *v,
|
||||
v->details->rm_extend.rm_so = OFF(cold);
|
||||
else
|
||||
v->details->rm_extend.rm_so = OFF(v->stop);
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -718,7 +718,7 @@ cdissect(struct vars *v,
|
||||
break;
|
||||
case '.': /* concatenation */
|
||||
assert(t->left != NULL && t->right != NULL);
|
||||
if (t->left->flags & SHORTER) /* reverse scan */
|
||||
if (t->left->flags & SHORTER) /* reverse scan */
|
||||
er = crevcondissect(v, t, begin, end);
|
||||
else
|
||||
er = ccondissect(v, t, begin, end);
|
||||
@ -729,7 +729,7 @@ cdissect(struct vars *v,
|
||||
break;
|
||||
case '*': /* iteration */
|
||||
assert(t->left != NULL);
|
||||
if (t->left->flags & SHORTER) /* reverse scan */
|
||||
if (t->left->flags & SHORTER) /* reverse scan */
|
||||
er = creviterdissect(v, t, begin, end);
|
||||
else
|
||||
er = citerdissect(v, t, begin, end);
|
||||
|
@ -235,7 +235,7 @@ pg_reg_getnumcharacters(const regex_t *regex, int co)
|
||||
|
||||
if (co <= 0 || co > cm->max) /* we reject 0 which is WHITE */
|
||||
return -1;
|
||||
if (cm->cd[co].flags & PSEUDO) /* also pseudocolors (BOS etc) */
|
||||
if (cm->cd[co].flags & PSEUDO) /* also pseudocolors (BOS etc) */
|
||||
return -1;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user