1# This file tests the auxiliary pattern conversion features of the PCRE2 2# library, in non-UTF mode. 3 4#forbid_utf 5#newline_default lf any anycrlf 6 7# -------- Tests of glob conversion -------- 8 9# Set the glob separator explicitly so that different OS defaults are not a 10# problem. Then test various errors. 11 12#pattern convert=glob,convert_glob_escape=\,convert_glob_separator=/ 13 14/abc/posix 15** The convert and posix modifiers are mutually exclusive 16 17# Separator must be / \ or . 18 19/a*b/convert_glob_separator=% 20** Invalid glob separator '%' 21 22# Can't have separator in a class 23 24"[ab/cd]" 25(?s)\A[ab/cd](?<!/)\z 26 27"[,-/]" 28(?s)\A[,-/](?<!/)\z 29 30/[ab/ 31** Pattern conversion error at offset 3: missing terminating ] for character class 32 33# Length check 34 35/abc/convert_length=11 36** Pattern conversion error at offset 3: no more memory 37 38/abc/convert_length=12 39(?s)\Aabc\z 40 41# Now some actual tests 42 43/a?b[]xy]*c/ 44(?s)\Aa[^/]b[\]xy](*COMMIT)[^/]*?c\z 45 azb]1234c 46 0: azb]1234c 47 48# Tests from the gitwildmatch list, with some additions 49 50/foo/ 51(?s)\Afoo\z 52 foo 53 0: foo 54/= Expect no match 55No match 56 bar 57No match 58 59// 60(?s)\A\z 61 \ 62 0: 63 64/???/ 65(?s)\A[^/][^/][^/]\z 66 foo 67 0: foo 68\= Expect no match 69 foobar 70No match 71 72/*/ 73(?s)\A[^/]*+\z 74 foo 75 0: foo 76 \ 77 0: 78 79/f*/ 80(?s)\Af(*COMMIT)[^/]*+\z 81 foo 82 0: foo 83 f 84 0: f 85 86/*f/ 87(?s)\A[^/]*?f\z 88 oof 89 0: oof 90\= Expect no match 91 foo 92No match 93 94/*foo*/ 95(?s)\A[^/]*?foo(*COMMIT)[^/]*+\z 96 foo 97 0: foo 98 food 99 0: food 100 aprilfool 101 0: aprilfool 102 103/*ob*a*r*/ 104(?s)\A[^/]*?ob(*COMMIT)[^/]*?a(*COMMIT)[^/]*?r(*COMMIT)[^/]*+\z 105 foobar 106 0: foobar 107 108/*ab/ 109(?s)\A[^/]*?ab\z 110 aaaaaaabababab 111 0: aaaaaaabababab 112 113/foo\*/ 114(?s)\Afoo\*\z 115 foo* 116 0: foo* 117 118/foo\*bar/ 119(?s)\Afoo\*bar\z 120\= Expect no match 121 foobar 122No match 123 124/f\\oo/ 125(?s)\Af\\oo\z 126 f\\oo 127 0: f\oo 128 129/*[al]?/ 130(?s)\A[^/]*?[al][^/]\z 131 ball 132 0: ball 133 134/[ten]/ 135(?s)\A[ten]\z 136\= Expect no match 137 ten 138No match 139 140/t[a-g]n/ 141(?s)\At[a-g]n\z 142 ten 143 0: ten 144 145/a[]]b/ 146(?s)\Aa[\]]b\z 147 a]b 148 0: a]b 149 150/a[]a-]b/ 151(?s)\Aa[\]a\-]b\z 152 153/a[]-]b/ 154(?s)\Aa[\]\-]b\z 155 a-b 156 0: a-b 157 a]b 158 0: a]b 159\= Expect no match 160 aab 161No match 162 163/a[]a-z]b/ 164(?s)\Aa[\]a-z]b\z 165 aab 166 0: aab 167 168/]/ 169(?s)\A\]\z 170 ] 171 0: ] 172 173/t[!a-g]n/ 174(?s)\At[^/a-g]n\z 175 ton 176 0: ton 177\= Expect no match 178 ten 179No match 180 181'[[:alpha:]][[:digit:]][[:upper:]]' 182(?s)\A[[:alpha:]][[:digit:]][[:upper:]]\z 183 a1B 184 0: a1B 185 186'[[:digit:][:upper:][:space:]]' 187(?s)\A[[:digit:][:upper:][:space:]]\z 188 A 189 0: A 190 1 191 0: 1 192 \ \= 193 0: 194\= Expect no match 195 a 196No match 197 . 198No match 199 200'[a-c[:digit:]x-z]' 201(?s)\A[a-c[:digit:]x-z]\z 202 5 203 0: 5 204 b 205 0: b 206 y 207 0: y 208\= Expect no match 209 q 210No match 211 212# End of gitwildmatch tests 213 214/*.j?g/ 215(?s)\A[^/]*?\.j[^/]g\z 216 pic01.jpg 217 0: pic01.jpg 218 .jpg 219 0: .jpg 220 pic02.jxg 221 0: pic02.jxg 222\= Expect no match 223 pic03.j/g 224No match 225 226/A[+-0]B/ 227(?s)\AA[+-0](?<!/)B\z 228 A+B 229 0: A+B 230 A.B 231 0: A.B 232 A0B 233 0: A0B 234\= Expect no match 235 A/B 236No match 237 238/*x?z/ 239(?s)\A[^/]*?x[^/]z\z 240 abc.xyz 241 0: abc.xyz 242\= Expect no match 243 .xyz 244 0: .xyz 245 246/?x?z/ 247(?s)\A[^/]x[^/]z\z 248 axyz 249 0: axyz 250\= Expect no match 251 .xyz 252 0: .xyz 253 254"[,-0]x?z" 255(?s)\A[,-0](?<!/)x[^/]z\z 256 ,xyz 257 0: ,xyz 258\= Expect no match 259 /xyz 260No match 261 .xyz 262 0: .xyz 263 264".x*" 265(?s)\A\.x(*COMMIT)[^/]*+\z 266 .xabc 267 0: .xabc 268 269/a[--0]z/ 270(?s)\Aa[\--0](?<!/)z\z 271 a-z 272 0: a-z 273 a.z 274 0: a.z 275 a0z 276 0: a0z 277\= Expect no match 278 a/z 279No match 280 a1z 281No match 282 283/<[a-c-d]>/ 284(?s)\A<[a-c\-d]>\z 285 <a> 286 0: <a> 287 <b> 288 0: <b> 289 <c> 290 0: <c> 291 <d> 292 0: <d> 293 <-> 294 0: <-> 295 296/a[[:digit:].]z/ 297(?s)\Aa[[:digit:].]z\z 298 a1z 299 0: a1z 300 a.z 301 0: a.z 302\= Expect no match 303 a:z 304No match 305 306/a[[:digit].]z/ 307(?s)\Aa[\[:digit]\.\]z\z 308 a[.]z 309 0: a[.]z 310 a:.]z 311 0: a:.]z 312 ad.]z 313 0: ad.]z 314 315/<[[:a[:digit:]b]>/ 316(?s)\A<[\[:a[:digit:]b]>\z 317 <[> 318 0: <[> 319 <:> 320 0: <:> 321 <a> 322 0: <a> 323 <9> 324 0: <9> 325 <b> 326 0: <b> 327\= Expect no match 328 <d> 329No match 330 331/a*b/convert_glob_separator=\ 332(?s)\Aa(*COMMIT)[^\\]*?b\z 333 334/a*b/convert_glob_separator=. 335(?s)\Aa(*COMMIT)[^\.]*?b\z 336 337/a*b/convert_glob_separator=/ 338(?s)\Aa(*COMMIT)[^/]*?b\z 339 340# Non control character checking 341 342/A\B\\C\D/ 343(?s)\AAB\\CD\z 344 345/\\{}\?\*+\[\]()|.^$/ 346(?s)\A\\\{\}\?\*\+\[\]\(\)\|\.\^\$\z 347 348/*a*\/*b*/ 349(?s)\A[^/]*?a(*COMMIT)[^/]*?/(*COMMIT)[^/]*?b(*COMMIT)[^/]*+\z 350 351/?a?\/?b?/ 352(?s)\A[^/]a[^/]/[^/]b[^/]\z 353 354/[a\\b\c][]][-][\]\-]/ 355(?s)\A[a\\bc][\]][\-][\]\-]\z 356 357/[^a\\b\c][!]][!-][^\]\-]/ 358(?s)\A[^/a\\bc][^/\]][^/\-][^/\]\-]\z 359 360/[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:word:][:xdigit:]]/ 361(?s)\A[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:word:][:xdigit:]](?<!/)\z 362 363"[/-/]" 364(?s)\A[/-/](?<!/)\z 365 366/[-----]/ 367(?s)\A[\--\-\-\-]\z 368 369/[------]/ 370(?s)\A[\--\-\--\-]\z 371 372/[!------]/ 373(?s)\A[^/\--\-\--\-]\z 374 375/[[:alpha:]-a]/ 376(?s)\A[[:alpha:]\-a]\z 377 378/[[:alpha:]][[:punct:]][[:ascii:]]/ 379(?s)\A[[:alpha:]][[:punct:]](?<!/)[[:ascii:]](?<!/)\z 380 381/[a-[:alpha:]]/ 382** Pattern conversion error at offset 4: invalid syntax 383 384/[[:alpha:/ 385** Pattern conversion error at offset 9: missing terminating ] for character class 386 387/[[:alpha:]/ 388** Pattern conversion error at offset 10: missing terminating ] for character class 389 390/[[:alphaa:]]/ 391(?s)\A[\[:alphaa:]\]\z 392 393/[[:xdigi:]]/ 394(?s)\A[\[:xdigi:]\]\z 395 396/[[:xdigit::]]/ 397(?s)\A[\[:xdigit::]\]\z 398 399/****/ 400(?s) 401 402/**\/abc/ 403(?s)(?:\A|/)abc\z 404 abc 405 0: abc 406 x/abc 407 0: /abc 408 xabc 409No match 410 411/abc\/**/ 412(?s)\Aabc/ 413 414/abc\/**\/abc/ 415(?s)\Aabc/(*COMMIT)(?:.*?/)??abc\z 416 417/**\/*a*b*g*n*t/ 418(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?b)(?>[^/]*?g)(?>[^/]*?n)(?>[^/]*?t\z) 419 abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt 420 0: /abcdefghijklmnop.txt 421 422/**\/*a*\/**/ 423(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?/) 424 xx/xx/xx/xax/xx/xb 425 0: /xax/ 426 427/**\/*a*/ 428(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*+\z) 429 xx/xx/xx/xax 430 0: /xax 431 xx/xx/xx/xax/xx 432No match 433 434/**\/*a*\/**\/*b*/ 435(?s)(?:\A|/)(?>[^/]*?a)(?>[^/]*?/)(*COMMIT)(?:.*?/)??(?>[^/]*?b)(?>[^/]*+\z) 436 xx/xx/xx/xax/xx/xb 437 0: /xax/xx/xb 438 xx/xx/xx/xax/xx/x 439No match 440 441"**a"convert=glob 442(?s)a\z 443 a 444 0: a 445 c/b/a 446 0: a 447 c/b/aaa 448 0: a 449 450"a**/b"convert=glob 451(?s)\Aa(*COMMIT).*?/b\z 452 a/b 453 0: a/b 454 ab 455No match 456 457"a/**b"convert=glob 458(?s)\Aa/(*COMMIT).*?b\z 459 a/b 460 0: a/b 461 ab 462No match 463 464#pattern convert=glob:glob_no_starstar 465 466/***/ 467(?s)\A[^/]*+\z 468 469/**a**/ 470(?s)\A[^/]*?a(*COMMIT)[^/]*+\z 471 472#pattern convert=unset 473#pattern convert=glob:glob_no_wild_separator 474 475/*/ 476(?s) 477 478/*a*/ 479(?s)a 480 481/**a**/ 482(?s)a 483 484/a*b/ 485(?s)\Aa(*COMMIT).*?b\z 486 487/*a*b*/ 488(?s)a(*COMMIT).*?b 489 490/??a??/ 491(?s)\A..a..\z 492 493#pattern convert=unset 494#pattern convert=glob,convert_glob_escape=0 495 496/a\b\cd/ 497(?s)\Aa\\b\\cd\z 498 499/**\/a/ 500(?s)\\/a\z 501 502/a`*b/convert_glob_escape=` 503(?s)\Aa\*b\z 504 505/a`*b/convert_glob_escape=0 506(?s)\Aa`(*COMMIT)[^/]*?b\z 507 508/a`*b/convert_glob_escape=x 509** Invalid glob escape 'x' 510 511# -------- Tests of extended POSIX conversion -------- 512 513#pattern convert=unset:posix_extended 514 515/<[[:a[:digit:]b]>/ 516(*NUL)<[[:a[:digit:]b]> 517 <[> 518 0: <[> 519 <:> 520 0: <:> 521 <a> 522 0: <a> 523 <9> 524 0: <9> 525 <b> 526 0: <b> 527\= Expect no match 528 <d> 529No match 530 531/a+\1b\\c|d[ab\c]/ 532(*NUL)a+1b\\c|d[ab\\c] 533 534/<[]bc]>/ 535(*NUL)<[]bc]> 536 <]> 537 0: <]> 538 <b> 539 0: <b> 540 <c> 541 0: <c> 542 543/<[^]bc]>/ 544(*NUL)<[^]bc]> 545 <.> 546 0: <.> 547\= Expect no match 548 <]> 549No match 550 <b> 551No match 552 553/(a)\1b/ 554(*NUL)(a)1b 555 a1b 556 0: a1b 557 1: a 558\= Expect no match 559 aab 560No match 561 562/(ab)c)d]/ 563(*NUL)(ab)c\)d\] 564 Xabc)d]Y 565 0: abc)d] 566 1: ab 567 568/a***b/ 569(*NUL)a*b 570 571# -------- Tests of basic POSIX conversion -------- 572 573#pattern convert=unset:posix_basic 574 575/a*b+c\+[def](ab)\(cd\)/ 576(*NUL)a*b\+c\+[def]\(ab\)(cd) 577 578/\(a\)\1b/ 579(*NUL)(a)\1b 580 aab 581 0: aab 582 1: a 583\= Expect no match 584 a1b 585No match 586 587/how.to how\.to/ 588(*NUL)how.to how\.to 589 how\nto how.to 590 0: how\x0ato how.to 591\= Expect no match 592 how\x{0}to how.to 593No match 594 595/^how to \^how to/ 596(*NUL)^how to \^how to 597 598/^*abc/ 599(*NUL)^\*abc 600 601/*abc/ 602(*NUL)\*abc 603 X*abcY 604 0: *abc 605 606/**abc/ 607(*NUL)\**abc 608 XabcY 609 0: abc 610 X*abcY 611 0: *abc 612 X**abcY 613 0: **abc 614 615/*ab\(*cd\)/ 616(*NUL)\*ab(\*cd) 617 618/^b\(c^d\)\(^e^f\)/ 619(*NUL)^b(c\^d)(^e\^f) 620 621/a***b/ 622(*NUL)a*b 623 624# End of testinput24 625