From cc4ded8914b4d89b506128417a0121b25fbcb4b2 Mon Sep 17 00:00:00 2001 From: TQ Hirsch <thequux@upstandinghackers.com> Date: Sun, 13 Apr 2014 22:29:49 +0000 Subject: [PATCH] Ported to OpenBSD. --- SConstruct | 2 ++ src/parsers/action.c | 4 ++-- src/parsers/and.c | 3 ++- src/parsers/ignore.c | 3 ++- src/parsers/not.c | 3 ++- src/parsers/optional.c | 3 ++- src/parsers/whitespace.c | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index 0fa3c8f1..972199a5 100644 --- a/SConstruct +++ b/SConstruct @@ -48,6 +48,8 @@ env.MergeFlags("-std=gnu99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-attr if env['PLATFORM'] == 'darwin': env.Append(SHLINKFLAGS = '-install_name ' + env["libpath"] + '/${TARGET.file}') +elif os.uname()[0] == "OpenBSD": + pass else: env.MergeFlags("-lrt") diff --git a/src/parsers/action.c b/src/parsers/action.c index e254a894..04eb7a4c 100644 --- a/src/parsers/action.c +++ b/src/parsers/action.c @@ -13,8 +13,8 @@ static HParseResult* parse_action(void *env, HParseState *state) { HParseResult *tmp = h_do_parse(a->p, state); //HParsedToken *tok = a->action(h_do_parse(a->p, state)); if(tmp) { - const HParsedToken *tok = a->action(tmp, a->user_data); - return make_result(state->arena, (HParsedToken*)tok); + HParsedToken *tok = (HParsedToken*)a->action(tmp, a->user_data); + return make_result(state->arena, tok); } else return NULL; } else // either the parser's missing or the action's missing diff --git a/src/parsers/and.c b/src/parsers/and.c index dfd91871..c5c9836d 100644 --- a/src/parsers/and.c +++ b/src/parsers/and.c @@ -25,5 +25,6 @@ HParser* h_and(const HParser* p) { } HParser* h_and__m(HAllocator* mm__, const HParser* p) { // zero-width postive lookahead - return h_new_parser(mm__, &and_vt, (void *)p); + void* env = (void*)p; + return h_new_parser(mm__, &and_vt, env); } diff --git a/src/parsers/ignore.c b/src/parsers/ignore.c index 9aa993ae..af606b0e 100644 --- a/src/parsers/ignore.c +++ b/src/parsers/ignore.c @@ -55,5 +55,6 @@ HParser* h_ignore(const HParser* p) { return h_ignore__m(&system_allocator, p); } HParser* h_ignore__m(HAllocator* mm__, const HParser* p) { - return h_new_parser(mm__, &ignore_vt, (void *)p); + void* env = (void*)p; + return h_new_parser(mm__, &ignore_vt, env); } diff --git a/src/parsers/not.c b/src/parsers/not.c index 8bf45dda..6c34bad4 100644 --- a/src/parsers/not.c +++ b/src/parsers/not.c @@ -21,5 +21,6 @@ HParser* h_not(const HParser* p) { return h_not__m(&system_allocator, p); } HParser* h_not__m(HAllocator* mm__, const HParser* p) { - return h_new_parser(mm__, ¬_vt, (void *)p); + void* env = (void*)p; + return h_new_parser(mm__, ¬_vt, env); } diff --git a/src/parsers/optional.c b/src/parsers/optional.c index ff9fc15b..ccee53fa 100644 --- a/src/parsers/optional.c +++ b/src/parsers/optional.c @@ -92,6 +92,7 @@ HParser* h_optional(const HParser* p) { HParser* h_optional__m(HAllocator* mm__, const HParser* p) { // TODO: re-add this //assert_message(p->vtable != &ignore_vt, "Thou shalt ignore an option, rather than the other way 'round."); - return h_new_parser(mm__, &optional_vt, (void *)p); + void* env = (void*)p; + return h_new_parser(mm__, &optional_vt, env); } diff --git a/src/parsers/whitespace.c b/src/parsers/whitespace.c index e37aa12e..04284e86 100644 --- a/src/parsers/whitespace.c +++ b/src/parsers/whitespace.c @@ -81,5 +81,6 @@ HParser* h_whitespace(const HParser* p) { return h_whitespace__m(&system_allocator, p); } HParser* h_whitespace__m(HAllocator* mm__, const HParser* p) { - return h_new_parser(mm__, &whitespace_vt, (void *)p); + void* env = (void*)p; + return h_new_parser(mm__, &whitespace_vt, env); } -- GitLab