(&mut self, mut req: Request<'_, S>)
| 146 | } |
| 147 | |
| 148 | pub fn search<S: StrDrive>(&mut self, mut req: Request<'_, S>) -> bool { |
| 149 | self.start = req.start; |
| 150 | req.string.adjust_cursor(&mut self.cursor, self.start); |
| 151 | |
| 152 | if req.start > req.end { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | let mut end = req.end; |
| 157 | |
| 158 | let mut ctx = MatchContext { |
| 159 | cursor: self.cursor, |
| 160 | code_position: 0, |
| 161 | toplevel: true, |
| 162 | jump: Jump::OpCode, |
| 163 | repeat_ctx_id: usize::MAX, |
| 164 | count: -1, |
| 165 | }; |
| 166 | |
| 167 | if ctx.peek_code(&req, 0) == SreOpcode::INFO as u32 { |
| 168 | /* optimization info block */ |
| 169 | /* <INFO> <1=skip> <2=flags> <3=min> <4=max> <5=prefix info> */ |
| 170 | let min = ctx.peek_code(&req, 3) as usize; |
| 171 | |
| 172 | if ctx.remaining_chars(&req) < min { |
| 173 | return false; |
| 174 | } |
| 175 | |
| 176 | if min > 1 { |
| 177 | /* adjust end point (but make sure we leave at least one |
| 178 | character in there, so literal search will work) */ |
| 179 | // no overflow can happen as remaining chars >= min |
| 180 | end -= min - 1; |
| 181 | |
| 182 | // adjust ctx position |
| 183 | if end < ctx.cursor.position { |
| 184 | let skip = end - self.cursor.position; |
| 185 | S::skip(&mut self.cursor, skip); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | let flags = SreInfo::from_bits_truncate(ctx.peek_code(&req, 2)); |
| 190 | |
| 191 | if flags.contains(SreInfo::PREFIX) { |
| 192 | if flags.contains(SreInfo::LITERAL) { |
| 193 | return search_info_literal::<true, S>(&mut req, self, ctx); |
| 194 | } else { |
| 195 | return search_info_literal::<false, S>(&mut req, self, ctx); |
| 196 | } |
| 197 | } else if flags.contains(SreInfo::CHARSET) { |
| 198 | return search_info_charset(&mut req, self, ctx); |
| 199 | } |
| 200 | // fallback to general search |
| 201 | // skip OP INFO |
| 202 | ctx.skip_code_from(&req, 1); |
| 203 | } |
| 204 | |
| 205 | if _match(&req, self, ctx) { |
no test coverage detected