Beispiel #1
0
int test_nfa() {
	bool b = simple_match("a(b*|c)", "abcdf");
	if (b == TRUE) {
		printf("simple_match success. \n");
	} else {
		printf("simple_match fail. \n");
	}
	return 0;
}
Beispiel #2
0
int main(int argc, const char * argv[]) {
    
    char text[100] = "hello,world!";
    char pattern[6] = "world";
    
    printf("The pisition is %d.\n",simple_match(text, pattern));
    
   
    return 0;
}
Beispiel #3
0
/*
 * Match pkg against pattern, return 1 if matching, 0 else
 */
int
pkg_match(const char *pattern, const char *pkg)
{
	if (!quick_pkg_match(pattern, pkg))
		return 0;

	if (strchr(pattern, '{') != (char *) NULL) {
		/* emulate csh-type alternates */
		return alternate_match(pattern, pkg);
	}
	if (strpbrk(pattern, "<>") != (char *) NULL) {
		int ret;

		/* perform relational dewey match on version number */
		ret = dewey_match(pattern, pkg);
		if (ret < 0)
			errx(EXIT_FAILURE, "dewey_match returned error");
		return ret;
	}
	if (strpbrk(pattern, "*?[]") != (char *) NULL) {
		/* glob match */
		if (glob_match(pattern, pkg))
			return 1;
	}

	/* no alternate, dewey or glob match -> simple compare */
	if (simple_match(pattern, pkg))
		return 1;

	/* globbing patterns and simple matches may be specified with or
	 * without the version number, so check for both cases. */

	{
		char *pattern_ver;
		int retval;

		pattern_ver = xasprintf("%s-[0-9]*", pattern);
		retval = glob_match(pattern_ver, pkg);
		free(pattern_ver);
		return retval;
	}
}
Beispiel #4
0
int bu_opposite(const void *left, const void *right, size_t n) {
        return simple_match(left, right, n, op_different);
}
Beispiel #5
0
int bu_equal(const void *left, const void *right, size_t n) {
        return simple_match(left, right, n, op_same);
}
Beispiel #6
0
int bu_memcmp(const void *left, const void *right, size_t n) {
        return !simple_match(left, right, n, op_same);
}