1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Remove typedef celt from the regex library, along with macro NOCELT.

The regex library used to have a notion of a "collating element" that was
distinct from a "character", but Henry Spencer never actually implemented
his planned support for multi-character collating elements, and the Tcl
crew ripped out most of the stubs for that years ago.  The only thing left
that distinguished the "celt" typedef from the "chr" typedef was that
"celt" was supposed to also be able to hold the not-a-character "NOCELT"
value.  However, NOCELT was not used anywhere after the MCCE stub removal
changes, which means there's no need for celt to be different from chr.
Removing the separate typedef simplifies matters and also removes a trap
for the unwary, in that celt is signed while chr may not be, so comparisons
could mean different things.  There's no bug there today because we
restrict CHR_MAX to be less than INT_MAX, but I think there may have been
such bugs before we did that, and there could be again if anyone ever
decides to fool with the range of chr.

This patch also removes assorted unnecessary casts to "chr" of values
that are already chrs.  Many of these seem to be leftover from days when
the code was compatible with pre-ANSI C.
This commit is contained in:
Tom Lane
2016-08-19 12:51:02 -04:00
parent 5285c5e873
commit 6eefd2422e
5 changed files with 33 additions and 38 deletions

View File

@ -78,7 +78,7 @@ addchr(struct cvec * cv, /* character vector */
chr c) /* character to add */
{
assert(cv->nchrs < cv->chrspace);
cv->chrs[cv->nchrs++] = (chr) c;
cv->chrs[cv->nchrs++] = c;
}
/*
@ -90,8 +90,8 @@ addrange(struct cvec * cv, /* character vector */
chr to) /* last character of range */
{
assert(cv->nranges < cv->rangespace);
cv->ranges[cv->nranges * 2] = (chr) from;
cv->ranges[cv->nranges * 2 + 1] = (chr) to;
cv->ranges[cv->nranges * 2] = from;
cv->ranges[cv->nranges * 2 + 1] = to;
cv->nranges++;
}