From 2abc0d7e29e5d6edd401ccfcab4cb281e9b420a1 Mon Sep 17 00:00:00 2001
From: Jeff Davis <jeff@j-davis.com>
Date: Mon, 6 Oct 2025 11:45:00 -0700
Subject: [PATCH v1 1/6] Rename static functions pg_wc_xyz() to regc_wc_xyz().

The former names are better suited to a set of exported functions,
which will be added in an upcoming commit.
---
 src/backend/regex/regc_locale.c    | 50 +++++++++++++++---------------
 src/backend/regex/regc_pg_locale.c | 34 ++++++++++----------
 src/backend/regex/regcomp.c        | 24 +++++++-------
 src/include/regex/regcustom.h      |  8 ++---
 4 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/src/backend/regex/regc_locale.c b/src/backend/regex/regc_locale.c
index 77d1ce28168..252418f4482 100644
--- a/src/backend/regex/regc_locale.c
+++ b/src/backend/regex/regc_locale.c
@@ -453,7 +453,7 @@ range(struct vars *v,			/* context */
 
 	for (c = a; c <= b; c++)
 	{
-		cc = pg_wc_tolower(c);
+		cc = regc_wc_tolower(c);
 		if (cc != c &&
 			(before(cc, a) || before(b, cc)))
 		{
@@ -464,7 +464,7 @@ range(struct vars *v,			/* context */
 			}
 			addchr(cv, cc);
 		}
-		cc = pg_wc_toupper(c);
+		cc = regc_wc_toupper(c);
 		if (cc != c &&
 			(before(cc, a) || before(b, cc)))
 		{
@@ -594,16 +594,16 @@ cclasscvec(struct vars *v,		/* context */
 	switch (cclasscode)
 	{
 		case CC_PRINT:
-			cv = pg_ctype_get_cache(pg_wc_isprint, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isprint, cclasscode);
 			break;
 		case CC_ALNUM:
-			cv = pg_ctype_get_cache(pg_wc_isalnum, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isalnum, cclasscode);
 			break;
 		case CC_ALPHA:
-			cv = pg_ctype_get_cache(pg_wc_isalpha, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isalpha, cclasscode);
 			break;
 		case CC_WORD:
-			cv = pg_ctype_get_cache(pg_wc_isword, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isword, cclasscode);
 			break;
 		case CC_ASCII:
 			/* hard-wired meaning */
@@ -624,10 +624,10 @@ cclasscvec(struct vars *v,		/* context */
 			addrange(cv, 0x7f, 0x9f);
 			break;
 		case CC_DIGIT:
-			cv = pg_ctype_get_cache(pg_wc_isdigit, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isdigit, cclasscode);
 			break;
 		case CC_PUNCT:
-			cv = pg_ctype_get_cache(pg_wc_ispunct, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_ispunct, cclasscode);
 			break;
 		case CC_XDIGIT:
 
@@ -645,16 +645,16 @@ cclasscvec(struct vars *v,		/* context */
 			}
 			break;
 		case CC_SPACE:
-			cv = pg_ctype_get_cache(pg_wc_isspace, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isspace, cclasscode);
 			break;
 		case CC_LOWER:
-			cv = pg_ctype_get_cache(pg_wc_islower, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_islower, cclasscode);
 			break;
 		case CC_UPPER:
-			cv = pg_ctype_get_cache(pg_wc_isupper, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isupper, cclasscode);
 			break;
 		case CC_GRAPH:
-			cv = pg_ctype_get_cache(pg_wc_isgraph, cclasscode);
+			cv = pg_ctype_get_cache(regc_wc_isgraph, cclasscode);
 			break;
 	}
 
@@ -679,29 +679,29 @@ cclass_column_index(struct colormap *cm, chr c)
 	 * Note: we should not see requests to consider cclasses that are not
 	 * treated as locale-specific by cclasscvec(), above.
 	 */
-	if (cm->classbits[CC_PRINT] && pg_wc_isprint(c))
+	if (cm->classbits[CC_PRINT] && regc_wc_isprint(c))
 		colnum |= cm->classbits[CC_PRINT];
-	if (cm->classbits[CC_ALNUM] && pg_wc_isalnum(c))
+	if (cm->classbits[CC_ALNUM] && regc_wc_isalnum(c))
 		colnum |= cm->classbits[CC_ALNUM];
-	if (cm->classbits[CC_ALPHA] && pg_wc_isalpha(c))
+	if (cm->classbits[CC_ALPHA] && regc_wc_isalpha(c))
 		colnum |= cm->classbits[CC_ALPHA];
-	if (cm->classbits[CC_WORD] && pg_wc_isword(c))
+	if (cm->classbits[CC_WORD] && regc_wc_isword(c))
 		colnum |= cm->classbits[CC_WORD];
 	assert(cm->classbits[CC_ASCII] == 0);
 	assert(cm->classbits[CC_BLANK] == 0);
 	assert(cm->classbits[CC_CNTRL] == 0);
-	if (cm->classbits[CC_DIGIT] && pg_wc_isdigit(c))
+	if (cm->classbits[CC_DIGIT] && regc_wc_isdigit(c))
 		colnum |= cm->classbits[CC_DIGIT];
-	if (cm->classbits[CC_PUNCT] && pg_wc_ispunct(c))
+	if (cm->classbits[CC_PUNCT] && regc_wc_ispunct(c))
 		colnum |= cm->classbits[CC_PUNCT];
 	assert(cm->classbits[CC_XDIGIT] == 0);
-	if (cm->classbits[CC_SPACE] && pg_wc_isspace(c))
+	if (cm->classbits[CC_SPACE] && regc_wc_isspace(c))
 		colnum |= cm->classbits[CC_SPACE];
-	if (cm->classbits[CC_LOWER] && pg_wc_islower(c))
+	if (cm->classbits[CC_LOWER] && regc_wc_islower(c))
 		colnum |= cm->classbits[CC_LOWER];
-	if (cm->classbits[CC_UPPER] && pg_wc_isupper(c))
+	if (cm->classbits[CC_UPPER] && regc_wc_isupper(c))
 		colnum |= cm->classbits[CC_UPPER];
-	if (cm->classbits[CC_GRAPH] && pg_wc_isgraph(c))
+	if (cm->classbits[CC_GRAPH] && regc_wc_isgraph(c))
 		colnum |= cm->classbits[CC_GRAPH];
 
 	return colnum;
@@ -721,8 +721,8 @@ allcases(struct vars *v,		/* context */
 	chr			lc,
 				uc;
 
-	lc = pg_wc_tolower(c);
-	uc = pg_wc_toupper(c);
+	lc = regc_wc_tolower(c);
+	uc = regc_wc_toupper(c);
 
 	cv = getcvec(v, 2, 0);
 	addchr(cv, lc);
@@ -760,7 +760,7 @@ casecmp(const chr *x, const chr *y, /* strings to compare */
 {
 	for (; len > 0; len--, x++, y++)
 	{
-		if ((*x != *y) && (pg_wc_tolower(*x) != pg_wc_tolower(*y)))
+		if ((*x != *y) && (regc_wc_tolower(*x) != regc_wc_tolower(*y)))
 			return 1;
 	}
 	return 0;
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c
index d9eab5357bc..c236d44624f 100644
--- a/src/backend/regex/regc_pg_locale.c
+++ b/src/backend/regex/regc_pg_locale.c
@@ -228,7 +228,7 @@ pg_set_regex_collation(Oid collation)
 }
 
 static int
-pg_wc_isdigit(pg_wchar c)
+regc_wc_isdigit(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -238,7 +238,7 @@ pg_wc_isdigit(pg_wchar c)
 }
 
 static int
-pg_wc_isalpha(pg_wchar c)
+regc_wc_isalpha(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -248,7 +248,7 @@ pg_wc_isalpha(pg_wchar c)
 }
 
 static int
-pg_wc_isalnum(pg_wchar c)
+regc_wc_isalnum(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -258,16 +258,16 @@ pg_wc_isalnum(pg_wchar c)
 }
 
 static int
-pg_wc_isword(pg_wchar c)
+regc_wc_isword(pg_wchar c)
 {
 	/* We define word characters as alnum class plus underscore */
 	if (c == CHR('_'))
 		return 1;
-	return pg_wc_isalnum(c);
+	return regc_wc_isalnum(c);
 }
 
 static int
-pg_wc_isupper(pg_wchar c)
+regc_wc_isupper(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -277,7 +277,7 @@ pg_wc_isupper(pg_wchar c)
 }
 
 static int
-pg_wc_islower(pg_wchar c)
+regc_wc_islower(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -287,7 +287,7 @@ pg_wc_islower(pg_wchar c)
 }
 
 static int
-pg_wc_isgraph(pg_wchar c)
+regc_wc_isgraph(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -297,7 +297,7 @@ pg_wc_isgraph(pg_wchar c)
 }
 
 static int
-pg_wc_isprint(pg_wchar c)
+regc_wc_isprint(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -307,7 +307,7 @@ pg_wc_isprint(pg_wchar c)
 }
 
 static int
-pg_wc_ispunct(pg_wchar c)
+regc_wc_ispunct(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -317,7 +317,7 @@ pg_wc_ispunct(pg_wchar c)
 }
 
 static int
-pg_wc_isspace(pg_wchar c)
+regc_wc_isspace(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 		return (c <= (pg_wchar) 127 &&
@@ -327,7 +327,7 @@ pg_wc_isspace(pg_wchar c)
 }
 
 static pg_wchar
-pg_wc_toupper(pg_wchar c)
+regc_wc_toupper(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 	{
@@ -340,7 +340,7 @@ pg_wc_toupper(pg_wchar c)
 }
 
 static pg_wchar
-pg_wc_tolower(pg_wchar c)
+regc_wc_tolower(pg_wchar c)
 {
 	if (pg_regex_locale->ctype_is_c)
 	{
@@ -366,11 +366,11 @@ pg_wc_tolower(pg_wchar c)
  * the main regex code expects us to return a failure indication instead.
  */
 
-typedef int (*pg_wc_probefunc) (pg_wchar c);
+typedef int (*regc_wc_probefunc) (pg_wchar c);
 
 typedef struct pg_ctype_cache
 {
-	pg_wc_probefunc probefunc;	/* pg_wc_isalpha or a sibling */
+	regc_wc_probefunc probefunc;	/* regc_wc_isalpha or a sibling */
 	pg_locale_t locale;			/* locale this entry is for */
 	struct cvec cv;				/* cache entry contents */
 	struct pg_ctype_cache *next;	/* chain link */
@@ -419,14 +419,14 @@ store_match(pg_ctype_cache *pcc, pg_wchar chr1, int nchrs)
 }
 
 /*
- * Given a probe function (e.g., pg_wc_isalpha) get a struct cvec for all
+ * Given a probe function (e.g., regc_wc_isalpha) get a struct cvec for all
  * chrs satisfying the probe function.  The active collation is the one
  * previously set by pg_set_regex_collation.  Return NULL if out of memory.
  *
  * Note that the result must not be freed or modified by caller.
  */
 static struct cvec *
-pg_ctype_get_cache(pg_wc_probefunc probefunc, int cclasscode)
+pg_ctype_get_cache(regc_wc_probefunc probefunc, int cclasscode)
 {
 	pg_ctype_cache *pcc;
 	pg_wchar	max_chr;
diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c
index 15b264e50f1..3e18e4a78a2 100644
--- a/src/backend/regex/regcomp.c
+++ b/src/backend/regex/regcomp.c
@@ -249,18 +249,18 @@ static struct cvec *getcvec(struct vars *v, int nchrs, int nranges);
 static void freecvec(struct cvec *cv);
 
 /* === regc_pg_locale.c === */
-static int	pg_wc_isdigit(pg_wchar c);
-static int	pg_wc_isalpha(pg_wchar c);
-static int	pg_wc_isalnum(pg_wchar c);
-static int	pg_wc_isword(pg_wchar c);
-static int	pg_wc_isupper(pg_wchar c);
-static int	pg_wc_islower(pg_wchar c);
-static int	pg_wc_isgraph(pg_wchar c);
-static int	pg_wc_isprint(pg_wchar c);
-static int	pg_wc_ispunct(pg_wchar c);
-static int	pg_wc_isspace(pg_wchar c);
-static pg_wchar pg_wc_toupper(pg_wchar c);
-static pg_wchar pg_wc_tolower(pg_wchar c);
+static int	regc_wc_isdigit(pg_wchar c);
+static int	regc_wc_isalpha(pg_wchar c);
+static int	regc_wc_isalnum(pg_wchar c);
+static int	regc_wc_isword(pg_wchar c);
+static int	regc_wc_isupper(pg_wchar c);
+static int	regc_wc_islower(pg_wchar c);
+static int	regc_wc_isgraph(pg_wchar c);
+static int	regc_wc_isprint(pg_wchar c);
+static int	regc_wc_ispunct(pg_wchar c);
+static int	regc_wc_isspace(pg_wchar c);
+static pg_wchar regc_wc_toupper(pg_wchar c);
+static pg_wchar regc_wc_tolower(pg_wchar c);
 
 /* === regc_locale.c === */
 static chr	element(struct vars *v, const chr *startp, const chr *endp);
diff --git a/src/include/regex/regcustom.h b/src/include/regex/regcustom.h
index af0fe97c796..1c0e92f168f 100644
--- a/src/include/regex/regcustom.h
+++ b/src/include/regex/regcustom.h
@@ -88,10 +88,10 @@ typedef unsigned uchr;			/* unsigned type that will hold a chr */
 #define MAX_SIMPLE_CHR	0x7FF	/* suitable value for Unicode */
 
 /* functions operating on chr */
-#define iscalnum(x) pg_wc_isalnum(x)
-#define iscalpha(x) pg_wc_isalpha(x)
-#define iscdigit(x) pg_wc_isdigit(x)
-#define iscspace(x) pg_wc_isspace(x)
+#define iscalnum(x) regc_wc_isalnum(x)
+#define iscalpha(x) regc_wc_isalpha(x)
+#define iscdigit(x) regc_wc_isdigit(x)
+#define iscspace(x) regc_wc_isspace(x)
 
 /* and pick up the standard header */
 #include "regex.h"
-- 
2.43.0

