if (!OidIsValid(collation))
{ /* *Thistypicallymeansthattheparsercouldnotresolveaconflict *ofimplicitcollations,soreportitthatway.
*/
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_COLLATION),
errmsg("could not determine which collation to use for regular expression"),
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
if (!locale->deterministic)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for regular expressions")));
staticint
pg_wc_isdigit(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISDIGIT)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isdigit(c, !pg_regex_locale->info.builtin.casemap_full); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswdigit_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isdigit_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isdigit(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isalpha(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALPHA)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isalpha(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalpha_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isalpha_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isalpha(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isalnum(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALNUM)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isalnum(c, !pg_regex_locale->info.builtin.casemap_full); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalnum_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isalnum_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isalnum(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isword(pg_wchar c)
{ /* We define word characters as alnum class plus underscore */ if (c == CHR('_')) return1; return pg_wc_isalnum(c);
}
staticint
pg_wc_isupper(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISUPPER)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isupper(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswupper_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isupper_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isupper(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_islower(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISLOWER)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_islower(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswlower_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
islower_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_islower(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isgraph(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISGRAPH)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isgraph(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswgraph_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isgraph_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isgraph(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isprint(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPRINT)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isprint(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswprint_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isprint_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isprint(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_ispunct(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPUNCT)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_ispunct(c, !pg_regex_locale->info.builtin.casemap_full); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswpunct_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
ispunct_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_ispunct(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
staticint
pg_wc_isspace(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISSPACE)); case PG_REGEX_STRATEGY_BUILTIN: return pg_u_isspace(c); case PG_REGEX_STRATEGY_LIBC_WIDE: if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswspace_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: return (c <= (pg_wchar) UCHAR_MAX &&
isspace_l((unsignedchar) c, pg_regex_locale->info.lt)); break; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_isspace(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
static pg_wchar
pg_wc_toupper(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: if (c <= (pg_wchar) 127) return pg_ascii_toupper((unsignedchar) c); return c; case PG_REGEX_STRATEGY_BUILTIN: return unicode_uppercase_simple(c); case PG_REGEX_STRATEGY_LIBC_WIDE: /* force C behavior for ASCII characters, per comments above */ if (pg_regex_locale->is_default && c <= (pg_wchar) 127) return pg_ascii_toupper((unsignedchar) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towupper_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: /* force C behavior for ASCII characters, per comments above */ if (pg_regex_locale->is_default && c <= (pg_wchar) 127) return pg_ascii_toupper((unsignedchar) c); if (c <= (pg_wchar) UCHAR_MAX) return toupper_l((unsignedchar) c, pg_regex_locale->info.lt); return c; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_toupper(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
static pg_wchar
pg_wc_tolower(pg_wchar c)
{ switch (pg_regex_strategy)
{ case PG_REGEX_STRATEGY_C: if (c <= (pg_wchar) 127) return pg_ascii_tolower((unsignedchar) c); return c; case PG_REGEX_STRATEGY_BUILTIN: return unicode_lowercase_simple(c); case PG_REGEX_STRATEGY_LIBC_WIDE: /* force C behavior for ASCII characters, per comments above */ if (pg_regex_locale->is_default && c <= (pg_wchar) 127) return pg_ascii_tolower((unsignedchar) c); if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return towlower_l((wint_t) c, pg_regex_locale->info.lt); /* FALL THRU */ case PG_REGEX_STRATEGY_LIBC_1BYTE: /* force C behavior for ASCII characters, per comments above */ if (pg_regex_locale->is_default && c <= (pg_wchar) 127) return pg_ascii_tolower((unsignedchar) c); if (c <= (pg_wchar) UCHAR_MAX) return tolower_l((unsignedchar) c, pg_regex_locale->info.lt); return c; case PG_REGEX_STRATEGY_ICU: #ifdef USE_ICU return u_tolower(c); #endif break;
} return0; /* can't get here, but keep compiler quiet */
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.