Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ruby.h"
- #include "string.h"
- static VALUE mExample;
- VALUE example2_cs_fast(char *s1, char *s2) {
- char *start = s1;
- while (*s1 && *s2 && (*++s1 == *++s2));
- if ((*s1 != 0 && *s1 != 47) || (*s2 != 0 && *s2 != 47)) {
- while(*--s1 != 47);
- }
- if (s1-start <= 1) { *s1++; } // correction for '/'
- *s1 = 0;
- return rb_str_new2(s1);
- }
- void Init_example() {
- mExample = rb_define_module("Example2");
- rb_define_module_function(mExample, "cs_fast", example2_cs_fast, 2);
- }
Add Comment
Please, Sign In to add comment