Guest User

Untitled

a guest
Feb 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include "ruby.h"
  2. #include "string.h"
  3.  
  4. static VALUE mExample;
  5.  
  6. VALUE example2_cs_fast(char *s1, char *s2) {
  7. char *start = s1;
  8. while (*s1 && *s2 && (*++s1 == *++s2));
  9. if ((*s1 != 0 && *s1 != 47) || (*s2 != 0 && *s2 != 47)) {
  10. while(*--s1 != 47);
  11. }
  12. if (s1-start <= 1) { *s1++; } // correction for '/'
  13. *s1 = 0;
  14. return rb_str_new2(s1);
  15. }
  16.  
  17. void Init_example() {
  18. mExample = rb_define_module("Example2");
  19. rb_define_module_function(mExample, "cs_fast", example2_cs_fast, 2);
  20. }
Add Comment
Please, Sign In to add comment