Skip to content

Commit

Permalink
considering comments after var=values
Browse files Browse the repository at this point in the history
  • Loading branch information
scovl committed May 7, 2024
1 parent a5d976d commit aa62616
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/validation_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#include "config.h"

char* trim_space(char* str);
bool validate_option(const char* key, const char* value);
bool validate_option(const char* key, char* value);

#endif
9 changes: 8 additions & 1 deletion src/validation_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ char* trim_space(char* str) {
return str;
}

bool validate_option(const char* key, const char* value) {
bool validate_option(const char* key, char* value) {
char* comment = strchr(value, '#');
if (comment) {
*comment = '\0';
}

value = trim_space(value);

for (size_t i = 0; i < sizeof(config_options) / sizeof(ConfigOption); i++) {
if (strcmp(config_options[i].name, key) == 0) {
switch (config_options[i].type) {
Expand Down

0 comments on commit aa62616

Please sign in to comment.