Lines Matching refs:p
175 static unsigned re_next_char(ReInput *p){ in re_next_char() argument
177 if( p->i>=p->mx ) return 0; in re_next_char()
178 c = p->z[p->i++]; in re_next_char()
180 if( (c&0xe0)==0xc0 && p->i<p->mx && (p->z[p->i]&0xc0)==0x80 ){ in re_next_char()
181 c = (c&0x1f)<<6 | (p->z[p->i++]&0x3f); in re_next_char()
183 }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80 in re_next_char()
184 && (p->z[p->i+1]&0xc0)==0x80 ){ in re_next_char()
185 c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f); in re_next_char()
186 p->i += 2; in re_next_char()
188 }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80 in re_next_char()
189 && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){ in re_next_char()
190 c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6) in re_next_char()
191 | (p->z[p->i+2]&0x3f); in re_next_char()
192 p->i += 3; in re_next_char()
200 static unsigned re_next_char_nocase(ReInput *p){ in re_next_char_nocase() argument
201 unsigned c = re_next_char(p); in re_next_char_nocase()
375 static int re_resize(ReCompiled *p, int N){ in re_resize() argument
378 aOp = sqlite3_realloc64(p->aOp, N*sizeof(p->aOp[0])); in re_resize()
380 p->aOp = aOp; in re_resize()
381 aArg = sqlite3_realloc64(p->aArg, N*sizeof(p->aArg[0])); in re_resize()
383 p->aArg = aArg; in re_resize()
384 p->nAlloc = N; in re_resize()
391 static int re_insert(ReCompiled *p, int iBefore, int op, int arg){ in re_insert() argument
393 if( p->nAlloc<=p->nState && re_resize(p, p->nAlloc*2) ) return 0; in re_insert()
394 for(i=p->nState; i>iBefore; i--){ in re_insert()
395 p->aOp[i] = p->aOp[i-1]; in re_insert()
396 p->aArg[i] = p->aArg[i-1]; in re_insert()
398 p->nState++; in re_insert()
399 p->aOp[iBefore] = (char)op; in re_insert()
400 p->aArg[iBefore] = arg; in re_insert()
406 static int re_append(ReCompiled *p, int op, int arg){ in re_append() argument
407 return re_insert(p, p->nState, op, arg); in re_append()
413 static void re_copy(ReCompiled *p, int iStart, int N){ in re_copy() argument
414 if( p->nState+N>=p->nAlloc && re_resize(p, p->nAlloc*2+N) ) return; in re_copy()
415 memcpy(&p->aOp[p->nState], &p->aOp[iStart], N*sizeof(p->aOp[0])); in re_copy()
416 memcpy(&p->aArg[p->nState], &p->aArg[iStart], N*sizeof(p->aArg[0])); in re_copy()
417 p->nState += N; in re_copy()
441 static unsigned re_esc_char(ReCompiled *p){ in re_esc_char() argument
446 if( p->sIn.i>=p->sIn.mx ) return 0; in re_esc_char()
447 c = p->sIn.z[p->sIn.i]; in re_esc_char()
448 if( c=='u' && p->sIn.i+4<p->sIn.mx ){ in re_esc_char()
449 const unsigned char *zIn = p->sIn.z + p->sIn.i; in re_esc_char()
455 p->sIn.i += 5; in re_esc_char()
459 if( c=='x' && p->sIn.i+2<p->sIn.mx ){ in re_esc_char()
460 const unsigned char *zIn = p->sIn.z + p->sIn.i; in re_esc_char()
464 p->sIn.i += 3; in re_esc_char()
471 p->sIn.i++; in re_esc_char()
473 p->zErr = "unknown \\ escape"; in re_esc_char()
482 static unsigned char rePeek(ReCompiled *p){ in rePeek() argument
483 return p->sIn.i<p->sIn.mx ? p->sIn.z[p->sIn.i] : 0; in rePeek()
490 static const char *re_subcompile_re(ReCompiled *p){ in re_subcompile_re() argument
493 iStart = p->nState; in re_subcompile_re()
494 zErr = re_subcompile_string(p); in re_subcompile_re()
496 while( rePeek(p)=='|' ){ in re_subcompile_re()
497 iEnd = p->nState; in re_subcompile_re()
498 re_insert(p, iStart, RE_OP_FORK, iEnd + 2 - iStart); in re_subcompile_re()
499 iGoto = re_append(p, RE_OP_GOTO, 0); in re_subcompile_re()
500 p->sIn.i++; in re_subcompile_re()
501 zErr = re_subcompile_string(p); in re_subcompile_re()
503 p->aArg[iGoto] = p->nState - iGoto; in re_subcompile_re()
512 static const char *re_subcompile_string(ReCompiled *p){ in re_subcompile_string() argument
517 while( (c = p->xNextChar(&p->sIn))!=0 ){ in re_subcompile_string()
518 iStart = p->nState; in re_subcompile_string()
522 p->sIn.i--; in re_subcompile_string()
526 zErr = re_subcompile_re(p); in re_subcompile_string()
528 if( rePeek(p)!=')' ) return "unmatched '('"; in re_subcompile_string()
529 p->sIn.i++; in re_subcompile_string()
533 if( rePeek(p)=='*' ){ in re_subcompile_string()
534 re_append(p, RE_OP_ANYSTAR, 0); in re_subcompile_string()
535 p->sIn.i++; in re_subcompile_string()
537 re_append(p, RE_OP_ANY, 0); in re_subcompile_string()
543 re_insert(p, iPrev, RE_OP_GOTO, p->nState - iPrev + 1); in re_subcompile_string()
544 re_append(p, RE_OP_FORK, iPrev - p->nState + 1); in re_subcompile_string()
549 re_append(p, RE_OP_FORK, iPrev - p->nState); in re_subcompile_string()
554 re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1); in re_subcompile_string()
558 re_append(p, RE_OP_MATCH, RE_EOF); in re_subcompile_string()
562 re_append(p, RE_OP_ATSTART, 0); in re_subcompile_string()
569 while( (c=rePeek(p))>='0' && c<='9' ){ m = m*10 + c - '0'; p->sIn.i++; } in re_subcompile_string()
572 p->sIn.i++; in re_subcompile_string()
574 while( (c=rePeek(p))>='0' && c<='9' ){ n = n*10 + c-'0'; p->sIn.i++; } in re_subcompile_string()
578 p->sIn.i++; in re_subcompile_string()
579 sz = p->nState - iPrev; in re_subcompile_string()
582 re_insert(p, iPrev, RE_OP_FORK, sz+1); in re_subcompile_string()
586 for(j=1; j<m; j++) re_copy(p, iPrev, sz); in re_subcompile_string()
589 re_append(p, RE_OP_FORK, sz+1); in re_subcompile_string()
590 re_copy(p, iPrev, sz); in re_subcompile_string()
593 re_append(p, RE_OP_FORK, -sz); in re_subcompile_string()
598 int iFirst = p->nState; in re_subcompile_string()
599 if( rePeek(p)=='^' ){ in re_subcompile_string()
600 re_append(p, RE_OP_CC_EXC, 0); in re_subcompile_string()
601 p->sIn.i++; in re_subcompile_string()
603 re_append(p, RE_OP_CC_INC, 0); in re_subcompile_string()
605 while( (c = p->xNextChar(&p->sIn))!=0 ){ in re_subcompile_string()
606 if( c=='[' && rePeek(p)==':' ){ in re_subcompile_string()
609 if( c=='\\' ) c = re_esc_char(p); in re_subcompile_string()
610 if( rePeek(p)=='-' ){ in re_subcompile_string()
611 re_append(p, RE_OP_CC_RANGE, c); in re_subcompile_string()
612 p->sIn.i++; in re_subcompile_string()
613 c = p->xNextChar(&p->sIn); in re_subcompile_string()
614 if( c=='\\' ) c = re_esc_char(p); in re_subcompile_string()
615 re_append(p, RE_OP_CC_RANGE, c); in re_subcompile_string()
617 re_append(p, RE_OP_CC_VALUE, c); in re_subcompile_string()
619 if( rePeek(p)==']' ){ p->sIn.i++; break; } in re_subcompile_string()
622 p->aArg[iFirst] = p->nState - iFirst; in re_subcompile_string()
627 switch( rePeek(p) ){ in re_subcompile_string()
637 p->sIn.i++; in re_subcompile_string()
638 re_append(p, specialOp, 0); in re_subcompile_string()
640 c = re_esc_char(p); in re_subcompile_string()
641 re_append(p, RE_OP_MATCH, c); in re_subcompile_string()
646 re_append(p, RE_OP_MATCH, c); in re_subcompile_string()