mirror of
https://github.com/postgres/postgres.git
synced 2025-12-06 00:02:13 +03:00
pgindent run. Make it all clean.
This commit is contained in:
@@ -12,37 +12,42 @@
|
||||
#define UCHARMAX 0xff
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
static int wchareq(unsigned char *p1, unsigned char *p2)
|
||||
static int
|
||||
wchareq(unsigned char *p1, unsigned char *p2)
|
||||
{
|
||||
int l;
|
||||
int l;
|
||||
|
||||
l = pg_mblen(p1);
|
||||
if (pg_mblen(p2) != l) {
|
||||
return(0);
|
||||
}
|
||||
while (l--) {
|
||||
if (pg_mblen(p2) != l)
|
||||
return (0);
|
||||
while (l--)
|
||||
{
|
||||
if (*p1++ != *p2++)
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
static int
|
||||
iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
{
|
||||
int c1, c2;
|
||||
int l;
|
||||
int c1,
|
||||
c2;
|
||||
int l;
|
||||
|
||||
/* short cut. if *p1 and *p2 is lower than UCHARMAX, then
|
||||
we assume they are ASCII */
|
||||
/*
|
||||
* short cut. if *p1 and *p2 is lower than UCHARMAX, then we assume
|
||||
* they are ASCII
|
||||
*/
|
||||
if (*p1 < UCHARMAX && *p2 < UCHARMAX)
|
||||
return(tolower(*p1) == tolower(*p2));
|
||||
return (tolower(*p1) == tolower(*p2));
|
||||
|
||||
if (*p1 < UCHARMAX)
|
||||
c1 = tolower(*p1);
|
||||
else
|
||||
{
|
||||
l = pg_mblen(p1);
|
||||
(void)pg_mb2wchar_with_len(p1, (pg_wchar *)&c1, l);
|
||||
(void) pg_mb2wchar_with_len(p1, (pg_wchar *) & c1, l);
|
||||
c1 = tolower(c1);
|
||||
}
|
||||
if (*p2 < UCHARMAX)
|
||||
@@ -50,10 +55,10 @@ static int iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
else
|
||||
{
|
||||
l = pg_mblen(p2);
|
||||
(void)pg_mb2wchar_with_len(p2, (pg_wchar *)&c2, l);
|
||||
(void) pg_mb2wchar_with_len(p2, (pg_wchar *) & c2, l);
|
||||
c2 = tolower(c2);
|
||||
}
|
||||
return(c1 == c2);
|
||||
return (c1 == c2);
|
||||
}
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
@@ -69,23 +74,28 @@ static int iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
static int
|
||||
MatchText(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
{
|
||||
/* Fast path for match-everything pattern
|
||||
* Include weird case of escape character as a percent sign or underscore,
|
||||
* when presumably that wildcard character becomes a literal.
|
||||
|
||||
/*
|
||||
* Fast path for match-everything pattern Include weird case of escape
|
||||
* character as a percent sign or underscore, when presumably that
|
||||
* wildcard character becomes a literal.
|
||||
*/
|
||||
if ((plen == 1) && (*p == '%')
|
||||
&& ! ((e != NULL) && (*e == '%')))
|
||||
&& !((e != NULL) && (*e == '%')))
|
||||
return LIKE_TRUE;
|
||||
|
||||
while ((tlen > 0) && (plen > 0))
|
||||
{
|
||||
/* If an escape character was specified and we find it here in the pattern,
|
||||
* then we'd better have an exact match for the next character.
|
||||
|
||||
/*
|
||||
* If an escape character was specified and we find it here in the
|
||||
* pattern, then we'd better have an exact match for the next
|
||||
* character.
|
||||
*/
|
||||
if ((e != NULL) && CHAREQ(p,e))
|
||||
if ((e != NULL) && CHAREQ(p, e))
|
||||
{
|
||||
NextChar(p, plen);
|
||||
if ((plen <= 0) || !CHAREQ(t,p))
|
||||
if ((plen <= 0) || !CHAREQ(t, p))
|
||||
return LIKE_FALSE;
|
||||
}
|
||||
else if (*p == '%')
|
||||
@@ -99,23 +109,23 @@ MatchText(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
return LIKE_TRUE;
|
||||
|
||||
/*
|
||||
* Otherwise, scan for a text position at which we can
|
||||
* match the rest of the pattern.
|
||||
* Otherwise, scan for a text position at which we can match
|
||||
* the rest of the pattern.
|
||||
*/
|
||||
while (tlen > 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* Optimization to prevent most recursion: don't
|
||||
* recurse unless first pattern char might match this
|
||||
* text char.
|
||||
* Optimization to prevent most recursion: don't recurse
|
||||
* unless first pattern char might match this text char.
|
||||
*/
|
||||
if (CHAREQ(t,p) || (*p == '_')
|
||||
|| ((e != NULL) && CHAREQ(p,e)))
|
||||
if (CHAREQ(t, p) || (*p == '_')
|
||||
|| ((e != NULL) && CHAREQ(p, e)))
|
||||
{
|
||||
int matched = MatchText(t, tlen, p, plen, e);
|
||||
int matched = MatchText(t, tlen, p, plen, e);
|
||||
|
||||
if (matched != LIKE_FALSE)
|
||||
return matched; /* TRUE or ABORT */
|
||||
return matched; /* TRUE or ABORT */
|
||||
}
|
||||
|
||||
NextChar(t, tlen);
|
||||
@@ -127,9 +137,11 @@ MatchText(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
*/
|
||||
return LIKE_ABORT;
|
||||
}
|
||||
else if ((*p != '_') && !CHAREQ(t,p))
|
||||
else if ((*p != '_') && !CHAREQ(t, p))
|
||||
{
|
||||
/* Not the single-character wildcard and no explicit match?
|
||||
|
||||
/*
|
||||
* Not the single-character wildcard and no explicit match?
|
||||
* Then time to quit...
|
||||
*/
|
||||
return LIKE_FALSE;
|
||||
@@ -143,7 +155,8 @@ MatchText(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
return LIKE_FALSE; /* end of pattern, but not of text */
|
||||
|
||||
/* End of input string. Do we have matching pattern remaining? */
|
||||
while ((plen > 0) && (*p == '%')) /* allow multiple %'s at end of pattern */
|
||||
while ((plen > 0) && (*p == '%')) /* allow multiple %'s at end of
|
||||
* pattern */
|
||||
NextChar(p, plen);
|
||||
if (plen <= 0)
|
||||
return LIKE_TRUE;
|
||||
@@ -153,28 +166,33 @@ MatchText(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
* start matching this pattern.
|
||||
*/
|
||||
return LIKE_ABORT;
|
||||
} /* MatchText() */
|
||||
} /* MatchText() */
|
||||
|
||||
static int
|
||||
MatchTextLower(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
{
|
||||
/* Fast path for match-everything pattern
|
||||
* Include weird case of escape character as a percent sign or underscore,
|
||||
* when presumably that wildcard character becomes a literal.
|
||||
|
||||
/*
|
||||
* Fast path for match-everything pattern Include weird case of escape
|
||||
* character as a percent sign or underscore, when presumably that
|
||||
* wildcard character becomes a literal.
|
||||
*/
|
||||
if ((plen == 1) && (*p == '%')
|
||||
&& ! ((e != NULL) && (*e == '%')))
|
||||
&& !((e != NULL) && (*e == '%')))
|
||||
return LIKE_TRUE;
|
||||
|
||||
while ((tlen > 0) && (plen > 0))
|
||||
{
|
||||
/* If an escape character was specified and we find it here in the pattern,
|
||||
* then we'd better have an exact match for the next character.
|
||||
|
||||
/*
|
||||
* If an escape character was specified and we find it here in the
|
||||
* pattern, then we'd better have an exact match for the next
|
||||
* character.
|
||||
*/
|
||||
if ((e != NULL) && ICHAREQ(p,e))
|
||||
if ((e != NULL) && ICHAREQ(p, e))
|
||||
{
|
||||
NextChar(p, plen);
|
||||
if ((plen <= 0) || !ICHAREQ(t,p))
|
||||
if ((plen <= 0) || !ICHAREQ(t, p))
|
||||
return LIKE_FALSE;
|
||||
}
|
||||
else if (*p == '%')
|
||||
@@ -188,23 +206,23 @@ MatchTextLower(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
return LIKE_TRUE;
|
||||
|
||||
/*
|
||||
* Otherwise, scan for a text position at which we can
|
||||
* match the rest of the pattern.
|
||||
* Otherwise, scan for a text position at which we can match
|
||||
* the rest of the pattern.
|
||||
*/
|
||||
while (tlen > 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* Optimization to prevent most recursion: don't
|
||||
* recurse unless first pattern char might match this
|
||||
* text char.
|
||||
* Optimization to prevent most recursion: don't recurse
|
||||
* unless first pattern char might match this text char.
|
||||
*/
|
||||
if (ICHAREQ(t,p) || (*p == '_')
|
||||
|| ((e != NULL) && ICHAREQ(p,e)))
|
||||
if (ICHAREQ(t, p) || (*p == '_')
|
||||
|| ((e != NULL) && ICHAREQ(p, e)))
|
||||
{
|
||||
int matched = MatchText(t, tlen, p, plen, e);
|
||||
int matched = MatchText(t, tlen, p, plen, e);
|
||||
|
||||
if (matched != LIKE_FALSE)
|
||||
return matched; /* TRUE or ABORT */
|
||||
return matched; /* TRUE or ABORT */
|
||||
}
|
||||
|
||||
NextChar(t, tlen);
|
||||
@@ -216,10 +234,8 @@ MatchTextLower(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
*/
|
||||
return LIKE_ABORT;
|
||||
}
|
||||
else if ((*p != '_') && !ICHAREQ(t,p))
|
||||
{
|
||||
else if ((*p != '_') && !ICHAREQ(t, p))
|
||||
return LIKE_FALSE;
|
||||
}
|
||||
|
||||
NextChar(t, tlen);
|
||||
NextChar(p, plen);
|
||||
@@ -229,7 +245,8 @@ MatchTextLower(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
return LIKE_FALSE; /* end of pattern, but not of text */
|
||||
|
||||
/* End of input string. Do we have matching pattern remaining? */
|
||||
while ((plen > 0) && (*p == '%')) /* allow multiple %'s at end of pattern */
|
||||
while ((plen > 0) && (*p == '%')) /* allow multiple %'s at end of
|
||||
* pattern */
|
||||
NextChar(p, plen);
|
||||
if (plen <= 0)
|
||||
return LIKE_TRUE;
|
||||
@@ -239,14 +256,16 @@ MatchTextLower(PG_CHAR * t, int tlen, PG_CHAR * p, int plen, char *e)
|
||||
* start matching this pattern.
|
||||
*/
|
||||
return LIKE_ABORT;
|
||||
} /* MatchTextLower() */
|
||||
} /* MatchTextLower() */
|
||||
|
||||
main()
|
||||
{
|
||||
unsigned char *t = "<EFBFBD><EFBFBD>Z01<EFBFBD><EFBFBD>";
|
||||
unsigned char *p = "_Z%";
|
||||
int tlen, plen;
|
||||
int tlen,
|
||||
plen;
|
||||
|
||||
tlen = strlen(t);
|
||||
plen = strlen(p);
|
||||
printf("%d\n",MatchTextLower(t,tlen,p,plen,"\\"));
|
||||
printf("%d\n", MatchTextLower(t, tlen, p, plen, "\\"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user