diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..488be107 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +project(HAMMER_PARSE C) + +file(GLOB_RECURSE APP_SRC_FILES + "src/*.c" +) + +# Create the app module +add_cfe_app(hammer_parse ${APP_SRC_FILES}) + +# The API to this library (which may be invoked/referenced from other apps) +# is stored in fsw/public_inc. Using "target_include_directories" is the +# preferred method of indicating this (vs. directory-scope "include_directories"). +target_include_directories(hammer_parse PUBLIC + src/backends + src/parsers + . + src) + + + + diff --git a/src/allocator.c b/src/allocator.c index 7c0862aa..7bf16ebd 100644 --- a/src/allocator.c +++ b/src/allocator.c @@ -284,12 +284,12 @@ void *h_arena_realloc(HArena *arena, void *ptr, size_t n) { // much data from the old block as there could have been. for (link = arena->head; link; link = link->next) { - if (ptr >= (void *)link->rest && ptr <= (void *)link->rest + link->used) + if ((char *)ptr >= (char *)link->rest && (char *)ptr <= (char *)link->rest + link->used) break; /* found it */ } assert(link != NULL); - ncopy = (void *)link->rest + link->used - ptr; + ncopy = ((char *)link->rest + link->used) - (char *)ptr; if (n < ncopy) ncopy = n; diff --git a/src/backends/packrat.c b/src/backends/packrat.c index 137d0751..0916a4f9 100644 --- a/src/backends/packrat.c +++ b/src/backends/packrat.c @@ -390,7 +390,7 @@ bool h_packrat_parse_chunk(HSuspendedParser *s, HInputStream *input) { h_platform_errx(1, "input length would overflow"); newlen = cat->length + input->length; cat->input = h_realloc(mm__, (void *)cat->input, newlen); - memcpy((void *)cat->input + cat->length, input->input, input->length); + memcpy((char *)cat->input + cat->length, input->input, input->length); cat->length = newlen; cat->last_chunk = input->last_chunk; diff --git a/src/hammer.c b/src/hammer.c index bee31d17..260f73cb 100644 --- a/src/hammer.c +++ b/src/hammer.c @@ -422,7 +422,7 @@ HParsedToken *act_backend_params(const HParseResult *p, void *user_data) { backend_params_t *bp = H_ALLOC(backend_params_t); - HParsedToken **fields = h_seq_elements(p->ast); + //HParsedToken **fields = h_seq_elements(p->ast); bp->len = h_seq_len(p->ast); bp->params = h_arena_malloc(p->arena, sizeof(backend_param_with_name_t) * bp->len); diff --git a/src/hammer.h b/src/hammer.h index 62e7d7dc..9a035afe 100644 --- a/src/hammer.h +++ b/src/hammer.h @@ -1239,7 +1239,7 @@ struct result_buf; bool h_append_buf(struct result_buf *buf, const char *input, int len); bool h_append_buf_c(struct result_buf *buf, char v); -bool h_append_buf_formatted(struct result_buf *buf, char *format, ...); +bool h_append_buf_formatted(struct result_buf *buf, const char *format, ...); /** @} */ diff --git a/src/parsers/unimplemented.c b/src/parsers/unimplemented.c index 23c65592..dbf5395b 100644 --- a/src/parsers/unimplemented.c +++ b/src/parsers/unimplemented.c @@ -18,5 +18,5 @@ static const HParserVtable unimplemented_vt = { static HParser unimplemented = {.vtable = &unimplemented_vt, .env = NULL}; -const HParser *h_unimplemented() { return &unimplemented; } +const HParser *h_unimplemented(void) { return &unimplemented; } const HParser *h_unimplemented__m(HAllocator *mm__) { return &unimplemented; } diff --git a/src/pprint.c b/src/pprint.c index e50eacf2..ec92e74f 100644 --- a/src/pprint.c +++ b/src/pprint.c @@ -141,7 +141,7 @@ bool h_append_buf_c(struct result_buf *buf, char v) { } /** append a formatted string to the result buffer */ -bool h_append_buf_formatted(struct result_buf *buf, char *format, ...) { +bool h_append_buf_formatted(struct result_buf *buf, const char *format, ...) { char *tmpbuf; int len; bool result; diff --git a/src/sloballoc.c b/src/sloballoc.c index e299d6e7..3dd22f04 100644 --- a/src/sloballoc.c +++ b/src/sloballoc.c @@ -187,7 +187,7 @@ static void h_slob_free(HAllocator *mm, void *p) { } static void *h_slob_realloc(HAllocator *mm, void *p, size_t size) { - SLOB *slob = (SLOB *)(mm + 1); + //SLOB *slob = (SLOB *)(mm + 1); assert(((void)"XXX need realloc for SLOB allocator", 0)); return NULL;