Skip to content

Commit

Permalink
Move variable used for trimming outside the while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
userwiths committed Jan 14, 2025
1 parent 71f56ce commit f26b10e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions common/optparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
long long numarg, lnumarg, lnumlimit;
int regflags = REG_EXTENDED | REG_NOSUB;
const char *inlinecomment = NULL;
char *trim_comment;

#ifdef _WIN32
if (!is_initialized) {
Expand Down Expand Up @@ -1187,11 +1188,10 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
numarg = -1;
inlinecomment = strchr(arg, '#');
if (inlinecomment != NULL) {
arg = strtok(arg, "#");
char *p2 = NULL;
p2 = arg + strlen(arg) - 1;
while (p2 >= arg && *p2 == ' ')
*(p2--) = '\0';
arg = strtok(arg, "#");
trim_comment = arg + strlen(arg) - 1;
while (trim_comment >= arg && *trim_comment == ' ')
*(trim_comment--) = '\0';
}
switch (optentry->argtype) {
case CLOPT_TYPE_STRING:
Expand Down

0 comments on commit f26b10e

Please sign in to comment.