Emergency fix for Ruby problems

With optimizations enabled "alloca(len)" generates code which depends on
"len > 0".  If "len == 0" then the stack pointer becomes botched.  This
fix simply avoids a call to "alloca(len)" in the latter case.  The root
of this problem may be deeper than this, hence I am calling this an
"emergency fix" for now but at least it fixes the crashes in the Ruby
interface that appear when compiling on Mac OS X 10.7.
This commit is contained in:
Bjorn Winckler
2011-07-21 21:57:33 +02:00
parent df0c4d770c
commit 6bd19ecf62
+8 -5
View File
@@ -765,11 +765,14 @@ static VALUE vim_message(VALUE self UNUSED, VALUE str)
char *buff, *p;
str = rb_obj_as_string(str);
buff = ALLOCA_N(char, RSTRING_LEN(str));
strcpy(buff, RSTRING_PTR(str));
p = strchr(buff, '\n');
if (p) *p = '\0';
MSG(buff);
if (RSTRING_LEN(str) > 0)
{
buff = ALLOCA_N(char, RSTRING_LEN(str));
strcpy(buff, RSTRING_PTR(str));
p = strchr(buff, '\n');
if (p) *p = '\0';
MSG(buff);
}
return Qnil;
}