diff options
author | Andrew Moss <1043609+amoss@users.noreply.github.com> | 2019-12-16 15:12:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 15:12:00 +0100 |
commit | c8c72f18a6a8fd09d3b6284e49525396b24e8395 (patch) | |
tree | 5b9aeaea7d72e1d1029d45f67c0a5f130ecc2f80 /libnetdata/simple_pattern | |
parent | c4bb3d2642ab34e6aca912b22e55aed52f84e974 (diff) |
Labels issues (#7515)
Initial work on host labels from the dedicated branch. Includes work for issues #7096, #7400, #7411, #7369, #7410, #7458, #7459, #7412 and #7408 by @vlvkobal, @thiagoftsm, @cakrit and @amoss.
Diffstat (limited to 'libnetdata/simple_pattern')
-rw-r--r-- | libnetdata/simple_pattern/simple_pattern.c | 23 | ||||
-rw-r--r-- | libnetdata/simple_pattern/simple_pattern.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libnetdata/simple_pattern/simple_pattern.c b/libnetdata/simple_pattern/simple_pattern.c index ab4b9de3c5..44fa42a629 100644 --- a/libnetdata/simple_pattern/simple_pattern.c +++ b/libnetdata/simple_pattern/simple_pattern.c @@ -331,3 +331,26 @@ extern int simple_pattern_is_potential_name(SIMPLE_PATTERN *p) } return (alpha || wildcards) && !colon; } + +char *simple_pattern_trim_around_equal(char *src) { + char *store = mallocz(strlen(src) +1); + if(!store) + return NULL; + + char *dst = store; + while (*src) { + if (*src == '=') { + if (*(dst -1) == ' ') + dst--; + + *dst++ = *src++; + if (*src == ' ') + src++; + } + + *dst++ = *src++; + } + *dst = 0x00; + + return store; +} diff --git a/libnetdata/simple_pattern/simple_pattern.h b/libnetdata/simple_pattern/simple_pattern.h index cb5e7699dd..ec6b535879 100644 --- a/libnetdata/simple_pattern/simple_pattern.h +++ b/libnetdata/simple_pattern/simple_pattern.h @@ -33,4 +33,7 @@ extern void simple_pattern_free(SIMPLE_PATTERN *list); extern void simple_pattern_dump(uint64_t debug_type, SIMPLE_PATTERN *p) ; extern int simple_pattern_is_potential_name(SIMPLE_PATTERN *p) ; +//Auxiliary function to create a pattern +char *simple_pattern_trim_around_equal(char *src); + #endif //NETDATA_SIMPLE_PATTERN_H |