Skip to content

Instantly share code, notes, and snippets.

View lopex's full-sized avatar

Marcin Mielżyński lopex

View GitHub Profile
diff --git a/core/src/main/java/org/jruby/RubyRegexp.java b/core/src/main/java/org/jruby/RubyRegexp.java
index a86ab9da95..42af190df0 100755
--- a/core/src/main/java/org/jruby/RubyRegexp.java
+++ b/core/src/main/java/org/jruby/RubyRegexp.java
@@ -1136,14 +1136,12 @@ public class RubyRegexp extends RubyObject implements ReOptions, EncodingCapable
@JRubyMethod(name = "match?")
public IRubyObject match_p(ThreadContext context, IRubyObject str) {
- IRubyObject[] dummy = new IRubyObject[1];
- return context.runtime.newBoolean(matchPos(context, str, null, dummy, 0) >= 0);
$ gcc testonig.c -I /usr/local/include/ -L /usr/local/lib/ -llibonigmo && ./a.exe
PATTERN: '(?<!ss)'
STRING: 'aaaa'
PATTERN: /(?<!ss)/ (UTF-8)
<list:600000460>
<anchor:6000486f0> look_behind_not
<list:600048770>
<alt:6000487b0>
<string:6000487f0>s
<list:600000460>
<anchor:6000486f0> look_behind_not
<list:600048770>
<alt:6000487b0>
<string:6000487f0>s
<string:600048830>S
<string:6000488b0> 0xc5 0xbf
<string:600048a30>s
<anchor:600048730> look_behind_not
<string:600048930> 0xc3 0x9f
package org.joni.benchmark;
import org.jcodings.specific.ASCIIEncoding;
import org.joni.Matcher;
import org.joni.Option;
import org.joni.Regex;
import org.joni.Syntax;
import org.joni.WarnCallback;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
[28/93] TestRegexp#test_invalid_escape_error = 0.01 s
1) Failure:
TestRegexp#test_invalid_escape_error [/opt/jruby/test/mri/ruby/test_regexp.rb:1112]:
Expected /invalid hex escape/ to match "[ruby-core:31048]:1: Invalid escape character syntax".
[29/93] TestRegexp#test_invalid_fragment = 0.00 s
2) Failure:
TestRegexp#test_invalid_fragment [/opt/jruby/test/mri/ruby/test_regexp.rb:1081]:
[ruby-core:27374].
SyntaxError expected but nothing was raised.
@lopex
lopex / text
Created January 19, 2018 22:51
PATTERN: /\X/
<RAW TREE>
<Enclose:0x14ae5a5 (NULL)>
state:
type: OPTION
regNum: 0, option: , callAddr: -1, minLength: 0, maxLength: 0, charLength: 0, optCount: 0
target: <Enclose:0x7f31245a (Enclose:0x14ae5a5)>
state:
type: STOP_BACKTRACK
trans_name = "utf8_mac"
src = open("#{repo_path}/enc/trans/#{trans_name}.c").read
process_binary "#{repo_path}/enc/trans/#{trans_name}.o", section_name do |name, binary, address|
case name
when /_byte_array/
size = src[/(\w+?_byte_array)\[(\d+?)\]/m, 2].to_i
open("test/" + name.capitalize, "wb") do |f|
f << [size].pack("N")
f << binary[address, size]
end
# coding: utf-8
repo_path = ARGV.first || '/usr/src/ruby-2.4.2' # path to ruby repo
section_name = "rdata"
def process_binary obj_name, section_name
binary = open(obj_name, "rb"){|f|f.read}
offset = `objdump -h -j .#{section_name} #{obj_name}`[/\.#{section_name}.*?(\w+)\s+\S+$/, 1].to_i(16)
`nm --defined-only #{obj_name}`.split("\n").map{|s|s.split(/\s+/)}.each do |address, _, name|
yield name, binary, address.to_i(16) + offset
%extend antnet::Net{
void each(){
for(antnet::nvector::iterator i=self->nodes().begin();i!=self->nodes().end();i++){
rb_yield(Data_Wrap_Struct(cNode.klass,0,0,*i));
}
}
};
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0</version>
<repositories>
<repository>
<id>rubygems-release</id>