diff --git a/Makefile b/Makefile index 8d1be9a..5dc3cde 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SRCDIR := src INCLUDEDIR := src -CC := $(shell which gcc-13 || which gcc || which clang) +CC := $(shell which gcc || which clang) CFLAGS := -std=c99 -pedantic -Wall -Wextra -I $(INCLUDEDIR) CDEBUG := -g CRELEASE := -O2 diff --git a/src/cmdapp.c b/src/cmdapp.c index c87925a..57da50d 100644 --- a/src/cmdapp.c +++ b/src/cmdapp.c @@ -742,6 +742,9 @@ int ca_parse(void* user_data) { && strcmp(result.opt->long_opt, "version") == 0) { ca_print_version(); } else { + if (result.opt->flags & CA_OPT_ARG) { + *result.opt->result = result.arg; + } if (app.opt_callback) { app.opt_callback(result.opt->short_opt, result.opt->long_opt, result.arg, user_data); diff --git a/test/Makefile b/test/Makefile index c7c5d09..373272c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,7 +3,7 @@ # Purpose: builds the test program for the libcmdapp library. # Requires: the libcmdapp library to be installed. -CC := $(shell which gcc-13 || which gcc || which clang) +CC := $(shell which gcc || which clang) CFLAGS := -std=c99 -pedantic -Wall -Wextra \ -Wno-unused-parameter SRC := main.c @@ -11,7 +11,7 @@ EXEC := main LIB := cmdapp CFLAGS += -I/usr/local/include/$(LIB) -LIBCONF := -L/usr/local/lib -l$(LIB) +LIBCONF := /usr/local/lib/libcmdapp.a #-L/usr/local/lib -l$(LIB) test: build_test @bash -c '\ diff --git a/test/main.c b/test/main.c index 726b65f..c4d31b9 100644 --- a/test/main.c +++ b/test/main.c @@ -62,7 +62,7 @@ int main(int argc, const char* argv[]) { return 1; } - printf("a was passed: %s\n", (*a) ? "true" : "false"); + printf("a was passed: %s (arg was %s)\n", (*a) ? "true" : "false", a_arg); free(app); }