From 90c62b49f95f35ff051ddaf3ff9f5f9eea2cb4fd Mon Sep 17 00:00:00 2001 From: Oleg Kofman Date: Wed, 2 Jul 2025 18:42:20 +0300 Subject: [PATCH 1/2] Fix include directory definition --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e3702..6d5c83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,10 @@ set("CPACK_RPM_SDK_PACKAGE_NAME" "${CPACK_RPM_LIB_PACKAGE_NAME}-devel") add_library(${PROJECT_NAME} SHARED ${srcs} ${hdrs}) -include_directories(${PROJECT_NAME} $ $) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-config LIBRARY From 1abb5b45b106f8330e91dd4022f568cd50e27e08 Mon Sep 17 00:00:00 2001 From: Oleg Kofman Date: Wed, 2 Jul 2025 19:17:39 +0300 Subject: [PATCH 2/2] Fix int types definition --- anyoption.cpp | 22 +++++++++++----------- anyoption.h | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/anyoption.cpp b/anyoption.cpp index 84a8ebd..a828472 100644 --- a/anyoption.cpp +++ b/anyoption.cpp @@ -109,8 +109,8 @@ void AnyOption::init(unsigned int maxopt, unsigned int maxcharopt) { once = true; hasoptions = false; autousage = false; - print_usage = false; - print_help = false; + print_usage = false; + print_help = false; strcpy(long_opt_prefix, "--"); @@ -264,7 +264,7 @@ void AnyOption::cleanup() { free(optcharindex); free(usage); if (values != nullptr) { - for (int i = 0; i < g_value_counter; i++) { + for (unsigned int i = 0; i < g_value_counter; i++) { delete[] values[i]; values[i] = nullptr; } @@ -637,7 +637,7 @@ int AnyOption::matchOpt(char *opt) { return -1; } bool AnyOption::matchChar(char c) { - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == c) { /* found match */ if (optchartype[i] == COMMON_OPT || optchartype[i] == @@ -698,7 +698,7 @@ bool AnyOption::getFlag(const char *option) { char *AnyOption::getValue(char option) { if (!valueStoreOK()) return nullptr; - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == option) return values[optcharindex[i]]; } @@ -708,7 +708,7 @@ char *AnyOption::getValue(char option) { bool AnyOption::getFlag(char option) { if (!valueStoreOK()) return false; - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == option) return findFlag(values[optcharindex[i]]); } @@ -759,7 +759,7 @@ bool AnyOption::setFlagOn(const char *option) { bool AnyOption::setValue(char option, char *value) { if (!valueStoreOK()) return false; - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == option) { size_t length = (strlen(value) + 1) * sizeof(char); allocValues(optcharindex[i], length); @@ -773,7 +773,7 @@ bool AnyOption::setValue(char option, char *value) { bool AnyOption::setFlagOn(char option) { if (!valueStoreOK()) return false; - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == option) { size_t length = (strlen(TRUE_FLAG) + 1) * sizeof(char); allocValues(optcharindex[i], length); @@ -786,7 +786,7 @@ bool AnyOption::setFlagOn(char option) { int AnyOption::getArgc() const { return new_argc; } -char *AnyOption::getArgv(int index) const { +char *AnyOption::getArgv(unsigned int index) const { if (index < new_argc) { return (argv[new_argv[index]]); } @@ -925,7 +925,7 @@ char *AnyOption::chomp(char *str) { void AnyOption::valuePairs(char *type, char *value) { if (strlen(chomp(type)) == 1) { /* this is a char option */ - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == type[0]) { /* match */ if (optchartype[i] == COMMON_OPT || optchartype[i] == FILE_OPT) { setValue(type[0], chomp(value)); @@ -951,7 +951,7 @@ void AnyOption::valuePairs(char *type, char *value) { void AnyOption::justValue(char *type) { if (strlen(chomp(type)) == 1) { /* this is a char option */ - for (int i = 0; i < optchar_counter; i++) { + for (unsigned int i = 0; i < optchar_counter; i++) { if (optionchars[i] == type[0]) { /* match */ if (optchartype[i] == COMMON_FLAG || optchartype[i] == FILE_FLAG) { setFlagOn(type[0]); diff --git a/anyoption.h b/anyoption.h index f24fff2..ae908b1 100644 --- a/anyoption.h +++ b/anyoption.h @@ -159,7 +159,7 @@ class AnyOption { * get the argument count and arguments sans the options */ int getArgc() const; - char *getArgv(int index) const; + char *getArgv(unsigned int index) const; bool hasOptions() const; private: /* the hidden data structure */ @@ -169,7 +169,7 @@ class AnyOption { char *appname; /* the application name from argv[0] */ int *new_argv; /* arguments sans options (index to argv) */ - int new_argc; /* argument count sans the options */ + unsigned int new_argc; /* argument count sans the options */ unsigned int max_legal_args; /* ignore extra arguments */ /* option strings storage + indexing */ @@ -184,11 +184,11 @@ class AnyOption { char *optionchars; /* storage */ OptionType *optchartype; /* type - common, command, file */ int *optcharindex; /* index into value storage */ - int optchar_counter; /* counter for added options */ + unsigned int optchar_counter; /* counter for added options */ /* values */ char **values; /* common value storage */ - int g_value_counter; /* globally updated value index LAME! */ + unsigned int g_value_counter; /* globally updated value index LAME! */ /* help and usage */ const char **usage; /* usage */