mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Improve some unicode functions
This commit is contained in:
parent
b9187061a7
commit
1b5a5719c3
33 changed files with 8366 additions and 197 deletions
|
@ -83,24 +83,29 @@ TEST(regex, testIpExtended) {
|
|||
regfree(&rx);
|
||||
}
|
||||
|
||||
TEST(regex, testUnicodeCharacterClass) {
|
||||
regex_t rx;
|
||||
EXPECT_EQ(REG_OK, regcomp(&rx, "^[[:alpha:]][[:alpha:]]$", 0));
|
||||
EXPECT_EQ(REG_OK, regexec(&rx, "𝐵𝑏", 0, 0, 0));
|
||||
EXPECT_NE(REG_OK, regexec(&rx, "₀₁", 0, 0, 0));
|
||||
regfree(&rx);
|
||||
}
|
||||
|
||||
void A(void) {
|
||||
regex_t rx;
|
||||
regcomp(&rx, "^[-._0-9A-Za-z]*$", REG_EXTENDED);
|
||||
regexec(&rx, "foo.com", 0, NULL, 0);
|
||||
regfree(&rx);
|
||||
}
|
||||
|
||||
void B(regex_t *rx) {
|
||||
regexec(rx, "foo.com", 0, NULL, 0);
|
||||
}
|
||||
|
||||
void C(void) {
|
||||
regex_t rx;
|
||||
regcomp(&rx, "^[-._0-9A-Za-z]*$", 0);
|
||||
regexec(&rx, "foo.com", 0, NULL, 0);
|
||||
regfree(&rx);
|
||||
}
|
||||
|
||||
void D(regex_t *rx, regmatch_t *m) {
|
||||
regexec(rx, "127.0.0.1", rx->re_nsub + 1, m, 0);
|
||||
}
|
||||
|
@ -113,7 +118,6 @@ BENCH(regex, bench) {
|
|||
regfree(&rx);
|
||||
EZBENCH2("easy api extended", donothing, A());
|
||||
EZBENCH2("easy api basic", donothing, C());
|
||||
|
||||
EXPECT_EQ(REG_OK, regcomp(&rx,
|
||||
"^"
|
||||
"\\([0-9][0-9]*\\)\\."
|
||||
|
@ -126,7 +130,6 @@ BENCH(regex, bench) {
|
|||
EZBENCH2("precompiled basic match", donothing, D(&rx, m));
|
||||
free(m);
|
||||
regfree(&rx);
|
||||
|
||||
EXPECT_EQ(REG_OK, regcomp(&rx,
|
||||
"^"
|
||||
"([0-9]{1,3})\\."
|
||||
|
@ -139,7 +142,6 @@ BENCH(regex, bench) {
|
|||
EZBENCH2("precompiled extended match", donothing, D(&rx, m));
|
||||
free(m);
|
||||
regfree(&rx);
|
||||
|
||||
EXPECT_EQ(REG_OK, regcomp(&rx,
|
||||
"^"
|
||||
"([0-9]{1,3})\\."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue