]>
jfr.im git - irc/evilnet/x3.git/blob - rx/rxstr.c
1 /* Copyright (C) 1995, 1996 Tom Lord
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU Library General Public License as published by
5 * the Free Software Foundation; either version 2, or (at your option)
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public License
14 * along with this software; see the file COPYING. If not, write to
15 * the Free Software Foundation, 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
28 rx_str_vmfn (void * closure
, unsigned const char ** burstp
, int * lenp
, int * offsetp
, int start
, int end
, int need
)
31 rx_str_vmfn (closure
, burstp
, lenp
, offsetp
, start
, end
, need
)
33 unsigned const char ** burstp
;
41 struct rx_str_closure
* strc
;
42 strc
= (struct rx_str_closure
*)closure
;
45 || (need
> strc
->len
))
56 rx_str_contextfn (void * closure
, struct rexp_node
* node
, int start
, int end
, struct rx_registers
* regs
)
59 rx_str_contextfn (closure
, node
, start
, end
, regs
)
61 struct rexp_node
* node
;
64 struct rx_registers
* regs
;
67 struct rx_str_closure
* strc
;
69 strc
= (struct rx_str_closure
*)closure
;
70 switch (node
->params
.intval
)
72 case '1': case '2': case '3': case '4': case '5':
73 case '6': case '7': case '8': case '9':
77 regn
= node
->params
.intval
- '0';
78 if ( (regs
[regn
].rm_so
== -1)
79 || ((end
- start
) != (regs
[regn
].rm_eo
- regs
[regn
].rm_so
)))
83 if (strc
->rules
.case_indep
)
84 cmp
= strncasecmp (strc
->str
+ start
,
85 strc
->str
+ regs
[regn
].rm_so
,
88 cmp
= strncmp (strc
->str
+ start
,
89 strc
->str
+ regs
[regn
].rm_so
,
100 return (( (start
== end
)
101 && ( ((start
== 0) && !strc
->rules
.not_bol
)
103 && strc
->rules
.newline_anchor
104 && (strc
->str
[start
- 1] == '\n'))))
111 return (( (start
== end
)
112 && ( ((start
== strc
->len
) && !strc
->rules
.not_eol
)
113 || ( (start
< strc
->len
)
114 && strc
->rules
.newline_anchor
115 && (strc
->str
[start
] == '\n'))))