> Ian Macdonald wrote:
> > On Wed 29 Oct 2003 at 17:06:07 -0500, Ian Macdonald wrote:
> >
> > > This can probably be fixed with this:
> > >
> > > cap_list = rb_str_split(rb_reg_new(txt, strlen(txt), 0), comma_sp);
> > >
> > > but this is entirely untested. Do you want to give it a try?
> >
> > OK, so that doesn't work. I know what the problem is, but I don't know
> > how to fix it.
>
> 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. 
ian / caliban.org             | 
http://www.caliban.org      | 
                            |