static int test_time(char const* file, int line, size_t cchBuff, int flags, size_t expectedResult, PAN_CHAR_T const* pattern)
{
    if('?' == 0[pattern])
    {
        string_t str = translate_pattern(pattern);

        return test_time(file, line, cchBuff, flags, expectedResult, str.c_str());
    }

    pantheios::util::auto_buffer_selector<PAN_CHAR_T, 256>::type    buff(cchBuff + 1);
    pan_beutil_time_t                                               tm(buff.size() - 1, (buff.size() > 1) ? &buff[0] : NULL);
    size_t                                                          actualResult = pantheios_util_getCurrentTime(&tm, flags);
    int                                                             matchRes = 0;

    buff[cchBuff] = '\0';
    if(cchBuff > 0)
    {
        buff[actualResult] = '\0';
    }

    if( expectedResult == actualResult &&
#ifdef PANTHEIOS_USE_WIDE_STRINGS
        0 == (matchRes = shwild::match(stlsoft::w2m(pattern), stlsoft::w2m(buff.data()))))
#else /* ? PANTHEIOS_USE_WIDE_STRINGS */
        0 == (matchRes = shwild::match(pattern, buff.data())))
#endif /* PANTHEIOS_USE_WIDE_STRINGS */
    {
        return true;
    }
    else
    {
Ejemplo n.º 2
0
Pattern
new_pattern(const char *pattern, int case_matters)
{
    int tpatlen = -1;
    const char *tpattern = translate_pattern(pattern, &tpatlen);
    regexp_t buf = mymalloc(sizeof(*buf), M_PATTERN);
    Pattern p;

    init_casefold_once();

    buf->buffer = 0;
    buf->allocated = 0;
    buf->translate = case_matters ? 0 : casefold;
    re_set_syntax(MOO_SYNTAX);

    if (tpattern
	&& !re_compile_pattern((void *) tpattern, tpatlen, buf)) {
	buf->fastmap = mymalloc(256 * sizeof(char), M_PATTERN);
	re_compile_fastmap(buf);
	p.ptr = buf;
    } else {
	if (buf->buffer)
	    free(buf->buffer);
	myfree(buf, M_PATTERN);
	p.ptr = 0;
    }

    return p;
}