Beispiel #1
0
int main(int argc, char *argv[]){
    char *regex=argv[1];
    char *haystack=argv[2];

    
    regex_t preg;	  /* Compiled pattern to search for. */

    //errcode = tre_regcomp(&preg, regexp, comp_flags);
    int search_str_len=strlen(regex);
    int cflags= REG_ICASE;
    ret = tre_compile(&preg, (const tre_char_t *)regex, search_str_len, cflags);
    //extern int
    //    tre_reganexec(const regex_t *preg, const char *string, size_t len,
    //            regamatch_t *match, regaparams_t params, int eflags);
    tre_reganexec(&preg,haystack,strlen(haystack));

    int errcode;
    regamatch_t match;
    regmatch_t pmatch[1];
    memset(&match, 0, sizeof(match));
    regaparams_t match_params;
    memset(&match_params,0,sizeof(match_params));


}
Beispiel #2
0
int
tre_regwncomp_l(regex_t *preg, const wchar_t *regex, size_t n, int cflags,
    locale_t loc)
{
  FIX_LOCALE(loc);
  return tre_compile(preg, regex, n, cflags, loc);
}
Beispiel #3
0
int
tre_regncomp_l(regex_t *preg, const char *regex, size_t n, int cflags,
    locale_t loc)
{
  int ret;
#if TRE_WCHAR
  tre_char_t *wregex;
  size_t wlen;

  wregex = xmalloc(sizeof(tre_char_t) * (n + 1));
  if (wregex == NULL)
    return REG_ESPACE;

  FIX_LOCALE(loc);

  /* If the current locale uses the standard single byte encoding of
     characters, we don't do a multibyte string conversion.  If we did,
     many applications which use the default locale would break since
     the default "C" locale uses the 7-bit ASCII character set, and
     all characters with the eighth bit set would be considered invalid. */
#if TRE_MULTIBYTE
  if (TRE_MB_CUR_MAX_L(loc) == 1)
#endif /* TRE_MULTIBYTE */
    {
      unsigned int i;
      const unsigned char *str = (const unsigned char *)regex;
      tre_char_t *wstr = wregex;

      for (i = 0; i < n; i++)
	*(wstr++) = *(str++);
      wlen = n;
    }
#if TRE_MULTIBYTE
  else
    {
      size_t consumed;
      tre_char_t *wcptr = wregex;
#ifdef HAVE_MBSTATE_T
      mbstate_t state;
      memset(&state, '\0', sizeof(state));
#endif /* HAVE_MBSTATE_T */
      while (n > 0)
	{
	  consumed = tre_mbrtowc_l(wcptr, regex, n, &state, loc);

	  switch (consumed)
	    {
	    case 0:
	      if (*regex == '\0')
		consumed = 1;
	      else
		{
		  xfree(wregex);
		  return REG_BADPAT;
		}
	      break;
	    case (size_t)-1:
	    case (size_t)-2:
	      DPRINT(("mbrtowc: error %d: %s.\n", errno, strerror(errno)));
	      xfree(wregex);
	      return REG_ILLSEQ;
	    }
	  regex += consumed;
	  n -= consumed;
	  wcptr++;
	}
      wlen = wcptr - wregex;
    }
#endif /* TRE_MULTIBYTE */

  wregex[wlen] = L'\0';
  ret = tre_compile(preg, wregex, wlen, cflags, loc);
  xfree(wregex);
#else /* !TRE_WCHAR */
  FIX_LOCALE(loc);
  ret = tre_compile(preg, (const tre_char_t *)regex, n, cflags, loc);
#endif /* !TRE_WCHAR */

  return ret;
}
Beispiel #4
0
int
tre_regwcomp_l(regex_t *preg, const wchar_t *regex, int cflags, locale_t loc)
{
  FIX_LOCALE(loc);
  return tre_compile(preg, regex, wcslen(regex), cflags, loc);
}
Beispiel #5
0
int
tre_regwncomp(regex_t *preg, const wchar_t *regex, size_t n, int cflags)
{
  return tre_compile(preg, regex, n, cflags, __get_locale());
}