From: Arran Cudbard-Bell Date: Wed, 27 Feb 2019 06:38:08 +0000 (+0800) Subject: Use fr_skip_spaces macro X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23e5d034ece0f52abb2f8e41ad1b849050d4f692;p=thirdparty%2Ffreeradius-server.git Use fr_skip_spaces macro --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 5ce73908963..159a572c3b5 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -164,7 +164,7 @@ static int encode_data_tlv(char *buffer, char **endptr, *p = '\0'; p = buffer + 1; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); length = encode_tlv(p, output, outlen); if (length == 0) return 0; @@ -178,7 +178,7 @@ static int encode_hex(char *p, uint8_t *output, size_t outlen) while (*p) { char *c1, *c2; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (!*p) break; @@ -215,7 +215,7 @@ static int encode_data(char *p, uint8_t *output, size_t outlen) return 0; } - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (*p == '{') { int sublen; @@ -224,7 +224,7 @@ static int encode_data(char *p, uint8_t *output, size_t outlen) length = 0; do { - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (!*p) { if (length == 0) { fprintf(stderr, "No data\n"); @@ -713,14 +713,14 @@ static void command_add(TALLOC_CTX *ctx, char *input, char *output, size_t outle * Set the name and try to find the syntax. */ name = p; - while (*p && !isspace((int) *p)) p++; + fr_skip_spaces(p); if (isspace(*p)) { *p = '\0'; p++; } - while (*p && isspace((int) *p)) p++; + fr_skip_spaces(p); if (*p) { table->syntax = talloc_strdup(table, p); @@ -871,7 +871,7 @@ do { \ ((p > buffer) && (p[-1] != '[')))) *p = '\0'; p = buffer; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (!*p) continue; DEBUG2("%s[%d]: %s\n", filename, lineno, buffer); @@ -1116,7 +1116,7 @@ do { \ if (strcmp(test_type, "$INCLUDE") == 0) { p += 9; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); q = strrchr(directory, '/'); if (q) { diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 68a84130387..28e3302f957 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -484,7 +484,7 @@ static bool do_xlats(char const *filename, FILE *fp) * Ignore blank lines and comments */ p = input; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (*p < ' ') continue; if (*p == '#') continue; diff --git a/src/lib/server/cf_file.c b/src/lib/server/cf_file.c index 74f89083150..afd5fe6b16a 100644 --- a/src/lib/server/cf_file.c +++ b/src/lib/server/cf_file.c @@ -38,6 +38,7 @@ RCSID("$Id$") #include #include +#include #include "cf_priv.h" @@ -815,7 +816,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, if (has_spaces) { ptr = cbuff; - while (isspace((int) *ptr)) ptr++; + fr_skip_spaces(ptr); if (ptr > cbuff) { memmove(cbuff, ptr, len - (ptr - cbuff)); @@ -831,7 +832,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, if (at_eof) break; ptr = buff[0]; - while (*ptr && isspace((int) *ptr)) ptr++; + fr_skip_spaces(ptr); #ifdef WITH_CONF_WRITE /* @@ -1395,7 +1396,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, case T_OP_EQ: case T_OP_SET: - while (isspace((int) *ptr)) ptr++; + fr_skip_spaces(ptr); /* * New parser: non-quoted strings are @@ -1496,7 +1497,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, /* * Require a comma, unless there's a comment. */ - while (isspace(*ptr)) ptr++; + fr_skip_spaces(ptr); if (*ptr == ',') { ptr++; @@ -1584,7 +1585,7 @@ static int cf_section_read(char const *filename, int *lineno, FILE *fp, /* * Done parsing one thing. Skip to EOL if possible. */ - while (isspace(*ptr)) ptr++; + fr_skip_spaces(ptr); if (*ptr == '#') continue; diff --git a/src/lib/server/command.c b/src/lib/server/command.c index 883edf3583d..43eb91693a8 100644 --- a/src/lib/server/command.c +++ b/src/lib/server/command.c @@ -1354,8 +1354,6 @@ int fr_command_tab_expand(TALLOC_CTX *ctx, fr_cmd_t *head, fr_cmd_info_t *info, /* * Magic parsing macros */ -#define SKIP_SPACES while (isspace((int) *word)) word++ - #define SKIP_NAME(name) do { p = word; q = name; while (*p && *q && (*p == *q)) { \ p++; \ q++; \ @@ -1871,7 +1869,7 @@ static char const *skip_word(char const *text) char const *word = text; if ((*word != '"') && (*word != '\'')) { - while (*word && !isspace((int) *word)) word++; + fr_skip_spaces(word); return word; } @@ -1911,7 +1909,7 @@ static int syntax_str_to_argv(int start_argc, fr_cmd_argv_t *start, fr_cmd_info_ *runnable = false; while (argv) { - SKIP_SPACES; + fr_skip_spaces(word); if (!*word) goto done; @@ -2174,7 +2172,7 @@ int fr_command_str_to_argv(fr_cmd_t *head, fr_cmd_info_t *info, char const *text cmd = info->cmd[argc]; rad_assert(cmd != NULL); - SKIP_SPACES; + fr_skip_spaces(word); if ((word[0] == '*') && isspace(word[1]) && cmd->added_name) { p = word + 1; @@ -2212,7 +2210,7 @@ skip_matched: * Search the remaining text for matching commands. */ while (cmd) { - SKIP_SPACES; + fr_skip_spaces(word); /* * Skip commands which we shouldn't know about... @@ -2332,7 +2330,7 @@ check_syntax: * runnable. */ if (!cmd->syntax_argv) { - SKIP_SPACES; + fr_skip_spaces(word); if (*word > 0) goto too_many; @@ -2354,7 +2352,7 @@ check_syntax: * input. */ if (!info->runnable && *word) { - SKIP_SPACES; + fr_skip_spaces(word); if (*word) goto too_many; } @@ -2478,7 +2476,7 @@ static int expand_syntax(fr_cmd_t *cmd, fr_cmd_info_t *info, fr_cmd_argv_t *argv * Loop over syntax_argv, looking for matches. */ for (/* nothing */ ; argv != NULL; argv = argv->next) { - SKIP_SPACES; + fr_skip_spaces(word); if (!*word) { return expand_all(cmd, info, argv, count, max_expansions, expansions); @@ -2675,7 +2673,7 @@ int fr_command_complete(fr_cmd_t *head, char const *text, int start, * Try to do this without mangling "text". */ while (cmd) { - SKIP_SPACES; + fr_skip_spaces(word); /* * Skip commands which we shouldn't know about... @@ -2800,7 +2798,7 @@ int fr_command_print_help(FILE *fp, fr_cmd_t *head, char const *text) * Try to do this without mangling "text". */ while (cmd) { - SKIP_SPACES; + fr_skip_spaces(word); /* * End of the input. Tab expand everything here. diff --git a/src/lib/server/cond_tokenize.c b/src/lib/server/cond_tokenize.c index 1b9bb838f5d..6784df1d0c3 100644 --- a/src/lib/server/cond_tokenize.c +++ b/src/lib/server/cond_tokenize.c @@ -303,7 +303,7 @@ static ssize_t cond_tokenize_cast(char const *start, fr_dict_attr_t const **pda, char const *q; fr_type_t cast; - while (isspace((int) *p)) p++; /* skip spaces before condition */ + fr_skip_spaces(p); /* skip spaces before condition */ if (*p != '<') { *pda = NULL; @@ -340,7 +340,7 @@ static ssize_t cond_tokenize_cast(char const *start, fr_dict_attr_t const **pda, q++; - while (isspace((int) *q)) q++; /* skip spaces after cast */ + fr_skip_spaces(q); /* skip spaces after cast */ return q - start; } @@ -478,7 +478,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er lhs = rhs = NULL; lhs_type = rhs_type = T_INVALID; - while (isspace((int) *p)) p++; /* skip spaces before condition */ + fr_skip_spaces(p); /* skip spaces before condition */ if (!*p) { return_P("Empty condition is invalid"); @@ -490,7 +490,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er if (*p == '!') { p++; c->negate = true; - while (isspace((int) *p)) p++; /* skip spaces after negation */ + fr_skip_spaces(p); /* skip spaces after negation */ /* * Just for stupidity @@ -520,7 +520,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er } p += slen; - while (isspace((int) *p)) p++; /* skip spaces after (COND)*/ + fr_skip_spaces(p); /* skip spaces after (COND)*/ } else { /* it's a bare FOO==BAR */ /* @@ -565,7 +565,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er FR_CAST_BASE + FR_TYPE_OCTETS); } - while (isspace((int)*p)) p++; /* skip spaces after LHS */ + fr_skip_spaces(p); /* skip spaces after LHS */ /* * We may (or not) have an operator @@ -718,7 +718,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er break; } - while (isspace((int) *p)) p++; /* skip spaces after operator */ + fr_skip_spaces(p); /* skip spaces after operator */ if (!*p) { return_P("Expected text after operator"); @@ -1229,7 +1229,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er keep_going: p += slen; - while (isspace((int) *p)) p++; /* skip spaces after RHS */ + fr_skip_spaces(p); /* skip spaces after RHS */ } /* parse OP RHS */ } /* parse a condition (COND) or FOO OP BAR*/ @@ -1242,7 +1242,7 @@ static ssize_t cond_tokenize(TALLOC_CTX *ctx, fr_cond_t **pcond, char const **er } p++; - while (isspace((int) *p)) p++; /* skip spaces after closing brace */ + fr_skip_spaces(p); /* skip spaces after closing brace */ goto done; } diff --git a/src/lib/server/users_file.c b/src/lib/server/users_file.c index 3d80dac3e12..456d975ab04 100644 --- a/src/lib/server/users_file.c +++ b/src/lib/server/users_file.c @@ -29,6 +29,7 @@ RCSID("$Id$") #include #include +#include #include @@ -136,7 +137,7 @@ int pairlist_read(TALLOC_CTX *ctx, fr_dict_t const *dict, char const *file, PAIR * ignore it. */ ptr = buffer; - while (isspace((int) *ptr)) ptr++; + fr_skip_spaces(ptr); if (*ptr == '#' || *ptr == '\n' || !*ptr) continue; @@ -164,7 +165,7 @@ parse_again: * $INCLUDE filename */ if (strcasecmp(entry, "$INCLUDE") == 0) { - while (isspace((int) *ptr)) ptr++; + fr_skip_spaces(ptr); /* * If it's an absolute pathname, diff --git a/src/lib/server/xlat_func.c b/src/lib/server/xlat_func.c index f91e45038db..50b5835633b 100644 --- a/src/lib/server/xlat_func.c +++ b/src/lib/server/xlat_func.c @@ -154,7 +154,7 @@ int xlat_fmt_to_cursor(TALLOC_CTX *ctx, fr_cursor_t **out, VALUE_PAIR *vp; fr_cursor_t *cursor; - while (isspace((int) *fmt)) fmt++; /* Not binary safe, but attr refs should only contain printable chars */ + fr_skip_spaces(fmt); /* Not binary safe, but attr refs should only contain printable chars */ if (tmpl_afrom_attr_str(NULL, &vpt, fmt, &(vp_tmpl_rules_t){ @@ -272,7 +272,7 @@ static ssize_t xlat_func_integer(UNUSED TALLOC_CTX *ctx, char **out, size_t outl uint64_t int64 = 0; /* Needs to be initialised to zero */ uint32_t int32 = 0; /* Needs to be initialised to zero */ - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; @@ -463,7 +463,7 @@ static ssize_t xlat_func_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED char **out, U if (!RDEBUG_ENABLED2) return 0; /* NOOP if debugging isn't enabled */ - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if (tmpl_afrom_attr_str(request, &vpt, fmt, &(vp_tmpl_rules_t){ @@ -695,7 +695,7 @@ static ssize_t xlat_func_xlat(TALLOC_CTX *ctx, char **out, size_t outlen, ssize_t slen; VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if (outlen < 3) { nothing: @@ -1703,7 +1703,7 @@ static ssize_t xlat_func_explode(TALLOC_CTX *ctx, char **out, size_t outlen, /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(ctx, &vpt, p, &(vp_tmpl_rules_t){ .dict_def = request->dict }); if (slen <= 0) { @@ -1928,7 +1928,7 @@ static ssize_t parse_pad(vp_tmpl_t **vpt_p, size_t *pad_len_p, char *pad_char_p, *vpt_p = NULL; p = fmt; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (*p != '&') { REDEBUG("First argument must be an attribute reference"); @@ -1943,7 +1943,7 @@ static ssize_t parse_pad(vp_tmpl_t **vpt_p, size_t *pad_len_p, char *pad_char_p, p = fmt + slen; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); pad_len = strtoul(p, &end, 10); if ((pad_len == ULONG_MAX) || (pad_len > 8192)) { @@ -1967,7 +1967,7 @@ static ssize_t parse_pad(vp_tmpl_t **vpt_p, size_t *pad_len_p, char *pad_char_p, return fmt - p; } - while (isspace((int) *p)) p++; + fr_skip_spaces(p); if (p[1] != '\0') { talloc_free(vpt); diff --git a/src/lib/sim/xlat.c b/src/lib/sim/xlat.c index 4baa67493b4..045ef9516a5 100644 --- a/src/lib/sim/xlat.c +++ b/src/lib/sim/xlat.c @@ -46,7 +46,7 @@ static ssize_t sim_xlat_id_method(TALLOC_CTX *ctx, char **out, UNUSED size_t out /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(our_ctx, &vpt, p, &(vp_tmpl_rules_t){ @@ -100,7 +100,7 @@ static ssize_t sim_xlat_id_type(TALLOC_CTX *ctx, char **out, UNUSED size_t outle /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(our_ctx, &vpt, p, &(vp_tmpl_rules_t){ @@ -153,7 +153,7 @@ static ssize_t sim_xlat_3gpp_pseudonym_key_index(TALLOC_CTX *ctx, char **out, UN /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(our_ctx, &vpt, p, &(vp_tmpl_rules_t){ @@ -201,7 +201,7 @@ static ssize_t sim_xlat_3gpp_pseudonym_decrypt(TALLOC_CTX *ctx, char **out, UNUS /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(our_ctx, &id_vpt, p, &(vp_tmpl_rules_t){ @@ -312,7 +312,7 @@ static ssize_t sim_xlat_3gpp_pseudonym_encrypt(TALLOC_CTX *ctx, char **out, UNUS /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); slen = tmpl_afrom_attr_substr(our_ctx, &id_vpt, p, &(vp_tmpl_rules_t){ diff --git a/src/lib/unlang/interpret.c b/src/lib/unlang/interpret.c index 38717a1386c..5258d9b8d98 100644 --- a/src/lib/unlang/interpret.c +++ b/src/lib/unlang/interpret.c @@ -1519,7 +1519,7 @@ static ssize_t xlat_interpreter(UNUSED TALLOC_CTX *ctx, char **out, size_t outle unlang_stack_frame_t *frame; unlang_t *instruction; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); /* * Find the correct stack frame. diff --git a/src/lib/util/misc.h b/src/lib/util/misc.h index 2655f6c6a6e..56e062296b0 100644 --- a/src/lib/util/misc.h +++ b/src/lib/util/misc.h @@ -38,10 +38,11 @@ extern "C" { typedef int8_t (*fr_cmp_t)(void const *a, void const *b); -/* - * Strip whitespace from the beginning of a string +/** Strip whitespace ('\t', '\n', '\v', '\f', '\r', ' ') from the beginning of a string + * + * @param[in,out] _p string to trim. */ -#define fr_skip_spaces(_x) while (isspace((int) *_x)) _x++ +#define fr_skip_spaces(_p) while(isspace((int)*(_p))) _p++ /* * Define TALLOC_DEBUG to check overflows with talloc. diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index b9b843c9407..8c4bc4a794f 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -259,12 +259,12 @@ ssize_t fr_pair_afrom_substr(TALLOC_CTX *ctx, VALUE_PAIR **out, p += slen; - while (isspace(*p)) p++; + fr_skip_spaces(p); if (*p != '=') { fr_strerror_printf("Invalid operator '%c'", *p); return -(p - in); } - while (isspace(*p)) p++; + fr_skip_spaces(p); switch (*p) { diff --git a/src/lib/util/token.c b/src/lib/util/token.c index 4a95724f68a..d79230dca72 100644 --- a/src/lib/util/token.c +++ b/src/lib/util/token.c @@ -27,6 +27,7 @@ RCSID("$Id$") #include "token.h" #include +#include #include #include @@ -267,7 +268,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, /* Skip whitespace */ p = *ptr; - while (*p && isspace((int) *p)) p++; + fr_skip_spaces(p); if (!*p) { *ptr = p; @@ -320,9 +321,8 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, * comma. */ if (!quote) { - if (isspace((int) *p)) { - break; - } + if (isspace((int) *p)) break; + if (tok) { for (t = tokenlist; t->name; t++) { @@ -419,7 +419,7 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, done: /* Skip whitespace again. */ - while (*p && isspace((int) *p)) p++; + fr_skip_spaces(p); *ptr = p; @@ -471,7 +471,7 @@ FR_TOKEN getstring(char const **ptr, char *buf, int buflen, bool unescape) p = *ptr; - while (*p && (isspace((int)*p))) p++; + fr_skip_spaces(p); *ptr = p; diff --git a/src/lib/util/trie.c b/src/lib/util/trie.c index 63ad874288e..87247b22e85 100644 --- a/src/lib/util/trie.c +++ b/src/lib/util/trie.c @@ -23,6 +23,7 @@ RCSID("$Id$") #include +#include #include #include #include @@ -2856,7 +2857,6 @@ static fr_trie_command_t commands[] = { }; #define MAX_ARGC (16) - int main(int argc, char **argv) { int lineno = 0; @@ -2912,7 +2912,7 @@ int main(int argc, char **argv) * Skip leading whitespace. */ p = buffer; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); /* * Skip (now) blank lines. diff --git a/src/modules/rlm_dict/rlm_dict.c b/src/modules/rlm_dict/rlm_dict.c index e5b5ce62837..7d56ba11d09 100644 --- a/src/modules/rlm_dict/rlm_dict.c +++ b/src/modules/rlm_dict/rlm_dict.c @@ -92,7 +92,7 @@ static ssize_t xlat_vendor(TALLOC_CTX *ctx, char **out, UNUSED size_t outlen, VALUE_PAIR *vp; fr_dict_vendor_t const *vendor; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; @@ -112,7 +112,7 @@ static ssize_t xlat_vendor_num(TALLOC_CTX *ctx, char **out, UNUSED size_t outlen { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; @@ -129,7 +129,7 @@ static ssize_t xlat_attr(TALLOC_CTX *ctx, char **out, size_t outlen, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; strlcpy(*out, vp->da->name, outlen); @@ -147,7 +147,7 @@ static ssize_t xlat_attr_num(TALLOC_CTX *ctx, char **out, UNUSED size_t outlen, { VALUE_PAIR *vp; - while (isspace((int) *fmt)) fmt++; + fr_skip_spaces(fmt); if ((xlat_fmt_get_vp(&vp, request, fmt) < 0) || !vp) return 0; diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index 0c0efc6529f..8afa5514c3c 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -167,7 +167,7 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer) /* * Look for a number. */ - while (isspace((int) *p)) p++; + fr_skip_spaces(p); /* * ~1 == 0xff...ffe @@ -453,7 +453,7 @@ static bool get_expression(REQUEST *request, char const **string, int64_t *answe if (!get_number(request, &p, &lhs)) return false; redo: - while (isspace((int) *p)) p++; + fr_skip_spaces(p); /* * A number by itself is OK. diff --git a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c index 622d23f8008..42de315d2c5 100644 --- a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c +++ b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c @@ -237,7 +237,7 @@ redo: * Skip leading spaces */ p = state->ptr; - while (isspace((int) *p)) p++; + fr_skip_spaces(p); /* * The line is all spaces, OR we've hit a comment. Go @@ -258,7 +258,7 @@ static int skip_spaces(rlm_isc_dhcp_tokenizer_t *state, char *p) state->ptr = p; char *start = p; - while (isspace((int) *state->ptr)) state->ptr++; + fr_skip_spaces(state->ptr); /* * If we ran out of text on this line, re-fill the @@ -347,7 +347,7 @@ redo: */ if (!*state->ptr) { int rcode; - + rcode = refill(state); if (rcode < 0) return rcode; @@ -397,7 +397,7 @@ redo: if (*p == ';') { if (semicolon == NO_SEMICOLON) { fr_strerror_printf("unexpected ';'"); - return -1; + return -1; } state->ptr = p; diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index cdaa36d5a3a..cd7899ddc9e 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -560,7 +560,7 @@ static ssize_t mschap_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, if ((*p == '\0') || (outlen <= 32)) return 0; - while (isspace(*p)) p++; + fr_skip_spaces(p); if (mschap_ntpwdhash(buffer, p) < 0) { REDEBUG("Failed generating NT-Password"); @@ -583,7 +583,7 @@ static ssize_t mschap_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, if ((*p == '\0') || (outlen <= 32)) return 0; - while (isspace(*p)) p++; + fr_skip_spaces(p); smbdes_lmpwdhash(p, buffer); fr_bin2hex(*out, buffer, LM_DIGEST_LENGTH); diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index ccc4d0b2a5c..402ca5b5ef9 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -750,7 +750,7 @@ static int rest_decode_post(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_s /* * Empty response? */ - while (isspace(*p)) p++; + fr_skip_spaces(p); if (*p == '\0') return 0; while (((q = strchr(p, '=')) != NULL) && (count < REST_BODY_MAX_ATTRS)) { @@ -1234,7 +1234,7 @@ static int rest_decode_json(rlm_rest_t const *instance, rlm_rest_section_t const /* * Empty response? */ - while (isspace(*p)) p++; + fr_skip_spaces(p); if (*p == '\0') return 0; json = json_tokener_parse(p); diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 2c64e444cd7..1da89c11622 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -356,7 +356,7 @@ static xlat_action_t rest_xlat(TALLOC_CTX *ctx, UNUSED fr_cursor_t *out, /* * Trim whitespace */ - while (isspace(*p) && p++); + fr_skip_spaces(p); handle = rctx->handle = fr_pool_connection_get(t->pool, request); if (!handle) return XLAT_ACTION_FAIL; diff --git a/src/modules/rlm_unpack/rlm_unpack.c b/src/modules/rlm_unpack/rlm_unpack.c index 11576c460e1..065185d4b4b 100644 --- a/src/modules/rlm_unpack/rlm_unpack.c +++ b/src/modules/rlm_unpack/rlm_unpack.c @@ -73,7 +73,7 @@ static ssize_t unpack_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen, strlcpy(buffer, fmt, sizeof(buffer)); p = buffer; - while (isspace((int) *p)) p++; /* skip leading spaces */ + fr_skip_spaces(p); /* skip leading spaces */ data_name = p;