From 71f56ce3ec928890a5e21143196253cfcc98bf33 Mon Sep 17 00:00:00 2001 From: "Stiliyan Tonev (Bark)" Date: Tue, 14 Jan 2025 11:25:26 +0200 Subject: [PATCH] Trim trailing spaces and run clang-format. --- common/optparser.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/optparser.c b/common/optparser.c index e89ecbd189..2431900ea2 100644 --- a/common/optparser.c +++ b/common/optparser.c @@ -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) { @@ -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] == '#') @@ -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); @@ -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: