]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use fr_skip_spaces macro
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 27 Feb 2019 06:38:08 +0000 (14:38 +0800)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 27 Feb 2019 06:38:08 +0000 (14:38 +0800)
20 files changed:
src/bin/unit_test_attribute.c
src/bin/unit_test_module.c
src/lib/server/cf_file.c
src/lib/server/command.c
src/lib/server/cond_tokenize.c
src/lib/server/users_file.c
src/lib/server/xlat_func.c
src/lib/sim/xlat.c
src/lib/unlang/interpret.c
src/lib/util/misc.h
src/lib/util/pair.c
src/lib/util/token.c
src/lib/util/trie.c
src/modules/rlm_dict/rlm_dict.c
src/modules/rlm_expr/rlm_expr.c
src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_rest/rest.c
src/modules/rlm_rest/rlm_rest.c
src/modules/rlm_unpack/rlm_unpack.c

index 5ce73908963470cb535a92e6bdb253a83198d210..159a572c3b5e41654f5d97c97aed6a89bc514ecc 100644 (file)
@@ -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) {
index 68a841303878562ac54ce1e54669c988f7971cfe..28e3302f957b062bd14c361173f8f531d42c0024 100644 (file)
@@ -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;
index 74f8908315038f80284e6e7a7be56fb5d38301ef..afd5fe6b16ae25607fbc99722211afe6d8c9ba63 100644 (file)
@@ -38,6 +38,7 @@ RCSID("$Id$")
 
 #include <freeradius-devel/util/cursor.h>
 #include <freeradius-devel/util/syserror.h>
+#include <freeradius-devel/util/misc.h>
 
 #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;
 
index 883edf3583dc3329699c6666d094a8f31934053d..43eb91693a89738a84367c0f70fe01085aa8b72e 100644 (file)
@@ -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.
index 1b9bb838f5dfc5da3d981345f916fa024a02fe87..6784df1d0c3ab7ee623835ae23a5b6b9a4076af2 100644 (file)
@@ -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;
        }
 
index 3d80dac3e12fcd4801c7e015b52f3f51c077056e..456d975ab04706e1349c8174ff2d13a250fac485 100644 (file)
@@ -29,6 +29,7 @@ RCSID("$Id$")
 #include <freeradius-devel/server/users_file.h>
 
 #include <freeradius-devel/util/syserror.h>
+#include <freeradius-devel/util/misc.h>
 
 #include <sys/stat.h>
 
@@ -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,
index f91e45038db38b8b515ce54a11615f13f7d8d385..50b5835633b8e85f1cadb5025b8bff48d15c1fdb 100644 (file)
@@ -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);
index 4baa67493b491f0f1045cb113c95db6e3577303f..045ef9516a577944f8af7f5148b230c86df758ef 100644 (file)
@@ -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){
index 38717a1386cf25963f7c256ee5edbace43c770c7..5258d9b8d986df1f1c862b3634c5bef83a683360 100644 (file)
@@ -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.
index 2655f6c6a6e78b9dd3f1b65caeaaedf29e862204..56e062296b07f891da6b87907066e0422b8684b8 100644 (file)
@@ -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.
index b9b843c9407fac0d0bf41e950996d7180f205dd8..8c4bc4a794fe58b7d4f98038c94244e0ee5815bb 100644 (file)
@@ -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) {
 
index 4a95724f68af009ebf20e76b089ca83a4e507257..d79230dca72b1374611e30fbd983516be9099313 100644 (file)
@@ -27,6 +27,7 @@ RCSID("$Id$")
 #include "token.h"
 
 #include <freeradius-devel/util/strerror.h>
+#include <freeradius-devel/util/misc.h>
 
 #include <ctype.h>
 #include <stdio.h>
@@ -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;
 
index 63ad874288e1b204291026c1b1d072444a968a76..87247b22e855b89aadd4b2892340c72f888ede4e 100644 (file)
@@ -23,6 +23,7 @@
 RCSID("$Id$")
 
 #include <freeradius-devel/util/dict.h>
+#include <freeradius-devel/util/misc.h>
 #include <freeradius-devel/util/syserror.h>
 #include <freeradius-devel/util/talloc.h>
 #include <freeradius-devel/util/trie.h>
@@ -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.
index e5b5ce62837f85c594acec75ed5fbfa61556f555..7d56ba11d0922ffb25fa050dbcc8d4301264dbc7 100644 (file)
@@ -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;
 
index 0c0efc6529f1a72f2a7ed40b4c995512a0b374e4..8afa5514c3cefe2ca274deee883f430480dfbcef 100644 (file)
@@ -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.
index 622d23f80085246957efbc200720c8956fd1517a..42de315d2c5ace6c7d1c56e3efcc057dab3ee279 100644 (file)
@@ -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;
index cdaa36d5a3a0732321d5217c2d2330057ea0f818..cd7899ddc9ed1edfbe7d91efd1a97d5caf15f84a 100644 (file)
@@ -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);
index ccc4d0b2a5cd898e80f6e3ee8399dd4cf29cd4e9..402ca5b5ef922bb8a432bc48d94c7d6d1f45e429 100644 (file)
@@ -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);
index 2c64e444cd7e645bbbce4df955072fefe3eac925..1da89c11622cdc3582718f915aa83788c7ed5bcf 100644 (file)
@@ -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;
index 11576c460e1707c60a06b057c9c57848262f5b2d..065185d4b4b1b330ffde7ede110fd90f29a98b6a 100644 (file)
@@ -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;