summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/misc/picotemplate-conf.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
commitbe1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch)
tree9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/misc/picotemplate-conf.pl
parentInitial commit. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/misc/picotemplate-conf.pl')
-rw-r--r--web/server/h2o/libh2o/misc/picotemplate-conf.pl21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/picotemplate-conf.pl b/web/server/h2o/libh2o/misc/picotemplate-conf.pl
new file mode 100644
index 00000000..95eaa7a8
--- /dev/null
+++ b/web/server/h2o/libh2o/misc/picotemplate-conf.pl
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+$main::push_expr = sub {
+ my $src = shift;
+ return qq{{ h2o_iovec_t _s = ($src); if (_s.len != 0 && _s.base[_s.len - 1] == '\\n') --_s.len; h2o_buffer_reserve(&_, _s.len); memcpy(_->bytes + _->size, _s.base, _s.len); _->size += _s.len; }};
+};
+
+$main::push_void_expr = sub {
+ my $src = shift;
+ return qq{{ size_t _l = _->size; { $src }; if (_->size != 0 && _l != _->size && _->bytes[_->size - 1] == '\\n') --_->size; }};
+};
+
+$main::push_str = sub {
+ my $str = shift;
+ $str =~ s/([\\'"])/\\$1/gs;
+ $str =~ s/\n/\\n/gs;
+ return $main::push_expr->(qq{h2o_iovec_init(H2O_STRLIT("$str"))});
+};
+
+1;