forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2a0af7f
committed
Allow complemented character class escapes within regex brackets.
The complement-class escapes \D, \S, \W are now allowed withinbracket expressions. There is no semantic difficulty with doingthat, but the rather hokey macro-expansion-based implementationpreviously used here couldn't cope.Also, invent "word" as an allowed character class name, thus "\w"is now equivalent to "[[:word:]]" outside brackets, or "[:word:]"within brackets. POSIX allows such implementation-specificextensions, and the same name is used in e.g. bash.One surprising compatibility issue this raises is that constructssuch as "[\w-_]" are now disallowed, as our documentation has alwayssaid they should be: character classes can't be endpoints of a range.Previously, because \w was just a macro for "[:alnum:]_", such aconstruct was read as "[[:alnum:]_-_]", so it was accepted so long asthe character after "-" was numerically greater than or equal to "_".Some implementation cleanup along the way:* Remove the lexnest() hack, and in consequence clean up wordchrs()to not interact with the lexer.* Fix colorcomplement() to not be O(N^2) in the number of colorsinvolved.* Get rid of useless-as-far-as-I-can-see calls of element()on single-character character element names in brackpart().element() always maps these to the character itself, and thingswould be quite broken if it didn't --- should "[a]" match somethingdifferent than "a" does? Besides, the shortcut path in brackpart()wasn't doing this anyway, making it even more inconsistent.Discussion:https://postgr.es/m/2845172.1613674385@sss.pgh.pa.usDiscussion:https://postgr.es/m/3220564.1613859619@sss.pgh.pa.us1 parent6b40d9b commit2a0af7f
File tree
10 files changed
+672
-271
lines changed- doc/src/sgml
- src
- backend/regex
- include/regex
- test/modules/test_regex
- expected
- sql
10 files changed
+672
-271
lines changedLines changed: 12 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6097 | 6097 |
| |
6098 | 6098 |
| |
6099 | 6099 |
| |
| 6100 | + | |
| 6101 | + | |
| 6102 | + | |
6100 | 6103 |
| |
6101 | 6104 |
| |
6102 | 6105 |
| |
| |||
6108 | 6111 |
| |
6109 | 6112 |
| |
6110 | 6113 |
| |
6111 |
| - | |
6112 |
| - | |
6113 |
| - | |
| 6114 | + | |
| 6115 | + | |
| 6116 | + | |
6114 | 6117 |
| |
6115 | 6118 |
| |
6116 | 6119 |
| |
| |||
6330 | 6333 |
| |
6331 | 6334 |
| |
6332 | 6335 |
| |
6333 |
| - | |
6334 |
| - | |
| 6336 | + | |
6335 | 6337 |
| |
6336 | 6338 |
| |
6337 | 6339 |
| |
| |||
6346 | 6348 |
| |
6347 | 6349 |
| |
6348 | 6350 |
| |
6349 |
| - | |
6350 |
| - | |
| 6351 | + | |
6351 | 6352 |
| |
6352 | 6353 |
| |
6353 | 6354 |
| |
6354 | 6355 |
| |
6355 | 6356 |
| |
6356 | 6357 |
| |
6357 |
| - | |
6358 |
| - | |
6359 |
| - | |
6360 |
| - | |
| 6358 | + | |
| 6359 | + | |
| 6360 | + | |
| 6361 | + | |
6361 | 6362 |
| |
6362 |
| - | |
6363 |
| - | |
6364 | 6363 |
| |
6365 | 6364 |
| |
6366 | 6365 |
| |
|
Lines changed: 4 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
519 | 519 |
| |
520 | 520 |
| |
521 | 521 |
| |
522 |
| - | |
523 |
| - | |
524 |
| - | |
525 |
| - | |
526 |
| - | |
527 |
| - | |
528 |
| - | |
529 |
| - | |
530 |
| - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
531 | 526 |
| |
532 | 527 |
| |
533 | 528 |
| |
|
Lines changed: 30 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
936 | 936 |
| |
937 | 937 |
| |
938 | 938 |
| |
939 |
| - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
940 | 949 |
| |
941 | 950 |
| |
942 | 951 |
| |
| |||
1062 | 1071 |
| |
1063 | 1072 |
| |
1064 | 1073 |
| |
| 1074 | + | |
1065 | 1075 |
| |
1066 | 1076 |
| |
1067 | 1077 |
| |
1068 | 1078 |
| |
1069 | 1079 |
| |
1070 | 1080 |
| |
1071 | 1081 |
| |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
1072 | 1095 |
| |
1073 |
| - | |
1074 |
| - | |
1075 |
| - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
1076 | 1102 |
| |
1077 | 1103 |
| |
1078 | 1104 |
| |
|
Lines changed: 16 additions & 150 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
196 |
| - | |
197 |
| - | |
198 |
| - | |
199 |
| - | |
200 |
| - | |
201 |
| - | |
202 |
| - | |
203 |
| - | |
204 |
| - | |
205 |
| - | |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
210 |
| - | |
211 |
| - | |
212 |
| - | |
213 |
| - | |
214 |
| - | |
215 |
| - | |
216 |
| - | |
217 |
| - | |
218 |
| - | |
219 |
| - | |
220 |
| - | |
221 |
| - | |
222 |
| - | |
223 |
| - | |
224 |
| - | |
225 |
| - | |
226 |
| - | |
227 |
| - | |
228 |
| - | |
229 |
| - | |
230 |
| - | |
231 |
| - | |
232 |
| - | |
233 |
| - | |
234 |
| - | |
235 |
| - | |
236 |
| - | |
237 |
| - | |
238 |
| - | |
239 |
| - | |
240 |
| - | |
241 |
| - | |
242 |
| - | |
243 |
| - | |
244 |
| - | |
245 |
| - | |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 |
| - | |
250 |
| - | |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
256 |
| - | |
257 |
| - | |
258 |
| - | |
259 |
| - | |
260 |
| - | |
261 |
| - | |
262 |
| - | |
263 |
| - | |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
270 |
| - | |
271 |
| - | |
272 |
| - | |
273 | 196 |
| |
274 | 197 |
| |
275 | 198 |
| |
| |||
292 | 215 |
| |
293 | 216 |
| |
294 | 217 |
| |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
301 |
| - | |
302 |
| - | |
303 | 218 |
| |
304 | 219 |
| |
305 | 220 |
| |
| |||
420 | 335 |
| |
421 | 336 |
| |
422 | 337 |
| |
423 |
| - | |
| 338 | + | |
| 339 | + | |
424 | 340 |
| |
425 | 341 |
| |
426 | 342 |
| |
| 343 | + | |
| 344 | + | |
427 | 345 |
| |
428 | 346 |
| |
429 |
| - | |
430 |
| - | |
431 |
| - | |
432 |
| - | |
433 |
| - | |
434 |
| - | |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
439 |
| - | |
440 |
| - | |
441 |
| - | |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
448 |
| - | |
449 | 347 |
| |
450 | 348 |
| |
451 | 349 |
| |
| |||
691 | 589 |
| |
692 | 590 |
| |
693 | 591 |
| |
694 |
| - | |
695 |
| - | |
696 |
| - | |
697 |
| - | |
698 |
| - | |
699 |
| - | |
700 |
| - | |
701 |
| - | |
702 |
| - | |
703 |
| - | |
704 |
| - | |
705 |
| - | |
706 |
| - | |
707 |
| - | |
708 |
| - | |
709 |
| - | |
710 |
| - | |
711 |
| - | |
712 |
| - | |
713 |
| - | |
714 |
| - | |
715 |
| - | |
716 |
| - | |
717 |
| - | |
718 |
| - | |
719 |
| - | |
720 |
| - | |
721 |
| - | |
722 |
| - | |
723 |
| - | |
724 |
| - | |
725 |
| - | |
726 |
| - | |
727 |
| - | |
728 |
| - | |
729 |
| - | |
| 592 | + | |
730 | 593 |
| |
731 | 594 |
| |
732 | 595 |
| |
733 | 596 |
| |
734 |
| - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
735 | 601 |
| |
736 |
| - | |
| 602 | + | |
737 | 603 |
| |
738 | 604 |
| |
739 | 605 |
| |
| |||
775 | 641 |
| |
776 | 642 |
| |
777 | 643 |
| |
778 |
| - | |
| 644 | + | |
779 | 645 |
| |
780 | 646 |
| |
781 | 647 |
| |
782 |
| - | |
| 648 | + | |
783 | 649 |
| |
784 | 650 |
| |
785 | 651 |
| |
| |||
802 | 668 |
| |
803 | 669 |
| |
804 | 670 |
| |
805 |
| - | |
| 671 | + | |
806 | 672 |
| |
807 | 673 |
| |
808 | 674 |
| |
809 |
| - | |
| 675 | + | |
810 | 676 |
| |
811 | 677 |
| |
812 | 678 |
| |
| |||
828 | 694 |
| |
829 | 695 |
| |
830 | 696 |
| |
831 |
| - | |
| 697 | + | |
832 | 698 |
| |
833 | 699 |
| |
834 | 700 |
| |
835 |
| - | |
| 701 | + | |
836 | 702 |
| |
837 | 703 |
| |
838 | 704 |
| |
|
0 commit comments
Comments
(0)