Beispiel #1
0
const char *utl_pmx_search(const char *pat, const char *txt, int fromstart)
{
  const char *ret=NULL;
  
  utl_pmx_error = NULL;
  utl_pmx_case = 1;
  
       if (strncmp(pat,"<utf>",5) == 0) {pat+=5; utl_pmx_utf8=1;}
  else if (strncmp(pat,"<iso>",5) == 0) {pat+=5; utl_pmx_utf8=0;}
    
  if (*pat == '^')  ret = utl_pmx_match(pat+1,txt);
  else while (!(ret = utl_pmx_match(pat,txt)) && *txt && !fromstart) {
         txt += utl_pmx_utf8 ? utl_pmx_get_utf8(txt, NULL) : 1;
       }
  _logdebug("ret: %p",ret);
  return ret;
}
Beispiel #2
0
const char *utl_pmx_scan(const char *pat, const char *txt, pmxaction_t func, void *aux)
{
  const char *ret =NULL;  
  utl_pmx_.error = NULL;
  utl_pmx_.csens = 1;
 
       if (strncmp(pat,"<utf>",5) == 0) {pat+=5; utl_pmx_.utf8=1;}
  else if (strncmp(pat,"<iso>",5) == 0) {pat+=5; utl_pmx_.utf8=0;}
      
  while (*txt)  {
     if ((ret = utl_pmx_match(pat,txt))) {
       if (func(utl_pmx_.capt[0][0],utl_pmx_.capt[0][1],aux))
         break;
       txt = utl_pmx_.capt[0][1];
     }
     else {
       txt += utl_pmx_.utf8 ? utlnextutf8(txt) : 1;
     }
  }

  return txt;
}