ASF Bugzilla – Attachment 35745 Details for
Bug 62134
apr_fnmatch_test is wrong on wild-card string with escape char (backslash)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Extra tests for apr_fnmatch_test function.
test-apr_fnmatch_test.cpp (text/plain), 1.50 KB, created by
soapand
on 2018-02-26 11:12:10 UTC
(
hide
)
Description:
Extra tests for apr_fnmatch_test function.
Filename:
MIME Type:
Creator:
soapand
Created:
2018-02-26 11:12:10 UTC
Size:
1.50 KB
patch
obsolete
>#include <stdio.h> >#include <stdlib.h> >#include <dlfcn.h> > > >#ifdef __cplusplus >extern "C" { >#endif > >typedef int (*apr_fnmatch_test_t)(const char *pattern); >apr_fnmatch_test_t apr_fnmatch_test; > >#ifdef __cplusplus >} >#endif > > >static void* get_sym(void *lib_handle, const char *symbol); >static void test_fnmatch_test(); > > >int main(int argc, char **argv) >{ > void *lib_handle; > lib_handle = dlopen("/lib64/libapr-1.so.0", RTLD_LAZY); > if (!lib_handle) > { > fprintf(stderr, "%s\n", dlerror()); > exit(1); > } > > apr_fnmatch_test = (apr_fnmatch_test_t) get_sym(lib_handle, "apr_fnmatch_test"); > > test_fnmatch_test(); > > dlclose(lib_handle); > return 0; >} > >static void* get_sym(void *lib_handle, const char *symbol) >{ > void *result = dlsym(lib_handle, symbol); > char *error; > if ((error = dlerror()) != NULL) > { > fprintf(stderr, "%s\n", error); > exit(1); > } > return result; >} > >static void test_fnmatch_test() >{ > static const struct test { > const char *pattern; > int result; > } ft_tests[] = { > { "a*b", 1 }, > { "a?", 1 }, > { "a\\b?", 1 }, > { "a[b-c]", 1 }, > { "a", 0 }, > { "a\\", 0 }, > > // My tests. > { "foo\\*bar", 1 }, > { "foo\\bar", 1 }, > > { NULL, 0 } > }; > const struct test *t; > > for (t = ft_tests; t->pattern != NULL; t++) { > int res = apr_fnmatch_test(t->pattern); > > if (res != t->result) { > printf("apr_fnmatch_test(\"%s\") returns %d, expected %d\n", t->pattern, res, t->result); > } > } > printf("done test_fnmatch_test\n"); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 62134
: 35745