summaryrefslogtreecommitdiff
path: root/testsuite/uniq.inp
blob: b1eddf3a99a90995d9b87c978b338b2ac2dedd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
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
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058









































































































































































































































































































































#define DPRINTF(p)		/*nothing */
#define DPRINTF(p) printf p
#define GETCHAR(c, eptr) c = *eptr;
#define GETCHARINC(c, eptr) c = *eptr++;
#define class pcre_class
#define match_condassert   0x01	/* Called to check a condition assertion */
#define match_isgroup      0x02	/* Set if start of bracketed group */
#else
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#ifdef DEBUG			/* Sigh. Some compilers never learn. */
#ifdef DEBUG			/* Sigh. Some compilers never learn. */
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef DEBUG
#ifdef __cplusplus
#include "internal.h"
&& length - re->max_match_size > start_offset)
((*ecode++ == OP_BEG_WORD) ? prev_is_word : cur_is_word))
((md->ctypes[*eptr] & ctype_word) != 0);
((md->ctypes[*eptr] & ctype_word) != 0);
((md->ctypes[eptr[-1]] & ctype_word) != 0);
((md->ctypes[eptr[-1]] & ctype_word) != 0);
(eptr == md->end_subject - 1 && *eptr != '\n'))
(eptr == md->end_subject - 1 && *eptr != '\n'))
(i.e. keep it out of the loop). Also we can test that there are at least
(md->ctypes[*eptr++] & ctype_digit) != 0)
(md->ctypes[*eptr++] & ctype_digit) == 0)
(md->ctypes[*eptr++] & ctype_space) != 0)
(md->ctypes[*eptr++] & ctype_space) == 0)
(md->ctypes[*eptr++] & ctype_word) != 0)
(md->ctypes[*eptr++] & ctype_word) == 0)
(offsetcount - 2) * sizeof (int));
(offsets == NULL && offsetcount > 0))
(pcre_free) (match_block.offset_vector);
(pcre_free) (match_block.offset_vector);
(pcre_free) (save);
(re->tables + fcc_offset)[req_char] : req_char;
*          Match a back-reference                *
*         Execute a Regular Expression           *
*         Match from current position            *
*        Debugging function to print chars       *
*      Perl-Compatible Regular Expressions       *
*    Macros and tables for character handling    *
*************************************************/
*************************************************/
*************************************************/
*************************************************/
*************************************************/
*************************************************/
*/
*/
*/
*/
*/
*iptr = -1;
*iptr++ = -1;
*prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
*prev == OP_ONCE)
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-1 => failed to match
/*
/* "Once" brackets are like assertion brackets except that after a match,
/* ... else fall through */
/* ... else fall through */
/* Advance to a possible match for an initial string after study */
/* Allow compilation as C++ source code, should anybody want to do that. */
/* Always fail if not enough characters left */
/* An alternation is the end of a branch; scan along to find the end of the
/* Assert before internal newline if multiline, or before a terminating
/* Assertion brackets. Check the alternative branches in turn - the
/* At the start of a bracketed group, add the current subject pointer to the
/* BRAZERO and BRAMINZERO occur just before a bracket group, indicating
/* Caseful comparisons */
/* Caseful comparisons */
/* Change option settings */
/* Common code for all repeated single character type matches */
/* Common code for all repeated single-character matches. We can give
/* Common code for all repeated single-character matches. We can give
/* Compute the minimum number of offsets that we need to reset each time. Doing
/* Conditional group: compilation checked that there are no more than
/* Continue as from after the assertion, updating the offsets high water
/* Continue from after the assertion, updating the offsets high water
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never gets here */
/* Control never reaches here */
/* Control never reaches here */
/* Copy the offset information from temporary store if necessary */
/* Do a single test if no case difference is set up */
/* Do not stick any code in here without much thought; it is assumed
/* End of a group, repeated or non-repeating. If we are at the end of
/* End of subject assertion (\z) */
/* End of subject or ending \n assertion (\Z) */
/* End of the pattern. If PCRE_NOTEMPTY is set, fail if we have matched
/* First, ensure the minimum number of matches are present. */
/* First, ensure the minimum number of matches are present. Use inline
/* First, ensure the minimum number of matches are present. We get back
/* Flag bits for the match() function */
/* For a non-repeating ket, just continue at this level. This also
/* For a non-repeating ket, just continue at this level. This also
/* For anchored or unanchored matches, there may be a "last known required
/* For extended extraction brackets (large number), we have to fish out
/* For extended extraction brackets (large number), we have to fish out the
/* For matches anchored to the end of the pattern, we can often avoid
/* If a back reference hasn't been set, the length that is passed is greater
/* If checking an assertion for a condition, return TRUE. */
/* If hit the end of the group (which could be repeated), fail */
/* If max == min we can continue with the main loop without the
/* If maximizing it is worth using inline code for speed, doing the type
/* If maximizing, find the longest possible run, then work backwards. */
/* If maximizing, find the longest string and work backwards */
/* If min = max, continue at the same level without recursing */
/* If min = max, continue at the same level without recursion.
/* If minimizing, keep testing the rest of the expression and advancing
/* If minimizing, keep trying and advancing the pointer */
/* If minimizing, we have to test the rest of the pattern before each
/* If req_char is set, we know that that character must appear in the subject
/* If the expression has got more back references than the offsets supplied can
/* If the length of the reference is zero, just continue with the
/* If the reference is unset, set the length to be longer than the amount
/* If we can't find the required character, break the matching loop */
/* If we have found the required character, save the point where we
/* In all other cases except a conditional group we have to check the
/* In case the recursion has set more capturing values, save the final
/* Include the internals header, which itself includes Standard C headers plus
/* Insufficient room for saving captured contents */
/* Loop for handling unanchored repeated matching attempts; for anchored regexs
/* Match a back reference, possibly repeatedly. Look past the end of the
/* Match a character class, possibly repeatedly. Look past the end of the
/* Match a negated single character */
/* Match a negated single character repeatedly. This is almost a repeat of
/* Match a run of characters */
/* Match a single character repeatedly; different opcodes share code. */
/* Match a single character type repeatedly; several different opcodes
/* Match a single character type; inline for speed */
/* Min and max values for the common repeats; for the maxima, 0 => infinity */
/* Move the subject pointer back. This occurs only at the start of
/* Negative assertion: all branches must fail to match */
/* Now start processing the operations. */
/* OP_KETRMAX */
/* OP_KETRMAX */
/* On entry ecode points to the first opcode, and eptr to the first character
/* Opening capturing bracket. If there is space in the offset vector, save
/* Or to a non-unique first char after study */
/* Or to a unique first char if possible */
/* Or to just after \n for a multiline match if possible */
/* Other types of node can be handled by a switch */
/* Otherwise test for either case */
/* Print a sequence of chars in printable format, stopping at the end of the
/* Recursion matches the current regex, nested. If there are any capturing
/* Reset the maximum number of extractions we might see. */
/* Reset the value of the ims flags, in case they got changed during
/* Reset the working variable associated with each extraction. These should
/* Separate the caselesss case for speed */
/* Set up for repetition, or handle the non-repeated case */
/* Set up the first character to match, if available. The first_char value is
/* Skip over conditional reference data or large extraction number data if
/* Start of subject assertion */
/* Start of subject unless notbol, or after internal newline if multiline */
/* Structure for building a chain of data that actually lives on the
/* The code is duplicated for the caseless and caseful cases, for speed,
/* The code is duplicated for the caseless and caseful cases, for speed,
/* The condition is an assertion. Call match() to evaluate it - setting
/* The ims options can vary during the matching as a result of the presence
/* The repeating kets try the rest of the pattern or restart from the
/* The repeating kets try the rest of the pattern or restart from the
/* There's been some horrible disaster. */
/* This "while" is the end of the "do" above */
/* This function applies a compiled re to a subject string and picks out
/* Use a macro for debugging printing, 'cause that limits the use of #ifdef
/* We don't need to repeat the search if we haven't yet reached the
/* When a match occurs, substrings will be set for all internal extractions;
/* Word boundary assertions */
/*************************************************
/*************************************************
/*************************************************
/*************************************************
/*************************************************
/*************************************************
1. This software is distributed in the hope that it will be useful,
2. The origin of this software must not be misrepresented, either by
3. Altered versions must be plainly marked as such, and must not be
4. If PCRE is embedded in any software that is released under the GNU
5.005. If there is an options reset, it will get obeyed in the normal
5.005. If there is an options reset, it will get obeyed in the normal
6 : 3 + (ecode[1] << 8) + ecode[2]),
< -1 => some kind of unexpected problem
= 0 => success, but offsets is not big enough
Arguments:
Arguments:
Arguments:
Arguments:
BOOL anchored;
BOOL cur_is_word = (eptr < md->end_subject) &&
BOOL cur_is_word = (eptr < md->end_subject) &&
BOOL is_subject;
BOOL minimize = FALSE;
BOOL prev_is_word = (eptr != md->start_subject) &&
BOOL prev_is_word = (eptr != md->start_subject) &&
BOOL rc;
BOOL startline;
BOOL using_temporary_offsets = FALSE;
Copyright (c) 1997-2000 University of Cambridge
DPRINTF ((">>>> returning %d\n", match_block.errorcode));
DPRINTF ((">>>> returning %d\n", rc));
DPRINTF (("Copied offsets from temporary memory\n"));
DPRINTF (("Freeing temporary memory\n"));
DPRINTF (("Freeing temporary memory\n"));
DPRINTF (("Got memory to hold back references\n"));
DPRINTF (("Unknown opcode %d\n", *ecode));
DPRINTF (("bracket %d failed\n", number));
DPRINTF (("bracket 0 failed\n"));
DPRINTF (("ims reset to %02lx\n", ims));
DPRINTF (("ims set to %02lx at group repeat\n", ims));
DPRINTF (("ims set to %02lx\n", ims));
DPRINTF (("matching %c{%d,%d} against subject %.*s\n", c, min, max,
DPRINTF (("negative matching %c{%d,%d} against subject %.*s\n", c, min, max,
DPRINTF (("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
DPRINTF (("start bracket 0\n"));
GETCHAR (c, eptr)	/* Get character */
GETCHARINC (c, eptr)	/* Get character; increment eptr */
GETCHARINC (c, eptr)	/* Get character; increment eptr */
General Purpose Licence (GPL), then the terms of that licence shall
However, if the referenced string is the empty string, always treat
If the bracket fails to match, we need to restore this value and also the
If there isn't enough space in the offset vector, treat this as if it were a
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Otherwise, we can use the vector supplied, rounding down its size to a multiple
Permission is granted to anyone to use this software for any purpose on any
REPEATCHAR:
REPEATNOTCHAR:
REPEATTYPE:
Returns:          > 0 => success; value is the number of elements filled in
Returns:       TRUE if matched
Returns:      TRUE if matched
Returns:     nothing
They are not both allowed to be zero. */
This is a library of functions to support regular expressions whose syntax
This is the forcible breaking of infinite loops as implemented in Perl
This is the forcible breaking of infinite loops as implemented in Perl
Writing separate code makes it go faster, as does using an autoincrement and
Written by: Philip Hazel <ph10@cam.ac.uk>
a move back into the brackets. Check the alternative branches in turn - the
address of eptr, so that eptr can be a register variable. */
an assertion "group", stop matching and return TRUE, but record the
an empty string - recursion will then try other alternatives, if any. */
an error. Save the top 15 values on the stack, and accept that the rest
an unanchored pattern, of course. If there's no first char and the pattern was
analyzing most of the pattern.  length > re->max_match_size is
anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
and advance one byte in the pattern code. */
and reinstate them after the recursion. However, we don't know how many
and semantics are as close as possible to those of the Perl 5 language. See
and the required character in fact is caseful. */
at run time, so we have to test for anchoring. The first char may be unset for
avoid duplicate testing (which takes significant time). This covers the vast
backing off on a match. */
bmtable = extra->data.bmtable;
both cases of the character. Otherwise set the two values the same, which will
bracketed group and go to there. */
brackets - for testing for empty matches
brackets started but not finished, we have to save their starting points
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
but WITHOUT ANY WARRANTY; without even the implied warranty of
c != md->lcc[*eptr++])
c = *ecode++ - OP_CRSTAR;
c = *ecode++ - OP_CRSTAR;
c = *ecode++ - OP_NOTSTAR;
c = *ecode++ - OP_STAR;
c = *ecode++ - OP_TYPESTAR;
c = *ecode++;
c = *ecode++;
c = *eptr++;
c = 15;
c = max - min;
c = md->end_subject - eptr;
c = md->lcc[c];
c = md->lcc[c];
c = md->offset_max;
c == md->lcc[*eptr++])
can't just fail here, because of the possibility of quantifiers with zero
case OP_ALT:
case OP_ANY:
case OP_ANY:
case OP_ANY:
case OP_ANY:
case OP_ASSERT:
case OP_ASSERTBACK:
case OP_ASSERTBACK_NOT:
case OP_ASSERT_NOT:
case OP_BEG_WORD:
case OP_BRA:		/* Non-capturing bracket: optimized */
case OP_BRAMINZERO:
case OP_BRANUMBER:
case OP_BRAZERO:
case OP_CHARS:
case OP_CIRC:
case OP_CLASS:
case OP_COND:
case OP_CREF:
case OP_CRMINPLUS:
case OP_CRMINPLUS:
case OP_CRMINQUERY:
case OP_CRMINQUERY:
case OP_CRMINRANGE:
case OP_CRMINRANGE:
case OP_CRMINSTAR:
case OP_CRMINSTAR:
case OP_CRPLUS:
case OP_CRPLUS:
case OP_CRQUERY:
case OP_CRQUERY:
case OP_CRRANGE:
case OP_CRRANGE:
case OP_CRSTAR:
case OP_CRSTAR:
case OP_DIGIT:
case OP_DIGIT:
case OP_DIGIT:
case OP_DIGIT:
case OP_DOLL:
case OP_END:
case OP_END_WORD:
case OP_EOD:
case OP_EODN:
case OP_EXACT:
case OP_KET:
case OP_KETRMAX:
case OP_KETRMIN:
case OP_MINPLUS:
case OP_MINQUERY:
case OP_MINSTAR:
case OP_MINUPTO:
case OP_NOT:
case OP_NOTEXACT:
case OP_NOTMINPLUS:
case OP_NOTMINQUERY:
case OP_NOTMINSTAR:
case OP_NOTMINUPTO:
case OP_NOTPLUS:
case OP_NOTQUERY:
case OP_NOTSTAR:
case OP_NOTUPTO:
case OP_NOT_DIGIT:
case OP_NOT_DIGIT:
case OP_NOT_DIGIT:
case OP_NOT_DIGIT:
case OP_NOT_WHITESPACE:
case OP_NOT_WHITESPACE:
case OP_NOT_WHITESPACE:
case OP_NOT_WHITESPACE:
case OP_NOT_WORDCHAR:
case OP_NOT_WORDCHAR:
case OP_NOT_WORDCHAR:
case OP_NOT_WORDCHAR:
case OP_NOT_WORD_BOUNDARY:
case OP_ONCE:
case OP_OPT:
case OP_PLUS:
case OP_QUERY:
case OP_RECURSE:
case OP_REF:
case OP_REVERSE:
case OP_SOD:
case OP_STAR:
case OP_TYPEEXACT:
case OP_TYPEMINPLUS:
case OP_TYPEMINQUERY:
case OP_TYPEMINSTAR:
case OP_TYPEMINUPTO:
case OP_TYPEPLUS:
case OP_TYPEQUERY:
case OP_TYPESTAR:
case OP_TYPEUPTO:
case OP_UPTO:
case OP_WHITESPACE:
case OP_WHITESPACE:
case OP_WHITESPACE:
case OP_WHITESPACE:
case OP_WORDCHAR:
case OP_WORDCHAR:
case OP_WORDCHAR:
case OP_WORDCHAR:
case OP_WORD_BOUNDARY:
case matching may be when this character is hit, so test for it in both its
caselessly, or if there are any changes of this flag within the regex, set up
cases if necessary. However, the different cased versions will not be set up
character" set. If the PCRE_CASELESS is set, implying that the match starts
characters and work backwards. */
characters and work backwards. */
code for maximizing the speed, and do the type test once at the start
code to character type repeats - written out again for speed. */
commoning these up that doesn't require a test of the positive/negative
computer system, and to redistribute it freely, subject to the following
const char *subject;
const pcre *re;
const pcre_extra *extra;
const uschar *bmtable = NULL;
const uschar *data = ecode + 1;	/* Save for matching */
const uschar *end_subject;
const uschar *next = ecode + 1;
const uschar *next = ecode + 1;
const uschar *p = md->start_subject + md->offset_vector[offset];
const uschar *p;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *pp = eptr;
const uschar *prev = ecode - (ecode[1] << 8) - ecode[2];
const uschar *prev = ecode;
const uschar *req_char_ptr = start_match - 1;
const uschar *saved_eptr = eptr;
const uschar *saved_eptr = eptrb->saved_eptr;
const uschar *saved_eptr;
const uschar *start_bits = NULL;
const uschar *start_match = (const uschar *) subject + start_offset;
continue;	/* With the main loop */
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
continue;
course of events. */
course of events. */
ctype = *ecode++;	/* Code for the character type */
cur_is_word == prev_is_word : cur_is_word != prev_is_word)
current high water mark for use by positive assertions. Do this also
default:		/* No repeat follows */
default:		/* No repeat follows */
default:
do
do
do
do
do
do
do
do
do
do
do
each branch of a lookbehind assertion. If we are too close to the start to
each substring: the offsets to the start and end of the substring.
ecode       position in code
ecode + ((offset < offset_top && md->offset_vector[offset] >= 0) ?
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += (ecode[1] << 8) + ecode[2];
ecode += 2;
ecode += 2;
ecode += 3 + (ecode[4] << 8) + ecode[5];
ecode += 33;	/* Advance past the item */
ecode += 3;		/* Advance past the item */
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 3;
ecode += 5;
ecode += 5;
ecode = next + 3;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
ecode++;
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else
else if ((extra->options & PCRE_STUDY_BM) != 0)
else if (first_char >= 0)
else if (start_bits != NULL)
else if (startline)
encountered */
end_subject = match_block.end_subject;
eptr        pointer in subject
eptr        points into the subject
eptr += c;
eptr += length;
eptr += length;
eptr += length;
eptr += length;
eptr += min;
eptr -= (ecode[1] << 8) + ecode[2];
eptr -= length;
eptr = md->end_match_ptr;
eptr = md->end_match_ptr;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptr++;
eptrb       pointer to chain of blocks containing eptr at start of
eptrb = &newptrb;
eptrb = eptrb->prev;	/* Back up the stack of bracket start pointers */
eptrblock *eptrb;
eptrblock newptrb;
eptrblock;
exactly what going to the ket would do. */
explicit claim or by omission.
external_extra  points to "hints" from pcre_study() or is NULL
external_re     points to the compiled expression
extraction by setting the offsets and bumping the high water mark. */
first_char = match_block.lcc[first_char];
first_char = re->first_char;
flags       can contain
for (;;)
for (i = 1; i <= c; i++)
for (i = 1; i <= c; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = 1; i <= min; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min; i < max; i++)
for (i = min;; i++)
for (i = min;; i++)
for (i = min;; i++)
for (i = min;; i++)
for (i = min;; i++)
for (i = min;; i++)
for (i = min;; i++)
for the "once" (not-backup up) groups. */
for the match to succeed. If the first character is set, req_char must be
found it, so that we don't search again next time round the loop if
from a previous iteration of this group, and be referred to by a reference
goto REPEATCHAR;
goto REPEATCHAR;
goto REPEATNOTCHAR;
goto REPEATNOTCHAR;
goto REPEATTYPE;
goto REPEATTYPE;
group number back at the start and if necessary complete handling an
happens for a repeating ket if no characters were matched in the group.
happens for a repeating ket if no characters were matched in the group.
here; that is handled in the code for KET. */
hold, we get a temporary bit of working store to use during the matching.
i.e. it could be ()* or ()? in the pattern. Brackets with fixed upper
if (!anchored)
if (!match (start_match, re->code, 2, &match_block, ims, NULL, match_isgroup))
if (!match_ref (offset, eptr, length, md, ims))
if (!match_ref (offset, eptr, length, md, ims))
if (!match_ref (offset, eptr, length, md, ims))
if (!md->endonly)
if (!rc)
if (!startline && extra != NULL)
if ((*ecode++ == OP_WORD_BOUNDARY) ?
if ((data[c / 8] & (1 << (c & 7))) != 0)
if ((data[c / 8] & (1 << (c & 7))) != 0)
if ((data[c / 8] & (1 << (c & 7))) == 0)
if ((extra->options & PCRE_STUDY_MAPPED) != 0)
if ((flags & match_condassert) != 0)
if ((flags & match_condassert) != 0)
if ((flags & match_isgroup) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_CASELESS) != 0)
if ((ims & PCRE_DOTALL) == 0 && c == '\n')
if ((ims & PCRE_DOTALL) == 0 && eptr < md->end_subject && *eptr == '\n')
if ((ims & PCRE_DOTALL) == 0)
if ((ims & PCRE_DOTALL) == 0)
if ((ims & PCRE_MULTILINE) != 0)
if ((ims & PCRE_MULTILINE) != 0)
if ((md->ctypes[*eptr++] & ctype_digit) != 0)
if ((md->ctypes[*eptr++] & ctype_digit) == 0)
if ((md->ctypes[*eptr++] & ctype_space) != 0)
if ((md->ctypes[*eptr++] & ctype_space) == 0)
if ((md->ctypes[*eptr++] & ctype_word) != 0)
if ((md->ctypes[*eptr++] & ctype_word) == 0)
if ((md->ctypes[c] & ctype_digit) != 0)
if ((md->ctypes[c] & ctype_digit) == 0)
if ((md->ctypes[c] & ctype_space) != 0)
if ((md->ctypes[c] & ctype_space) == 0)
if ((md->ctypes[c] & ctype_word) != 0)
if ((md->ctypes[c] & ctype_word) == 0)
if ((options & ~PUBLIC_EXEC_OPTIONS) != 0)
if ((re->options & PCRE_FIRSTSET) != 0)
if ((re->options & PCRE_REQCHSET) != 0)
if ((start_bits[c / 8] & (1 << (c & 7))) == 0)
if (*ecode != OP_ONCE && *ecode != OP_ALT)
if (*ecode == OP_KET || eptr == saved_eptr)
if (*ecode == OP_KET || eptr == saved_eptr)
if (*ecode == OP_KET)
if (*ecode == OP_KETRMIN)
if (*ecode == OP_KETRMIN)
if (*ecode++ != *eptr++)
if (*ecode++ == *eptr++)
if (*eptr != '\n')
if (*eptr++ == '\n')
if (*p++ != *eptr++)
if (*p++ == req_char)
if (*prev != OP_COND)
if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
if (bmtable != NULL)
if (bmtable[*start_match])
if (c != *eptr++)
if (c != md->lcc[*eptr++])
if (c < 16)
if (c == *eptr++)
if (c == md->lcc[*eptr++])
if (c > md->end_subject - eptr)
if (cur_is_word == prev_is_word ||
if (ecode[3] == OP_CREF)	/* Condition is extraction test */
if (ecode[3] == OP_OPT)
if (eptr != md->start_subject && eptr[-1] != '\n')
if (eptr != md->start_subject)
if (eptr < md->end_subject - 1 ||
if (eptr < md->end_subject - 1 ||
if (eptr < md->end_subject)
if (eptr < md->end_subject)
if (eptr < md->start_subject)
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject ||
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) != 0)
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_digit) == 0)
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) != 0)
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_space) == 0)
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) != 0)
if (eptr >= md->end_subject || (md->ctypes[*eptr] & ctype_word) == 0)
if (eptr >= md->end_subject || *eptr == '\n')
if (eptr >= md->end_subject || c != *eptr)
if (eptr >= md->end_subject || c != md->lcc[*eptr])
if (eptr >= md->end_subject || c == *eptr)
if (eptr >= md->end_subject || c == md->lcc[*eptr])
if (eptr >= md->end_subject)
if (eptr >= md->end_subject)
if (eptr >= md->end_subject)
if (eptr >= md->end_subject)
if (eptr >= md->end_subject)
if (eptr++ >= md->end_subject)
if (i >= max || !match_ref (offset, eptr, length, md, ims))
if (i >= max || eptr >= md->end_subject ||
if (i >= max || eptr >= md->end_subject ||
if (i >= max || eptr >= md->end_subject || c != *eptr++)
if (i >= max || eptr >= md->end_subject || c == *eptr++)
if (i >= max || eptr >= md->end_subject)
if (i >= max || eptr >= md->end_subject)
if (is_subject && length > md->end_subject - p)
if (isprint (c = *(p++)))
if (length == 0)
if (length > md->end_subject - eptr)
if (length > md->end_subject - eptr)
if (match (eptr, ecode + 3, offset_top, md, ims, NULL,
if (match (eptr, ecode + 3, offset_top, md, ims, NULL, match_isgroup))
if (match (eptr, ecode + 3, offset_top, md, ims, NULL, match_isgroup))
if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0) ||
if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0) ||
if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
if (match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr, next + 3, offset_top, md, ims, eptrb, match_isgroup))
if (match (eptr, next, offset_top, md, ims, eptrb, match_isgroup))
if (match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
if (match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup) ||
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match (eptr--, ecode, offset_top, md, ims, eptrb, 0))
if (match_block.end_offset_top > offsetcount)
if (match_block.offset_vector != NULL)
if (match_block.offset_vector == NULL)
if (max == 0)
if (max == 0)
if (max == 0)
if (max == 0)
if (max == 0)
if (max == 0)
if (max == 0)
if (md->lcc[*ecode++] != md->lcc[*eptr++])
if (md->lcc[*ecode++] == md->lcc[*eptr++])
if (md->lcc[*p++] != md->lcc[*eptr++])
if (md->notbol && eptr == md->start_subject)
if (md->notempty && eptr == md->start_match)
if (md->noteol)
if (md->noteol)
if (min == max)
if (min == max)
if (min == max)
if (min == max)
if (min == max)
if (min == max)
if (min == max)
if (min > 0)
if (min > md->end_subject - eptr)
if (min > md->end_subject - eptr)
if (min > md->end_subject - eptr)
if (minimize)
if (minimize)
if (minimize)
if (minimize)
if (minimize)
if (minimize)
if (minimize)
if (number > 0)
if (number > EXTRACT_BASIC_MAX) 
if (number > EXTRACT_BASIC_MAX) 
if (offset < md->offset_max)
if (offset >= md->offset_max)
if (offset_top <= offset)
if (offsetcount < 2)
if (offsetcount >= 4)
if (op > OP_BRA)
if (p > req_char_ptr)
if (p >= end_subject)
if (pp == req_char || pp == req_char2)
if (re == NULL || subject == NULL ||
if (re->magic_number != MAGIC_NUMBER)
if (re->max_match_size >= 0
if (re->top_backref > 0 && re->top_backref >= ocount / 3)
if (req_char == req_char2)
if (req_char >= 0)
if (resetcount > offsetcount)
if (save != stacksave)
if (save == NULL)
if (skipped_chars)
if (start_match + bmtable[256] > end_subject)
if (start_match > match_block.start_subject + start_offset)
if (using_temporary_offsets)
if (using_temporary_offsets)
if certain parts of the pattern were not used. */
if the malloc fails ... there is no way of returning to the top level with
implied in the second condition, because start_offset > 0. */
ims         current /i, /m, and /s options
ims         the ims flags
ims = (ims & ~PCRE_IMS) | ecode[4];
ims = ecode[1];
ims = original_ims;
ims = re->options & (PCRE_CASELESS | PCRE_MULTILINE | PCRE_DOTALL);
in the pattern. */
in the subject string, while eptrb holds the value of eptr at the start of the
initialize them to avoid reading uninitialized locations. */
inline, and there are *still* stupid compilers about that don't like indented
inside the group.
int
int *offsets;
int *save;
int c;
int first_char = -1;
int flags;
int length;
int length;
int length;
int length;
int min, max, ctype;
int number = *prev - OP_BRA;
int number = op - OP_BRA;
int offset = (ecode[1] << 9) | (ecode[2] << 1);		/* Doubled reference number */
int offset = (ecode[4] << 9) | (ecode[5] << 1);	/* Doubled reference number */
int offset;
int offset;
int offset;
int offset_top;
int offsetcount;
int op = (int) *ecode;
int options;
int rc;
int req_char = -1;
int req_char2 = -1;
int resetcount, ocount;
int save_offset1 = md->offset_vector[offset];
int save_offset2 = md->offset_vector[offset + 1];
int save_offset3 = md->offset_vector[md->offset_end - number];
int skipped_chars = 0;
int stacksave[15];
int start_offset;
is a bit large to put on the stack, but using malloc for small numbers
is_subject  TRUE if printing from within md->start_subject
it as matched, any number of times (otherwise there could be infinite
item to see if there is repeat information following. The code is similar
item to see if there is repeat information following. Then obey similar
last bracketed group - used for breaking infinite loops matching zero-length
later in the subject; otherwise the test starts at the match point. This
length          length of subject string (may contain binary zeros)
length      length to be matched
length      number to print
length = (offset >= offset_top || md->offset_vector[offset] < 0) ?
length = md->end_subject - p;
level without recursing. Otherwise, if minimizing, keep trying the rest of
level without recursing. Otherwise, if minimizing, keep trying the rest of
loop. */
loops). */
main loop. */
majority of cases. It will be suboptimal when the case flag changes in a regex
mark, since extracts may have been taken during the assertion. */
mark, since extracts may have been taken. */
match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0))
match (eptr, ecode + 3, offset_top, md, ims, eptrb, 0))
match (eptr, ecode, offset_top, md, ims, eptrb, flags)
match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
match (eptr, prev, offset_top, md, ims, eptrb, match_isgroup))
match_block.ctypes = re->tables + ctypes_offset;
match_block.end_subject = match_block.start_subject + length;
match_block.endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
match_block.errorcode = PCRE_ERROR_NOMATCH;	/* Default error */
match_block.errorcode == PCRE_ERROR_NOMATCH &&
match_block.lcc = re->tables + lcc_offset;
match_block.lcc[*start_match] != first_char)
match_block.notbol = (options & PCRE_NOTBOL) != 0;
match_block.notempty = (options & PCRE_NOTEMPTY) != 0;
match_block.noteol = (options & PCRE_NOTEOL) != 0;
match_block.offset_end = ocount;
match_block.offset_max = (2 * ocount) / 3;
match_block.offset_overflow = FALSE;
match_block.offset_overflow = TRUE;
match_block.offset_vector = (int *) (pcre_malloc) (ocount * sizeof (int));
match_block.offset_vector = offsets;
match_block.start_match = start_match;
match_block.start_pattern = re->code;
match_block.start_subject = (const uschar *) subject;
match_condassert - this is an assertion condition
match_condassert | match_isgroup))
match_data *md;
match_data *md;
match_data *md;
match_data match_block;
match_isgroup - this is the start of a bracketed group
match_isgroup);
match_ref (offset, eptr, length, md, ims)
matches, we carry on as at the end of a normal bracket, leaving the subject
matching won't pass the KET for an assertion. If any one branch matches,
matching won't pass the KET for this kind of subpattern. If any one branch
max = (ecode[1] << 8) + ecode[2];
max = (ecode[1] << 8) + ecode[2];
max = (ecode[1] << 8) + ecode[2];
max = (ecode[3] << 8) + ecode[4];
max = (ecode[3] << 8) + ecode[4];
max = INT_MAX;
max = INT_MAX;
max = INT_MAX;
max = INT_MAX;
max = INT_MAX;
max = INT_MAX;
max = INT_MAX;
max = rep_max[c];	/* zero for max => infinity */
max = rep_max[c];	/* zero for max => infinity */
max = rep_max[c];	/* zero for max => infinity */
max = rep_max[c];	/* zero for max => infinity */
max = rep_max[c];	/* zero for max => infinity */
max, eptr));
max, eptr));
maximum. Alternatively, if maximizing, find the maximum number of
maximum. Alternatively, if maximizing, find the maximum number of
may be wrong. */
md          pointer to "static" info for the match
md          pointer to matching data block, if is_subject is TRUE
md          points to match data block
md->end_match_ptr = eptr;	/* For ONCE */
md->end_match_ptr = eptr;	/* Record where we ended */
md->end_offset_top = offset_top;	/* and how many extracts were taken */
md->end_offset_top = offset_top;
md->end_subject - eptr + 1 :
md->errorcode = PCRE_ERROR_UNKNOWN_NODE;
md->offset_overflow = TRUE;
md->offset_vector[md->offset_end - i] = save[i];
md->offset_vector[md->offset_end - number] = eptr - md->start_subject;
md->offset_vector[md->offset_end - number] = save_offset3;
md->offset_vector[md->offset_end - number];
md->offset_vector[offset + 1] - md->offset_vector[offset];
md->offset_vector[offset + 1] = eptr - md->start_subject;
md->offset_vector[offset + 1] = save_offset2;
md->offset_vector[offset] =
md->offset_vector[offset] = save_offset1;
memcpy (offsets + 2, match_block.offset_vector + 2,
min = (ecode[1] << 8) + ecode[2];
min = (ecode[1] << 8) + ecode[2];
min = 0;
min = 0;
min = 0;
min = max = (ecode[1] << 8) + ecode[2];
min = max = (ecode[1] << 8) + ecode[2];
min = max = (ecode[1] << 8) + ecode[2];
min = max = 1;
min = rep_min[c];	/* Pick up values from tables; */
min = rep_min[c];	/* Pick up values from tables; */
min = rep_min[c];	/* Pick up values from tables; */
min = rep_min[c];	/* Pick up values from tables; */
min = rep_min[c];	/* Pick up values from tables; */
minima. */
minimize = (*ecode == OP_CRMINRANGE);
minimize = (*ecode == OP_CRMINRANGE);
minimize = (c & 1) != 0;
minimize = (c & 1) != 0;
minimize = (c & 1) != 0;
minimize = (c & 1) != 0;
minimize = (c & 1) != 0;
minimize = *ecode == OP_MINUPTO;
minimize = *ecode == OP_NOTMINUPTO;
minimize = *ecode == OP_TYPEMINUPTO;
minimize = TRUE;
minimum number of matches are present. If min = max, continue at the same
minimum number of matches are present. If min = max, continue at the same
misrepresented as being the original software.
move back, this match function fails. */
mustn't change the current values of the data slot, because they may be set
need to recurse. */
never be used unless previously set, but they get saved and restored, and so we
never set for an anchored regular expression, but the anchoring may be forced
newline unless endonly is set, else end of subject unless noteol is set. */
newptrb.prev = eptrb;
newptrb.saved_eptr = eptr;
next += (next[1] << 8) + next[2];
next += (next[1] << 8) + next[2];
non-capturing bracket. Don't worry about setting the flag for the error case
number = (ecode[4] << 8) | ecode[5];
number = (prev[4] << 8) | prev[5];
number from a dummy opcode at the start. */
number, then move along the subject till after the recursive match,
ocount = offsetcount - (offsetcount % 3);
ocount = re->top_backref * 3 + 3;
of (?ims) items in the pattern. They are kept in a local variable so that
of 3. */
of subject left; this ensures that every attempt at a match fails. We
offset      index into the offset vector
offset = number << 1;
offset = number << 1;
offset_top  current top pointer
offset_top = md->end_offset_top;
offset_top = md->end_offset_top;
offset_top = md->end_offset_top;
offset_top = offset + 2;
offset_top, md, ims, eptrb, match_isgroup);
offsetcount     the number of elements in the vector
offsets         points to a vector of ints to be filled in with offsets
offsets[0] = start_match - match_block.start_subject;
offsets[1] = match_block.end_match_ptr - match_block.start_subject;
op = OP_BRA;
opcode. */
optimization can save a huge amount of backtracking in patterns with nested
option for each character match. Maybe that wouldn't add very much to the
options         option bits
p           points to characters
p--;
p--;
past the end if there is only one branch, but that's OK because that is
pchars (ecode, length, FALSE, md);
pchars (eptr, 16, TRUE, md);
pchars (eptr, length, TRUE, md);
pchars (eptr, length, TRUE, md);
pchars (p, length, FALSE, md);
pchars (p, length, is_subject, md)
pchars (start_match, end_subject - start_match, TRUE, &match_block);
pcre_exec (re, extra, subject, length, start_offset, options, offsets, offsetcount)
place we found it at last time. */
pointer. */
portions of the string if it matches. Two elements in the vector are set for
pre-processor statements. I suppose it's only been 10 years... */
preceded by BRAZERO or BRAMINZERO. */
preceding bracket, in the appropriate order. */
preceding bracket, in the appropriate order. We need to reset any options
printf (" against backref ");
printf (" against pattern ");
printf ("%c", c);
printf (">>>> Match against: ");
printf (">>>>> Skipped %d chars to reach first character\n",
printf ("\\x%02x", c);
printf ("\n");
printf ("\n");
printf ("\n");
printf ("\n");
printf ("\n");
printf ("end bracket %d", number);
printf ("matching subject ");
printf ("matching subject ");
printf ("matching subject <null> against pattern ");
printf ("matching subject <null>");
printf ("start bracket %d subject=", number);
rc = 0;
rc = match (eptr, md->start_pattern, offset_top, md, ims, eptrb,
rc = match_block.offset_overflow ? 0 : match_block.end_offset_top / 2;
register const uschar *ecode;
register const uschar *eptr;
register const uschar *eptr;
register const uschar *p = start_match + ((first_char >= 0) ? 1 : 0);
register int *iend = iptr + resetcount;
register int *iend = iptr - resetcount / 2 + 1;
register int *iptr = match_block.offset_vector + ocount;
register int *iptr = match_block.offset_vector;
register int c = *start_match;
register int c;
register int i;
register int length = ecode[1];
register int pp = *p++;
repeat it in the interests of efficiency. */
repeat limits are compiled as a number of copies, with the optional ones
req_char = re->req_char;
req_char2 = ((re->options & (PCRE_CASELESS | PCRE_ICHANGED)) != 0) ?
req_char_ptr = p;
resetcount = 2 + re->top_bracket * 2;
resetcount = ocount;
restoring at the exit of a group is easy. */
restrictions:
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return PCRE_ERROR_BADMAGIC;
return PCRE_ERROR_BADOPTION;
return PCRE_ERROR_NOMATCH;
return PCRE_ERROR_NOMEMORY;
return PCRE_ERROR_NULL;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return TRUE;
return match (eptr,
return match (eptr, ecode + 3, offset_top, md, ims, eptrb, match_isgroup);
return match_block.errorcode;
return rc;
save = (int *) (pcre_malloc) ((c + 1) * sizeof (int));
save = stacksave;
save = stacksave;
save[i] = md->offset_vector[md->offset_end - i];
seems expensive. As a compromise, the stack is used when there are fewer
share code. This is very similar to the code for single characters, but we
similar code to character type repeats - written out again for speed.
since matching characters is likely to be quite common. First, ensure the
since matching characters is likely to be quite common. First, ensure the
skipped_chars += bmtable[*start_match],
skipped_chars += bmtable[256] - 1;
skipped_chars -= bmtable[256] - 1;
skipped_chars);
skipped_chars++,
skipped_chars++,
skipped_chars++,
skipped_chars++,
stack of such pointers, to be re-instated at the end of the group when we hit
stack, for holding the values of the subject pointer at the start of each
start of each branch to move the current point backwards, so the code at
start_bits = extra->data.start_bits;
start_match += bmtable[*start_match];
start_match += bmtable[256] - 1;
start_match -= bmtable[256] - 1;
start_match = (const uschar *) subject + length - re->max_match_size;
start_match++ < end_subject);
start_match++;
start_match++;
start_match++;
start_match++;
start_offset    where to start in the subject string
startline = (re->options & PCRE_STARTLINE) != 0;
static BOOL
static BOOL
static const char rep_max[] =
static const char rep_min[] =
static void
strings.
struct eptrblock *prev;
studied, there may be a bitmap of possible first characters. */
subject         points to the subject string
subject if the requested.
subpattern - to break infinite loops. */
subpattern, so as to detect when an empty string has been matched by a
subsequent match. */
such there are (offset_top records the completed total) so we just have
supersede any condition above with which it is incompatible.
switch (*ecode)
switch (*ecode)
switch (ctype)
switch (ctype)
switch (ctype)
switch (op)
test once at the start (i.e. keep it out of the loop). */
than 16 values to store; otherwise malloc is used. A problem is what to do
than the number of characters left in the string, so the match fails.
that "continue" in the code above comes out to here to repeat the main
that changed within the bracket before re-running it, so check the next
that it may occur zero times. It may repeat infinitely, or not at all -
the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
the closing ket. When match() is called in other circumstances, we don't add to
the code for a repeated single character, but I haven't found a nice way of
the current subject position in the working slot at the top of the vector. We
the expression and advancing one matching character if failing, up to the
the expression and advancing one matching character if failing, up to the
the external pcre header. */
the file Tech.Notes for some information on the internals.
the final argument TRUE causes it to stop at the end of an assertion. */
the group. */
the length of the reference string explicitly rather than passing the
the loop runs just once. */
the minimum number of bytes before we start. */
the number from a dummy opcode at the start. */
the point in the subject string is not moved back. Thus there can never be
the pointer while it matches the class. */
the same bracket.
the stack. */
the start hasn't passed this character yet. */
the subject. */
the subject. */
there were too many extractions, set the return code to zero. In the case
this level is identical to the lookahead case. */
this makes a huge difference to execution time when there aren't many brackets
those back references that we can. In this case there need not be overflow
time taken, but character matching *is* what this is all about... */
to save all the potential data. There may be up to 99 such values, which
to that for character classes, but repeated for efficiency. Then obey
two branches. If the condition is false, skipping the first branch takes us
typedef struct eptrblock
unless PCRE_CASELESS was given or the casing state changes within the regex.
unlimited repeats that aren't going to match. We don't know what the state of
unsigned long int ims = 0;
unsigned long int ims;
unsigned long int ims;
unsigned long int original_ims = ims;		/* Save for resetting on ')' */
up quickly if there are fewer than the minimum number of characters left in
up quickly if there are fewer than the minimum number of characters left in
using_temporary_offsets = TRUE;
values of the final offsets, in case they were set by a previous iteration of
we just need to set up the whole thing as substring 0 before returning. If
where we had to get some local store to hold offsets for backreferences, copy
while (!anchored &&
while (*ecode == OP_ALT)
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*ecode == OP_ALT);
while (*next == OP_ALT);
while (*next == OP_ALT);
while (--iptr >= iend)
while (eptr >= pp)
while (eptr >= pp)
while (eptr >= pp)
while (eptr >= pp)
while (eptr >= pp)
while (eptr >= pp)
while (eptr >= pp)
while (iptr < iend)
while (length-- > 0)
while (length-- > 0)
while (length-- > 0)
while (length-- > 0)
while (length-- > 0)
while (p < end_subject)
while (p < end_subject)
while (start_match < end_subject &&
while (start_match < end_subject && *start_match != first_char)
while (start_match < end_subject && start_match[-1] != '\n')
while (start_match < end_subject)
while (start_match < end_subject)
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{0, 0, 0, 0, 1, 1};
{0, 0, 1, 1, 0, 0};
}				/* End of main loop */
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}