Skip to content

Commit 34ac7ce

Browse files
committed
fix: try to get rid of gcc-ASAN weird error
1 parent 154e515 commit 34ac7ce

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: ggiraph
33
Title: Make 'ggplot2' Graphics Interactive
4-
Version: 0.8.11
4+
Version: 0.8.12
55
Authors@R: c(
66
person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")),
77
person("Panagiotis", "Skintzos", , "sigmapi@posteo.net", role = "aut"),

src/interactive.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
#include "dsvg.h"
55
#include <regex>
66

7+
std::string safe_regex_replace(const std::string& input, const std::string& pattern, const std::string& replacement) {
8+
size_t start_pos = 0;
9+
std::string result = input;
10+
while ((start_pos = result.find(pattern, start_pos)) != std::string::npos) {
11+
result.replace(start_pos, pattern.length(), replacement);
12+
start_pos += replacement.length(); // Advance past the replacement
13+
}
14+
return result;
15+
}
16+
717
INDEX InteractiveElements::push(SVGElement* el) {
818
const INDEX index = IndexedElements::push(el);
919
if (el) {
@@ -81,8 +91,8 @@ std::string compile_css(const std::string& cls_prefix, const char* cls_suffix,
8191
const std::string& canvas_id, const char* data_attr,
8292
const char* data_value, const char* css) {
8393
std::string cls = cls_prefix + cls_suffix + canvas_id + "[" + data_attr + " = \"" + data_value + "\"]";
84-
std::regex pattern("_CLASSNAME_");
85-
return std::regex_replace(css, pattern, cls);
94+
std::string css_str(css);
95+
return safe_regex_replace(css_str, "_CLASSNAME_", cls);;
8696
}
8797

8898
// [[Rcpp::export]]

0 commit comments

Comments
 (0)