Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-config
LIBRARY
Expand Down
22 changes: 11 additions & 11 deletions anyoption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "--");

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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] ==
Expand Down Expand Up @@ -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]];
}
Expand All @@ -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]]);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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]]);
}
Expand Down Expand Up @@ -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));
Expand All @@ -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]);
Expand Down
8 changes: 4 additions & 4 deletions anyoption.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand All @@ -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 */
Expand Down