コード例 #1
0
ファイル: ltre_w.c プロジェクト: Themroc/tre
static int compile_regex (lua_State *L, const TArgComp *argC, TPosix **pud) {
    int res;
    TPosix *ud;

    ud = (TPosix *)lua_newuserdata (L, sizeof (TPosix));
    memset (ud, 0, sizeof (TPosix));          /* initialize all members to 0 */

    res = tre_regwncomp (&ud->r, (const wchar_t*)argC->pattern, argC->patlen/ALG_CHARSIZE, argC->cflags);
    if (res != 0)
        return generate_error (L, ud, res);

    if (argC->cflags & REG_NOSUB)
        ud->r.re_nsub = 0;
    ud->match = (regmatch_t *) Lmalloc (L, (ALG_NSUB(ud) + 1) * sizeof (regmatch_t));
    lua_pushvalue (L, ALG_ENVIRONINDEX);
    lua_setmetatable (L, -2);

    if (pud) *pud = ud;
    return 1;
}
コード例 #2
0
int
tre_regwcomp(regex_t *preg, const wchar_t *regex, int cflags)
{
  return tre_regwncomp(preg, regex, wcslen(regex), cflags);
}