Skip to content

Commit

Permalink
Trim trailing spaces and run clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
userwiths committed Jan 14, 2025
1 parent ef7d483 commit 71f56ce
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions common/optparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
char shortopts[MAXCMDOPTS];
regex_t regex;
long long numarg, lnumarg, lnumlimit;
int regflags = REG_EXTENDED | REG_NOSUB;
const char* inlinecomment = NULL;
int regflags = REG_EXTENDED | REG_NOSUB;
const char *inlinecomment = NULL;

#ifdef _WIN32
if (!is_initialized) {
Expand Down Expand Up @@ -1013,8 +1013,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
break;

buff = buffer;
for (i = 0; i < (int)strlen(buff) - 1 && (buff[i] == ' ' || buff[i] == '\t'); i++)
;
for (i = 0; i < (int)strlen(buff) - 1 && (buff[i] == ' ' || buff[i] == '\t'); i++);
buff += i;
line++;
if (strlen(buff) <= 2 || buff[0] == '#')
Expand All @@ -1035,11 +1034,9 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
}
name = buff;
*pt++ = 0;
for (i = 0; i < (int)strlen(pt) - 1 && (pt[i] == ' ' || pt[i] == '\t'); i++)
;
for (i = 0; i < (int)strlen(pt) - 1 && (pt[i] == ' ' || pt[i] == '\t'); i++);
pt += i;
for (i = strlen(pt); i >= 1 && (pt[i - 1] == ' ' || pt[i - 1] == '\t' || pt[i - 1] == '\n'); i--)
;
for (i = strlen(pt); i >= 1 && (pt[i - 1] == ' ' || pt[i - 1] == '\t' || pt[i - 1] == '\n'); i--);
if (!i) {
if (verbose)
fprintf(stderr, "ERROR: Missing argument for option at %s:%d\n", cfgfile, line);
Expand Down Expand Up @@ -1187,10 +1184,14 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
}
}

numarg = -1;
numarg = -1;
inlinecomment = strchr(arg, '#');
if (inlinecomment != NULL) {
arg = strtok(arg, "#");
arg = strtok(arg, "#");
char *p2 = NULL;
p2 = arg + strlen(arg) - 1;
while (p2 >= arg && *p2 == ' ')
*(p2--) = '\0';
}
switch (optentry->argtype) {
case CLOPT_TYPE_STRING:
Expand Down

0 comments on commit 71f56ce

Please sign in to comment.