summaryrefslogtreecommitdiff
path: root/template/prelude.c.tmpl
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-19 14:12:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-19 14:12:00 +0000
commit69161305662bd96e9e1f1bb261a750b636b99f93 (patch)
treed4cc8e063843d1d3ce3ee66c1ba904a7ef5e7b02 /template/prelude.c.tmpl
parent68f374727ae772476d617af9f059e9b66e8176fb (diff)
downloadbundler-69161305662bd96e9e1f1bb261a750b636b99f93.tar.gz
parse.y: NUL-terminate ruby_sourcefile
* parse.y (yycompile): in some cases (warning, error, dtrace,...), ruby_sourcefile is expected to be NUL-terminated, so ensure it. * template/prelude.c.tmpl (prelude_name): NUL-terminate to get rid of copying static data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template/prelude.c.tmpl')
-rw-r--r--template/prelude.c.tmpl13
1 files changed, 6 insertions, 7 deletions
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index b12a27059c..a359e45cf8 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -86,9 +86,7 @@ Prelude.new(output && output[/\w+(?=_prelude.c\b)/] || 'prelude', ARGV, vpath).i
% preludes.each {|i, prelude, lines, sub|
% name = prelude_name(*prelude)
-static const struct {
- char L0[<%=name.size%><%=%>];
-} prelude_name<%=i%><%=%> = {"<%=c_esc(name)%>"};
+static const char prelude_name<%=i%><%=%>[] = "<%=c_esc(name)%>";
static const struct {
% size = beg = 0
% lines.each_with_index {|(line, comment), n|
@@ -138,7 +136,8 @@ prelude_prefix_path(VALUE self)
% end
% unless preludes.empty?
-#define PRELUDE_STR(n) rb_usascii_str_new_static(prelude_##n.L0, sizeof(prelude_##n))
+#define PRELUDE_NAME(n) rb_usascii_str_new_static(prelude_name##n, sizeof(prelude_name##n)-1)
+#define PRELUDE_CODE(n) rb_usascii_str_new_static(prelude_code##n.L0, sizeof(prelude_code##n))
#if defined __GNUC__ && __GNUC__ >= 5
# pragma GCC diagnostic push
# pragma GCC diagnostic error "-Wmissing-field-initializers"
@@ -189,8 +188,8 @@ prelude_require(VALUE self, VALUE nth)
% @preludes.each_value do |i, prelude, lines, sub|
% if sub
case <%=i%><%=%>:
- code = PRELUDE_STR(code<%=i%><%=%>);
- name = PRELUDE_STR(name<%=i%><%=%>);
+ code = PRELUDE_CODE(<%=i%><%=%>);
+ name = PRELUDE_NAME(<%=i%><%=%>);
break;
% end
% end
@@ -222,7 +221,7 @@ Init_<%=@init_name%><%=%>(void)
% end
% preludes.each do |i, prelude, lines, sub|
% next if sub
- prelude_eval(PRELUDE_STR(code<%=i%><%=%>), PRELUDE_STR(name<%=i%><%=%>), 1);
+ prelude_eval(PRELUDE_CODE(<%=i%><%=%>), PRELUDE_NAME(<%=i%><%=%>), 1);
% end
% if @have_sublib
rb_gc_force_recycle(prelude);