I took the trouble to port ferret to ruby 1.9.1 yesterday evening. I have it working on my mac. Here’s a gem for you to try – I have labelled it 0.11.6.19. If you use it let me know how it runs, but it’s at your own risk, I haven’t extensively tested it. [UPDATE: this gem has been updated 5th April 2009 – please test. There is also a fork at github] I’ve made mostly simple changes in the code:
- Changed all struct RString -> ptr to use the RSTRING_PTR macro, except for cases where it was being used to add items to an array where rb_ary_store was used.
- Changed all struct RString -> len to use the RSTRING_LEN macro
- Changed all struct RArray -> ptr to use the RARRAY_PTR macro
- Changed all struct RArray -> len to use the RARRAY_LEN macro
- Removed manual adjustment of the len member of RArray. In fact ruby 1.9 stores small arrays of 3 items or less differently from larger ones, and this adds complexity. It is better to use the rb_ary_store method which will use the correct pointer and will keep the length in sync with the number of items in the array.
- Changed all struct RHash -> tbl to ntbl
- Removed references to rb_thread_critical
- Removed 4th argument from calls to rb_cvar_set
- Included ruby/re.h and not regex.h, and altered tokenizer code to correctly use the new regexp library
- Included ruby/st.h and not st.h
- Some other minor changes to error messages formats causing compiler warnings
By the way, acts_as_ferret also runs with some very minor surgery, Thomas von Deyen has a fork here.