Sha256: 2afd28db1b4083e06665e8e9cc76e4654bc64ebd94f3fccf170e4197c09145ff

Contents?: true

Size: 873 Bytes

Versions: 20

Compression:

Stored size: 873 Bytes

Contents

#include "rbs_extension.h"

VALUE rbs_unquote_string(parserstate *state, range rg, int offset_bytes) {
  VALUE string = state->lexstate->string;
  rb_encoding *enc = rb_enc_get(string);

  unsigned int first_char = rb_enc_mbc_to_codepoint(
    RSTRING_PTR(string) + rg.start.byte_pos + offset_bytes,
    RSTRING_END(string),
    enc
  );

  int byte_length = rg.end.byte_pos - rg.start.byte_pos - offset_bytes;

  if (first_char == '"' || first_char == '\'' || first_char == '`') {
    int bs = rb_enc_codelen(first_char, enc);
    offset_bytes += bs;
    byte_length -= 2 * bs;
  }

  char *buffer = RSTRING_PTR(state->lexstate->string) + rg.start.byte_pos + offset_bytes;
  VALUE str = rb_enc_str_new(buffer, byte_length, enc);

  return rb_funcall(
    RBS_Types_Literal,
    rb_intern("unescape_string"),
    2,
    str,
    first_char == '\"' ? Qtrue : Qfalse
  );
}

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rbs-3.7.0.dev.1 ext/rbs_extension/unescape.c
rbs-3.6.1 ext/rbs_extension/unescape.c
rbs-3.6.0 ext/rbs_extension/unescape.c
rbs-3.6.0.pre.3 ext/rbs_extension/unescape.c
rbs-3.6.0.pre.2 ext/rbs_extension/unescape.c
rbs-3.6.0.pre.1 ext/rbs_extension/unescape.c
rbs-3.6.0.dev.1 ext/rbs_extension/unescape.c
rbs-3.5.3 ext/rbs_extension/unescape.c
rbs-3.5.2 ext/rbs_extension/unescape.c
rbs-3.5.1 ext/rbs_extension/unescape.c
rbs-3.5.1.pre.1 ext/rbs_extension/unescape.c
rbs-3.5.0 ext/rbs_extension/unescape.c
rbs-3.5.0.pre.2 ext/rbs_extension/unescape.c
rbs-3.5.0.pre.1 ext/rbs_extension/unescape.c
rbs-3.4.4 ext/rbs_extension/unescape.c
rbs-3.4.3 ext/rbs_extension/unescape.c
rbs-3.4.2 ext/rbs_extension/unescape.c
rbs-3.4.1 ext/rbs_extension/unescape.c
rbs-3.4.0 ext/rbs_extension/unescape.c
rbs-3.4.0.pre.1 ext/rbs_extension/unescape.c