Skip to content

Commit

Permalink
misc updates to work with newer compilers e.g. latest mingw64 gcc (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty authored Jul 30, 2024
1 parent 1d78e1e commit badf65a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ ${JQ_BUNDLE_LIB}: ${JQ_SRC} # -D_REENTRANT needed for clang to not break
--disable-shared \
--enable-static \
${CONFIGURE_HOST} \
&& ${MAKE} install
&& (${MAKE} install -k || echo)

${JSONWRITER_OBJECT}: ${JSONWRITER_SRC}/jsonwriter.c
@mkdir -p `dirname "$@"`
Expand Down
4 changes: 1 addition & 3 deletions app/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,9 @@ static enum zsv_ext_status ext_add_command(zsv_execution_context ctx,
static enum zsv_ext_status ext_parse_all(zsv_execution_context ctx,
void *user_context,
void (*row_handler)(void *ctx),
struct zsv_opts *const custom,
struct zsv_prop_handler *custom_prop
struct zsv_opts *const custom
) {
struct zsv_opts opts = custom ? *custom : ext_parser_opts(ctx);
struct zsv_prop_handler custom_prop_handler = custom_prop ? *custom_prop : zsv_get_default_custom_prop_handler();

if(row_handler)
opts.row_handler = row_handler;
Expand Down
2 changes: 1 addition & 1 deletion app/cli_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int parse_extensions_ini(struct cli_config *config, char err_if_not_found
}

static struct zsv_ext_command *ext_command_new(const char *id, const char *help,
enum zsv_ext_status (*extmain)(zsv_execution_context ctx, int argc, const char *argv[])
enum zsv_ext_status (*extmain)(zsv_execution_context ctx, int argc, const char *argv[], struct zsv_opts *, const char *)
) {
struct zsv_ext_command *cmd = calloc(1, sizeof(*cmd));
cmd->id = strdup(id ? id : "");
Expand Down
2 changes: 1 addition & 1 deletion app/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static int zsv_echo_parse_overwrite_source(struct zsv_echo_data *data, const cha
if(!(data->o.sqlite3.filename && *data->o.sqlite3.filename
&& data->o.sqlite3.sql && *data->o.sqlite3.sql)) {
free(data->o.sqlite3.filename);
fprintf(stderr, "Invalid query string");
fprintf(stderr, "Invalid query string\n");
return 1;
}

Expand Down
5 changes: 3 additions & 2 deletions app/external/yajl_helper/yajl_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void yajl_helper_walk_path(struct yajl_helper_parse_state *st,

static void dump_path(void *ctx, unsigned depth, char type,
unsigned item_index, const char *map_key) {
(void)(depth);
FILE *out = ctx;
fwrite(&type,1,1,out);
if(type == '[')
Expand Down Expand Up @@ -442,8 +443,8 @@ static int yajl_helper_null(void *ctx) {
return process_value(st, ctx, &value);
}

static int yajl_helper_error(void * ctx, const unsigned char *buf,
unsigned bufLen, int err_no) {
static int yajl_helper_error(void * ctx, const char *buf,
size_t bufLen, int err_no) {
(void)(err_no);
struct yajl_helper_parse_state *st = ctx;

Expand Down
10 changes: 10 additions & 0 deletions app/utils/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

#include <zsv/utils/dl.h>

#ifdef _WIN32

#include <windows.h>
#define RTLD_LAZY 0
void *dlsym(void* handle, const char* symbol) {
return (void *)GetProcAddress((HINSTANCE)(handle), (symbol));
}
#endif


void (*zsv_dlsym(void *restrict handle, const char *restrict name))(void) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
Expand Down
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Optional configuration:
--minimal=yes do not include extra features (default=no)
--arch=ARCH use -march=ARCH. Set to 'none' for none, else defaults to 'native'
--jq-prefix=JQ_PREFIX specify directory containing lib/libjq and include/jq.h
defaults to PREFIX if not specified and PREFIX/include/jq.h exists
Installation directories:
--prefix=PREFIX main installation prefix [\$PREFIX or /usr/local]
Expand Down Expand Up @@ -482,6 +483,7 @@ case "$host" in
*-*mingw32|*-*msys*|*-windows-gnu)
CFLAGS_STD="$CFLAGS_STD -D__USE_MINGW_ANSI_STDIO"
MINGW=1
ARCH=none
usepie=no
usepic=no
;;
Expand Down Expand Up @@ -645,6 +647,10 @@ if [ "$usetermcap" = "yes" ] || [ "$usetermcap" = "auto" ] ; then
fi
fi

if [ "$JQ_PREFIX" == "" ] && [ "$PREFIX" != "" ] && [ -f "$PREFIX/include/jq.h" ] ; then
JQ_PREFIX="$PREFIX"
fi

if [ "$JQ_PREFIX" != "" ] && [ "$CROSS_COMPILING" = "no" ] ; then
echo "checking --prefix-jq ${JQ_PREFIX}"
if ! tryldflag LDFLAGS_JQ -ljq -L${JQ_PREFIX}/lib ; then
Expand Down
2 changes: 1 addition & 1 deletion include/zsv/utils/win/dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define RTLD_LAZY 0
void *dlopen(const char *dll_name, int flags);

#define dlsym(x, y) (GetProcAddress((HINSTANCE)(x), (y)))
void *dlsym(void* handle, const char* symbol);

int dlclose(void *handle);

Expand Down

0 comments on commit badf65a

Please sign in to comment.