}
static void gr_copy_escape_part (char *dst, const char *src, size_t dst_len,
- char escape_char)
+ char escape_char, _Bool preserve_separator)
{
memset (dst, 0, dst_len);
break;
}
- if ((src[i] == '.')
+ if ((!preserve_separator && (src[i] == '.'))
|| isspace ((int) src[i])
|| iscntrl ((int) src[i]))
dst[i] = escape_char;
if (postfix == NULL)
postfix = "";
+ _Bool preserve_separator = (flags & GRAPHITE_PRESERVE_SEPARATOR) ? 1 : 0;
+
gr_copy_escape_part (n_host, vl->host,
- sizeof (n_host), escape_char);
+ sizeof (n_host), escape_char, preserve_separator);
gr_copy_escape_part (n_plugin, vl->plugin,
- sizeof (n_plugin), escape_char);
+ sizeof (n_plugin), escape_char, preserve_separator);
gr_copy_escape_part (n_plugin_instance, vl->plugin_instance,
- sizeof (n_plugin_instance), escape_char);
+ sizeof (n_plugin_instance), escape_char, preserve_separator);
gr_copy_escape_part (n_type, vl->type,
- sizeof (n_type), escape_char);
+ sizeof (n_type), escape_char, preserve_separator);
gr_copy_escape_part (n_type_instance, vl->type_instance,
- sizeof (n_type_instance), escape_char);
+ sizeof (n_type_instance), escape_char, preserve_separator);
if (n_plugin_instance[0] != '\0')
ssnprintf (tmp_plugin, sizeof (tmp_plugin), "%s%c%s",
.flags = GRAPHITE_ALWAYS_APPEND_DS,
.want_name = "example@com.test-foo.single-bar.value",
},
+ /* flag GRAPHITE_PRESERVE_SEPARATOR */
+ {
+ .plugin_instance = "f.o.o",
+ .type_instance = "b.a.r",
+ .flags = 0,
+ .want_name = "example@com.test-f@o@o.single-b@a@r",
+ },
+ {
+ .plugin_instance = "f.o.o",
+ .type_instance = "b.a.r",
+ .flags = GRAPHITE_PRESERVE_SEPARATOR,
+ .want_name = "example.com.test-f.o.o.single-b.a.r",
+ },
/* prefix and suffix */
{
.prefix = "foo.",