Skip to content

Commit

Permalink
Never actually set argument result
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanuppal committed Mar 16, 2024
1 parent 3d494bf commit 8a9994f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/cmdapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# 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
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 '\
Expand Down
2 changes: 1 addition & 1 deletion test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 8a9994f

Please sign in to comment.