I
Ian Macdonald
You're way ahead of me... I'm not sure I even understand the problem.
:-(
I have a piece of code that look like this:
const char *comma_sp = ", ";
cap_list = rb_str_split(rb_str_new2(txt), comma_sp);
This worked fine in Ruby 1.6.x, but in 1.8.x, it generates a warning in
any code that invokes the method:
/usr/bin/mycal:101: warning: string pattern instead of regexp; metacharacters no longer effective
Now, I understand why this happens and I'm quite capable of fixing the
same error when it occurs in pure Ruby code, but I can't seem to figure
out how to fix it in Ruby C.
The prototype from intern.h looks like this:
VALUE rb_str_split _((VALUE, const char*));
So, what's the problem? How do I pass rb_str_split a regex as its second
argument, instead of a string?
I thought the answer might be this:
cap_list = rb_str_split(rb_str_new2(txt),
rb_reg_new(comma_sp,
strlen(comma_sp), 0));
but that makes a VALUE out of the second argument, which is not what the
prototype expects, so a warning is issued during compilation.
Any ideas?
Ian
--
Ian Macdonald | Ashes to ashes, dust to dust, If God won't
System Administrator | have you, the devil must.
(e-mail address removed) |
http://www.caliban.org |
|