Skip to content

Commit

Permalink
[Truffle] Fixed the 'character_ascii_p' primitive.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 31, 2015
1 parent 2b4851a commit ad4dcf0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyRegexp.java
Expand Up @@ -1864,7 +1864,7 @@ private static void appendRegexpString19(Ruby runtime, ByteList to, byte[]bytes,
c = enc.mbcToCode(bytes, p, end);
}

if (!Encoding.isAscii(c)) {
if (!Encoding.'isAscii(c)) {
p += StringSupport.length(enc, bytes, p, end);
} else if (c != '/' && enc.isPrint(c)) {
p += cl;
Expand Down
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/chomp_tags.txt

This file was deleted.

Expand Up @@ -22,6 +22,7 @@
* Copyright (C) 2006 Ola Bini <ola@ologix.com>
* Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com>
*
*
* Some of the code in this class is transliterated from C++ code in Rubinius.
*
* Copyright (c) 2007-2014, Evan Phoenix and contributors
Expand Down Expand Up @@ -98,7 +99,16 @@ public CharacterAsciiPrimitiveNode(CharacterAsciiPrimitiveNode prev) {

@Specialization
public boolean isCharacterAscii(RubyString character) {
return StringSupport.isAsciiOnly(character);
final ByteList bytes = character.getByteList();
final int codepoint = StringSupport.preciseCodePoint(
bytes.getEncoding(),
bytes.getUnsafeBytes(),
bytes.getBegin(),
bytes.getBegin() + bytes.getRealSize());

final boolean found = codepoint != -1;

return found && Encoding.isAscii(codepoint);
}
}

Expand Down

0 comments on commit ad4dcf0

Please sign in to comment.