>>>>> "S" == Sam Ruby <rubys / intertwingly.net> writes:

S> sample/test.rb:system ........./sample/test.rb:1873: [BUG] Segmentation 
S> fault
S> ruby 1.9.0 (2008-01-13 revision 0) [i686-linux]

 For this test, the problem is with

 /./u

 more precisely in reg_fragment_setenc_gen() (parse.y) there is

reg_fragment_setenc_gen(struct parser_params* parser, VALUE str, int options)
{
    int c = RE_OPTION_ENCODING_IDX(options);

    if (c) {
        int opt, idx;
        rb_char_to_option_kcode(c, &opt, &idx);
        if (idx != ENCODING_GET(str) && !ENCODING_IS_ASCII8BIT(str) &&
            rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) {
            compile_error(PARSER_ARG
                          "regexp encoding option '%c' differs from source encoding '%s'",
                          c, rb_enc_name(rb_enc_get(str)));
        }
        ENCODING_SET(str, idx);
    }
}


 rb_char_to_option_kcode() give in idx one of the constant defined in re.c

#define ARG_KCODE_NONE	      0
#define ARG_KCODE_EUC 	      1
#define ARG_KCODE_SJIS	      2
#define ARG_KCODE_UTF8	      3

 this is not what ruby want but rather something like this

extern int
rb_char_to_index_kcode(int c)
{
    int idx;

    switch (c) {
      case 'e':
          idx = rb_enc_find_index("EUC-JP");
          break;
      case 's':
          idx = rb_enc_find_index("Shift_JIS");
          break;
      case 'u':
          idx = rb_enc_find_index("UTF-8");
          break;
      default:
          idx = -1;
          break;
    }
    return idx;
}


 please *verify* it because I'm surely wrong.


Guy Decoux