summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/simple_pattern/simple_pattern.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:33:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 17:34:10 +0000
commit83ba6762cc43d9db581b979bb5e3445669e46cc2 (patch)
tree2e69833b43f791ed253a7a20318b767ebe56cdb8 /src/libnetdata/simple_pattern/simple_pattern.c
parentReleasing debian version 1.47.5-1. (diff)
downloadnetdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.tar.xz
netdata-83ba6762cc43d9db581b979bb5e3445669e46cc2.zip
Merging upstream version 2.0.3+dfsg (Closes: #923993, #1042533, #1045145).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/simple_pattern/simple_pattern.c')
-rw-r--r--src/libnetdata/simple_pattern/simple_pattern.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libnetdata/simple_pattern/simple_pattern.c b/src/libnetdata/simple_pattern/simple_pattern.c
index 7a7f41b1c..d0feefb4d 100644
--- a/src/libnetdata/simple_pattern/simple_pattern.c
+++ b/src/libnetdata/simple_pattern/simple_pattern.c
@@ -78,18 +78,21 @@ SIMPLE_PATTERN *simple_pattern_create(const char *list, const char *separators,
if(unlikely(!list || !*list)) return root;
- char isseparator[256] = {
- [' '] = 1 // space
- , ['\t'] = 1 // tab
- , ['\r'] = 1 // carriage return
- , ['\n'] = 1 // new line
- , ['\f'] = 1 // form feed
- , ['\v'] = 1 // vertical tab
+ bool isseparator[256] = {
+ [' '] = true // space
+ , ['\t'] = true // tab
+ , ['\r'] = true // carriage return
+ , ['\n'] = true // new line
+ , ['\f'] = true // form feed
+ , ['\v'] = true // vertical tab
};
- if (unlikely(separators && *separators)) {
- memset(&isseparator[0], 0, sizeof(isseparator));
- while(*separators) isseparator[(unsigned char)*separators++] = 1;
+ if (unlikely(separators == SIMPLE_PATTERN_NO_SEPARATORS))
+ memset(isseparator, false, sizeof(isseparator));
+
+ else if (unlikely(separators && *separators)) {
+ memset(isseparator, false, sizeof(isseparator));
+ while(*separators) isseparator[(unsigned char)*separators++] = true;
}
char *buf = mallocz(strlen(list) + 1);