00001
#if !defined(RXH) || defined(RX_WANT_SE_DEFS)
00002
#define RXH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034
00035
00036
00037
#ifndef RX_WANT_SE_DEFS
00038
00039
00040
00041
#ifndef RX_subset
00042 typedef unsigned int RX_subset;
00043
#define RX_subset_bits (32)
00044
#define RX_subset_mask (RX_subset_bits - 1)
00045
#endif
00046
00047 typedef RX_subset *
rx_Bitset;
00048
00049
#ifdef __STDC__
00050 typedef void (*
rx_bitset_iterator) (
void *,
int member_index);
00051
#else
00052
typedef void (*
rx_bitset_iterator) ();
00053
#endif
00054
00055
#define rx_bitset_subset(N) ((N) / RX_subset_bits)
00056
#define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)])
00057
#define RX_bitset_access(B,N,OP) \
00058
((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask])
00059
#define RX_bitset_member(B,N) RX_bitset_access(B, N, &)
00060
#define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=)
00061
#define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~)
00062
#define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= )
00063
#define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits)
00064
#define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset))
00065
00066
00067
00068
00069
00070
#ifdef __STDC__
00071 typedef int (*
rx_sp_comparer) (
void * a,
void * b);
00072
#else
00073
typedef int (*
rx_sp_comparer) ();
00074
#endif
00075
00076 struct rx_sp_node
00077 {
00078 void *
key;
00079 void *
data;
00080 struct rx_sp_node *
kids[2];
00081 };
00082
00083
#ifdef __STDC__
00084 typedef void (*
rx_sp_key_data_freer) (
struct rx_sp_node *);
00085
#else
00086
typedef void (*
rx_sp_key_data_freer) ();
00087
#endif
00088
00089
00090
00091
00092 struct rx_hash_item
00093 {
00094 struct rx_hash_item *
next_same_hash;
00095 struct rx_hash *
table;
00096 unsigned long hash;
00097 void *
data;
00098 void *
binding;
00099 };
00100
00101 struct rx_hash
00102 {
00103 struct rx_hash *
parent;
00104 int refs;
00105 struct rx_hash *
children[13];
00106 struct rx_hash_item *
buckets [13];
00107 int bucket_size [13];
00108 };
00109
00110
struct rx_hash_rules;
00111
00112
#ifdef __STDC__
00113
00114 typedef int (*
rx_hash_eq)(
void *,
void *);
00115 typedef struct rx_hash * (*rx_alloc_hash)(
struct rx_hash_rules *);
00116 typedef void (*
rx_free_hash)(
struct rx_hash *,
00117
struct rx_hash_rules *);
00118 typedef struct rx_hash_item * (*rx_alloc_hash_item)(
struct rx_hash_rules *,
00119
void *);
00120 typedef void (*
rx_free_hash_item)(
struct rx_hash_item *,
00121
struct rx_hash_rules *);
00122
#else
00123
typedef int (*
rx_hash_eq)();
00124
typedef struct rx_hash * (*rx_alloc_hash)();
00125
typedef void (*
rx_free_hash)();
00126
typedef struct rx_hash_item * (*rx_alloc_hash_item)();
00127
typedef void (*
rx_free_hash_item)();
00128
#endif
00129
00130 struct rx_hash_rules
00131 {
00132 rx_hash_eq eq;
00133 rx_alloc_hash hash_alloc;
00134 rx_free_hash free_hash;
00135 rx_alloc_hash_item hash_item_alloc;
00136 rx_free_hash_item free_hash_item;
00137 };
00138
00139
00140
00141
00142
struct rx_cache;
00143
struct rx_superset;
00144
struct rx;
00145
struct rx_se_list;
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
#ifdef __STDC__
00226 typedef int (*
rx_se_list_order) (
struct rx *,
00227
struct rx_se_list *,
00228
struct rx_se_list *);
00229
#else
00230
typedef int (*
rx_se_list_order) ();
00231
#endif
00232
00233
00234
00235
00236
00237
00238
00239
00240 struct rx
00241 {
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 int rx_id;
00257
00258
00259
00260
00261 struct rx_cache *
cache;
00262
00263
00264
00265
00266
00267
00268 int local_cset_size;
00269
00270
00271
00272
00273
00274 void *
buffer;
00275 unsigned long allocated;
00276
00277
00278
00279
00280
00281
00282 unsigned long reserved;
00283
00284
00285
00286
00287
00288
00289
00290 int nodec;
00291
00292
00293 int epsnodec;
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 struct rx_hash se_list_memo;
00304
00305
00306
00307 struct rx_hash set_list_memo;
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 void **
instruction_table;
00322
00323
00324
00325
00326
00327
00328
00329 struct rx_nfa_state *
nfa_states;
00330
00331
00332
00333 struct rx_nfa_state *
start;
00334
00335
00336
00337
00338 rx_se_list_order se_list_cmp;
00339
00340 struct rx_superset *
start_set;
00341 };
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 enum rexp_node_type
00359 {
00360
r_cset,
00361
r_concat,
00362
r_alternate,
00363
r_opt,
00364
r_star,
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
r_2phase_star,
00383
00384
00385
00386
r_side_effect,
00387
00388
00389
00390
00391
r_data
00392 };
00393
00394
00395
00396
00397
00398
00399
00400 typedef void *
rx_side_effect;
00401
00402
00403
00404 struct rexp_node
00405 {
00406 enum rexp_node_type type;
00407
union
00408
{
00409 rx_Bitset cset;
00410 rx_side_effect side_effect;
00411
struct
00412
{
00413 struct rexp_node *
left;
00414 struct rexp_node *
right;
00415 } pair;
00416 void *
data;
00417 } params;
00418 };
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428 struct rx_nfa_state
00429 {
00430
00431 struct rx_nfa_state *
next;
00432
00433
00434
00435
00436
00437
00438 int id;
00439
00440
00441 struct rx_nfa_edge *
edges;
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 struct rx_possible_future *
futures;
00499
00500
00501
00502 unsigned int is_final:1;
00503 unsigned int is_start:1;
00504
00505
00506 unsigned int eclosure_needed:1;
00507 unsigned int mark:1;
00508 };
00509
00510
00511
00512 enum rx_nfa_etype
00513 {
00514
00515
00516
00517
ne_cset,
00518
00519
00520
00521
00522
ne_epsilon,
00523
00524
00525
00526
00527
00528
ne_side_effect
00529 };
00530
00531 struct rx_nfa_edge
00532 {
00533 struct rx_nfa_edge *
next;
00534 enum rx_nfa_etype type;
00535 struct rx_nfa_state *
dest;
00536
union
00537
{
00538 rx_Bitset cset;
00539 rx_side_effect side_effect;
00540 } params;
00541 };
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 struct rx_nfa_state_set
00553 {
00554 struct rx_nfa_state *
car;
00555 struct rx_nfa_state_set *
cdr;
00556 };
00557
00558 struct rx_se_list
00559 {
00560 rx_side_effect car;
00561 struct rx_se_list *
cdr;
00562 };
00563
00564 struct rx_possible_future
00565 {
00566 struct rx_possible_future *
next;
00567 struct rx_se_list *
effects;
00568 struct rx_nfa_state_set *
destset;
00569 };
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659 enum rx_opcode
00660 {
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
rx_backtrack_point = 0,
00674
00675
00676
00677
00678
00679
00680
rx_do_side_effects =
rx_backtrack_point + 1,
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
rx_cache_miss =
rx_do_side_effects + 1,
00692
00693
00694
00695
00696
00697
00698
00699
00700
rx_next_char =
rx_cache_miss + 1,
00701
00702
00703
00704
rx_backtrack =
rx_next_char + 1,
00705
00706
00707
00708
00709
rx_error_inx =
rx_backtrack + 1,
00710
00711
rx_num_instructions =
rx_error_inx + 1
00712 };
00713
00714
00715
00716
00717
extern void *
rx_id_instruction_table[
rx_num_instructions];
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753 struct rx_inx
00754 {
00755 void *
data;
00756 void *
data_2;
00757 void *
inx;
00758 void *
fnord;
00759 };
00760
00761
#ifndef RX_TAIL_ARRAY
00762
#define RX_TAIL_ARRAY 1
00763
#endif
00764
00765
00766
00767
00768
00769 struct rx_superset
00770 {
00771 int refs;
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 int id;
00785
00786 struct rx_nfa_state *
car;
00787 struct rx_superset *
cdr;
00788
00789
00790 struct rx_superstate *
superstate;
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 struct rx *
starts_for;
00812
00813
00814
00815
00816 struct rx_hash_item hash_item;
00817 };
00818
00819
#define rx_protect_superset(RX,CON) (++(CON)->refs)
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831 struct rx_super_edge
00832 {
00833 struct rx_super_edge *
next;
00834 struct rx_inx rx_backtrack_frame;
00835 int cset_size;
00836 rx_Bitset cset;
00837 struct rx_distinct_future *
options;
00838 };
00839
00840
00841
00842
00843
00844
00845 struct rx_superstate
00846 {
00847 int rx_id;
00848 int locks;
00849
00850
00851
00852
00853
00854
00855 struct rx_superstate *
next_recyclable;
00856 struct rx_superstate *
prev_recyclable;
00857
00858
00859
00860
00861 struct rx_distinct_future *
transition_refs;
00862
00863
00864 struct rx_superset *
contents;
00865
00866
00867 struct rx_super_edge *
edges;
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886 int is_semifree;
00887
00888
00889
00890
00891
00892
00893 int trans_size;
00894
00895
00896 struct rx_inx transitions[RX_TAIL_ARRAY];
00897 };
00898
00899
00900
00901
00902
00903
00904 struct rx_distinct_future
00905 {
00906 struct rx_distinct_future *
next_same_super_edge[2];
00907 struct rx_distinct_future *
next_same_dest;
00908 struct rx_distinct_future *
prev_same_dest;
00909 struct rx_superstate *
present;
00910 struct rx_superstate *
future;
00911 struct rx_super_edge *
edge;
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927 struct rx_inx future_frame;
00928
00929 struct rx_inx side_effects_frame;
00930 struct rx_se_list *
effects;
00931 };
00932
00933
#define rx_lock_superstate(R,S) ((S)->locks++)
00934
#define rx_unlock_superstate(R,S) (--(S)->locks)
00935
00936
00937
00938
00939 struct rx_blocklist
00940 {
00941 struct rx_blocklist *
next;
00942 int bytes;
00943 };
00944
00945 struct rx_freelist
00946 {
00947 struct rx_freelist *
next;
00948 };
00949
00950
struct rx_cache;
00951
00952
#ifdef __STDC__
00953 typedef void (*
rx_morecore_fn)(
struct rx_cache *);
00954
#else
00955
typedef void (*
rx_morecore_fn)();
00956
#endif
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976 struct rx_cache
00977 {
00978 struct rx_hash_rules superset_hash_rules;
00979
00980
00981
00982
00983 struct rx_blocklist *
memory;
00984 struct rx_blocklist *
memory_pos;
00985 int bytes_left;
00986 char *
memory_addr;
00987 rx_morecore_fn morecore;
00988
00989
00990 struct rx_freelist *
free_superstates;
00991 struct rx_freelist *
free_transition_classes;
00992 struct rx_freelist *
free_discernable_futures;
00993 struct rx_freelist *
free_supersets;
00994 struct rx_freelist *
free_hash;
00995
00996
00997
00998
00999 struct rx_superstate *
lru_superstate;
01000 struct rx_superstate *
semifree_superstate;
01001
01002 struct rx_superset *
empty_superset;
01003
01004 int superstates;
01005 int semifree_superstates;
01006 int hits;
01007 int misses;
01008 int superstates_allowed;
01009
01010 int local_cset_size;
01011 void **
instruction_table;
01012
01013 struct rx_hash superset_table;
01014 };
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
#ifndef __GNUC__
01025
#ifdef __STDC__
01026
#define __const__ const
01027
#else
01028
#define __const__
01029
#endif
01030
#endif
01031
01032
01033 struct rx_string_position
01034 {
01035 __const__
unsigned char *
pos;
01036 __const__
unsigned char *
string;
01037 __const__
unsigned char *
end;
01038 int offset;
01039 int size;
01040 int search_direction;
01041 int search_end;
01042 };
01043
01044
01045 enum rx_get_burst_return
01046 {
01047
rx_get_burst_continuation,
01048
rx_get_burst_error,
01049
rx_get_burst_ok,
01050
rx_get_burst_no_more
01051 };
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
#ifdef __STDC__
01067
typedef enum rx_get_burst_return
01068 (*rx_get_burst_fn) (
struct rx_string_position * pos,
01069
void *
app_closure,
01070
int stop);
01071
01072
#else
01073 typedef enum rx_get_burst_return (*rx_get_burst_fn) ();
01074
#endif
01075
01076
01077 enum rx_back_check_return
01078 {
01079
rx_back_check_continuation,
01080
rx_back_check_error,
01081
rx_back_check_pass,
01082
rx_back_check_fail
01083 };
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
#ifdef __STDC__
01095
typedef enum rx_back_check_return
01096 (*rx_back_check_fn) (
struct rx_string_position * pos,
01097
int lparen,
01098
int rparen,
01099
unsigned char * translate,
01100
void *
app_closure,
01101
int stop);
01102
01103
#else
01104 typedef enum rx_back_check_return (*rx_back_check_fn) ();
01105
#endif
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
#ifdef __STDC__
01116 typedef int (*
rx_fetch_char_fn) (
struct rx_string_position * pos,
01117
int offset,
01118
void *
app_closure,
01119
int stop);
01120
#else
01121
typedef int (*
rx_fetch_char_fn) ();
01122
#endif
01123
01124
01125 enum rx_search_return
01126 {
01127
rx_search_continuation = -4,
01128
rx_search_error = -3,
01129
rx_search_soft_fail = -2,
01130
rx_search_fail = -1
01131
01132 };
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
extern __const__
char *
re_error_msg[];
01147
01148
01149
01150 typedef enum
01151 {
01152
REG_NOERROR = 0,
01153
REG_NOMATCH,
01154
01155
01156
01157
REG_BADPAT,
01158
REG_ECOLLATE,
01159
REG_ECTYPE,
01160
REG_EESCAPE,
01161
REG_ESUBREG,
01162
REG_EBRACK,
01163
REG_EPAREN,
01164
REG_EBRACE,
01165
REG_BADBR,
01166
REG_ERANGE,
01167
REG_ESPACE,
01168
REG_BADRPT,
01169
01170
01171
REG_EEND,
01172
REG_ESIZE,
01173
REG_ERPAREN
01174 }
reg_errcode_t;
01175
01176
01177
01178
01179
01180
01181 enum re_side_effects
01182 {
01183
#define RX_WANT_SE_DEFS 1
01184
#undef RX_DEF_SE
01185
#undef RX_DEF_CPLX_SE
01186
#define RX_DEF_SE(IDEM, NAME, VALUE) NAME VALUE,
01187
#define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) NAME VALUE,
01188
#include "MNrx.h"
01189
#undef RX_DEF_SE
01190
#undef RX_DEF_CPLX_SE
01191
#undef RX_WANT_SE_DEFS
01192
re_floogle_flap = 65533
01193 };
01194
01195
01196
01197
01198
01199
01200 struct re_se_params
01201 {
01202 enum re_side_effects se;
01203 int op1;
01204 int op2;
01205 };
01206
01207 typedef unsigned reg_syntax_t;
01208
01209 struct re_pattern_buffer
01210 {
01211 struct rx rx;
01212 reg_syntax_t syntax;
01213
01214 unsigned int no_sub:1;
01215 unsigned int not_bol:1;
01216 unsigned int not_eol:1;
01217 unsigned int newline_anchor:1;
01218 unsigned int least_subs:1;
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228 unsigned int match_regs_on_stack:1;
01229 unsigned int search_regs_on_stack:1;
01230
01231
01232 unsigned int is_anchored:1;
01233 unsigned int begbuf_only:1;
01234
01235
01236
01237
01238
01239
01240
01241
#define REGS_UNALLOCATED 0
01242
#define REGS_REALLOCATE 1
01243
#define REGS_FIXED 2
01244 unsigned int regs_allocated:2;
01245
01246
01247
01248
01249
01250
01251
01252 unsigned char * translate;
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264 char *
syntax_parens;
01265
01266
01267 size_t
re_nsub;
01268
01269 void *
buffer;
01270 unsigned long allocated;
01271
01272
01273
01274
01275 char *
fastmap;
01276
01277 unsigned int fastmap_accurate:1;
01278 unsigned int can_match_empty:1;
01279 struct rx_nfa_state *
start;
01280
01281
01282
01283
01284 struct re_se_params *
se_params;
01285
01286
01287
01288
01289
01290 rx_Bitset fastset;
01291 };
01292
01293
01294 typedef int regoff_t;
01295
01296
01297
01298 struct re_registers
01299 {
01300 unsigned num_regs;
01301 regoff_t *
start;
01302 regoff_t *
end;
01303 };
01304
01305 typedef struct re_pattern_buffer regex_t;
01306
01307
01308
01309
01310 typedef struct
01311
{
01312 regoff_t rm_so;
01313 regoff_t rm_eo;
01314 }
regmatch_t;
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
01326
01327
01328
01329
01330
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
01331
01332
01333
01334
01335
01336
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
01351
01352
01353
01354
01355
01356
01357
01358
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
01359
01360
01361
01362
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
01363
01364
01365
01366
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
01367
01368
01369
01370
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
01371
01372
01373
01374
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
01375
01376
01377
01378
01379
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
01380
01381
01382
01383
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
01384
01385
01386
01387
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
01388
01389
01390
01391
01392
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
01393
01394
01395
01396
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
01397
01398
01399
01400
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
01401
01402
01403
01404
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
01405
01406
01407
01408
01409
01410
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
01411
01412
01413
01414
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
01415
01416
01417
01418
01419
01420
extern reg_syntax_t re_syntax_options;
01421
01422
01423
01424
01425
01426
#define RE_SYNTAX_EMACS 0
01427
01428
#define RE_SYNTAX_AWK \
01429
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
01430
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
01431
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
01432
| RE_UNMATCHED_RIGHT_PAREN_ORD)
01433
01434
#define RE_SYNTAX_POSIX_AWK \
01435
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
01436
01437
#define RE_SYNTAX_GREP \
01438
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
01439
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
01440
| RE_NEWLINE_ALT)
01441
01442
#define RE_SYNTAX_EGREP \
01443
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
01444
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
01445
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
01446
| RE_NO_BK_VBAR)
01447
01448
#define RE_SYNTAX_POSIX_EGREP \
01449
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
01450
01451
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
01452
01453
01454
#define _RE_SYNTAX_POSIX_COMMON \
01455
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
01456
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
01457
01458
#define RE_SYNTAX_POSIX_BASIC \
01459
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
01460
01461
01462
01463
01464
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
01465
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
01466
01467
#define RE_SYNTAX_POSIX_EXTENDED \
01468
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
01469
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
01470
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
01471
| RE_UNMATCHED_RIGHT_PAREN_ORD)
01472
01473
01474
01475
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
01476
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
01477
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
01478
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
01479
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
01480
01481
01482
01483
01484
01485
#ifdef RE_DUP_MAX
01486
#undef RE_DUP_MAX
01487
#endif
01488
#define RE_DUP_MAX ((1 << 15) - 1)
01489
01490
01491
01492
01493
01494
01495
01496
#define REG_EXTENDED 1
01497
01498
01499
01500
#define REG_ICASE (REG_EXTENDED << 1)
01501
01502
01503
01504
01505
#define REG_NEWLINE (REG_ICASE << 1)
01506
01507
01508
01509
#define REG_NOSUB (REG_NEWLINE << 1)
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
#define REG_NOTBOL 1
01520
01521
01522
#define REG_NOTEOL (1 << 1)
01523
01524
01525
01526
01527
01528
01529
01530
01531
#ifndef RE_NREGS
01532
#define RE_NREGS 30
01533
#endif
01534
01535
extern int rx_cache_bound;
01536
extern char rx_version_string[];
01537
01538
01539
01540
#ifdef RX_WANT_RX_DEFS
01541
01542
01543
01544
01545
01546
01547
01548
#ifdef __STDC__
01549 typedef void (*
rx_hash_freefn) (
struct rx_hash_item * it);
01550
#else
01551
typedef void (*
rx_hash_freefn) ();
01552
#endif
01553
01554
01555
01556
01557
#ifdef __STDC__
01558
RX_DECL
int rx_bitset_is_equal (
int size, rx_Bitset a, rx_Bitset b);
01559 RX_DECL
int rx_bitset_is_subset (
int size, rx_Bitset a, rx_Bitset b);
01560 RX_DECL
int rx_bitset_empty (
int size, rx_Bitset set);
01561 RX_DECL
void rx_bitset_null (
int size, rx_Bitset b);
01562 RX_DECL
void rx_bitset_universe (
int size, rx_Bitset b);
01563 RX_DECL
void rx_bitset_complement (
int size, rx_Bitset b);
01564 RX_DECL
void rx_bitset_assign (
int size, rx_Bitset a, rx_Bitset b);
01565 RX_DECL
void rx_bitset_union (
int size, rx_Bitset a, rx_Bitset b);
01566 RX_DECL
void rx_bitset_intersection (
int size,
01567 rx_Bitset a, rx_Bitset b);
01568 RX_DECL
void rx_bitset_difference (
int size, rx_Bitset a, rx_Bitset b);
01569 RX_DECL
void rx_bitset_revdifference (
int size,
01570 rx_Bitset a, rx_Bitset b);
01571 RX_DECL
void rx_bitset_xor (
int size, rx_Bitset a, rx_Bitset b);
01572 RX_DECL
unsigned long rx_bitset_hash (
int size, rx_Bitset b);
01573 RX_DECL
struct rx_hash_item *
rx_hash_find (
struct rx_hash * table,
01574
unsigned long hash,
01575
void * value,
01576
struct rx_hash_rules * rules);
01577 RX_DECL
struct rx_hash_item *
rx_hash_store (
struct rx_hash * table,
01578
unsigned long hash,
01579
void * value,
01580
struct rx_hash_rules * rules);
01581 RX_DECL
void rx_hash_free (
struct rx_hash_item * it,
struct rx_hash_rules * rules);
01582 RX_DECL
void rx_free_hash_table (
struct rx_hash * tab,
rx_hash_freefn freefn,
01583
struct rx_hash_rules * rules);
01584 RX_DECL
rx_Bitset rx_cset (
struct rx *
rx);
01585 RX_DECL
rx_Bitset rx_copy_cset (
struct rx *
rx, rx_Bitset a);
01586 RX_DECL
void rx_free_cset (
struct rx *
rx, rx_Bitset c);
01587 RX_DECL
struct rexp_node *
rexp_node (
struct rx *
rx,
01588
enum rexp_node_type type);
01589 RX_DECL
struct rexp_node *
rx_mk_r_cset (
struct rx *
rx,
01590 rx_Bitset b);
01591 RX_DECL
struct rexp_node *
rx_mk_r_concat (
struct rx *
rx,
01592
struct rexp_node * a,
01593
struct rexp_node * b);
01594 RX_DECL
struct rexp_node *
rx_mk_r_alternate (
struct rx *
rx,
01595
struct rexp_node * a,
01596
struct rexp_node * b);
01597 RX_DECL
struct rexp_node *
rx_mk_r_opt (
struct rx *
rx,
01598
struct rexp_node * a);
01599 RX_DECL
struct rexp_node *
rx_mk_r_star (
struct rx *
rx,
01600
struct rexp_node * a);
01601 RX_DECL
struct rexp_node *
rx_mk_r_2phase_star (
struct rx *
rx,
01602
struct rexp_node * a,
01603
struct rexp_node * b);
01604 RX_DECL
struct rexp_node *
rx_mk_r_side_effect (
struct rx *
rx,
01605 rx_side_effect a);
01606 RX_DECL
struct rexp_node *
rx_mk_r_data (
struct rx *
rx,
01607
void * a);
01608 RX_DECL
void rx_free_rexp (
struct rx *
rx,
struct rexp_node * node);
01609 RX_DECL
struct rexp_node *
rx_copy_rexp (
struct rx *
rx,
01610
struct rexp_node *node);
01611 RX_DECL
struct rx_nfa_state *
rx_nfa_state (
struct rx *
rx);
01612 RX_DECL
void rx_free_nfa_state (
struct rx_nfa_state * n);
01613 RX_DECL
struct rx_nfa_state *
rx_id_to_nfa_state (
struct rx *
rx,
01614
int id);
01615 RX_DECL
struct rx_nfa_edge *
rx_nfa_edge (
struct rx *
rx,
01616
enum rx_nfa_etype type,
01617
struct rx_nfa_state *start,
01618
struct rx_nfa_state *dest);
01619 RX_DECL
void rx_free_nfa_edge (
struct rx_nfa_edge * e);
01620 RX_DECL
void rx_free_nfa (
struct rx *
rx);
01621 RX_DECL
int rx_build_nfa (
struct rx *
rx,
01622
struct rexp_node *rexp,
01623
struct rx_nfa_state **start,
01624
struct rx_nfa_state **end);
01625 RX_DECL
void rx_name_nfa_states (
struct rx *
rx);
01626 RX_DECL
int rx_eclose_nfa (
struct rx *
rx);
01627 RX_DECL
void rx_delete_epsilon_transitions (
struct rx *
rx);
01628 RX_DECL
int rx_compactify_nfa (
struct rx *
rx,
01629
void **mem,
unsigned long *size);
01630 RX_DECL
void rx_release_superset (
struct rx *
rx,
01631
struct rx_superset *set);
01632 RX_DECL
struct rx_superset *
rx_superset_cons (
struct rx *
rx,
01633
struct rx_nfa_state *car,
struct rx_superset *cdr);
01634 RX_DECL
struct rx_superset *
rx_superstate_eclosure_union
01635 (
struct rx *
rx,
struct rx_superset *set,
struct rx_nfa_state_set *ecl);
01636 RX_DECL
struct rx_superstate *
rx_superstate (
struct rx *rx,
01637
struct rx_superset *set);
01638 RX_DECL
struct rx_inx *
rx_handle_cache_miss
01639 (
struct rx *rx,
struct rx_superstate *super,
unsigned char chr,
void *data);
01640 RX_DECL
reg_errcode_t rx_compile (__const__
char *pattern,
int size,
01641 reg_syntax_t syntax,
01642
struct re_pattern_buffer * rxb);
01643 RX_DECL
void rx_blow_up_fastmap (
struct re_pattern_buffer * rxb);
01644
#else
01645 RX_DECL
int rx_bitset_is_equal ();
01646 RX_DECL
int rx_bitset_is_subset ();
01647 RX_DECL
int rx_bitset_empty ();
01648 RX_DECL
void rx_bitset_null ();
01649 RX_DECL
void rx_bitset_universe ();
01650 RX_DECL
void rx_bitset_complement ();
01651 RX_DECL
void rx_bitset_assign ();
01652 RX_DECL
void rx_bitset_union ();
01653 RX_DECL
void rx_bitset_intersection ();
01654 RX_DECL
void rx_bitset_difference ();
01655 RX_DECL
void rx_bitset_revdifference ();
01656 RX_DECL
void rx_bitset_xor ();
01657 RX_DECL
unsigned long rx_bitset_hash ();
01658 RX_DECL
struct rx_hash_item *
rx_hash_find ();
01659 RX_DECL
struct rx_hash_item *
rx_hash_store ();
01660 RX_DECL
void rx_hash_free ();
01661 RX_DECL
void rx_free_hash_table ();
01662 RX_DECL
rx_Bitset rx_cset ();
01663 RX_DECL
rx_Bitset rx_copy_cset ();
01664 RX_DECL
void rx_free_cset ();
01665 RX_DECL
struct rexp_node *
rexp_node ();
01666 RX_DECL
struct rexp_node *
rx_mk_r_cset ();
01667 RX_DECL
struct rexp_node *
rx_mk_r_concat ();
01668 RX_DECL
struct rexp_node *
rx_mk_r_alternate ();
01669 RX_DECL
struct rexp_node *
rx_mk_r_opt ();
01670 RX_DECL
struct rexp_node *
rx_mk_r_star ();
01671 RX_DECL
struct rexp_node *
rx_mk_r_2phase_star ();
01672 RX_DECL
struct rexp_node *
rx_mk_r_side_effect ();
01673 RX_DECL
struct rexp_node *
rx_mk_r_data ();
01674 RX_DECL
void rx_free_rexp ();
01675 RX_DECL
struct rexp_node *
rx_copy_rexp ();
01676 RX_DECL
struct rx_nfa_state *
rx_nfa_state ();
01677 RX_DECL
void rx_free_nfa_state ();
01678 RX_DECL
struct rx_nfa_state *
rx_id_to_nfa_state ();
01679 RX_DECL
struct rx_nfa_edge *
rx_nfa_edge ();
01680 RX_DECL
void rx_free_nfa_edge ();
01681 RX_DECL
void rx_free_nfa ();
01682 RX_DECL
int rx_build_nfa ();
01683 RX_DECL
void rx_name_nfa_states ();
01684 RX_DECL
int rx_eclose_nfa ();
01685 RX_DECL
void rx_delete_epsilon_transitions ();
01686 RX_DECL
int rx_compactify_nfa ();
01687 RX_DECL
void rx_release_superset ();
01688 RX_DECL
struct rx_superset *
rx_superset_cons ();
01689 RX_DECL
struct rx_superset *
rx_superstate_eclosure_union ();
01690 RX_DECL
struct rx_superstate *
rx_superstate ();
01691 RX_DECL
struct rx_inx *
rx_handle_cache_miss ();
01692 RX_DECL
reg_errcode_t rx_compile ();
01693 RX_DECL
void rx_blow_up_fastmap ();
01694
#endif
01695
01696
01697
#endif
01698
01699
01700
01701
#ifdef __STDC__
01702
extern int re_search_2 (
struct re_pattern_buffer *rxb,
01703 __const__
char * string1,
int size1,
01704 __const__
char * string2,
int size2,
01705
int startpos,
int range,
01706
struct re_registers *regs,
01707
int stop);
01708
extern int re_search (
struct re_pattern_buffer * rxb, __const__
char *string,
01709
int size,
int startpos,
int range,
01710
struct re_registers *regs);
01711
extern int re_match_2 (
struct re_pattern_buffer * rxb,
01712 __const__
char * string1,
int size1,
01713 __const__
char * string2,
int size2,
01714
int pos,
struct re_registers *regs,
int stop);
01715
extern int re_match (
struct re_pattern_buffer * rxb,
01716 __const__
char * string,
01717
int size,
int pos,
01718
struct re_registers *regs);
01719
extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
01720
extern void re_set_registers (
struct re_pattern_buffer *bufp,
01721
struct re_registers *regs,
01722
unsigned num_regs,
01723 regoff_t * starts, regoff_t * ends);
01724
extern __const__
char *
re_compile_pattern (__const__
char *pattern,
01725
int length,
01726
struct re_pattern_buffer * rxb);
01727
extern int re_compile_fastmap (
struct re_pattern_buffer * rxb);
01728
extern char *
re_comp (__const__
char *s);
01729
extern int re_exec (__const__
char *s);
01730
extern int regcomp (regex_t * preg, __const__
char * pattern,
int cflags);
01731
extern int regexec (__const__ regex_t *preg, __const__
char *string,
01732 size_t nmatch,
regmatch_t pmatch[],
01733
int eflags);
01734
extern size_t
regerror (
int errcode, __const__ regex_t *preg,
01735
char *errbuf, size_t errbuf_size);
01736
extern void regfree (regex_t *preg);
01737
01738
#else
01739
extern int re_search_2 ();
01740
extern int re_search ();
01741
extern int re_match_2 ();
01742
extern int re_match ();
01743
extern reg_syntax_t re_set_syntax ();
01744
extern void re_set_registers ();
01745
extern __const__
char *
re_compile_pattern ();
01746
extern int re_compile_fastmap ();
01747
extern char *
re_comp ();
01748
extern int re_exec ();
01749
extern int regcomp ();
01750
extern int regexec ();
01751
extern size_t
regerror ();
01752
extern void regfree ();
01753
01754
#endif
01755
01756
01757
01758
#ifdef RX_WANT_RX_DEFS
01759
01760 struct rx_counter_frame
01761 {
01762 int tag;
01763 int val;
01764 struct rx_counter_frame *
inherited_from;
01765 struct rx_counter_frame *
cdr;
01766 };
01767
01768 struct rx_backtrack_frame
01769 {
01770 char *
counter_stack_sp;
01771
01772
01773
01774
01775
01776
01777 struct rx_superstate *
stk_super;
01778 unsigned int stk_c;
01779 struct rx_string_position stk_test_pos;
01780 int stk_last_l;
01781 int stk_last_r;
01782 int stk_test_ret;
01783
01784
01785
01786
01787 struct rx_distinct_future *
df;
01788 struct rx_distinct_future *
first_df;
01789
01790
#ifdef RX_DEBUG
01791 int stk_line_no;
01792
#endif
01793
};
01794
01795 struct rx_stack_chunk
01796 {
01797 struct rx_stack_chunk *
next_chunk;
01798 int bytes_left;
01799 char *
sp;
01800 };
01801
01802 enum rx_outer_entry
01803 {
01804
rx_outer_start,
01805
rx_outer_fastmap,
01806
rx_outer_test,
01807
rx_outer_restore_pos
01808 };
01809
01810 enum rx_fastmap_return
01811 {
01812
rx_fastmap_continuation,
01813
rx_fastmap_error,
01814
rx_fastmap_ok,
01815
rx_fastmap_fail
01816 };
01817
01818 enum rx_fastmap_entry
01819 {
01820
rx_fastmap_start,
01821
rx_fastmap_string_break
01822 };
01823
01824 enum rx_test_return
01825 {
01826
rx_test_continuation,
01827
rx_test_error,
01828
rx_test_fail,
01829
rx_test_ok
01830 };
01831
01832 enum rx_test_internal_return
01833 {
01834
rx_test_internal_error,
01835
rx_test_found_first,
01836
rx_test_line_finished
01837 };
01838
01839 enum rx_test_match_entry
01840 {
01841
rx_test_start,
01842
rx_test_cache_hit_loop,
01843
rx_test_backreference_check,
01844
rx_test_backtrack_return
01845 };
01846
01847 struct rx_search_state
01848 {
01849
01850
01851
01852
01853
01854
01855 unsigned num_regs;
01856 regoff_t * lparen;
01857 regoff_t * rparen;
01858 regoff_t *
best_lpspace;
01859 regoff_t *
best_rpspace;
01860
01861
01862
01863
01864
01865 int last_l;
01866 int last_r;
01867
01868 int *
best_lparen;
01869 int *
best_rparen;
01870
01871
01872
01873
01874 int best_last_l;
01875 int best_last_r;
01876
01877
01878 unsigned char * translate;
01879
01880 struct rx_string_position outer_pos;
01881
01882 struct rx_superstate *
start_super;
01883 int nfa_choice;
01884 int first_found;
01885 int ret_val;
01886
01887
01888 enum rx_outer_entry outer_search_resume_pt;
01889 struct re_pattern_buffer *
saved_rxb;
01890 int saved_startpos;
01891 int saved_range;
01892 int saved_stop;
01893 int saved_total_size;
01894 rx_get_burst_fn saved_get_burst;
01895 rx_back_check_fn saved_back_check;
01896 struct re_registers *
saved_regs;
01897
01901 char *
fastmap;
01902 int fastmap_chr;
01903 int fastmap_val;
01904
01905
01906 enum rx_fastmap_entry fastmap_resume_pt;
01907
01912
01913 struct rx_superstate * super;
01914
01915
01916
01917
01918 struct rx_inx *
ifr;
01919
01920
01921
01922
01923
01924 unsigned char c;
01925
01926
01927 struct rx_string_position test_pos;
01928
01929 struct rx_stack_chunk *
counter_stack;
01930 struct rx_stack_chunk *
backtrack_stack;
01931 int backtrack_frame_bytes;
01932 int chunk_bytes;
01933 struct rx_stack_chunk *
free_chunks;
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952 int test_ret;
01953
01954 int could_have_continued;
01955
01956
#ifdef RX_DEBUG
01957 int backtrack_depth;
01958
01959
01960
01961
01962
01963
01964 int line_no;
01965 int lines_found;
01966
#endif
01967
01968
01969
01970 enum rx_test_match_entry test_match_resume_pt;
01971 struct rx_inx *
saved_next_tr_table;
01972 struct rx_inx *
saved_this_tr_table;
01973 int saved_reg;
01974 struct rx_backtrack_frame *
saved_bf;
01975
01976 };
01977
01978
01979
extern char rx_slowmap[];
01980
extern unsigned char rx_id_translation[];
01981
01982
static __inline__
void
01983 init_fastmap (rxb, search_state)
01984 struct
re_pattern_buffer * rxb;
01985 struct
rx_search_state * search_state;
01986 {
01987
search_state->
fastmap = (
rxb->
fastmap
01988 ? (
char *)
rxb->
fastmap
01989 : (
char *)
rx_slowmap);
01990
01991
01992
01993
01994
01995
if ((
search_state->
fastmap ==
rxb->
fastmap) && !
rxb->
fastmap_accurate)
01996
rx_blow_up_fastmap (
rxb);
01997
search_state->
fastmap_chr = -1;
01998
search_state->
fastmap_val = 0;
01999
search_state->
fastmap_resume_pt =
rx_fastmap_start;
02000 }
02001
02002
static __inline__
void
02003 uninit_fastmap (rxb, search_state)
02004 struct
re_pattern_buffer * rxb;
02005 struct
rx_search_state * search_state;
02006 {
02007
02008
if (
search_state->
fastmap_chr >= 0)
02009
search_state->
fastmap[
search_state->
fastmap_chr]
02010 =
search_state->
fastmap_val;
02011 }
02012
02013
static __inline__
int
02014 fastmap_search (rxb, stop, get_burst, app_closure, search_state)
02015 struct
re_pattern_buffer * rxb;
02016
int stop;
02017 rx_get_burst_fn get_burst;
02018
void * app_closure;
02019 struct
rx_search_state * search_state;
02020 {
02021
enum rx_fastmap_entry pc;
02022
02023
if (0)
02024 {
02025 return_continuation:
02026
search_state->
fastmap_resume_pt = pc;
02027
return rx_fastmap_continuation;
02028 }
02029
02030 pc =
search_state->
fastmap_resume_pt;
02031
02032
switch (pc)
02033 {
02034
default:
02035
return rx_fastmap_error;
02036
case rx_fastmap_start:
02037 init_fastmap_sentinal:
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
if (
search_state->
outer_pos.
size)
02048 {
02049
search_state->
fastmap_chr = ((
search_state->
outer_pos.
search_direction == 1)
02050 ? *(
search_state->
outer_pos.
end - 1)
02051 : *
search_state->
outer_pos.
string);
02052
search_state->
fastmap_val
02053 =
search_state->
fastmap[
search_state->
fastmap_chr];
02054
search_state->
fastmap[
search_state->
fastmap_chr] = 1;
02055 }
02056
else
02057 {
02058
search_state->
fastmap_chr = -1;
02059
search_state->
fastmap_val = 0;
02060 }
02061
02062
if (
search_state->
outer_pos.
pos >=
search_state->
outer_pos.
end)
02063
goto fastmap_hit_bound;
02064
else
02065 {
02066
if (
search_state->
outer_pos.
search_direction == 1)
02067 {
02068
if (
search_state->
fastmap_val)
02069 {
02070
for (;;)
02071 {
02072
while (!
search_state->
fastmap[*
search_state->
outer_pos.
pos])
02073 ++
search_state->
outer_pos.
pos;
02074
return rx_fastmap_ok;
02075 }
02076 }
02077
else
02078 {
02079
for (;;)
02080 {
02081
while (!
search_state->
fastmap[*
search_state->
outer_pos.
pos])
02082 ++
search_state->
outer_pos.
pos;
02083
if (*
search_state->
outer_pos.
pos !=
search_state->
fastmap_chr)
02084
return rx_fastmap_ok;
02085
else
02086 {
02087 ++
search_state->
outer_pos.
pos;
02088
if (
search_state->
outer_pos.
pos ==
search_state->
outer_pos.
end)
02089
goto fastmap_hit_bound;
02090 }
02091 }
02092 }
02093 }
02094
else
02095 {
02096 __const__
unsigned char * bound;
02097 bound =
search_state->
outer_pos.
string - 1;
02098
if (
search_state->
fastmap_val)
02099 {
02100
for (;;)
02101 {
02102
while (!
search_state->
fastmap[*
search_state->
outer_pos.
pos])
02103 --
search_state->
outer_pos.
pos;
02104
return rx_fastmap_ok;
02105 }
02106 }
02107
else
02108 {
02109
for (;;)
02110 {
02111
while (!
search_state->
fastmap[*
search_state->
outer_pos.
pos])
02112 --
search_state->
outer_pos.
pos;
02113
if ((*
search_state->
outer_pos.
pos !=
search_state->
fastmap_chr) ||
search_state->
fastmap_val)
02114
return rx_fastmap_ok;
02115
else
02116 {
02117 --
search_state->
outer_pos.
pos;
02118
if (
search_state->
outer_pos.
pos == bound)
02119
goto fastmap_hit_bound;
02120 }
02121 }
02122 }
02123 }
02124 }
02125
02126
case rx_fastmap_string_break:
02127 fastmap_hit_bound:
02128 {
02129
02130
02131
02132
02133
02134
int burst_state;
02135 burst_state =
get_burst (&
search_state->
outer_pos,
app_closure,
stop);
02136
switch (burst_state)
02137 {
02138
default:
02139
case rx_get_burst_error:
02140
return rx_fastmap_error;
02141
case rx_get_burst_continuation:
02142 {
02143 pc =
rx_fastmap_string_break;
02144
goto return_continuation;
02145 }
02146
case rx_get_burst_ok:
02147
goto init_fastmap_sentinal;
02148
case rx_get_burst_no_more:
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
return ( (
search_state->
outer_pos.
search_direction == 1)
02159 ?
rx_fastmap_ok
02160 :
rx_fastmap_fail);
02161 }
02162 }
02163 }
02164
02165 }
02166
02167
02168
02169
#ifdef emacs
02170
#error this is not emacs
02171
02172
02173
02174
02175
02176
02177
02178
#endif
02179
02180
02181
02182
02183
#ifdef RX_MEMDBUG
02184
#include <malloc.h>
02185
#endif
02186
02187
02188
02189
02190
#if HAVE_STRING_H || STDC_HEADERS
02191
#include <string.h>
02192
02193
#ifndef bcmp
02194
#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
02195
#endif
02196
02197
#ifndef bcopy
02198
#define bcopy(s, d, n) memcpy ((d), (s), (n))
02199
#endif
02200
02201
#ifndef bzero
02202
#define bzero(s, n) memset ((s), 0, (n))
02203
#endif
02204
02205
#else
02206
#include <strings.h>
02207
#endif
02208
02209
#ifdef STDC_HEADERS
02210
#include <stdlib.h>
02211
#else
02212
02213
02214
02215
#endif
02216
02217
02218
02219
02220
02221
#define CHAR_SET_SIZE (1 << CHARBITS)
02222
02223
#ifndef emacs
02224
02225
02226
02227
02228
#ifndef Sword
02229
#define Sword 1
02230
#endif
02231
#define SYNTAX(c) re_syntax_table[c]
02232
RX_DECL
char re_syntax_table[CHAR_SET_SIZE];
02233
#endif
02234
02235
02236
02237
02238
02239
02240
#define AT_STRINGS_BEG() \
02241
( -1 \
02242
== ((search_state.test_pos.pos - search_state.test_pos.string) \
02243
+ search_state.test_pos.offset))
02244
02245
#define AT_STRINGS_END() \
02246
( (total_size - 1) \
02247
== ((search_state.test_pos.pos - search_state.test_pos.string) \
02248
+ search_state.test_pos.offset))
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
#define LETTER_P(POS,OFF) \
02259
( SYNTAX (fetch_char(POS, OFF, app_closure, stop)) \
02260
== Sword)
02261
02262
02263
02264
02265
#define AT_WORD_BOUNDARY(d) \
02266
(AT_STRINGS_BEG () || AT_STRINGS_END () || LETTER_P (d,0) != LETTER_P (d, 1))
02267
02268
02269
#ifdef RX_SUPPORT_CONTINUATIONS
02270
#define RX_STACK_ALLOC(BYTES) malloc(BYTES)
02271
#define RX_STACK_FREE(MEM) free(MEM)
02272
#else
02273
#define RX_STACK_ALLOC(BYTES) alloca(BYTES)
02274
#define RX_STACK_FREE(MEM) \
02275
((struct rx_stack_chunk *)MEM)->next_chunk = search_state.free_chunks; \
02276
search_state.free_chunks = ((struct rx_stack_chunk *)MEM);
02277
02278
#endif
02279
02280
#define PUSH(CHUNK_VAR,BYTES) \
02281
if (!CHUNK_VAR || (CHUNK_VAR->bytes_left < (BYTES))) \
02282
{ \
02283
struct rx_stack_chunk * new_chunk; \
02284
if (search_state.free_chunks) \
02285
{ \
02286
new_chunk = search_state.free_chunks; \
02287
search_state.free_chunks = search_state.free_chunks->next_chunk; \
02288
} \
02289
else \
02290
{ \
02291
new_chunk = (struct rx_stack_chunk *)RX_STACK_ALLOC(search_state.chunk_bytes); \
02292
if (!new_chunk) \
02293
{ \
02294
search_state.ret_val = 0; \
02295
goto test_do_return; \
02296
} \
02297
} \
02298
new_chunk->sp = (char *)new_chunk + sizeof (struct rx_stack_chunk); \
02299
new_chunk->bytes_left = (search_state.chunk_bytes \
02300
- (BYTES) \
02301
- sizeof (struct rx_stack_chunk)); \
02302
new_chunk->next_chunk = CHUNK_VAR; \
02303
CHUNK_VAR = new_chunk; \
02304
} \
02305
else \
02306
(CHUNK_VAR->sp += (BYTES)), (CHUNK_VAR->bytes_left -= (BYTES))
02307
02308
#define POP(CHUNK_VAR,BYTES) \
02309
if (CHUNK_VAR->sp == ((char *)CHUNK_VAR + sizeof(*CHUNK_VAR))) \
02310
{ \
02311
struct rx_stack_chunk * new_chunk = CHUNK_VAR->next_chunk; \
02312
RX_STACK_FREE(CHUNK_VAR); \
02313
CHUNK_VAR = new_chunk; \
02314
} \
02315
else \
02316
(CHUNK_VAR->sp -= BYTES), (CHUNK_VAR->bytes_left += BYTES)
02317
02318
02319
02320
#define SRCH_TRANSLATE(C) search_state.translate[(unsigned char) (C)]
02321
02322
02323
02324
02325
#ifdef __STDC__
02326
RX_DECL __inline__
int
02327
rx_search (
struct re_pattern_buffer * rxb,
02328
int startpos,
02329
int range,
02330
int stop,
02331
int total_size,
02332 rx_get_burst_fn get_burst,
02333 rx_back_check_fn back_check,
02334
rx_fetch_char_fn fetch_char,
02335
void * app_closure,
02336
struct re_registers * regs,
02337
struct rx_search_state * resume_state,
02338
struct rx_search_state * save_state)
02339 #
else
02340 RX_DECL __inline__
int
02341
rx_search (rxb, startpos, range, stop, total_size,
02342 get_burst, back_check, fetch_char,
02343 app_closure, regs, resume_state, save_state)
02344 struct
re_pattern_buffer * rxb;
02345 int startpos;
02346 int range;
02347 int stop;
02348 int total_size;
02349 rx_get_burst_fn get_burst;
02350 rx_back_check_fn back_check;
02351 rx_fetch_char_fn fetch_char;
02352 void * app_closure;
02353 struct
re_registers * regs;
02354 struct
rx_search_state * resume_state;
02355 struct
rx_search_state * save_state;
02356 #endif
02357 {
02358
int pc;
02359
int test_state;
02360
struct rx_search_state search_state;
02361
02362
search_state.
free_chunks = 0;
02363
if (!
resume_state)
02364 pc =
rx_outer_start;
02365
else
02366 {
02367
search_state = *
resume_state;
02368
regs =
search_state.
saved_regs;
02369
rxb =
search_state.
saved_rxb;
02370
startpos =
search_state.
saved_startpos;
02371
range =
search_state.
saved_range;
02372
stop =
search_state.
saved_stop;
02373
total_size =
search_state.
saved_total_size;
02374
get_burst =
search_state.
saved_get_burst;
02375
back_check =
search_state.
saved_back_check;
02376 pc =
search_state.
outer_search_resume_pt;
02377
if (0)
02378 {
02379 return_continuation:
02380
if (
save_state)
02381 {
02382 *
save_state =
search_state;
02383
save_state->
saved_regs =
regs;
02384
save_state->
saved_rxb =
rxb;
02385
save_state->
saved_startpos =
startpos;
02386
save_state->
saved_range =
range;
02387
save_state->
saved_stop =
stop;
02388
save_state->
saved_total_size =
total_size;
02389
save_state->
saved_get_burst =
get_burst;
02390
save_state->
saved_back_check =
back_check;
02391
save_state->
outer_search_resume_pt = pc;
02392 }
02393
return rx_search_continuation;
02394 }
02395 }
02396
02397
switch (pc)
02398 {
02399
case rx_outer_start:
02400
search_state.
ret_val =
rx_search_fail;
02401 (
search_state.
lparen
02402 =
search_state.
rparen
02403 =
search_state.
best_lpspace
02404 =
search_state.
best_rpspace
02405 = 0);
02406
02407
02408
02409
02410
search_state.
num_regs =
rxb->
re_nsub + 1;
02411
02412
02413
02414
if ((startpos < 0) || (startpos >
total_size))
02415
return rx_search_fail;
02416
02417
02418 {
02419
int endpos;
02420 endpos =
startpos +
range;
02421
if (endpos < -1)
02422
range = (-1 -
startpos);
02423
else if (endpos > (
total_size + 1))
02424
range =
total_size -
startpos;
02425 }
02426
02427
02428
02429
02430
if (
rxb->
begbuf_only && (
range > 0))
02431 {
02432
if (
startpos > 0)
02433
return rx_search_fail;
02434
else
02435
range = 1;
02436 }
02437
02438
02439
if (!
regs ||
rxb->
no_sub)
02440 {
02441
search_state.
best_lpspace =
02442 (
regoff_t *)REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t));
02443
search_state.
best_rpspace =
02444 (
regoff_t *)REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t));
02445
search_state.
best_lparen =
search_state.
best_lpspace;
02446
search_state.
best_rparen =
search_state.
best_rpspace;
02447 }
02448
else
02449 {
02450
02451
if (
rxb->
regs_allocated == REGS_UNALLOCATED)
02452 {
02453
02454
02455
regs->num_regs = MAX (RE_NREGS,
rxb->
re_nsub + 1);
02456
regs->start = ((
regoff_t *)
02457 malloc (
regs->num_regs * sizeof (
regoff_t)));
02458
regs->end = ((
regoff_t *)
02459 malloc (
regs->num_regs * sizeof (
regoff_t)));
02460
if (
regs->start == 0 ||
regs->end == 0)
02461
return rx_search_error;
02462
rxb->
regs_allocated = REGS_REALLOCATE;
02463 }
02464
else if (
rxb->
regs_allocated == REGS_REALLOCATE)
02465 {
02466
02467
02468
if (
regs->num_regs <
search_state.
num_regs + 1)
02469 {
02470
regs->num_regs =
search_state.
num_regs + 1;
02471
regs->start = ((
regoff_t *)
02472 realloc (
regs->start,
02473
regs->num_regs * sizeof (
regoff_t)));
02474
regs->end = ((
regoff_t *)
02475 realloc (
regs->end,
02476
regs->num_regs * sizeof (
regoff_t)));
02477
if (
regs->start == 0 ||
regs->end == 0)
02478
return rx_search_error;
02479 }
02480 }
02481
else if (
rxb->
regs_allocated != REGS_FIXED)
02482
return rx_search_error;
02483
02484
if (
regs->num_regs <
search_state.
num_regs + 1)
02485 {
02486
search_state.
best_lpspace =
02487 ((
regoff_t *)
02488 REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t)));
02489
search_state.
best_rpspace =
02490 ((
regoff_t *)
02491 REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t)));
02492
search_state.
best_lparen =
search_state.
best_lpspace;
02493
search_state.
best_rparen =
search_state.
best_rpspace;
02494 }
02495
else
02496 {
02497
search_state.
best_lparen =
regs->start;
02498
search_state.
best_rparen =
regs->end;
02499 }
02500 }
02501
02502
search_state.
lparen =
02503 (
regoff_t *) REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t));
02504
search_state.
rparen =
02505 (
regoff_t *) REGEX_ALLOCATE (
search_state.
num_regs *
sizeof(
regoff_t));
02506
02507
if (! (
search_state.
best_rparen
02508 &&
search_state.
best_lparen
02509 &&
search_state.
lparen &&
search_state.
rparen))
02510
return rx_search_error;
02511
02512
search_state.
best_last_l =
search_state.
best_last_r = -1;
02513
02514
search_state.
translate = (
rxb->
translate
02515 ?
rxb->
translate
02516 :
rx_id_translation);
02517
02518
02519
02520
02521
02522
02523
02524
02525
search_state.
nfa_choice = (
regs && !
rxb->
least_subs) ?
'\0' :
'\1';
02526
02527
02528
02529
02530
02531
search_state.
first_found = !
regs;
02532
02533
if (
range >= 0)
02534 {
02535
search_state.
outer_pos.
search_end =
startpos +
range;
02536
search_state.
outer_pos.
search_direction = 1;
02537 }
02538
else
02539 {
02540
search_state.
outer_pos.
search_end =
startpos +
range;
02541
search_state.
outer_pos.
search_direction = -1;
02542 }
02543
02544
02545
if ((
search_state.
outer_pos.
search_direction == 1)
02546 ? (
startpos >
search_state.
outer_pos.
search_end)
02547 : (
startpos <
search_state.
outer_pos.
search_end))
02548
return rx_search_fail;
02549
02550
02551 {
02552
struct rx_superset * start_contents;
02553
struct rx_nfa_state_set * start_nfa_set;
02554
02555
02556
02557
02558 start_nfa_set =
rxb->
start->
futures->
destset;
02559
if (
rxb->
rx.
start_set
02560 && (
rxb->
rx.
start_set->
starts_for == &
rxb->
rx))
02561 start_contents =
rxb->
rx.
start_set;
02562
else
02563 {
02564 start_contents =
02565
rx_superstate_eclosure_union (&
rxb->
rx,
02566
rx_superset_cons (&
rxb->
rx, 0, 0),
02567 start_nfa_set);
02568
02569
if (!start_contents)
02570
return rx_search_fail;
02571
02572 start_contents->starts_for = &
rxb->
rx;
02573
rxb->
rx.
start_set = start_contents;
02574 }
02575
if ( start_contents->superstate
02576 && (start_contents->superstate->rx_id ==
rxb->
rx.
rx_id))
02577 {
02578
search_state.
start_super = start_contents->superstate;
02579 rx_lock_superstate (&
rxb->
rx,
search_state.
start_super);
02580 }
02581
else
02582 {
02583 rx_protect_superset (&
rxb->
rx, start_contents);
02584
02585
search_state.
start_super =
rx_superstate (&
rxb->
rx, start_contents);
02586
if (!
search_state.
start_super)
02587
return rx_search_fail;
02588 rx_lock_superstate (&
rxb->
rx,
search_state.
start_super);
02589
rx_release_superset (&
rxb->
rx, start_contents);
02590 }
02591 }
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609 (
search_state.
outer_pos.
string
02610 =
search_state.
outer_pos.
end
02611 = 0);
02612
02613
search_state.
outer_pos.
offset = 0;
02614
search_state.
outer_pos.
size = 0;
02615
search_state.
outer_pos.
pos = (
unsigned char *)
startpos;
02616 init_fastmap (
rxb, &
search_state);
02617
02618
search_state.
fastmap_resume_pt =
rx_fastmap_start;
02619
case rx_outer_fastmap:
02620
02621 pseudo_do:
02622 {
02623 {
02624
int fastmap_state;
02625 fastmap_state = fastmap_search (
rxb,
stop,
get_burst,
app_closure,
02626 &
search_state);
02627
switch (fastmap_state)
02628 {
02629
case rx_fastmap_continuation:
02630 pc =
rx_outer_fastmap;
02631
goto return_continuation;
02632
case rx_fastmap_fail:
02633
goto finish;
02634
case rx_fastmap_ok:
02635
break;
02636 }
02637 }
02638
02639
02640
02641
02642
02643
startpos = (
search_state.
outer_pos.
pos
02644 -
search_state.
outer_pos.
string
02645 +
search_state.
outer_pos.
offset);
02646
#if 0
02647
if ((
range > 0) && (
startpos ==
search_state.
outer_pos.
search_end))
02648
goto finish;
02649
#endif
02650
}
02651
02652
search_state.
test_match_resume_pt =
rx_test_start;
02653
02654
case rx_outer_test:
02655
02656 {
02657
goto test_match;
02658 test_returns_to_search:
02659
switch (test_state)
02660 {
02661
case rx_test_continuation:
02662 pc =
rx_outer_test;
02663
goto return_continuation;
02664
case rx_test_error:
02665
search_state.
ret_val =
rx_search_error;
02666
goto finish;
02667
case rx_test_fail:
02668
break;
02669
case rx_test_ok:
02670
goto finish;
02671 }
02672
search_state.
outer_pos.
pos +=
search_state.
outer_pos.
search_direction;
02673
startpos +=
search_state.
outer_pos.
search_direction;
02674
#if 0
02675
if (
search_state.
test_pos.
pos <
search_state.
test_pos.
end)
02676
break;
02677
#endif
02678
}
02679
02680
case rx_outer_restore_pos:
02681 {
02682
int x;
02683 x =
get_burst (&
search_state.
outer_pos,
app_closure,
stop);
02684
switch (x)
02685 {
02686
case rx_get_burst_continuation:
02687 pc =
rx_outer_restore_pos;
02688
goto return_continuation;
02689
case rx_get_burst_error:
02690
search_state.
ret_val =
rx_search_error;
02691
goto finish;
02692
case rx_get_burst_no_more:
02693
if (
rxb->
can_match_empty)
02694
break;
02695
goto finish;
02696
case rx_get_burst_ok:
02697
break;
02698 }
02699 }
02700
02701
if ((
search_state.
outer_pos.
search_direction == 1)
02702 ? (
startpos <=
search_state.
outer_pos.
search_end)
02703 : (
startpos >
search_state.
outer_pos.
search_end))
02704
goto pseudo_do;
02705
02706
02707 finish:
02708 uninit_fastmap (
rxb, &
search_state);
02709
if (
search_state.
start_super)
02710 rx_unlock_superstate (&
rxb->
rx,
search_state.
start_super);
02711
02712
#ifdef regex_malloc
02713
if (
search_state.
lparen) free (
search_state.
lparen);
02714
if (
search_state.
rparen) free (
search_state.
rparen);
02715
if (
search_state.
best_lpspace) free (
search_state.
best_lpspace);
02716
if (
search_state.
best_rpspace) free (
search_state.
best_rpspace);
02717
#endif
02718
return search_state.
ret_val;
02719 }
02720
02721
02722 test_match:
02723 {
02724
enum rx_test_match_entry test_pc;
02725
int inx;
02726 test_pc =
search_state.
test_match_resume_pt;
02727
if (test_pc ==
rx_test_start)
02728 {
02729
#ifdef RX_DEBUG
02730
search_state.
backtrack_depth = 0;
02731
#endif
02732
search_state.
last_l =
search_state.
last_r = 0;
02733
search_state.
lparen[0] =
startpos;
02734
search_state.
super =
search_state.
start_super;
02735
search_state.
c =
search_state.
nfa_choice;
02736
search_state.
test_pos.
pos =
search_state.
outer_pos.
pos - 1;
02737
search_state.
test_pos.
string =
search_state.
outer_pos.
string;
02738
search_state.
test_pos.
end =
search_state.
outer_pos.
end;
02739
search_state.
test_pos.
offset =
search_state.
outer_pos.
offset;
02740
search_state.
test_pos.
size =
search_state.
outer_pos.
size;
02741
search_state.
test_pos.
search_direction = 1;
02742
search_state.
counter_stack = 0;
02743
search_state.
backtrack_stack = 0;
02744
search_state.
backtrack_frame_bytes =
02745 (
sizeof (
struct rx_backtrack_frame)
02746 + (
rxb->match_regs_on_stack
02747 ? sizeof (
regoff_t) * (
search_state.
num_regs + 1) * 2
02748 : 0));
02749
search_state.
chunk_bytes =
search_state.
backtrack_frame_bytes * 64;
02750
search_state.
test_ret =
rx_test_line_finished;
02751
search_state.
could_have_continued = 0;
02752 }
02753
02754
02755
02756 pseudo_while_1:
02757
switch (test_pc)
02758 {
02759
case rx_test_cache_hit_loop:
02760
goto resume_continuation_1;
02761
case rx_test_backreference_check:
02762
goto resume_continuation_2;
02763
case rx_test_backtrack_return:
02764
goto resume_continuation_3;
02765
case rx_test_start:
02766
#ifdef RX_DEBUG
02767
02768
02769
02770
02771
02772
02773
search_state.
line_no = 0;
02774
search_state.
lines_found = 0;
02775
#endif
02776
02777 top_of_cycle:
02778
02779
02780
02781
02782
search_state.
ifr = &
search_state.
super->
transitions [
search_state.
c];
02783
02784 recurse_test_match:
02785
02786
02787
02788
02789
02790
02791 restart:
02792
02793
02794
02795
02796
02797 {
02798
struct rx_inx * next_tr_table;
02799
struct rx_inx * this_tr_table;
02800
02801
02802
02803
02804
02805
02806
02807 next_tr_table = (
struct rx_inx *)
search_state.
ifr->
data;
02808 this_tr_table =
search_state.
super->
transitions;
02809
while (next_tr_table)
02810 {
02811
#ifdef RX_DEBUG_0
02812
if (rx_debug_trace)
02813 {
02814
struct rx_superset * setp;
02815
02816 fprintf (stderr,
"%d %d>> re_next_char @ %d (%d)",
02817
search_state.
line_no,
02818
search_state.
backtrack_depth,
02819 (
search_state.
test_pos.
pos -
search_state.
test_pos.
string
02820 +
search_state.
test_pos.
offset),
search_state.
c);
02821
02822
search_state.
super =
02823 ((
struct rx_superstate *)
02824 ((
char *)this_tr_table
02825 - ((
unsigned long)
02826 ((
struct rx_superstate *)0)->transitions)));
02827
02828 setp =
search_state.
super->
contents;
02829 fprintf (stderr,
" superstet (rx=%d, &=%x: ",
02830
rxb->
rx.
rx_id, setp);
02831
while (setp)
02832 {
02833 fprintf (stderr,
"%d ", setp->id);
02834 setp = setp->cdr;
02835 }
02836 fprintf (stderr,
"\n");
02837 }
02838
#endif
02839
this_tr_table = next_tr_table;
02840 ++
search_state.
test_pos.
pos;
02841
if (
search_state.
test_pos.
pos ==
search_state.
test_pos.
end)
02842 {
02843
int burst_state;
02844 try_burst_1:
02845 burst_state =
get_burst (&
search_state.
test_pos,
02846
app_closure,
stop);
02847
switch (burst_state)
02848 {
02849
case rx_get_burst_continuation:
02850
search_state.
saved_this_tr_table = this_tr_table;
02851
search_state.
saved_next_tr_table = next_tr_table;
02852 test_pc =
rx_test_cache_hit_loop;
02853
goto test_return_continuation;
02854
02855 resume_continuation_1:
02856
02857
search_state.
saved_this_tr_table = this_tr_table;
02858
search_state.
saved_next_tr_table = next_tr_table;
02859
goto try_burst_1;
02860
02861
case rx_get_burst_ok:
02862
02863
break;
02864
02865
case rx_get_burst_no_more:
02866
search_state.
test_ret =
rx_test_line_finished;
02867
search_state.
could_have_continued = 1;
02868
goto test_do_return;
02869
02870
case rx_get_burst_error:
02871
02872
search_state.
test_ret =
rx_test_internal_error;
02873
goto test_do_return;
02874 }
02875 }
02876
search_state.
c = *
search_state.
test_pos.
pos;
02877
search_state.
ifr = this_tr_table +
search_state.
c;
02878 next_tr_table = (
struct rx_inx *)
search_state.
ifr->
data;
02879 }
02880
02881
02882
02883
02884
02885
02886
02887
search_state.
super =
02888 ((
struct rx_superstate *)
02889 ((
char *)this_tr_table
02890 - ((
unsigned long)
02891 ((
struct rx_superstate *)0)->transitions)));
02892 }
02893
02894
02895
02896
02897 inx = (
int)
search_state.
ifr->
inx;
02898
#ifdef RX_DEBUG_0
02899
if (rx_debug_trace)
02900 {
02901
struct rx_superset * setp =
search_state.
super->
contents;
02902
02903 fprintf (stderr,
"%d %d>> %s @ %d (%d)",
search_state.
line_no,
02904
search_state.
backtrack_depth,
02905 inx_names[inx],
02906 (
search_state.
test_pos.
pos -
search_state.
test_pos.
string
02907 + (test_pos.half == 0 ? 0 : size1)),
search_state.
c);
02908
02909 fprintf (stderr,
" superstet (rx=%d, &=%x: ",
02910
rxb->
rx.
rx_id, setp);
02911
while (setp)
02912 {
02913 fprintf (stderr,
"%d ", setp->id);
02914 setp = setp->cdr;
02915 }
02916 fprintf (stderr,
"\n");
02917 }
02918
#endif
02919
switch ((
enum rx_opcode)inx)
02920 {
02921
case rx_do_side_effects:
02922
02923
02924
02925
02926 {
02927
struct rx_distinct_future * df =
02928 (
struct rx_distinct_future *)
search_state.
ifr->
data_2;
02929
struct rx_se_list * el = df->effects;
02930
02931
02932
02933
while (el)
02934 {
02935
long effect;
02936 effect = (
long)el->car;
02937
if (effect < 0)
02938 {
02939
#ifdef RX_DEBUG_0
02940
if (rx_debug_trace)
02941 {
02942
struct rx_superset * setp =
search_state.
super->
contents;
02943
02944 fprintf (stderr,
"....%d %d>> %s\n",
search_state.
line_no,
02945
search_state.
backtrack_depth,
02946 efnames[-effect]);
02947 }
02948
#endif
02949
switch ((
enum re_side_effects) effect)
02950
02951 {
02952
case re_se_pushback:
02953
search_state.
ifr = &df->future_frame;
02954
if (!
search_state.
ifr->
data)
02955 {
02956
struct rx_superstate * sup;
02957 sup =
search_state.
super;
02958 rx_lock_superstate (rx, sup);
02959
if (!
rx_handle_cache_miss (&
rxb->
rx,
02960
search_state.
super,
02961
search_state.
c,
02962 (
search_state.
ifr
02963 ->
data_2)))
02964 {
02965 rx_unlock_superstate (rx, sup);
02966
search_state.
test_ret =
rx_test_internal_error;
02967
goto test_do_return;
02968 }
02969 rx_unlock_superstate (rx, sup);
02970 }
02971
02972
search_state.
c =
't';
02973
search_state.
super
02974 = ((
struct rx_superstate *)
02975 ((
char *)
search_state.
ifr->
data
02976 - (
long)(((
struct rx_superstate *)0)
02977 ->transitions)));
02978
goto top_of_cycle;
02979
break;
02980
case re_se_push0:
02981 {
02982
struct rx_counter_frame * old_cf
02983 = (
search_state.
counter_stack
02984 ? ((
struct rx_counter_frame *)
02985
search_state.
counter_stack->
sp)
02986 : 0);
02987
struct rx_counter_frame * cf;
02988 PUSH (
search_state.
counter_stack,
02989 sizeof (
struct rx_counter_frame));
02990 cf = ((
struct rx_counter_frame *)
02991
search_state.
counter_stack->
sp);
02992 cf->tag = re_se_iter;
02993 cf->val = 0;
02994 cf->inherited_from = 0;
02995 cf->cdr = old_cf;
02996
break;
02997 }
02998
case re_se_fail:
02999
goto test_do_return;
03000
case re_se_begbuf:
03001
if (!AT_STRINGS_BEG ())
03002
goto test_do_return;
03003
break;
03004
case re_se_endbuf:
03005
if (!AT_STRINGS_END ())
03006
goto test_do_return;
03007
break;
03008
case re_se_wordbeg:
03009
if ( LETTER_P (&
search_state.
test_pos, 1)
03010 && ( AT_STRINGS_BEG()
03011 || !LETTER_P (&
search_state.
test_pos, 0)))
03012
break;
03013
else
03014
goto test_do_return;
03015
case re_se_wordend:
03016
if ( !AT_STRINGS_BEG ()
03017 && LETTER_P (&
search_state.
test_pos, 0)
03018 && (AT_STRINGS_END ()
03019 || !LETTER_P (&
search_state.
test_pos, 1)))
03020
break;
03021
else
03022
goto test_do_return;
03023
case re_se_wordbound:
03024
if (AT_WORD_BOUNDARY (&
search_state.
test_pos))
03025
break;
03026
else
03027
goto test_do_return;
03028
case re_se_notwordbound:
03029
if (!AT_WORD_BOUNDARY (&
search_state.
test_pos))
03030
break;
03031
else
03032
goto test_do_return;
03033
case re_se_hat:
03034
if (AT_STRINGS_BEG ())
03035 {
03036
if (
rxb->
not_bol)
03037
goto test_do_return;
03038
else
03039
break;
03040 }
03041
else
03042 {
03043
char pos_c = *
search_state.
test_pos.
pos;
03044
if ( (SRCH_TRANSLATE (pos_c)
03045 == SRCH_TRANSLATE(
'\n'))
03046 &&
rxb->
newline_anchor)
03047
break;
03048
else
03049
goto test_do_return;
03050 }
03051
case re_se_dollar:
03052
if (AT_STRINGS_END ())
03053 {
03054
if (
rxb->
not_eol)
03055
goto test_do_return;
03056
else
03057
break;
03058 }
03059
else
03060 {
03061
if ( ( SRCH_TRANSLATE (
fetch_char
03062 (&
search_state.
test_pos, 1,
03063
app_closure,
stop))
03064 == SRCH_TRANSLATE (
'\n'))
03065 &&
rxb->
newline_anchor)
03066
break;
03067
else
03068
goto test_do_return;
03069 }
03070
03071
case re_se_try:
03072
03073
03074
03075
03076
03077
break;
03078
03079
case re_se_pushpos:
03080 {
03081
int urhere =
03082 ((
int)(
search_state.
test_pos.
pos
03083 -
search_state.
test_pos.
string)
03084 +
search_state.
test_pos.
offset);
03085
struct rx_counter_frame * old_cf
03086 = (
search_state.
counter_stack
03087 ? ((
struct rx_counter_frame *)
03088
search_state.
counter_stack->
sp)
03089 : 0);
03090
struct rx_counter_frame * cf;
03091 PUSH(
search_state.
counter_stack,
03092 sizeof (
struct rx_counter_frame));
03093 cf = ((
struct rx_counter_frame *)
03094
search_state.
counter_stack->
sp);
03095 cf->tag = re_se_pushpos;
03096 cf->val = urhere;
03097 cf->inherited_from = 0;
03098 cf->cdr = old_cf;
03099
break;
03100 }
03101
03102
case re_se_chkpos:
03103 {
03104
int urhere =
03105 ((
int)(
search_state.
test_pos.
pos
03106 -
search_state.
test_pos.
string)
03107 +
search_state.
test_pos.
offset);
03108
struct rx_counter_frame * cf
03109 = ((
struct rx_counter_frame *)
03110
search_state.
counter_stack->
sp);
03111
if (cf->val == urhere)
03112
goto test_do_return;
03113 cf->val = urhere;
03114
break;
03115 }
03116
break;
03117
03118
case re_se_poppos:
03119 POP(
search_state.
counter_stack,
03120 sizeof (
struct rx_counter_frame));
03121
break;
03122
03123
03124
case re_se_at_dot:
03125
case re_se_syntax:
03126
case re_se_not_syntax:
03127
#ifdef emacs
03128
03129
03130
03131
#endif
03132
break;
03133
case re_se_win:
03134
case re_se_lparen:
03135
case re_se_rparen:
03136
case re_se_backref:
03137
case re_se_iter:
03138
case re_se_end_iter:
03139
case re_se_tv:
03140
case re_floogle_flap:
03141
search_state.
ret_val = 0;
03142
goto test_do_return;
03143 }
03144 }
03145
else
03146 {
03147
#ifdef RX_DEBUG_0
03148
if (rx_debug_trace)
03149 fprintf (stderr,
"....%d %d>> %s %d %d\n",
search_state.
line_no,
03150
search_state.
backtrack_depth,
03151 efnames2[
rxb->
se_params [effect].
se],
03152
rxb->
se_params [effect].
op1,
03153
rxb->
se_params [effect].
op2);
03154
#endif
03155
switch (
rxb->
se_params [effect].
se)
03156 {
03157
case re_se_win:
03158
03159
03160
03161
03162
03163
03164
03165 {
03166
int urhere =
03167 ((
int)(
search_state.
test_pos.
pos
03168 -
search_state.
test_pos.
string)
03169 +
search_state.
test_pos.
offset);
03170
03171
if ( (
search_state.
best_last_r < 0)
03172 || (urhere + 1 >
search_state.
best_rparen[0]))
03173 {
03174
03175
03176
03177
int x;
03178
for (x = 0; x <=
search_state.
last_l; ++x)
03179
search_state.
best_lparen[x] =
search_state.
lparen[x];
03180
search_state.
best_last_l =
search_state.
last_l;
03181
for (x = 0; x <=
search_state.
last_r; ++x)
03182
search_state.
best_rparen[x] =
search_state.
rparen[x];
03183
search_state.
best_rparen[0] = urhere + 1;
03184
search_state.
best_last_r =
search_state.
last_r;
03185 }
03186
03187
03188
03189
03190
if (
search_state.
first_found)
03191 {
03192
search_state.
test_ret =
rx_test_found_first;
03193
goto test_do_return;
03194 }
03195 }
03196
break;
03197
case re_se_lparen:
03198 {
03199
int urhere =
03200 ((
int)(
search_state.
test_pos.
pos
03201 -
search_state.
test_pos.
string)
03202 +
search_state.
test_pos.
offset);
03203
03204
int reg =
rxb->
se_params [effect].
op1;
03205
#if 0
03206
if (reg >
search_state.
last_l)
03207
#endif
03208
{
03209
search_state.
lparen[reg] = urhere + 1;
03210
03211
03212
03213
03214
03215
03216
03217
if (
search_state.
last_l < reg)
03218
while (++
search_state.
last_l < reg)
03219
search_state.
lparen[
search_state.
last_l] = -1;
03220 }
03221
break;
03222 }
03223
03224
case re_se_rparen:
03225 {
03226
int urhere =
03227 ((
int)(
search_state.
test_pos.
pos
03228 -
search_state.
test_pos.
string)
03229 +
search_state.
test_pos.
offset);
03230
int reg =
rxb->
se_params [effect].
op1;
03231
search_state.
rparen[reg] = urhere + 1;
03232
if (
search_state.
last_r < reg)
03233 {
03234
while (++
search_state.
last_r < reg)
03235
search_state.
rparen[
search_state.
last_r]
03236 = -1;
03237 }
03238
break;
03239 }
03240
03241
case re_se_backref:
03242 {
03243
int reg =
rxb->
se_params [effect].
op1;
03244
if ( reg >
search_state.
last_r
03245 ||
search_state.
rparen[reg] < 0)
03246
goto test_do_return;
03247
03248 {
03249
int backref_status;
03250 check_backreference:
03251 backref_status
03252 =
back_check (&
search_state.
test_pos,
03253
search_state.
lparen[reg],
03254
search_state.
rparen[reg],
03255
search_state.
translate,
03256
app_closure,
03257
stop);
03258
switch (backref_status)
03259 {
03260
case rx_back_check_continuation:
03261
search_state.
saved_reg = reg;
03262 test_pc =
rx_test_backreference_check;
03263
goto test_return_continuation;
03264 resume_continuation_2:
03265 reg =
search_state.
saved_reg;
03266
goto check_backreference;
03267
case rx_back_check_fail:
03268
03269
goto test_do_return;
03270
case rx_back_check_pass:
03271
03272
03273
03274
03275
break;
03276 }
03277 }
03278
break;
03279 }
03280
case re_se_iter:
03281 {
03282
struct rx_counter_frame * csp
03283 = ((
struct rx_counter_frame *)
03284
search_state.
counter_stack->
sp);
03285
if (csp->val ==
rxb->
se_params[effect].
op2)
03286
goto test_do_return;
03287
else
03288 ++csp->val;
03289
break;
03290 }
03291
case re_se_end_iter:
03292 {
03293
struct rx_counter_frame * csp
03294 = ((
struct rx_counter_frame *)
03295
search_state.
counter_stack->
sp);
03296
if (csp->val <
rxb->
se_params[effect].
op1)
03297
goto test_do_return;
03298
else
03299 {
03300
struct rx_counter_frame * source = csp;
03301
while (source->inherited_from)
03302 source = source->inherited_from;
03303
if (!source || !source->cdr)
03304 {
03305 POP(
search_state.
counter_stack,
03306
sizeof(
struct rx_counter_frame));
03307 }
03308
else
03309 {
03310 source = source->cdr;
03311 csp->val = source->val;
03312 csp->tag = source->tag;
03313 csp->cdr = 0;
03314 csp->inherited_from = source;
03315 }
03316 }
03317
break;
03318 }
03319
case re_se_tv:
03320
03321
break;
03322
case re_se_try:
03323
case re_se_pushback:
03324
case re_se_push0:
03325
case re_se_pushpos:
03326
case re_se_chkpos:
03327
case re_se_poppos:
03328
case re_se_at_dot:
03329
case re_se_syntax:
03330
case re_se_not_syntax:
03331
case re_se_begbuf:
03332
case re_se_hat:
03333
case re_se_wordbeg:
03334
case re_se_wordbound:
03335
case re_se_notwordbound:
03336
case re_se_wordend:
03337
case re_se_endbuf:
03338
case re_se_dollar:
03339
case re_se_fail:
03340
case re_floogle_flap:
03341
search_state.
ret_val = 0;
03342
goto test_do_return;
03343 }
03344 }
03345 el = el->cdr;
03346 }
03347
03348
03349
03350
03351
search_state.
ifr = &df->future_frame;
03352
goto restart;
03353 }
03354
03355
case rx_backtrack_point:
03356 {
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
struct rx_backtrack_frame * bf;
03369
03370 PUSH(
search_state.
backtrack_stack,
03371
search_state.
backtrack_frame_bytes);
03372
#ifdef RX_DEBUG_0
03373
++
search_state.
backtrack_depth;
03374
#endif
03375
03376 bf = ((
struct rx_backtrack_frame *)
03377
search_state.
backtrack_stack->
sp);
03378 {
03379 bf->stk_super =
search_state.
super;
03380
03381
03382
03383 rx_lock_superstate (&
rxb->
rx,
search_state.
super);
03384
#ifdef RX_DEBUG_0
03385
bf->stk_search_state.line_no =
search_state.
line_no;
03386
#endif
03387
bf->stk_c =
search_state.
c;
03388 bf->stk_test_pos =
search_state.
test_pos;
03389 bf->stk_last_l =
search_state.
last_l;
03390 bf->stk_last_r =
search_state.
last_r;
03391 bf->df = ((
struct rx_super_edge *)
03392
search_state.
ifr->
data_2)->options;
03393 bf->first_df = bf->df;
03394 bf->counter_stack_sp = (
search_state.
counter_stack
03395 ?
search_state.
counter_stack->
sp
03396 : 0);
03397 bf->stk_test_ret =
search_state.
test_ret;
03398
if (
rxb->
match_regs_on_stack)
03399 {
03400
int x;
03401
regoff_t * stk =
03402 (
regoff_t *)((
char *)bf +
sizeof (*bf));
03403
for (x = 0; x <=
search_state.
last_l; ++x)
03404 stk[x] =
search_state.
lparen[x];
03405 stk += x;
03406
for (x = 0; x <=
search_state.
last_r; ++x)
03407 stk[x] =
search_state.
rparen[x];
03408 }
03409 }
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424 while_non_det_options:
03425
#ifdef RX_DEBUG_0
03426
++
search_state.
lines_found;
03427
if (rx_debug_trace)
03428 fprintf (stderr,
"@@@ %d calls %d @@@\n",
03429
search_state.
line_no,
search_state.
lines_found);
03430
03431
search_state.
line_no =
search_state.
lines_found;
03432
#endif
03433
03434
if (bf->df->next_same_super_edge[0] == bf->first_df)
03435 {
03436
03437
03438
03439
search_state.
ifr = (bf->df->effects
03440 ? &bf->df->side_effects_frame
03441 : &bf->df->future_frame);
03442
03443 rx_unlock_superstate (&
rxb->
rx,
search_state.
super);
03444 POP(
search_state.
backtrack_stack,
03445
search_state.
backtrack_frame_bytes);
03446
#ifdef RX_DEBUG
03447
--
search_state.
backtrack_depth;
03448
#endif
03449
goto restart;
03450 }
03451
else
03452 {
03453
if (
search_state.
counter_stack)
03454 {
03455
struct rx_counter_frame * old_cf
03456 = ((
struct rx_counter_frame *)
search_state.
counter_stack->
sp);
03457
struct rx_counter_frame * cf;
03458 PUSH(
search_state.
counter_stack, sizeof (
struct rx_counter_frame));
03459 cf = ((
struct rx_counter_frame *)
search_state.
counter_stack->
sp);
03460 cf->tag = old_cf->tag;
03461 cf->val = old_cf->val;
03462 cf->inherited_from = old_cf;
03463 cf->cdr = 0;
03464 }
03465
03466
search_state.
ifr = (bf->df->effects
03467 ? &bf->df->side_effects_frame
03468 : &bf->df->future_frame);
03469
goto recurse_test_match;
03470 }
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480 test_do_return:
03481
03482
if (!
search_state.
backtrack_stack)
03483 {
03484
#ifdef RX_DEBUG_0
03485
if (rx_debug_trace)
03486 fprintf (stderr,
"!!! %d bails returning %d !!!\n",
03487
search_state.
line_no,
search_state.
test_ret);
03488
#endif
03489
03490
03491
if (
search_state.
test_ret !=
rx_test_internal_error)
03492
goto return_from_test_match;
03493
else
03494
goto error_in_testing_match;
03495 }
03496
03497
03498
03499
03500
03501 bf = ((
struct rx_backtrack_frame *)
03502
search_state.
backtrack_stack->
sp);
03503
#ifdef RX_DEBUG_0
03504
if (rx_debug_trace)
03505 fprintf (stderr,
"+++ %d returns %d (to %d)+++\n",
03506
search_state.
line_no,
03507
search_state.
test_ret,
03508 bf->stk_search_state.line_no);
03509
#endif
03510
03511
while (
search_state.
counter_stack
03512 && (!bf->counter_stack_sp
03513 || (bf->counter_stack_sp
03514 !=
search_state.
counter_stack->
sp)))
03515 {
03516 POP(
search_state.
counter_stack,
03517 sizeof (
struct rx_counter_frame));
03518 }
03519
03520
if (
search_state.
test_ret ==
rx_test_internal_error)
03521 {
03522 POP (
search_state.
backtrack_stack,
03523
search_state.
backtrack_frame_bytes);
03524
search_state.
test_ret =
rx_test_internal_error;
03525
goto test_do_return;
03526 }
03527
03528
03529
03530
03531
if ( (
search_state.
test_ret ==
rx_test_found_first)
03532 &&
search_state.
first_found)
03533 {
03534 rx_unlock_superstate (&
rxb->
rx, bf->stk_super);
03535 POP (
search_state.
backtrack_stack,
03536
search_state.
backtrack_frame_bytes);
03537
goto test_do_return;
03538 }
03539
03540
search_state.
test_ret = bf->stk_test_ret;
03541
search_state.
last_l = bf->stk_last_l;
03542
search_state.
last_r = bf->stk_last_r;
03543 bf->df = bf->df->next_same_super_edge[0];
03544
search_state.
super = bf->stk_super;
03545
search_state.
c = bf->stk_c;
03546
#ifdef RX_DEBUG_0
03547
search_state.
line_no = bf->stk_search_state.line_no;
03548
#endif
03549
03550
if (
rxb->
match_regs_on_stack)
03551 {
03552
int x;
03553
regoff_t * stk =
03554 (
regoff_t *)((
char *)bf +
sizeof (*bf));
03555
for (x = 0; x <=
search_state.
last_l; ++x)
03556
search_state.
lparen[x] = stk[x];
03557 stk += x;
03558
for (x = 0; x <=
search_state.
last_r; ++x)
03559
search_state.
rparen[x] = stk[x];
03560 }
03561
03562 {
03563
int x;
03564 try_burst_2:
03565 x =
get_burst (&bf->stk_test_pos,
app_closure,
stop);
03566
switch (x)
03567 {
03568
case rx_get_burst_continuation:
03569
search_state.
saved_bf = bf;
03570 test_pc =
rx_test_backtrack_return;
03571
goto test_return_continuation;
03572 resume_continuation_3:
03573 bf =
search_state.
saved_bf;
03574
goto try_burst_2;
03575
case rx_get_burst_no_more:
03576
03577
03578
03579
case rx_get_burst_error:
03580
search_state.
test_ret =
rx_test_internal_error;
03581
goto test_do_return;
03582
case rx_get_burst_ok:
03583
break;
03584 }
03585 }
03586
search_state.
test_pos = bf->stk_test_pos;
03587
goto while_non_det_options;
03588 }
03589
03590
03591
case rx_cache_miss:
03592
03593
03594
03595
03596
03597
search_state.
ifr =
rx_handle_cache_miss (&
rxb->
rx,
03598
search_state.
super,
03599
search_state.
c,
03600
search_state.
ifr->
data_2);
03601
if (!
search_state.
ifr)
03602 {
03603
search_state.
test_ret =
rx_test_internal_error;
03604
goto test_do_return;
03605 }
03606
goto restart;
03607
03608
case rx_backtrack:
03609
03610
03611
03612
03613
goto test_do_return;
03614
03615
case rx_next_char:
03616
case rx_error_inx:
03617
case rx_num_instructions:
03618
search_state.
ret_val = 0;
03619
goto test_do_return;
03620 }
03621
goto pseudo_while_1;
03622 }
03623
03624
03625
03626
03627
03628 error_in_testing_match:
03629 test_state =
rx_test_error;
03630
goto test_returns_to_search;
03631
03632
03633
03634
03635
03636 return_from_test_match:
03637
03638
if (
search_state.
best_last_l >= 0)
03639 {
03640
if (
regs && (
regs->start !=
search_state.
best_lparen))
03641 {
03642 bcopy (
search_state.
best_lparen,
regs->start,
03643
regs->num_regs * sizeof (
int));
03644 bcopy (
search_state.
best_rparen,
regs->end,
03645
regs->num_regs * sizeof (
int));
03646 }
03647
if (
regs && !
rxb->
no_sub)
03648 {
03649
int q;
03650
int bound = (
regs->num_regs >
search_state.
num_regs
03651 ?
regs->num_regs
03652 :
search_state.
num_regs);
03653
regoff_t * s =
regs->start;
03654
regoff_t * e =
regs->end;
03655
for (q =
search_state.
best_last_l + 1; q < bound; ++q)
03656 s[q] = e[q] = -1;
03657 }
03658
search_state.
ret_val =
search_state.
best_lparen[0];
03659 test_state =
rx_test_ok;
03660
goto test_returns_to_search;
03661 }
03662
else
03663 {
03664 test_state =
rx_test_fail;
03665
goto test_returns_to_search;
03666 }
03667
03668 test_return_continuation:
03669
search_state.
test_match_resume_pt = test_pc;
03670 test_state =
rx_test_continuation;
03671
goto test_returns_to_search;
03672 }
03673 }
03674
03675
03676
03677
#endif
03678
03679
03680
03681
#else
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03694
03695 RX_DEF_SE(1, re_se_try, = -1)
03696
03697 RX_DEF_SE(0, re_se_pushback, = re_se_try - 1)
03698 RX_DEF_SE(0, re_se_push0, = re_se_pushback -1)
03699 RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1)
03700 RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1)
03701 RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1)
03702
03703 RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1)
03704 RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1)
03705 RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1)
03706
03707 RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1)
03708 RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1)
03709
03710 RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1)
03711 RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1)
03712 RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1)
03713
03714 RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1)
03715 RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1)
03716
03717
03718
03719
03720
03721 RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1)
03722
03723
03724 RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1)
03725
03726
03727
03728
03729
03730 RX_DEF_CPLX_SE(1, re_se_win, = 0)
03731 RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1)
03732 RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1)
03733 RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1)
03734 RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1)
03735 RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1)
03736 RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1)
03737
03738 #endif
03739
03740 #endif