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 \
core_options.o \
libretro-sdk/compat/compat.o \
libretro-sdk/compat/compat_fnmatch.o \
cheats.o \
core_info.o \
libretro-sdk/file/config_file.o \
@ -162,7 +163,7 @@ OBJ += frontend/frontend.o \
record/record_driver.o \
performance.o
# RarchDB
# LibretroDB
OBJ += libretrodb/bintree.o \
libretrodb/rarchdb.o \

View File

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

View File

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

View File

@ -7,6 +7,7 @@
#include "rarchdb.h"
#include "rmsgpack_dom.h"
#include <compat/fnmatch.h>
#define MAX_ERROR_LEN 256
#define MAX_ARGS 50
@ -314,6 +315,32 @@ static struct rmsgpack_dom_value operator_and (
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 (
struct rmsgpack_dom_value input,
unsigned argc,
@ -372,6 +399,7 @@ struct registered_func registered_functions[100] = {
{"or", operator_or},
{"and", operator_and},
{"between", between},
{"glob", q_glob},
{NULL, NULL}
};
@ -468,10 +496,13 @@ static struct buffer parse_string(
struct rmsgpack_dom_value * value,
const char ** error
) {
char terminator;
char terminator = '\0';
char c;
const char * str_start;
buff = get_char(buff, &terminator, error);
if (*error) {
return buff;
}
if (terminator != '"' && terminator != '\'') {
buff.offset--;
raise_expected_string(buff.offset, error);
@ -683,7 +714,7 @@ static struct buffer parse_argument(
) {
arg->type = AT_FUNCTION;
buff = parse_method_call(buff, &arg->invocation, error);
} else if (peek(buff, "{")){
} else if (peek(buff, "{")) {
arg->type = AT_FUNCTION;
buff = parse_table(buff, &arg->invocation, error);
} else {
@ -724,16 +755,16 @@ static struct buffer parse_table(
args[argi].value.type = RDT_STRING;
args[argi].value.string.len = ident_len;
args[argi].value.string.buff = calloc(
ident_len + 1,
sizeof(char)
);
ident_len + 1,
sizeof(char)
);
if (!args[argi].value.string.buff) {
goto clean;
}
strncpy(
args[argi].value.string.buff,
ident_name,
ident_len
args[argi].value.string.buff,
ident_name,
ident_len
);
}
} else {

View File

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

View File

@ -71,6 +71,7 @@ tests = {
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_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})"),
}
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
# 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
indent_func_def_param = false # false/true
indent_func_def_param = true # false/true
# Same as indent_func_call_param, but for function protos
indent_func_proto_param = false # false/true