예제 #1
0
  // Make string based on internal data encoding (which ironically is its
  // external encoding.  This seems messy and we should consider a more
  // uniform method for makeing strings (we have a slightly different variant
  // of this in RubyIO.
  private RubyString makeString(Ruby runtime, ByteList buf, boolean setEncoding) {
    if (runtime.is1_9() && setEncoding) buf.setEncoding(ptr.string.getEncoding());

    RubyString str = RubyString.newString(runtime, buf);
    str.setTaint(true);

    return str;
  }
예제 #2
0
  // Make string based on internal data encoding (which ironically is its
  // external encoding.  This seems messy and we should consider a more
  // uniform method for makeing strings (we have a slightly different variant
  // of this in RubyIO.
  private RubyString makeString(Ruby runtime, ByteList buf) {
    if (runtime.is1_9()) buf.setEncoding(data.internal.getEncoding());

    RubyString str = RubyString.newString(runtime, buf);
    str.setTaint(true);

    return str;
  }
예제 #3
0
    public final IRubyObject invoke(Ruby runtime, Function function, HeapInvocationBuffer args) {
      long address = invoker.invokeAddress(function, args);
      if (address == 0) {
        return runtime.getNil();
      }
      int len = (int) IO.getStringLength(address);
      if (len == 0) {
        return RubyString.newEmptyString(runtime);
      }
      byte[] bytes = new byte[len];
      IO.getByteArray(address, bytes, 0, len);

      RubyString s = RubyString.newStringShared(runtime, bytes);
      s.setTaint(true);
      return s;
    }
예제 #4
0
  @Override
  protected IRubyObject inspectAry(ThreadContext context) {
    if (!packed()) return super.inspectAry(context);

    final Ruby runtime = context.runtime;
    RubyString str =
        RubyString.newStringLight(runtime, DEFAULT_INSPECT_STR_SIZE, USASCIIEncoding.INSTANCE);
    EncodingUtils.strBufCat(runtime, str, OPEN_BRACKET);
    boolean tainted = isTaint();

    RubyString s = inspect(context, value);
    if (s.isTaint()) tainted = true;
    else str.setEncoding(s.getEncoding());
    str.cat19(s);

    EncodingUtils.strBufCat(runtime, str, CLOSE_BRACKET);

    if (tainted) str.setTaint(true);

    return str;
  }