Update libretroDB and bake in compat_fnmatch.c

This commit is contained in:
twinaphex 2015-01-20 01:00:17 +01:00
parent cf8f6cf1b2
commit 6fbc02a6b4
7 changed files with 49 additions and 12 deletions

View File

@ -130,6 +130,7 @@ OBJ += frontend/frontend.o \
libretro-sdk/queues/fifo_buffer.o \ libretro-sdk/queues/fifo_buffer.o \
core_options.o \ core_options.o \
libretro-sdk/compat/compat.o \ libretro-sdk/compat/compat.o \
libretro-sdk/compat/compat_fnmatch.o \
cheats.o \ cheats.o \
core_info.o \ core_info.o \
libretro-sdk/file/config_file.o \ libretro-sdk/file/config_file.o \
@ -162,7 +163,7 @@ OBJ += frontend/frontend.o \
record/record_driver.o \ record/record_driver.o \
performance.o performance.o
# RarchDB # LibretroDB
OBJ += libretrodb/bintree.o \ OBJ += libretrodb/bintree.o \
libretrodb/rarchdb.o \ libretrodb/rarchdb.o \

View File

@ -62,6 +62,7 @@ PERFORMANCE
COMPATIBILITY COMPATIBILITY
============================================================ */ ============================================================ */
#include "../compat/compat.c" #include "../compat/compat.c"
#include "../libretro-sdk/compat/compat_fnmatch.c"
/*============================================================ /*============================================================
CONFIG FILE CONFIG FILE

View File

@ -8,6 +8,7 @@ LUA_CONVERTER_OBJ = rmsgpack.o \
bintree.o \ bintree.o \
query.o \ query.o \
lua_converter.o \ lua_converter.o \
rl_fnmatch.c \
$(NULL) $(NULL)
RARCHDB_TOOL_OBJ = rmsgpack.o \ RARCHDB_TOOL_OBJ = rmsgpack.o \
@ -16,11 +17,13 @@ RARCHDB_TOOL_OBJ = rmsgpack.o \
bintree.o \ bintree.o \
query.o \ query.o \
rarchdb.o \ rarchdb.o \
rl_fnmatch.c \
$(NULL) $(NULL)
TESTLIB_C = testlib.c \ TESTLIB_C = testlib.c \
lua_common.c \ lua_common.c \
query.c \ query.c \
rl_fnmatch.c \
rarchdb.c \ rarchdb.c \
bintree.c \ bintree.c \
rmsgpack.c \ rmsgpack.c \

View File

@ -7,6 +7,7 @@
#include "rarchdb.h" #include "rarchdb.h"
#include "rmsgpack_dom.h" #include "rmsgpack_dom.h"
#include <compat/fnmatch.h>
#define MAX_ERROR_LEN 256 #define MAX_ERROR_LEN 256
#define MAX_ARGS 50 #define MAX_ARGS 50
@ -314,6 +315,32 @@ static struct rmsgpack_dom_value operator_and (
return res; return res;
} }
static struct rmsgpack_dom_value q_glob (
struct rmsgpack_dom_value input,
unsigned argc,
const struct argument * argv
) {
struct rmsgpack_dom_value res;
unsigned i;
res.type = RDT_BOOL;
res.bool_ = 0;
if (argc != 1) {
return res;
}
if (argv[0].type != AT_VALUE || argv[0].value.type != RDT_STRING) {
return res;
}
if (input.type != RDT_STRING) {
return res;
}
res.bool_ = rl_fnmatch(
argv[0].value.string.buff,
input.string.buff,
0
) == 0;
return res;
}
static struct rmsgpack_dom_value all_map ( static struct rmsgpack_dom_value all_map (
struct rmsgpack_dom_value input, struct rmsgpack_dom_value input,
unsigned argc, unsigned argc,
@ -372,6 +399,7 @@ struct registered_func registered_functions[100] = {
{"or", operator_or}, {"or", operator_or},
{"and", operator_and}, {"and", operator_and},
{"between", between}, {"between", between},
{"glob", q_glob},
{NULL, NULL} {NULL, NULL}
}; };
@ -468,10 +496,13 @@ static struct buffer parse_string(
struct rmsgpack_dom_value * value, struct rmsgpack_dom_value * value,
const char ** error const char ** error
) { ) {
char terminator; char terminator = '\0';
char c; char c;
const char * str_start; const char * str_start;
buff = get_char(buff, &terminator, error); buff = get_char(buff, &terminator, error);
if (*error) {
return buff;
}
if (terminator != '"' && terminator != '\'') { if (terminator != '"' && terminator != '\'') {
buff.offset--; buff.offset--;
raise_expected_string(buff.offset, error); raise_expected_string(buff.offset, error);

View File

@ -78,7 +78,7 @@ int main(
rarchdb_create_index(&db, index_name, field_name); rarchdb_create_index(&db, index_name, field_name);
} else { } else {
printf("Unkonwn command %s\n", argv[1]); printf("Unkonwn command %s\n", argv[2]);
return 1; return 1;
} }
rarchdb_close(&db); rarchdb_close(&db);

View File

@ -71,6 +71,7 @@ tests = {
test_string_field = query_test({{a="test"}, {a=4}}, {{a="test"}}, "{'a':'test'}"), test_string_field = query_test({{a="test"}, {a=4}}, {{a="test"}}, "{'a':'test'}"),
test_or_operator = query_test({{a="test"}, {a=4}, {a=5}}, {{a="test"}, {a=4}}, "{'a':or('test', 4)}"), test_or_operator = query_test({{a="test"}, {a=4}, {a=5}}, {{a="test"}, {a=4}}, "{'a':or('test', 4)}"),
test_or_between = query_test({{a="test"}, {a=4}, {a=5}, {}}, {{a="test"}, {a=4}, {a=5}}, "{'a':or('test', between(2, 7))}"), test_or_between = query_test({{a="test"}, {a=4}, {a=5}, {}}, {{a="test"}, {a=4}, {a=5}}, "{'a':or('test', between(2, 7))}"),
test_glob = query_test({{a="abc"}, {a="acd"}}, {{a="abc"}}, "{'a':glob('*b*')}"),
test_root_function = query_test({{a=1}, {b=4}, {a=5}, {}}, {{a=1}, {b=4}}, "or({a:1},{b:4})"), test_root_function = query_test({{a=1}, {b=4}, {a=5}, {}}, {{a=1}, {b=4}}, "or({a:1},{b:4})"),
} }
for name, cb in pairs(tests) do for name, cb in pairs(tests) do

View File

@ -121,10 +121,10 @@ indent_func_def_force_col1 = false # false/true
# True: indent continued function call parameters one indent level # True: indent continued function call parameters one indent level
# False: align parameters under the open paren # False: align parameters under the open paren
indent_func_call_param = false # false/true indent_func_call_param = true # false/true
# Same as indent_func_call_param, but for function defs # Same as indent_func_call_param, but for function defs
indent_func_def_param = false # false/true indent_func_def_param = true # false/true
# Same as indent_func_call_param, but for function protos # Same as indent_func_call_param, but for function protos
indent_func_proto_param = false # false/true indent_func_proto_param = false # false/true