private boolean end_with_pCommon(IRubyObject arg) { IRubyObject tmp = arg.checkStringType(); if (tmp.isNil()) return false; RubyString otherString = (RubyString)tmp; int otherLength = otherString.value.getRealSize(); Encoding enc = checkEncoding(otherString); if (value.getRealSize() < otherLength) return false; int p = value.getBegin(); int end = p + value.getRealSize(); if (otherLength == 0) { // other is '', so return true return true; } int s = end - otherLength; if (enc.leftAdjustCharHead(value.getUnsafeBytes(), p, s, end) != s) return false; return value.endsWith(otherString.value); }
private boolean end_with_pCommon(IRubyObject arg) { IRubyObject tmp = arg.checkStringType(); if (tmp.isNil()) return false; RubyString otherString = (RubyString)tmp; int otherLength = otherString.value.getRealSize(); Encoding enc = checkEncoding(otherString); if (value.getRealSize() < otherLength) return false; int p = value.getBegin(); int end = p + value.getRealSize(); if (otherLength == 0) { // other is '', so return true return true; } int s = end - otherLength; if (enc.leftAdjustCharHead(value.getUnsafeBytes(), p, s, end) != s) return false; return value.endsWith(otherString.value); }
private static void putsSingle(ThreadContext context, Ruby runtime, IRubyObject maybeIO, IRubyObject arg, RubyString separator) { ByteList line; if (arg.isNil()) { line = getNilByteList(runtime); } else if (runtime.isInspecting(arg)) { line = RECURSIVE_BYTELIST; } else if (arg instanceof RubyArray) { inspectPuts(context, maybeIO, (RubyArray) arg); return; } else { line = arg.asString().getByteList(); } write(context, maybeIO, line); if (line.length() == 0 || !line.endsWith(separator.getByteList())) { write(context, maybeIO, separator.getByteList()); } }
private static void putsSingle(ThreadContext context, Ruby runtime, IRubyObject maybeIO, IRubyObject arg, RubyString separator) { ByteList line; if (arg.isNil()) { line = getNilByteList(runtime); } else if (runtime.isInspecting(arg)) { line = RECURSIVE_BYTELIST; } else if (arg instanceof RubyArray) { inspectPuts(context, maybeIO, (RubyArray) arg); return; } else { line = arg.asString().getByteList(); } write(context, maybeIO, line); if (line.length() == 0 || !line.endsWith(separator.getByteList())) { write(context, maybeIO, separator.getByteList()); } }
boolean writeSeparator = line.length() == 0 || !line.endsWith(separator.getByteList());
boolean writeSeparator = line.length() == 0 || !line.endsWith(separator.getByteList());
private IRubyObject chompBangCommon(Ruby runtime, IRubyObject rsObj) { if (rsObj.isNil()) return rsObj; RubyString rs = rsObj.convertToString(); int p = value.getBegin(); int len = value.getRealSize(); byte[] bytes = value.getUnsafeBytes(); int rslen = rs.value.getRealSize(); if (rslen == 0) { while (len > 0 && bytes[p + len - 1] == (byte)'\n') { len--; if (len > 0 && bytes[p + len - 1] == (byte)'\r') len--; } if (len < value.getRealSize()) { view(0, len); return this; } return runtime.getNil(); } if (rslen > len) return runtime.getNil(); byte newline = rs.value.getUnsafeBytes()[rslen - 1]; if (rslen == 1 && newline == (byte)'\n') return smartChopBangCommon(runtime); if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { view(0, value.getRealSize() - rslen); return this; } return runtime.getNil(); }
private IRubyObject chompBangCommon(Ruby runtime, IRubyObject rsObj) { if (rsObj.isNil()) return rsObj; RubyString rs = rsObj.convertToString(); int p = value.getBegin(); int len = value.getRealSize(); byte[] bytes = value.getUnsafeBytes(); int rslen = rs.value.getRealSize(); if (rslen == 0) { while (len > 0 && bytes[p + len - 1] == (byte)'\n') { len--; if (len > 0 && bytes[p + len - 1] == (byte)'\r') len--; } if (len < value.getRealSize()) { view(0, len); return this; } return runtime.getNil(); } if (rslen > len) return runtime.getNil(); byte newline = rs.value.getUnsafeBytes()[rslen - 1]; if (rslen == 1 && newline == (byte)'\n') return smartChopBangCommon(runtime); if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { view(0, value.getRealSize() - rslen); return this; } return runtime.getNil(); }
if (line == null || !line.getByteList().endsWith(NEWLINE)) { RubyIO.write(context, maybeIO, RubyString.newStringShared(runtime, NEWLINE));
if (line == null || !line.getByteList().endsWith(NEWLINE)) { RubyIO.write(context, maybeIO, RubyString.newStringShared(runtime, NEWLINE));
if (!line.getByteList().endsWith(NEWLINE)) { RubyIO.write(context, maybeIO, RubyString.newStringShared(runtime, NEWLINE));
if (line.length() == 0 || !line.endsWith(separator.getByteList())) { write(context, separator.getByteList());
if (!line.getByteList().endsWith(NEWLINE)) { RubyIO.write(context, maybeIO, RubyString.newStringShared(runtime, NEWLINE));
if (buff[begin + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { view(0, value.realSize - rslen); return this;
if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { if (enc.leftAdjustCharHead(bytes, p, pp, end) != pp) return runtime.getNil(); if (getCodeRange() != CR_7BIT) clearCodeRange();
if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { if (enc.leftAdjustCharHead(bytes, p, pp, end) != pp) return runtime.getNil(); if (getCodeRange() != CR_7BIT) clearCodeRange();
if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { if (enc.leftAdjustCharHead(bytes, p, pp, end) != pp) return runtime.getNil(); if (getCodeRange() != CR_7BIT) clearCodeRange();
if (bytes[p + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { if (enc.leftAdjustCharHead(bytes, p, pp, end) != pp) return runtime.getNil(); if (getCodeRange() != CR_7BIT) clearCodeRange();
if (!line.getByteList().endsWith(NEWLINE)) { callMethod(context, "write", RubyString.newStringShared(getRuntime(), NEWLINE));
if (!line.getByteList().endsWith(NEWLINE)) { callMethod(context, "write", RubyString.newStringShared(getRuntime(), NEWLINE));