Ruby Issue Tracking System: Issues
https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2020-12-08T09:45:17Z
Ruby Issue Tracking System
Redmine
Ruby master - Misc #17376 (Assigned): Reduce number of GitHub Actions
https://redmine.ruby-lang.org/issues/17376
2020-12-08T09:45:17Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>At this time we have 127 checks for GitHub commits, but unfortunately GitHub UI only shows 100 checks.<br>
It sometimes makes we don't see a failed check.<br>
Could you reduce number of GitHub actions at least less than 100?</p>
Ruby master - Feature #16275 (Closed): Revert `.:` syntax
https://redmine.ruby-lang.org/issues/16275
2019-10-23T15:26:13Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p><code>obj.:method</code> is introduced at r66667 by <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Proposal: Shorthand operator for Object#method (Open)" href="https://redmine.ruby-lang.org/issues/12125">#12125</a> and <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Syntax sugar for method reference (Closed)" href="https://redmine.ruby-lang.org/issues/13581">#13581</a>.<br>
It encourages the functional programming style in Ruby.</p>
<p>But this shorthand syntax is just for methods of <code>self</code> without arguments.<br>
It causes another feature requests like <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Proposal: Shorthand operator for "#instance_method" (Open)" href="https://redmine.ruby-lang.org/issues/16273">#16273</a> (and lambda compositions like <a class="issue tracker-1 status-7 priority-4 priority-default closed" title="Bug: Refactor Proc#>> and #<< (Feedback)" href="https://redmine.ruby-lang.org/issues/15428">#15428</a>).</p>
<p>Such features will introduce a new view of Ruby but no one illustrates the whole picture yet.<br>
I worried about such patch work may cause a conflict with future expansion of functional programing style or a just a garbage feature.</p>
<p><code>.:</code> syntax is introduced in 2.7.0 preview1, not released in production yet.<br>
How about reverting at this time and re-introduce with a big picture.</p>
Ruby master - Feature #16131 (Closed): Remove $SAFE, taint and trust
https://redmine.ruby-lang.org/issues/16131
2019-08-29T07:14:34Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Ruby had Taint checking which is originally introduced in Perl.<br>
<a href="https://en.wikipedia.org/wiki/Taint_checking" class="external">https://en.wikipedia.org/wiki/Taint_checking</a></p>
<p>It was intended to provide a useful tool for handle objects which are come from outside.<br>
Input data is set as tainted by default and call untaint if you checked or filtered the value.<br>
Some people used this feature in the age of CGI.</p>
<p>But these days, no one use the mechanism and input libraries usually doesn't support it.<br>
For example rack, as following shows its input is not tainted and the mechanism is unusable.</p>
<pre><code>% cat foo.ru
run ->(env) do
['200', {'Content-Type' => 'text/plain'}, ["Is QUERY_STRING tainted?: #{env["QUERY_STRING"].tainted?}"]]
end
% rackup foo.ru
[51724] Puma starting in cluster mode...
[51724] * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
[51724] * Min threads: 3, max threads: 3
[51724] * Environment: development
[51724] * Process workers: 1
[51724] * Preloading application
[51724] * Listening on tcp://localhost:9292
[51724] Use Ctrl-C to stop
[51737] + Gemfile in context: /Users/naruse/work/td-cdp-api/Gemfile
[51724] - Worker 0 (pid: 51737) booted, phase: 0
</code></pre>
<pre><code>% curl http://localhost:9292/\?foo=1
Is QUERY_STRING tainted?: false
</code></pre>
<p>Therefore I think Taint checking mechanism is unusable on the current Ruby ecosystem.</p>
<p>On the other hand we experienced multiple vulnerability around $SAFE and taint mechanism.<br>
<a href="https://cse.google.com/cse?q=taint&cx=008288045305770251182%3Afvruzsaknew&ie=UTF-8" class="external">https://cse.google.com/cse?q=taint&cx=008288045305770251182%3Afvruzsaknew&ie=UTF-8</a><br>
The cost of maintaining it is expensive.</p>
<p>In conclusion, I think the taint mechanism is too expensive to maintain for the merit of it.<br>
I suggest to remove it.</p>
Ruby master - Feature #15958 (Closed): Time#inspect with frac
https://redmine.ruby-lang.org/issues/15958
2019-06-25T13:12:18Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>When Matz changed Time#to_s format in 2006, frac part of Time string is dropped because it is considered not useful.<br>
<a href="https://blade.ruby-lang.org/ruby-dev/29440">[ruby-dev:29440]</a></p>
<p>But recently we encounters some troubles the comparison of Time objects whose frac parts are different.<br>
<a href="https://twitter.com/__gfx__/status/1143056072422219776" class="external">https://twitter.com/__gfx__/status/1143056072422219776</a></p>
<p>For example a is original object and b is once stored in RDB (and dropped the frac part).<br>
Or there're multiple time objects which are generated in a single HTTP request.<br>
Of course they are different and assert_equal will be failed but inspect doesn't show the frac part.</p>
Ruby master - Bug #15398 (Closed): TestThread#test_signal_at_join fails on FreeBSD
https://redmine.ruby-lang.org/issues/15398
2018-12-11T09:10:02Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Since r64538 or r64539, TestThread#test_signal_at_join is failing on our FreeBSD CI.</p>
<pre><code>+ <n>) Error:
+TestThread#test_signal_at_join:
+Timeout::Error: execution of assert_separately expired timeout (120 sec)
+pid 80587 killed by SIGTERM (signal 15)
+| BAhvOhRTaWduYWxFeGNlcHRpb24KOgltZXNnIgxTSUdURVJNOgdidFsMSSIU
+| LTozNzppbiBgd3JpdGUnBjoGRUZJIhMtOjM3OmluIGBwdXRzJwY7CEZJIikt
+| OjM3OmluIGBibG9jayAoMiBsZXZlbHMpIGluIDxtYWluPicGOwhGSSIULToz
+| NDppbiBgdGltZXMnBjsIRkkiHi06MzQ6aW4gYGJsb2NrIGluIDxtYWluPicG
+| OwhGSSIULToxMDppbiBgcG9wZW4nBjsIRkkiFS06MTA6aW4gYDxtYWluPicG
+| OwhGOgpzaWdub2kUOgpjYXVzZTA6EWJ0X2xvY2F0aW9uc0AH
+| assertions=122
+|
</code></pre>
<p><a href="https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd11zfs/ruby-trunk/log/20180826T003001Z.diff.html.gz" class="external">https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd11zfs/ruby-trunk/log/20180826T003001Z.diff.html.gz</a></p>
<p>Note that this doesn't happen on my private FreeBSD box.</p>
Ruby master - Bug #14208 (Closed): raise error if value contains CR/LF in iniheader of initialize...
https://redmine.ruby-lang.org/issues/14208
2017-12-20T12:04:47Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>like r59693, initialize_http_header also should raise error.</p>
<p><a href="https://twitter.com/DouweM/status/943441930142220289" class="external">https://twitter.com/DouweM/status/943441930142220289</a></p>
Ruby master - Feature #13881 (Open): Use getcontext/setcontext on OS X
https://redmine.ruby-lang.org/issues/13881
2017-09-08T09:10:50Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>getcontext/setcontext is first appeared on OS X 10.5 but deprecated on 10.6.<br>
It seems because POSIX removed them from recent specs.</p>
<p>IEEE Std 1003.1, 2004 Edition says makecontext's use of function declarators with empty parentheses<br>
is an obsolescent feature.<br>
<a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html" class="external">http://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html</a></p>
<p>Then POSIX.1-2008 removed those functions.</p>
<p>But OS X 10.13 still has them maybe because some essential applications uses them for co-routines.<br>
Therefore we can use them for performance.</p>
<pre><code>diff --git a/configure.in b/configure.in
index 08e109317f..3e75eb3cf2 100644
--- a/configure.in
+++ b/configure.in
@@ -1142,8 +1142,6 @@ AS_CASE(["$target_os"],
ac_cv_header_syscall_h=no
])
AS_IF([test $macosx_10_5 = yes], [
- ac_cv_func_getcontext=no
- ac_cv_func_setcontext=no
], [
AC_DEFINE(BROKEN_SETREUID, 1)
AC_DEFINE(BROKEN_SETREGID, 1)
diff --git a/cont.c b/cont.c
index c86095775c..f94883ef02 100644
--- a/cont.c
+++ b/cont.c
@@ -65,7 +65,15 @@
#ifndef _WIN32
#include <unistd.h>
#include <sys/mman.h>
-#include <ucontext.h>
+# ifdef __APPLE__
+/* avoid deprecated maks on ucontext.h */
+int getcontext(ucontext_t *);
+void makecontext(ucontext_t *, void (*)(), int, ...);
+int setcontext(const ucontext_t *);
+int swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict);
+# else
+# include <ucontext.h>
+# endif
#endif
#define RB_PAGE_SIZE (pagesize)
#define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1))
</code></pre>
Ruby master - Feature #13873 (Closed): Optimize Dir.glob with FNM_EXTGLOB
https://redmine.ruby-lang.org/issues/13873
2017-09-05T17:51:27Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Rails often queries Dir.glob with complex pattern.</p>
<p>On accessing Rails site, it calls glob as follows on querying templates.<br>
Note that Dir[] insists File::FNM_EXTGLOB.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="k">def</span> <span class="nf">find_template_paths</span><span class="p">(</span><span class="n">query</span><span class="p">)</span>
<span class="no">Dir</span><span class="p">[</span><span class="n">query</span><span class="p">].</span><span class="nf">uniq</span><span class="p">.</span><span class="nf">reject</span> <span class="k">do</span> <span class="o">|</span><span class="n">filename</span><span class="o">|</span>
<span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="o">||</span>
<span class="c1"># deals with case-insensitive file systems.</span>
<span class="o">!</span><span class="no">File</span><span class="p">.</span><span class="nf">fnmatch</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="no">File</span><span class="o">::</span><span class="no">FNM_EXTGLOB</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p><a href="https://github.com/rails/rails/blob/6f1c18308ebffc97d51440cdeed7be71de58f26a/actionview/lib/action_view/template/resolver.rb#L247" class="external">https://github.com/rails/rails/blob/6f1c18308ebffc97d51440cdeed7be71de58f26a/actionview/lib/action_view/template/resolver.rb#L247</a></p>
<p>For example on accessing index page of Post Model (/posts), it calls following glob:<br>
Dir["/home/naruse/foo/app/views/posts/index{.en,}{.html,.text,.js,.css,.ics,.csv,.vcf,.png,.jpeg,.gif,.bmp,.tiff,.svg,.mpeg,.xml,.rss,.atom,.yaml,.multipart_form,.url_encoded_form,.json,.pdf,.zip,.gzip,}{}{.raw,.erb,.html,.builder,.ruby,.coffee,.jbuilder,}"]'</p>
<p>It calls many stat as follows:</p>
<pre><code>% sudo strace ./miniruby58882 -e'Dir["/home/naruse/foo/app/views/posts/index{.en,}{.html,.text,.js,.css,.ics,.csv,.vcf,.png,.jpeg,.gif,.bmp,.tiff,.svg,.mpeg,.xml,.rss,.atom,.yaml,.multipart_form,.url_encoded_form,.json,.pdf,.zip,.gzip,}{}{.raw,.erb,.html,.builder,.ruby,.coffee,.jbuilder,}"]'|&grep newfstatat|wc -l
400
</code></pre>
<p>Because current glob implementation handles braces in early stage,<br>
then calls stat for each combination of brace patterns instead of using readdir results.</p>
<p>Below is a patch to use readdir instead of hundreds of syscalls.<br>
Note that this patch changes the order of the result as follows:</p>
<pre><code> 1) Failure:
TestDir#test_glob [/home/naruse/ruby/test/ruby/test_dir.rb:157]:
<["/tmp/test-all/__test_dir__20170906-8620-ka8yqu/}}{}",
"/tmp/test-all/__test_dir__20170906-8620-ka8yqu/}}a"]> expected but was
<["/tmp/test-all/__test_dir__20170906-8620-ka8yqu/}}a",
"/tmp/test-all/__test_dir__20170906-8620-ka8yqu/}}{}"]>.
</code></pre>
<pre><code>diff --git a/dir.c b/dir.c
index b7afaec4e0..7ca84fa8c5 100644
--- a/dir.c
+++ b/dir.c
@@ -290,6 +290,8 @@ bracket(
#define UNESCAPE(p) (escape && *(p) == '\\' ? (p) + 1 : (p))
#define ISEND(p) (!*(p) || (pathname && *(p) == '/'))
#define RETURN(val) return *pcur = p, *scur = s, (val);
+#define FNMATCH_ALLOC_N(type, n) ((type *)malloc(sizeof(type) * (n)))
+#define FNMATCH_FREE(ptr) free(ptr)
static int
fnmatch_helper(
@@ -348,6 +350,56 @@ fnmatch_helper(
}
goto failed;
}
+
+ case '{': {
+ size_t len = pend - p;
+ char *buf = FNMATCH_ALLOC_N(char, len);
+ const char *rbrace = NULL;
+ while (p < pend) {
+ const char *t = ++p;
+ int nest = 0;
+ while (p < pend && !(*p == ',' && nest == 0)) {
+ if (*p == '{') nest++;
+ if (*p == '}') {
+ if (nest == 0) {
+ if (!rbrace) rbrace = p;
+ goto rest;
+ }
+ nest--;
+ }
+ if (*p == '\\' && escape) {
+ if (++p >= pend) break;
+ }
+ Inc(p, pend, enc);
+ }
+ if (!rbrace) {
+ rbrace = p;
+ while (rbrace < pend && !(*rbrace == '}' && nest == 0)) {
+ if (*rbrace == '{') nest++;
+ if (*rbrace == '}') nest--;
+ if (*rbrace == '\\' && escape) {
+ if (++p >= pend) break;
+ }
+ Inc(rbrace, pend, enc);
+ }
+ }
+rest:
+ memcpy(buf, t, p-t);
+ buf[p-t]=0;
+ strlcpy(buf+(p-t), rbrace+1, len-(p-t));
+ {
+ const char *pp = buf, *ss = s;
+ r = fnmatch_helper((const char **)&pp, &ss, flags|FNM_DOTMATCH, enc);
+ }
+ if (r == 0) {
+ p = buf;
+ FNMATCH_FREE(buf);
+ RETURN(0);
+ }
+ if (p >= rbrace) break;
+ }
+ FNMATCH_FREE(buf);
+ }
}
/* ordinary */
@@ -1426,6 +1478,12 @@ has_magic(const char *p, const char *pend, int flags, rb_encoding *enc)
case '[':
return MAGICAL;
+ case '{':
+ if (flags & FNM_EXTGLOB) {
+ return MAGICAL;
+ }
+ break;
+
case '\\':
if (escape && p++ >= pend)
continue;
@@ -2272,6 +2330,13 @@ push_pattern(const char *path, VALUE ary, void *enc)
rb_ary_push(ary, name);
}
+struct push_glob_args {
+ struct glob_args glob;
+ int flags;
+ int fd;
+};
+static int push_caller(const char *path, VALUE val, void *enc);
+
static int
ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
rb_encoding *enc, VALUE var)
@@ -2280,7 +2345,7 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
const char *p = str;
const char *pend = p + strlen(p);
const char *s = p;
- const char *lbrace = 0, *rbrace = 0;
+ const char *lbrace = NULL, *rbrace = NULL;
int nest = 0, status = 0;
while (*p) {
@@ -2299,9 +2364,18 @@ ruby_brace_expand(const char *str, int flags, ruby_glob_func *func, VALUE arg,
if (lbrace && rbrace) {
size_t len = strlen(s) + 1;
- char *buf = GLOB_ALLOC_N(char, len);
+ char *buf;
long shift;
+ if (func == push_caller && !strchr(lbrace, '/')) {
+ /* Now it reaches file basename entry. */
+ /* Handle braces in glob_helper */
+ struct push_glob_args *a = (struct push_glob_args *)arg;
+ a->flags |= FNM_EXTGLOB;
+ return glob_call_func(func, s, arg, enc);
+ }
+
+ buf = GLOB_ALLOC_N(char, len);
if (!buf) return -1;
memcpy(buf, s, lbrace-s);
shift = (lbrace-s);
@@ -2365,12 +2439,6 @@ ruby_brace_glob(const char *str, int flags, ruby_glob_func *func, VALUE arg)
return ruby_brace_glob_with_enc(str, flags, func, arg, rb_ascii8bit_encoding());
}
-struct push_glob_args {
- struct glob_args glob;
- int flags;
- int fd;
-};
-
static int
push_caller(const char *path, VALUE val, void *enc)
{
</code></pre>
Ruby master - Feature #13712 (Closed): String#start_with? with regexp
https://redmine.ruby-lang.org/issues/13712
2017-07-04T09:18:51Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>String#start_with? should receive regexp.</p>
<p>When I write a parser, I want to check a string is start with a pattern or not.<br>
It's just the same thing with <a href="https://ruby-doc.org/stdlib-2.4.0/libdoc/strscan/rdoc/StringScanner.html#method-i-match-3F" class="external">StringScanner#match</a></p>
<p>If I want to do the same thing with normal string method, it needs to write like <code>/\A#{re}/.match(…)</code>.<br>
But if re is argument, it needs to create a new temporary regexp every time.</p>
<p>Though we have a workaround as follows but it's bit tricky.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="s2">"foo "</span><span class="p">.</span><span class="nf">rindex</span><span class="p">(</span><span class="sr">/fo+./</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</code></pre>
<p>A patch is following:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/re.c b/re.c
index d0aa2a792e..f672ba75ec 100644
</span><span class="gd">--- a/re.c
</span><span class="gi">+++ b/re.c
</span><span class="p">@@ -1588,6 +1588,84 @@</span> rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
return rb_reg_search0(re, str, pos, reverse, 1);
}
<span class="gi">+bool
+rb_reg_start_with_p(VALUE re, VALUE str)
+{
+ long pos = 0;
+ long result;
+ VALUE match;
+ struct re_registers regi, *regs = &regi;
+ regex_t *reg;
+ int tmpreg;
+ onig_errmsg_buffer err = "";
+
+ reg = rb_reg_prepare_re0(re, str, err);
+ tmpreg = reg != RREGEXP_PTR(re);
+ if (!tmpreg) RREGEXP(re)->usecnt++;
+
+ match = rb_backref_get();
+ if (!NIL_P(match)) {
+ if (FL_TEST(match, MATCH_BUSY)) {
+ match = Qnil;
+ }
+ else {
+ regs = RMATCH_REGS(match);
+ }
+ }
+ if (NIL_P(match)) {
+ MEMZERO(regs, struct re_registers, 1);
+ }
+ result = onig_match(reg,
+ (UChar*)(RSTRING_PTR(str)),
+ ((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
+ (UChar*)(RSTRING_PTR(str)),
+ regs, ONIG_OPTION_NONE);
+ if (!tmpreg) RREGEXP(re)->usecnt--;
+ if (tmpreg) {
+ if (RREGEXP(re)->usecnt) {
+ onig_free(reg);
+ }
+ else {
+ onig_free(RREGEXP_PTR(re));
+ RREGEXP_PTR(re) = reg;
+ }
+ }
+ if (result < 0) {
+ if (regs == &regi)
+ onig_region_free(regs, 0);
+ if (result == ONIG_MISMATCH) {
+ rb_backref_set(Qnil);
+ return false;
+ }
+ else {
+ onig_error_code_to_str((UChar*)err, (int)result);
+ rb_reg_raise(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), err, re);
+ }
+ }
+
+ if (NIL_P(match)) {
+ int err;
+ match = match_alloc(rb_cMatch);
+ err = rb_reg_region_copy(RMATCH_REGS(match), regs);
+ onig_region_free(regs, 0);
+ if (err) rb_memerror();
+ }
+ else {
+ FL_UNSET(match, FL_TAINT);
+ }
+
+ RMATCH(match)->str = rb_str_new4(str);
+ OBJ_INFECT(match, str);
+
+ RMATCH(match)->regexp = re;
+ RMATCH(match)->rmatch->char_offset_updated = 0;
+ rb_backref_set(match);
+
+ OBJ_INFECT(match, re);
+
+ return true;
+}
+
</span> VALUE
rb_reg_nth_defined(int nth, VALUE match)
{
<span class="gh">diff --git a/string.c b/string.c
index 072f1329ee..6542a4acb1 100644
</span><span class="gd">--- a/string.c
</span><span class="gi">+++ b/string.c
</span><span class="p">@@ -9126,6 +9126,7 @@</span> rb_str_rpartition(VALUE str, VALUE sep)
RSTRING_LEN(str)-pos-RSTRING_LEN(sep)));
}
<span class="gi">+extern bool rb_reg_start_with_p(VALUE re, VALUE str);
</span> /*
* call-seq:
* str.start_with?([prefixes]+) -> true or false
<span class="p">@@ -9146,11 +9147,20 @@</span> rb_str_start_with(int argc, VALUE *argv, VALUE str)
for (i=0; i<argc; i++) {
VALUE tmp = argv[i];
<span class="gd">- StringValue(tmp);
- rb_enc_check(str, tmp);
- if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
- return Qtrue;
</span><span class="gi">+ switch (BUILTIN_TYPE(tmp)) {
+ case T_REGEXP:
+ {
+ bool r = rb_reg_start_with_p(tmp, str);
+ if (r) return Qtrue;
+ }
+ break;
+ default:
+ StringValue(tmp);
+ rb_enc_check(str, tmp);
+ if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
+ if (memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
+ return Qtrue;
+ }
</span> }
return Qfalse;
}
</code></pre>
Ruby master - Bug #13304 (Closed): public function rb_thread_fd_close is removed at r57422
https://redmine.ruby-lang.org/issues/13304
2017-03-12T19:06:16Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>It hits abi-check:<br>
<a href="http://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-2.4/log/20170312T170653Z.log.html.gz#abi-check" class="external">http://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-2.4/log/20170312T170653Z.log.html.gz#abi-check</a></p>
Ruby master - Feature #13303 (Feedback): String#any? as !String#empty?
https://redmine.ruby-lang.org/issues/13303
2017-03-12T18:29:26Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Once I proposed "some container#nonempty?" on <a class="issue tracker-2 status-7 priority-4 priority-default closed" title="Feature: some container#nonempty? (Feedback)" href="https://redmine.ruby-lang.org/issues/12075">#12075</a>, and understand there's Array#any?.</p>
<p>Today I found String doesn't have such method.</p>
Ruby master - Bug #13150 (Closed): TestMarshal failures on FreeBSD with gcc7 because of GC
https://redmine.ruby-lang.org/issues/13150
2017-01-23T16:58:04Z
naruse (Yui NARUSE)
naruse@airemix.jp
<pre><code> 1) Failure:
TestMarshal#test_context_switch [/home/naruse/ruby/test/ruby/test_marshal.rb:368]:
[StopIteration] exception expected, not.
Class: <RuntimeError>
Message: <"Marshal.dump reentered at marshal_dump">
---Backtrace---
/home/naruse/ruby/test/ruby/test_marshal.rb:345:in `dump'
/home/naruse/ruby/test/ruby/test_marshal.rb:345:in `dump_each'
../../ruby/test/runner.rb: TestMarshal#test_context_switch:1:in `each'
---------------
2) Failure:
TestMarshal#test_gc [/home/naruse/ruby/test/ruby/test_marshal.rb:187]:
Exception raised:
<#<RuntimeError: Marshal.dump reentered at _dump>>.
Finished tests in 0.153251s, 698.2016 tests/s, 6238.1380 assertions/s.
107 tests, 956 assertions, 2 failures, 0 errors, 0 skips
ruby -v: ruby 2.5.0dev (2017-01-23 trunk 57407) [x86_64-freebsd10.3]
</code></pre>
Ruby master - Misc #13027 (Closed): Release Engineering 2.4
https://redmine.ruby-lang.org/issues/13027
2016-12-12T14:43:37Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>META ticket for Release Engineering 2.4.</p>
<p>see also <a class="version" href="https://redmine.ruby-lang.org/versions/33">2.4</a></p>
<ul>
<li>current status: feature freeze</li>
<li>Q: Can I add a new feature?
<ul>
<li>A: No. Its status is already "feature freeze".</li>
</ul>
</li>
<li>Q: Can I fix a bug?
<ul>
<li>A: Yes</li>
</ul>
</li>
<li>Q: I want to complain about 2.4.0-rc1
<ul>
<li>A: create a ticket. It may change 2.4.0 RTM.</li>
</ul>
</li>
<li>Q: When ruby_2_4 branch is created?
<ul>
<li>A: scheduled on 2016-12-23</li>
</ul>
</li>
<li>Q: When Ruby 2.4.0 is released?
<ul>
<li>A: scheduled at 2016-12-25T00:00:00/03:00:00</li>
</ul>
</li>
</ul>
Ruby master - Feature #13020 (Closed): Zlib.gzip and Zlib.gunzip
https://redmine.ruby-lang.org/issues/13020
2016-12-09T22:37:22Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>I added Zlib.deflate/inflate [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add Zlib.deflate / Zlib.inflate (Closed)" href="https://redmine.ruby-lang.org/issues/4180">#4180</a>] before, but writing/reading gzip is still too complex.<br>
It should have shorthand method.</p>
Ruby master - Bug #12568 (Closed): wrong ArgumentError if an array is given for instance_exec wit...
https://redmine.ruby-lang.org/issues/12568
2016-07-07T18:50:32Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>From Ruby 2.2 to trunk, it wrongly raise ArgumentError as follows:</p>
<p>Sample code:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">instance_exec</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]){</span><span class="o">|</span><span class="n">a</span><span class="o">|</span> <span class="nb">p</span> <span class="n">a</span><span class="p">}</span>
<span class="n">instance_exec</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">]){</span><span class="o">|</span><span class="n">a</span><span class="o">=</span><span class="p">[]</span><span class="o">|</span> <span class="nb">p</span> <span class="n">a</span><span class="p">}</span>
<span class="n">instance_exec</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">],</span> <span class="o">&-></span><span class="p">(</span><span class="n">a</span><span class="p">){</span> <span class="nb">p</span> <span class="n">a</span> <span class="p">})</span>
<span class="o">-></span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="p">[]){</span> <span class="nb">p</span> <span class="n">a</span> <span class="p">}.</span><span class="nf">to_proc</span><span class="p">.</span><span class="nf">call</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="n">instance_exec</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">],</span> <span class="o">&-></span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="p">[]){</span> <span class="nb">p</span> <span class="n">a</span> <span class="p">})</span>
</code></pre>
<p>Expected result:</p>
<pre><code>[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
</code></pre>
<p>Actual result:</p>
<pre><code>[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
test.rb:7:in `block in <main>': wrong number of arguments (given 3, expected 0..1) (ArgumentError)
from test.rb:7:in `instance_exec'
from test.rb:7:in `<main>'
</code></pre>
<p>This issue affect <a href="https://github.com/rails/rails/pull/25699" class="external">https://github.com/rails/rails/pull/25699</a></p>
Ruby master - Misc #12474 (Third Party's Issue): Wishlist for Windows Unix compatibility features
https://redmine.ruby-lang.org/issues/12474
2016-06-09T08:37:29Z
naruse (Yui NARUSE)
naruse@airemix.jp
<a name="fork2"></a>
<h2 >fork(2)<a href="#fork2" class="wiki-anchor">¶</a></h2>
<p>Windows already has related features like <code>CreateProcess</code>, but for servers and workers fork is required for source code compatibility of existing scripts,<br>
which are written for Unix.</p>
<a name="nonblocking-IO"></a>
<h2 >nonblocking IO<a href="#nonblocking-IO" class="wiki-anchor">¶</a></h2>
<ul>
<li>To check socket's availability by <code>IO#read_nonblock</code> <a href="https://github.com/ruby/ruby/pull/1089" class="external">https://github.com/ruby/ruby/pull/1089</a>
</li>
<li><code>O_NONBLOCK</code></li>
</ul>
<a name="Signal"></a>
<h2 >Signal<a href="#Signal" class="wiki-anchor">¶</a></h2>
<p>Windows doesn't support true Signal.<br>
<a href="https://msdn.microsoft.com/en-us//library/xdkz3x12.aspx" class="external">https://msdn.microsoft.com/en-us//library/xdkz3x12.aspx</a></p>
<a name="tz"></a>
<h2 >tz<a href="#tz" class="wiki-anchor">¶</a></h2>
<p>Get IANA timezone name of current timezone from OS.</p>
<a name="Remove-a-file-which-is-opened-by-another-process"></a>
<h2 >Remove a file which is opened by another process<a href="#Remove-a-file-which-is-opened-by-another-process" class="wiki-anchor">¶</a></h2>
<p>If the process opens the file with <code>CreateFile</code> with <code>FILE_SHARE_DELETE</code> flag, another process can remove the file.<br>
But in that case processes can't remove its parent folder.<br>
<a href="https://bugs.ruby-lang.org/issues/11218" class="external">https://bugs.ruby-lang.org/issues/11218</a></p>
<a name="symlink"></a>
<h2 >symlink<a href="#symlink" class="wiki-anchor">¶</a></h2>
<p>Windows has mklink and SeCreateSymbolicLinkPrivilege, but it has some limitations.<br>
<a href="http://k-takata.o.oo7.jp/diary/2013-04.html#03" class="external">http://k-takata.o.oo7.jp/diary/2013-04.html#03</a><br>
<a href="https://twitter.com/n0kada/status/570232516545638400" class="external">https://twitter.com/n0kada/status/570232516545638400</a></p>
<a name="Bug-18882-On-64-mingw-ucrt-Fileread-sometimes-doesnt-read-entire-file-alanwu"></a>
<h2 >[Bug <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: File.read cuts off a text file with special characters when reading it on MS Windows (Rejected)" href="https://redmine.ruby-lang.org/issues/18882">#18882</a>] On 64-mingw-ucrt, File.read() sometimes doesn't read entire file (alanwu)<a href="#Bug-18882-On-64-mingw-ucrt-Fileread-sometimes-doesnt-read-entire-file-alanwu" class="wiki-anchor">¶</a></h2>
<p><a href="https://github.com/ruby/dev-meeting-log/blob/master/DevMeeting-2022-07-21.md#bug-18882-on-64-mingw-ucrt-fileread-sometimes-doesnt-read-entire-file-alanwu" class="external">https://github.com/ruby/dev-meeting-log/blob/master/DevMeeting-2022-07-21.md#bug-18882-on-64-mingw-ucrt-fileread-sometimes-doesnt-read-entire-file-alanwu</a></p>
<a name="fd"></a>
<h2 >fd<a href="#fd" class="wiki-anchor">¶</a></h2>
<a name="Generic-handling-of-file-pipe-socket-by-fd"></a>
<h3 >Generic handling of file, pipe, socket by fd<a href="#Generic-handling-of-file-pipe-socket-by-fd" class="wiki-anchor">¶</a></h3>
<a name="fd-passing-to-child-process-other-than-012"></a>
<h3 >fd passing to child process other than 0,1,2<a href="#fd-passing-to-child-process-other-than-012" class="wiki-anchor">¶</a></h3>
<a name="Get-access-mode-from-fdHANDLE"></a>
<h3 >Get access mode from fd/HANDLE<a href="#Get-access-mode-from-fdHANDLE" class="wiki-anchor">¶</a></h3>
<a name="System-side-append-mode"></a>
<h3 >System side append mode<a href="#System-side-append-mode" class="wiki-anchor">¶</a></h3>
<p><a href="https://bugs.ruby-lang.org/issues/18605" class="external">https://bugs.ruby-lang.org/issues/18605</a></p>
<a name="a-high-performance-selector-API"></a>
<h3 >a high performance selector API<a href="#a-high-performance-selector-API" class="wiki-anchor">¶</a></h3>
<p><a href="https://tonyarcieri.com/a-gentle-introduction-to-nio4r" class="external">https://tonyarcieri.com/a-gentle-introduction-to-nio4r</a></p>
<a name="socket"></a>
<h2 >socket<a href="#socket" class="wiki-anchor">¶</a></h2>
<p><code>CloseHandle</code> should work with socket.</p>
<a name="writev2"></a>
<h2 >writev(2)<a href="#writev2" class="wiki-anchor">¶</a></h2>
<p><a href="https://twitter.com/okuoku/status/670212493134852097" class="external">https://twitter.com/okuoku/status/670212493134852097</a><br>
<a href="https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365749%28v=vs.85%29.aspx" class="external">https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa365749%28v=vs.85%29.aspx</a></p>
<a name="ANSI-color-code"></a>
<h2 >ANSI color code<a href="#ANSI-color-code" class="wiki-anchor">¶</a></h2>
<p><a href="http://srad.jp/story/16/02/09/0639223/" class="external">http://srad.jp/story/16/02/09/0639223/</a></p>
<a name="UNIXSocket"></a>
<h2 ><del>UNIXSocket</del><a href="#UNIXSocket" class="wiki-anchor">¶</a></h2>
<p><del>We can emuate UNIXSocket with named pipe?</del><br>
Implemented [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Support `UNIXSocket` on Windows (Closed)" href="https://redmine.ruby-lang.org/issues/19135">#19135</a>]</p>
Ruby master - Feature #12336 (Closed): Use -std=gnu99 instead of -std=c99 for GCC
https://redmine.ruby-lang.org/issues/12336
2016-05-01T09:58:53Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>r36038以降、Ruby本体をビルドする際にはGCCに-stdオプションを与えており、<br>
若干の変更を経て現在では-std=iso9899:1999 (-std=c99相当)を指定しています。</p>
<p>しかしこの指定の場合、GCCのC標準関数の代わりにビルトイン関数を用いる最適化が行われないため、<br>
現在ちょっと残念な状態が続いています。<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html" class="external">https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html</a></p>
<p>また、これの導入のきっかけはおそらくr36029の</p>
<ul>
<li>compile.c (iseq_set_sequence): nonstatic initializer of an aggregate type is a C99ism.</li>
<li>compile.c (enum compile_array_type_t): comma at the end of enum list is a C99ism.</li>
</ul>
<p>だと思うのですが、すでにc99相当なのであんまり効いてない……かな?<br>
もっともやりがちなMixed Declarationsは別に-Wdeclaration-after-statementがあるのでそれはそれで問題ありません。<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html" class="external">https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html</a><br>
<a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html" class="external">https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html</a></p>
<p>現在だと、-std=gnu99でおおむね同レベルの警告を維持できると同時に、<br>
GCCのビルトイン関数を使えるようになってわずかな手間でちょっと早くなって嬉しいと思うのですがいかがでしょう。</p>
Ruby master - Bug #12320 (Closed): Skip SHA from test_digest_constants for LibreSSL 2.3
https://redmine.ruby-lang.org/issues/12320
2016-04-26T06:30:04Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Backport r53718 to fix the first one of ruby/openssl#40<br>
<a href="https://github.com/ruby/openssl/issues/40#issuecomment-159839338" class="external">https://github.com/ruby/openssl/issues/40#issuecomment-159839338</a></p>
Ruby master - Misc #12283 (Closed): Obsolete ChangeLog and commit message in Git-style
https://redmine.ruby-lang.org/issues/12283
2016-04-14T18:57:41Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>How about Git-style commit message instead of ChangeLog?</p>
<a name="Proposal"></a>
<h2 >Proposal<a href="#Proposal" class="wiki-anchor">¶</a></h2>
<p>After we reach the consensus</p>
<ol>
<li>Write a commit message in Git-style.</li>
</ol>
<ul>
<li>Line 1: summary of commit (around 80 characters or less, <50 is better)</li>
<li>Line 2: empty line</li>
<li>Line 3-: More detailed explanation of commit</li>
</ul>
<p>See also: <a href="https://git-scm.com/book/ch5-2.html#Commit-Guidelines" class="external">https://git-scm.com/book/ch5-2.html#Commit-Guidelines</a></p>
<ol start="2">
<li>Stop manually edit ChangeLog and auto-generate on <code>make dist</code>.</li>
</ol>
<a name="Rationale"></a>
<h2 >Rationale<a href="#Rationale" class="wiki-anchor">¶</a></h2>
<p>A good commit message should include the objective of the commit.<br>
Committers should write "what purpose the change is for".<br>
In this sense, ChangeLog is not a good format. It lists per-file changes, so committers tend to write just "how the files were changed".</p>
<p>Also, ChangeLog causes commit conflicts frequently.<br>
Though it is not related with the actual commit.<br>
People who uses svn/git should see the log with it; ChangeLog is only for tarball users.</p>
<a name="Status"></a>
<h2 >Status<a href="#Status" class="wiki-anchor">¶</a></h2>
<p>mame made this proposal at the developers' meeting (13 Apr.), and there was no objection.</p>
<p>Matz agreed with this proposal, provided that a ChangeLog-like plain-text file is generated from the commit log.<br>
The release manager will create the file when Ruby is released.</p>
<a name="Note"></a>
<h3 >Note<a href="#Note" class="wiki-anchor">¶</a></h3>
<p>This ticket does NOT propose a migration from SVN to Git. Never discuss that in this ticket.</p>
Ruby master - Feature #12225 (Rejected): Remove inline assemblers and always enables USE_MACHINE_...
https://redmine.ruby-lang.org/issues/12225
2016-03-28T08:20:39Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Current vm_exec.c stores pc an explicitly declared register to get PC.<br>
Since recent CPUs and compilers are very smart, we expect they optimizes their use of registers.</p>
<p>With following patch the benchmark becomes following:</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/vm_exec.c b/vm_exec.c
index 5e4ff94..6f7c1ad 100644
</span><span class="gd">--- a/vm_exec.c
</span><span class="gi">+++ b/vm_exec.c
</span><span class="p">@@ -15,23 +15,6 @@</span>
static void vm_analysis_insn(int insn);
#endif
<span class="gd">-#if VMDEBUG > 0
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-
-#elif defined(__GNUC__) && defined(__x86_64__)
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
-
-#elif defined(__GNUC__) && defined(__i386__)
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg)
-
-#elif defined(__GNUC__) && defined(__powerpc64__)
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
-
-#else
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-#endif
-/* #define DECL_SC_REG(r, reg) VALUE reg_##r */
-
</span> #if VM_DEBUG_STACKOVERFLOW
NORETURN(static void vm_stack_overflow_for_insn(void));
static void
<span class="p">@@ -49,41 +32,12 @@</span> vm_exec_core(rb_thread_t *th, VALUE initial)
{
#if OPT_STACK_CACHING
<span class="gd">-#if 0
-#elif __GNUC__ && __x86_64__ && !defined(__native_client__)
- DECL_SC_REG(VALUE, a, "12");
- DECL_SC_REG(VALUE, b, "13");
-#else
</span> register VALUE reg_a;
register VALUE reg_b;
#endif
<span class="gd">-#endif
</span>
<span class="gd">-#if defined(__GNUC__) && defined(__i386__)
- DECL_SC_REG(const VALUE *, pc, "di");
- DECL_SC_REG(rb_control_frame_t *, cfp, "si");
-#define USE_MACHINE_REGS 1
-
-#elif defined(__GNUC__) && defined(__x86_64__)
- DECL_SC_REG(const VALUE *, pc, "14");
-# if defined(__native_client__)
- DECL_SC_REG(rb_control_frame_t *, cfp, "13");
-# else
- DECL_SC_REG(rb_control_frame_t *, cfp, "15");
-# endif
-#define USE_MACHINE_REGS 1
-
-#elif defined(__GNUC__) && defined(__powerpc64__)
- DECL_SC_REG(const VALUE *, pc, "14");
- DECL_SC_REG(rb_control_frame_t *, cfp, "15");
-#define USE_MACHINE_REGS 1
-
-#else
</span> register rb_control_frame_t *reg_cfp;
const VALUE *reg_pc;
<span class="gd">-#endif
-
-#if USE_MACHINE_REGS
</span>
#undef RESTORE_REGS
#define RESTORE_REGS() \
<span class="p">@@ -98,7 +52,6 @@</span> vm_exec_core(rb_thread_t *th, VALUE initial)
#define GET_PC() (reg_pc)
#undef SET_PC
#define SET_PC(x) (reg_cfp->pc = REG_PC = (x))
<span class="gd">-#endif
</span>
#if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
#include "vmtc.inc"
</code></pre>
<pre><code>Speedup ratio: compare with the result of `ruby 2.4.0dev (2016-03-27 trunk 54303) [x86_64-linux]' (greater is better)
name built-ruby
loop_whileloop 1.016
vm1_attr_ivar* 0.991
vm1_attr_ivar_set* 0.976
vm1_block* 1.013
vm1_const* 0.924
vm1_ensure* 0.978
vm1_float_simple* 1.006
vm1_gc_short_lived* 1.011
vm1_gc_short_with_complex_long* 1.036
vm1_gc_short_with_long* 1.064
vm1_gc_short_with_symbol* 0.997
vm1_gc_wb_ary* 1.005
vm1_gc_wb_ary_promoted* 1.000
vm1_gc_wb_obj* 0.977
vm1_gc_wb_obj_promoted* 1.029
vm1_ivar* 1.054
vm1_ivar_set* 0.961
vm1_length* 1.019
vm1_lvar_init* 0.962
vm1_lvar_set* 0.991
vm1_neq* 0.976
vm1_not* 0.903
vm1_rescue* 0.983
vm1_simplereturn* 1.005
vm1_swap* 1.000
vm1_yield* 0.979
</code></pre>
<pre><code>additional example micro benchmark
BEFORE gcc 4.8:
Performance counter stats for './miniruby -e@v=42; n=100_000_000;while n>0; x=x|x; x=x|x;n-=1;end':
7218.124555 task-clock (msec) # 0.998 CPUs utilized
123 context-switches # 0.017 K/sec
2 cpu-migrations # 0.000 K/sec
906 page-faults # 0.126 K/sec
21374094581 cycles # 2.961 GHz
4469895839 stalled-cycles-frontend # 20.91% frontend cycles idle
<not supported> stalled-cycles-backend
55226298374 instructions # 2.58 insns per cycle
# 0.08 stalled cycles per insn
7805291103 branches # 1081.346 M/sec
200172514 branch-misses # 2.56% of all branches
7.230608341 seconds time elapsed
BEFORE gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04):
Performance counter stats for './miniruby -e@v=42; n=100_000_000;while n>0; x=x|x; x=x|x;n-=1;end':
8054.736236 task-clock (msec) # 0.998 CPUs utilized
128 context-switches # 0.016 K/sec
2 cpu-migrations # 0.000 K/sec
895 page-faults # 0.111 K/sec
23776261112 cycles # 2.952 GHz
7078686240 stalled-cycles-frontend # 29.77% frontend cycles idle
<not supported> stalled-cycles-backend
53126508523 instructions # 2.23 insns per cycle
# 0.13 stalled cycles per insn
7505454893 branches # 931.806 M/sec
201181233 branch-misses # 2.68% of all branches
8.074872624 seconds time elapsed
AFTER gcc version 4.8.5 (Ubuntu 4.8.5-2ubuntu1~14.04.1):
Performance counter stats for './miniruby -e@v=42; n=100_000_000;while n>0; x=x|x; x=x|x;n-=1;end':
7267.867318 task-clock (msec) # 0.997 CPUs utilized
169 context-switches # 0.023 K/sec
1 cpu-migrations # 0.000 K/sec
899 page-faults # 0.124 K/sec
21563673390 cycles # 2.967 GHz
4952119471 stalled-cycles-frontend # 22.97% frontend cycles idle
<not supported> stalled-cycles-backend
53226715304 instructions # 2.47 insns per cycle
# 0.09 stalled cycles per insn
7805365852 branches # 1073.955 M/sec
200218594 branch-misses # 2.57% of all branches
7.286793973 seconds time elapsed
AFTER gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04):
Performance counter stats for './miniruby -e@v=42; n=100_000_000;while n>0; x=x|x; x=x|x;n-=1;end':
7146.899779 task-clock (msec) # 0.998 CPUs utilized
166 context-switches # 0.023 K/sec
2 cpu-migrations # 0.000 K/sec
899 page-faults # 0.126 K/sec
21188099959 cycles # 2.965 GHz
4839187155 stalled-cycles-frontend # 22.84% frontend cycles idle
<not supported> stalled-cycles-backend
52525802838 instructions # 2.48 insns per cycle
# 0.09 stalled cycles per insn
7505329721 branches # 1050.152 M/sec
200175714 branch-misses # 2.67% of all branches
7.157645157 seconds time elapsed
</code></pre>
Ruby master - Feature #12075 (Feedback): some container#nonempty?
https://redmine.ruby-lang.org/issues/12075
2016-02-16T08:08:28Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>I sometimes write following code.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">ary</span> <span class="o">=</span> <span class="n">some_metho_returns_nil_or_empty_container</span><span class="p">()</span> <span class="c1"># nil or "" or [] or {}</span>
<span class="k">if</span> <span class="n">ary</span> <span class="o">&&</span> <span class="o">!</span><span class="n">ary</span><span class="p">.</span><span class="nf">empty?</span>
<span class="c1"># some code</span>
<span class="k">end</span>
</code></pre>
<p>But the condition <code>ary && !ary.empty?</code> is too long and complex.<br>
Though Ruby 2.3 introduces <code>&.</code>, but this can’t be written as <code>ary&.empty?</code>.</p>
<p>One idea is add <code>nonempty?</code> write as <code>ary&.nonempty?</code>.</p>
<p>akr: <code>nonempty?</code> is not good name because human is not good at handling</p>
<p>This discussion matches following core classes:</p>
<ul>
<li>String</li>
<li>Array</li>
<li>Hash</li>
</ul>
Ruby master - Feature #12005 (Closed): Unify Fixnum and Bignum into Integer
https://redmine.ruby-lang.org/issues/12005
2016-01-19T02:38:01Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>CRuby has two <code>Integer</code> classes, <code>Fixnum</code> and <code>Bignum</code>.<br>
But it is implementation detail.<br>
They should be seen as a single class <code>Integer</code> like <code>Flonum</code>.</p>
<a name="Compatibility-note"></a>
<h2 >Compatibility note<a href="#Compatibility-note" class="wiki-anchor">¶</a></h2>
<ul>
<li>Q: How do I check whether Fixnum and Bignum are unified or not?</li>
<li>A: check RUBY_INTEGER_UNIFICATION macro</li>
</ul>
Ruby master - Feature #11801 (Closed): rb_inspect shouldn't raise error even if calling inspect r...
https://redmine.ruby-lang.org/issues/11801
2015-12-10T04:22:06Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Current rb_inspect raises Encoding::Compatibility error if obj.inspect returns a string<br>
whose encoding is not compatible with resulted string's encoding.<br>
But the behavior is not useful on inspecting an array or a hash containing such strings<br>
because it prevents to dump them.</p>
<p>Following patch changes to escape such strings like String#inspect.</p>
<pre><code>diff --git a/object.c b/object.c
index d339ff9..1f73cb4 100644
--- a/object.c
+++ b/object.c
@@ -465,6 +465,7 @@ rb_any_to_s(VALUE obj)
return str;
}
+VALUE rb_str_escape(VALUE str);
/*
* If the default external encoding is ASCII compatible, the encoding of
* the inspected result must be compatible with it.
@@ -478,11 +479,11 @@ rb_inspect(VALUE obj)
rb_encoding *ext = rb_default_external_encoding();
if (!rb_enc_asciicompat(ext)) {
if (!rb_enc_str_asciionly_p(str))
- rb_raise(rb_eEncCompatError, "inspected result must be ASCII only if default external encoding is ASCII incompatible");
+ return rb_str_escape(str);
return str;
}
if (rb_enc_get(str) != ext && !rb_enc_str_asciionly_p(str))
- rb_raise(rb_eEncCompatError, "inspected result must be ASCII only or use the default external encoding");
+ return rb_str_escape(str);
return str;
}
diff --git a/string.c b/string.c
index e6df91d..319c516 100644
--- a/string.c
+++ b/string.c
@@ -5265,6 +5265,70 @@ rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
return l;
}
+VALUE
+rb_str_escape(VALUE str)
+{
+ int encidx = ENCODING_GET(str);
+ rb_encoding *enc = rb_enc_from_index(encidx);
+ const char *p = RSTRING_PTR(str);
+ const char *pend = RSTRING_END(str);
+ const char *prev = p;
+ char buf[CHAR_ESC_LEN + 1];
+ VALUE result = rb_str_buf_new(0);
+ int unicode_p = rb_enc_unicode_p(enc);
+ int asciicompat = rb_enc_asciicompat(enc);
+
+ while (p < pend) {
+ unsigned int c, cc;
+ int n = rb_enc_precise_mbclen(p, pend, enc);
+ if (!MBCLEN_CHARFOUND_P(n)) {
+ if (p > prev) str_buf_cat(result, prev, p - prev);
+ n = rb_enc_mbminlen(enc);
+ if (pend < p + n)
+ n = (int)(pend - p);
+ while (n--) {
+ snprintf(buf, CHAR_ESC_LEN, "\\x%02X", *p & 0377);
+ str_buf_cat(result, buf, strlen(buf));
+ prev = ++p;
+ }
+ continue;
+ }
+ n = MBCLEN_CHARFOUND_LEN(n);
+ c = rb_enc_mbc_to_codepoint(p, pend, enc);
+ p += n;
+ switch (c) {
+ case '\n': cc = 'n'; break;
+ case '\r': cc = 'r'; break;
+ case '\t': cc = 't'; break;
+ case '\f': cc = 'f'; break;
+ case '\013': cc = 'v'; break;
+ case '\010': cc = 'b'; break;
+ case '\007': cc = 'a'; break;
+ case 033: cc = 'e'; break;
+ default: cc = 0; break;
+ }
+ if (cc) {
+ if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
+ buf[0] = '\\';
+ buf[1] = (char)cc;
+ str_buf_cat(result, buf, 2);
+ prev = p;
+ }
+ else if (asciicompat && rb_enc_isascii(c, enc) && ISPRINT(c)) {
+ }
+ else {
+ if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
+ rb_str_buf_cat_escaped_char(result, c, unicode_p);
+ prev = p;
+ }
+ }
+ if (p > prev) str_buf_cat(result, prev, p - prev);
+ ENCODING_CODERANGE_SET(result, rb_usascii_encindex(), ENC_CODERANGE_7BIT);
+
+ OBJ_INFECT_RAW(result, str);
+ return result;
+}
+
/*
* call-seq:
* str.inspect -> string
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index ca25f85..2e9e65b 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -278,7 +278,7 @@ def test_object_utf16_32_inspect
o = Object.new
[Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].each do |e|
o.instance_eval "undef inspect;def inspect;'abc'.encode('#{e}');end"
- assert_raise(Encoding::CompatibilityError) { [o].inspect }
+ assert_equal '[abc]', [o].inspect
end
ensure
Encoding.default_internal = orig_int
@@ -302,13 +302,18 @@ def o.inspect
def o.inspect
"abc".encode(Encoding.default_external)
end
- assert_raise(Encoding::CompatibilityError) { [o].inspect }
+ assert_equal '[abc]', [o].inspect
Encoding.default_external = Encoding::US_ASCII
def o.inspect
"\u3042"
end
- assert_raise(Encoding::CompatibilityError) { [o].inspect }
+ assert_equal '[\u3042]', [o].inspect
+
+ def o.inspect
+ "\x82\xa0".force_encoding(Encoding::Windows_31J)
+ end
+ assert_equal '[\x{82A0}]', [o].inspect
ensure
Encoding.default_internal = orig_int
Encoding.default_external = orig_ext
diff --git a/core/array/shared/inspect.rb b/core/array/shared/inspect.rb
index dc30518..a169fd0 100644
--- a/core/array/shared/inspect.rb
+++ b/core/array/shared/inspect.rb
@@ -83,9 +83,9 @@ describe :array_inspect, shared: true do
it "raises if inspected result is not default external encoding" do
utf_16be = mock("utf_16be")
- utf_16be.should_receive(:inspect).and_return("utf_16be".encode!(Encoding::UTF_16BE))
+ utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE))
- lambda { [utf_16be].send(@method) }.should raise_error(Encoding::CompatibilityError)
+ [utf_16be].send(@method).should == '["utf_16be \u3042"]'
end
end
end
</code></pre>
Ruby master - Bug #11613 (Closed): test_aspawn_too_long_path creates too many processes
https://redmine.ruby-lang.org/issues/11613
2015-10-22T16:52:33Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>At least on FreeBSD, spawn("echo|echo|echo|echo|echo|echo|echo| ...20000 times") success and create 20000 zombie processes.<br>
To prevent this you can add rlimit_nproc: 1 because it tests sh itself, don't test spawned echos.</p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gh">diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 32dcaed..7877171 100644
</span><span class="gd">--- a/test/ruby/test_process.rb
</span><span class="gi">+++ b/test/ruby/test_process.rb
</span><span class="p">@@ -1600,7 +1600,7 @@</span> class TestProcess < Test::Unit::TestCase
assert_raise(*exs, mesg) do
begin
loop do
<span class="gd">- Process.spawn(cmds.join(sep), [STDOUT, STDERR]=>File::NULL)
</span><span class="gi">+ Process.spawn(cmds.join(sep), [STDOUT, STDERR]=>File::NULL, rlimit_nproc: 1)
</span> min = [cmds.size, min].max
cmds *= 100
end
</code></pre>
Ruby master - Feature #11558 (Closed): Time related C APIs
https://redmine.ruby-lang.org/issues/11558
2015-09-30T05:59:44Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Time関連のC APIを追加して欲しいです。<br>
具体的には以下のようなものが欲しいです。</p>
<p>struct timespecとoffsetを取って、Timeを返してください。<br>
VALUE rb_time_timespec_new(const struct timespec *ts, int offset);<br>
趣旨としては、[秒, ナノ秒, offset]からTimeを作って欲しいと言うことです。<br>
(rb_time_num_new(Rational, offset)とかだと手間かかる上に遅い)</p>
<p>現在時刻をstruct timespecで欲しいです。<br>
void timespec_now(struct timespec *ts);</p>
<p>既存の非公開APIを公開してください。<br>
struct tm * localtime_with_gmtoff_zone(const time_t *t, struct tm *result, long *gmtoff, const char **zone);<br>
time_t timegm_noleapsecond(struct tm *tm);<br>
void tm_add_offset(struct tm *tm, long diff);</p>
<p><a href="https://github.com/nurse/strptime/blob/v0.1.1/ext/strptime/ruby_time.c" class="external">https://github.com/nurse/strptime/blob/v0.1.1/ext/strptime/ruby_time.c</a></p>
Ruby master - Misc #11516 (Closed): Ruby 2.3.0 release engeneering
https://redmine.ruby-lang.org/issues/11516
2015-09-09T06:13:18Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>For the management of release blockers.</p>
<p>Current Phase:<br>
Next release: preview1</p>
<p>Q: When ruby_2_2 branch is created?<br>
A: On RC1</p>
Ruby master - Feature #11253 (Closed): rb_io_modestr_oflags for Ruby API
https://redmine.ruby-lang.org/issues/11253
2015-06-12T08:18:12Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>If you have a wrapper of IO.open, you may handle mode.<br>
For example on Windows, you may want to add 'b' / OBINARY to given mode.</p>
<p>But some modes has only integer form like O_CLOEXEC, O_EXCL.<br>
If so you need to convert from modestr to oflags</p>
<p>Therefore how about adding a Ruby API version of rb_io_modestr_oflags</p>
Ruby master - Feature #11251 (Closed): Thread#name and Thread#name=
https://redmine.ruby-lang.org/issues/11251
2015-06-12T02:48:43Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Threadの名前の取得・設定を行うAPIを追加しませんか。</p>
<p><a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: Thread.new without block. (Assigned)" href="https://redmine.ruby-lang.org/issues/6694">#6694</a> や <a class="issue tracker-2 status-2 priority-4 priority-default" title="Feature: Configuration for Thread/Fiber creation (Assigned)" href="https://redmine.ruby-lang.org/issues/6695">#6695</a> などで断続的に議論がなされ、r47670 で一部自動で名前が付けられるようになったりもしていますが、<br>
Rubyレベルでそれを見る手段は提供されていませんし、明示的に付けることも出来ません。</p>
<p>今でもニーズは結構あるようです。</p>
<blockquote>
<p>"Fluentdでどのスレッドがどのプラグインに属しているのかが簡単に分かるようになるんですよね”<br>
<a href="https://twitter.com/repeatedly/status/608855851131011073" class="external">https://twitter.com/repeatedly/status/608855851131011073</a><br>
"確かにRubyのスレッドに名前付けられたら良さそう。主にログで識別する用途で。"<br>
<a href="https://twitter.com/frsyuki/status/608863065598140417" class="external">https://twitter.com/frsyuki/status/608863065598140417</a></p>
</blockquote>
<pre><code>Linux (glibc 2.12+)
int pthread_setname_np(pthread_t thread, const char *name);
int pthread_getname_np(pthread_t thread, char *name, size_t len);
FreeBSD
void pthread_set_name_np(pthread_t, const char *);
NetBSD
int pthread_getname_np(pthread_t thread, char *name, size_t len);
int pthread_setname_np(pthread_t thread, const char *name, void *arg);
http://netbsd.gw.com/cgi-bin/man-cgi?pthread_setname_np++NetBSD-current
OS X
/usr/include/pthread/pthread.h:int pthread_getname_np(pthread_t,char*,size_t);
/usr/include/pthread/pthread.h:int pthread_setname_np(const char*);
</code></pre>
Ruby master - Feature #11220 (Rejected): strptime(%6N)
https://redmine.ruby-lang.org/issues/11220
2015-06-04T14:46:35Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>strftimeにはマイクロ秒などでの出力を指定する、%6N, %9Nというフォーマットがあります。<br>
一方で、パースを行うstrptimeにはそのような指定子が現在ありません。</p>
<p>そのようなものに対するニーズはぼちぼちあるようなので入れませんか。<br>
<a href="http://answers.splunk.com/answers/1946/time-format-and-subseconds.html" class="external">http://answers.splunk.com/answers/1946/time-format-and-subseconds.html</a><br>
<a href="https://twitter.com/nalsh/status/606414387352502272" class="external">https://twitter.com/nalsh/status/606414387352502272</a></p>
<pre><code>diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index e318af1..89a6421 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -611,6 +611,33 @@ date__strptime_internal(const char *str, size_t slen,
recur("%a %b %e %H:%M:%S %Z %Y");
goto matched;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ VALUE n;
+ size_t w;
+ int sign = 1;
+ size_t osi;
+ w = read_digits(&fmt[fi], &n, 1);
+ fi += w;
+ w = NUM2SIZET(n);
+
+ if (issign(str[si])) {
+ if (str[si] == '-')
+ sign = -1;
+ si++;
+ }
+ osi = si;
+ READ_DIGITS(n, w == 0 ? 9 : w)
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("sec_fraction",
+ rb_rational_new2(n,
+ f_expt(INT2FIX(10),
+ ULONG2NUM(si - osi))));
+ goto matched;
+ }
+
default:
if (str[si] != '%')
fail();
</code></pre>
Ruby master - Bug #11206 (Closed): short file name match incompatibility
https://redmine.ruby-lang.org/issues/11206
2015-06-01T17:54:57Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>When I develop a foo.gem, my working diretory has foo.gemspec and foo.gem.<br>
If I run <code>gem install -l foo</code>, it fails as following:</p>
<p>ERROR: While executing gem ... (Gem::Package::FormatError)<br>
package metadata is missing in foo.gemspec</p>
<p>Because gem command tries to traverse the current directory with Dir["*.gem"],<br>
and it include *.gemspec.</p>
<p>Another example, Rakefile has <code>rake clean</code> task and it is specified by CLEAN constant.<br>
if I specify CLEAN.include( "*.gem" ), it removes *.gemspec.</p>
Ruby master - Bug #11172 (Closed): Windowsでmode: ab+の時に開いたファイルの内容が読めない
https://redmine.ruby-lang.org/issues/11172
2015-05-23T15:23:47Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Windowsでopen("hoge.txt", "ab+")すると、開いたファイルの既存の内容が読めません。<br>
File::APPEND|File::CREAT|File::RDWR|File::BINARYでも同様です。</p>
<p>Unixでは読める上に、a+の時、つまり_openを使う場合も読めるので、意図しない挙動でしょう。</p>
<pre><code>diff --git a/win32/win32.c b/win32/win32.c
index 55e0d2e..57d9df4 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -6476,12 +6476,16 @@ rb_w32_close(int fd)
}
static int
-setup_overlapped(OVERLAPPED *ol, int fd)
+setup_overlapped(OVERLAPPED *ol, int fd, int iswrite)
{
memset(ol, 0, sizeof(*ol));
if (!(_osfile(fd) & (FDEV | FPIPE))) {
LONG high = 0;
- DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT;
+ /* On mode:a, it can write only FILE_END.
+ * On mode:a+, though it can write only FILE_END,
+ * it can read from everywhere.
+ */
+ DWORD method = ((_osfile(fd) & FAPPEND) && iswrite) ? FILE_END : FILE_CURRENT;
DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method);
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
@@ -6578,7 +6582,7 @@ rb_w32_read(int fd, void *buf, size_t size)
/* if have cancel_io, use Overlapped I/O */
if (cancel_io) {
- if (setup_overlapped(&ol, fd)) {
+ if (setup_overlapped(&ol, fd, FALSE)) {
rb_acrt_lowio_unlock_fh(fd);
return -1;
}
@@ -6708,7 +6712,7 @@ rb_w32_write(int fd, const void *buf, size_t size)
/* if have cancel_io, use Overlapped I/O */
if (cancel_io) {
- if (setup_overlapped(&ol, fd)) {
+ if (setup_overlapped(&ol, fd, TRUE)) {
rb_acrt_lowio_unlock_fh(fd);
return -1;
}
</code></pre>
Ruby master - Misc #10553 (Closed): Ruby 2.2.0 release engeneering
https://redmine.ruby-lang.org/issues/10553
2014-11-28T13:01:41Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>For the management of release blockers.</p>
<p>Current Phase: feature freeze; changing feature is not allowed unless naruse explicitly allowed.<br>
Next release: RC1 (scheduled on 2014-12-1x)</p>
<p>Q: When ruby_2_2 branch is created?<br>
A: On RC1</p>
<p>Q: Can I add/change a feature?<br>
A: Get explicit permission from naruse</p>
Ruby master - Feature #9816 (Assigned): 文字列内の数字を数値として比較するメソッド
https://redmine.ruby-lang.org/issues/9816
2014-05-08T09:37:26Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>文字列内の数字を数値として比較するメソッドを追加しませんか</p>
<p>そのような比較は一般的な用途としてはGUIシェルのファイラーが比較に用いており、<br>
Windows では StrCmpLogicalW が、OS X では NSString:compare:options:へのNSNumericSearch定数が提供されています。<br>
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb759947(v=vs.85).aspx" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/bb759947(v=vs.85).aspx</a><br>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/c/econst/NSNumericSearch" class="external">https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/c/econst/NSNumericSearch</a></p>
<p>上記のような処理自体はさほど難しいものではありませんが、Rubyレベルで実装すると大量のオブジェクトを作ってしまいます。<br>
例えば <code>Gem::Version.new("2.1.10".freeze)<=>Gem::Version.new("2.1.9".freeze)</code> は47個、<br>
<code>"2.1.10".freeze.split('.').map(&:to_i)<=>"2.1.9".freeze.split('.').map(&:to_i)</code> だと16個のオブジェクトを作ります。<br>
<code>"2.1.10".freeze.numericcmp"2.1.9".freeze</code> ならば、もちろんオブジェクトは一つも作りません。</p>
<p>なお、上記の例でも示唆していますが、本メソッドは Ruby のバージョン表記の TEENY が2桁になった場合の比較に用いることができます。</p>
<p>パッチは以下の通りです。<br>
なお、メソッド名は String#numericcmp としています。<br>
(String#casecmpを念頭に置いた)</p>
<pre><code>diff --git a/string.c b/string.c
index c589c80..66f667f 100644
--- a/string.c
+++ b/string.c
@@ -2569,6 +2569,131 @@ rb_str_casecmp(VALUE str1, VALUE str2)
return INT2FIX(-1);
}
+VALUE
+numerical_compare(const char **pp1, const char *p1end, const char **pp2, const char *p2end)
+{
+ const char *s1 = *pp1, *p1, *s2 = *pp2, *p2;
+ ptrdiff_t len1, len2;
+ int r;
+
+ while (s1 < p1end && *s1 == '0') s1++;
+ p1 = s1;
+ while (p1 < p1end && ISDIGIT(*p1)) p1++;
+ len1 = p1 - s1;
+
+ while (s2 < p2end && *s2 == '0') s2++;
+ p2 = s2;
+ while (p2 < p2end && ISDIGIT(*p2)) p2++;
+ len2 = p2 - s2;
+
+ if (len1 != len2) {
+ return INT2FIX(len1 < len2 ? -1 : 1);
+ }
+
+ r = memcmp(s1, s2, len1);
+ if (r) return r < 0 ? INT2FIX(-1) : INT2FIX(1);
+
+ len1 = s1 - *pp1;
+ len2 = s2 - *pp2;
+ if (len1 != len2) {
+ return INT2FIX(len1 < len2 ? -1 : 1);
+ }
+
+ *pp1 = p1;
+ *pp2 = p2;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * str.numericcmp(other_str) -> -1, 0, +1 or nil
+ *
+ * Variant of <code>String#<=></code>, which considers digits in strings
+ * are numeric value..
+ *
+ * "a1".numericcmp("a1") #=> 0
+ * "aa".numericcmp("a1") #=> 1
+ * "a1".numericcmp("aa") #=> -1
+ * "a1".numericcmp("a01") #=> -1
+ * "2.1.2".numericcmp("2.1.10") #=> 1
+ */
+
+static VALUE
+rb_str_numericcmp(VALUE str1, VALUE str2)
+{
+ long len;
+ rb_encoding *enc;
+ const char *p1, *p1end, *p2, *p2end;
+
+ StringValue(str2);
+ enc = rb_enc_compatible(str1, str2);
+ if (!enc) {
+ return Qnil;
+ }
+
+ p1 = RSTRING_PTR(str1); p1end = RSTRING_END(str1);
+ p2 = RSTRING_PTR(str2); p2end = RSTRING_END(str2);
+ if (single_byte_optimizable(str1) && single_byte_optimizable(str2)) {
+ while (p1 < p1end && p2 < p2end) {
+ if (ISDIGIT(*p1)) {
+ if (ISDIGIT(*p2)) {
+ VALUE r = numerical_compare(&p1, p1end, &p2, p2end);
+ if (!NIL_P(r)) return r;
+ }
+ else {
+ return INT2FIX(-1);
+ }
+ }
+ else if (ISDIGIT(*p2)) {
+ return INT2FIX(1);
+ }
+ if (*p1 != *p2) return INT2FIX(*p1 < *p2 ? -1 : 1);
+ p1++;
+ p2++;
+ }
+ }
+ else {
+ while (p1 < p1end && p2 < p2end) {
+ int l1, c1 = rb_enc_ascget(p1, p1end, &l1, enc);
+ int l2, c2 = rb_enc_ascget(p2, p2end, &l2, enc);
+
+ if (0 <= c1 && 0 <= c2) {
+ if (ISDIGIT(*p1)) {
+ if (ISDIGIT(*p2)) {
+ VALUE r = numerical_compare(&p1, p1end, &p2, p2end);
+ if (!NIL_P(r)) return r;
+ }
+ else {
+ return INT2FIX(-1);
+ }
+ }
+ else if (ISDIGIT(*p2)) {
+ return INT2FIX(1);
+ }
+ if (*p1 != *p2) return INT2FIX(*p1 < *p2 ? -1 : 1);
+ p1++;
+ p2++;
+ }
+ else {
+ int r;
+ l1 = rb_enc_mbclen(p1, p1end, enc);
+ l2 = rb_enc_mbclen(p2, p2end, enc);
+ len = l1 < l2 ? l1 : l2;
+ r = memcmp(p1, p2, len);
+ if (r != 0)
+ return INT2FIX(r < 0 ? -1 : 1);
+ if (l1 != l2)
+ return INT2FIX(l1 < l2 ? -1 : 1);
+ }
+ p1 += l1;
+ p2 += l2;
+ }
+ }
+ if (RSTRING_LEN(str1) == RSTRING_LEN(str2)) return INT2FIX(0);
+ if (RSTRING_LEN(str1) > RSTRING_LEN(str2)) return INT2FIX(1);
+ return INT2FIX(-1);
+}
+
static long
rb_str_index(VALUE str, VALUE sub, long offset)
{
@@ -8721,6 +8846,7 @@ Init_String(void)
rb_define_method(rb_cString, "eql?", rb_str_eql, 1);
rb_define_method(rb_cString, "hash", rb_str_hash_m, 0);
rb_define_method(rb_cString, "casecmp", rb_str_casecmp, 1);
+ rb_define_method(rb_cString, "numericcmp", rb_str_numericcmp, 1);
rb_define_method(rb_cString, "+", rb_str_plus, 1);
rb_define_method(rb_cString, "*", rb_str_times, 1);
rb_define_method(rb_cString, "%", rb_str_format_m, 1);
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 8366424..f9c788b 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2104,6 +2104,29 @@ class TestString < Test::Unit::TestCase
assert_equal(1, "\u3042B".casecmp("\u3042a"))
end
+ def test_numericcmp
+ assert_equal(-1, "2.1.0".numericcmp("2.1.1"))
+ assert_equal(-1, "2.1.9".numericcmp("2.1.10"))
+ assert_equal( 0, "a1".numericcmp("a1"))
+ assert_equal( 1, "aa".numericcmp("a1"))
+ assert_equal(-1, "a1".numericcmp("aa"))
+ assert_equal(-1, "a1".numericcmp("a01"))
+ assert_equal(-1, "a0001".numericcmp("a00001"))
+ assert_equal( 0, "a1a".numericcmp("a1a"))
+ assert_equal( 1, "a1b".numericcmp("a1a"))
+ assert_equal(-1, "a9a".numericcmp("a10a"))
+ assert_equal( 1, "b".numericcmp("a"))
+ assert_equal( 0, "\u30421".numericcmp("\u30421"))
+ assert_equal( 1, "\u3042\u3042".numericcmp("\u30421"))
+ assert_equal(-1, "\u30421".numericcmp("\u3042\u3042"))
+ assert_equal(-1, "\u30421".numericcmp("\u304201"))
+ assert_equal(-1, "\u30420001".numericcmp("\u304200001"))
+ assert_equal( 0, "\u30421\u3042".numericcmp("\u30421\u3042"))
+ assert_equal( 1, "\u30421\u3044".numericcmp("\u30421\u3042"))
+ assert_equal(-1, "\u30429\u3042".numericcmp("\u304210\u3042"))
+ assert_equal( 1, "\u3044".numericcmp("\u3042"))
+ end
+
def test_upcase2
assert_equal("\u3042AB", "\u3042aB".upcase)
end
</code></pre>
Ruby master - Bug #9287 (Closed): 'rb_obj_write' discards qualifiers from pointer target type
https://redmine.ruby-lang.org/issues/9287
2013-12-23T18:22:00Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>array.c: In function 'rb_ary_new_from_args':<br>
array.c:506: warning: passing argument 2 of 'rb_obj_write' discards qualifiers from pointer target type<br>
などといった警告が出ます。</p>
<p><a href="http://fb32.rubyci.org/~chkbuild/ruby-trunk/log/20131223T070301Z.log.html.gz" class="external">http://fb32.rubyci.org/~chkbuild/ruby-trunk/log/20131223T070301Z.log.html.gz</a></p>
Ruby master - Bug #8711 (Closed): 最近NoMemoryErrorが多い
https://redmine.ruby-lang.org/issues/8711
2013-07-31T16:06:27Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>最近 rubyci で NoMemoryError を出して失敗することが多いので、それを追跡するスレ</p>
<p>= TestFiber#test_many_fibers<br>
<a href="http://u64b.rubyci.org/~chkbuild/ruby-trunk/log/20130730T233301Z.diff.html.gz" class="external">http://u64b.rubyci.org/~chkbuild/ruby-trunk/log/20130730T233301Z.diff.html.gz</a><br>
<a href="http://rbci.lakewood.privs.net/ruby-trunk/log/20130731T001002Z.diff.html.gz" class="external">http://rbci.lakewood.privs.net/ruby-trunk/log/20130731T001002Z.diff.html.gz</a></p>
<p>= FiberError: can't alloc machine stack to fiber<br>
<a href="http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20130729T200302Z.diff.html.gz" class="external">http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20130729T200302Z.diff.html.gz</a></p>
Ruby master - Feature #8539 (Closed): Unbundle ext/tk
https://redmine.ruby-lang.org/issues/8539
2013-06-18T00:25:36Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>How about unbundling ext/tk from Ruby repository?</p>
<p>ext/tk is a bundled extension library for GUI programming with tk.<br>
It is introduced in 1999 and long maintained with CRuby itself.</p>
<p>But nowadays its maintenance is not so active.<br>
Moreover ext/tk is not the de facto standard over Ruby GUI though it is bundled for 14 years.<br>
(maybe because tk is not de facto of GUI toolkit)<br>
GUI libraries for Ruby should compete in the wilds.</p>
<p>So I propose unbundling ext/tk.<br>
It should be another repository for example on github and people should install it as gem.</p>
<p>How do you think?</p>
Ruby master - Bug #8492 (Closed): ObjectSpace.after_gc_start_hook aborts with GC.stress
https://redmine.ruby-lang.org/issues/8492
2013-06-05T12:45:13Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>以下を実行すると assert(during_gc > 0) に失敗して abort します。<br>
ruby -robjspace -e'ObjectSpace.after_gc_start_hook=proc{};GC.stress=true;{}'<br>
gc.c:3818 の<br>
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);<br>
実行後に、during_gc が 0 になっている模様。</p>
Ruby master - Bug #8484 (Closed): Restoring conditions through the ruby method call during VM pro...
https://redmine.ruby-lang.org/issues/8484
2013-06-04T12:33:15Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>r41041 で、ブロック呼び出し前の VM 内の処理中に Ruby のメソッドが何らかの理由で呼ばれると argv が壊れるという問題を直しました。<br>
具体的には、</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="n">y</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nc">y</span><span class="o">.</span><span class="nf">s</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="k">yield</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">m</span> <span class="o">=</span> <span class="no">Object</span><span class="p">.</span><span class="nf">new</span>
<span class="k">def</span> <span class="nc">m</span><span class="o">.</span><span class="nf">method_missing</span><span class="p">(</span><span class="o">*</span><span class="n">a</span><span class="p">)</span>
<span class="k">super</span>
<span class="k">end</span>
<span class="n">assert_equal</span> <span class="p">[</span><span class="n">m</span><span class="p">,</span> <span class="kp">nil</span><span class="p">],</span> <span class="n">y</span><span class="p">.</span><span class="nf">s</span><span class="p">(</span><span class="n">m</span><span class="p">){</span><span class="o">|</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="o">|</span><span class="p">[</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">]}</span>
</code></pre>
<p>のようなコードの場合、</p>
<ul>
<li>
<code>y.s</code> に <code>m</code> と <code>block</code> が渡される</li>
<li>
<code>y.s</code> で <code>yield(a)</code> が呼ばれる</li>
<li>
<code>argv</code>が設定される</li>
<li>
<code>vm_invoke_block</code> 内の <code>VALUE * const rsp = GET_SP() - ci->argc; SET_SP(rsp);</code> で <code>argv</code> の先頭に <code>sp</code> が設定される</li>
<li><code>vm_yield_setup_args</code></li>
<li><code>vm_yield_setup_block_args</code></li>
<li>
<code>y.s</code> のブロックパラメータは2つなのに、引数は一つなので、<code>a.to_ary</code> が呼ばれる (<code>rb_check_array_type(arg0)</code>)</li>
<li>
<code>method_missing</code> が呼ばれる</li>
<li>
<code>super</code> が呼ばれる (このへんで <code>vm _push_frame</code> が呼ばれる)</li>
<li>
<code>vm_push_frame</code>のinitialize local variablesのところで<code>argv</code>に<code>nil</code>が代入されて破壊される</li>
</ul>
<p>で、これ自体は <code>argv</code> を対比しておいて戻せばよいです。<br>
また、<code>SET_SP(rsp)</code>のあたりは、ささださん曰く「 <code>argv</code> に書き込みがない、という前提でそこは作ってるんだよね」だそうな。<br>
しかし、「そんな前提わかるかっ」ですし、<br>
methodの方は <code>SAVE_RESTORE_CI(tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a"), ci);</code> ともうちょっとわかりやすく書いてあるので、<br>
「頂いた問題点を元に、一度全部総点検が必要そうです」とのことですので、お願いします。</p>
Ruby master - Feature #8414 (Closed): String#scrub!
https://redmine.ruby-lang.org/issues/8414
2013-05-17T16:38:09Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>r40390 [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Replacing ill-formed subsequencce (Closed)" href="https://redmine.ruby-lang.org/issues/6752">#6752</a>] で で追加した String#scrub ですが、破壊的メソッド版も追加していいでしょうか。<br>
lib/uri/common.rb いじっていて、欲しくなったので。</p>
Ruby master - Misc #8288 (Closed): Ruby 2.1.0 release engeneering
https://redmine.ruby-lang.org/issues/8288
2013-04-19T03:31:49Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>This is meta issue for releasing Ruby 2.1.0</p>
<p>see also <a href="https://bugs.ruby-lang.org/versions/27" class="external">https://bugs.ruby-lang.org/versions/27</a></p>
Ruby master - Feature #8217 (Closed): OpenSSL::BN.new with integers
https://redmine.ruby-lang.org/issues/8217
2013-04-04T15:59:31Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Current OpenSSL::BN.new gets only strings, so users must do integer.to_s, it costs extra resource.<br>
Therefore I propose OpenSSL::BN.new to allow Fixnu/Bignum.</p>
<p>diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c<br>
index 1038135..1f1ebba 100644<br>
--- a/ext/openssl/ossl_bn.c<br>
+++ b/ext/openssl/ossl_bn.c<br>
@@ -120,6 +120,44 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)<br>
base = NUM2INT(bs);<br>
}</p>
<ul>
<li>if (RB_TYPE_P(str, T_FIXNUM)) {</li>
<li>long i;</li>
<li>unsigned char <em>bin = (unsigned char</em>)ALLOC_N(long, 1);</li>
<li>long n = FIX2LONG(str);</li>
<li>unsigned long un = abs(n);</li>
<li>
<li>for (i = sizeof(VALUE) - 1; 0 <= i; i--) {</li>
<li>
<pre><code> bin[i] = un&0xff;
</code></pre>
</li>
<li>
<pre><code> un >>= 8;
</code></pre>
</li>
<li>}</li>
<li>
<li>GetBN(self, bn);</li>
<li>if (!BN_bin2bn(bin, sizeof(long), bn)) {</li>
<li>
<pre><code> ossl_raise(eBNError, NULL);
</code></pre>
</li>
<li>}</li>
<li>if (n < 0) BN_set_negative(bn, 1);</li>
<li>return self;</li>
<li>}</li>
<li>else if (RB_TYPE_P(str, T_BIGNUM)) {</li>
<li>long i, j;</li>
<li>BDIGIT *ds = RBIGNUM_DIGITS(str);</li>
<li>unsigned char <em>bin = (unsigned char</em>)ALLOC_N(BDIGIT, RBIGNUM_LEN(str));</li>
<li>
<li>for (i = 0; RBIGNUM_LEN(str) > i; i++) {</li>
<li>
<pre><code> BDIGIT v = ds[i];
</code></pre>
</li>
<li>
<pre><code> for (j = sizeof(BDIGIT) - 1; 0 <= j; j--) {
</code></pre>
</li>
<li>
<pre><code> bin[(RBIGNUM_LEN(str)-1-i)*sizeof(BDIGIT)+j] = v&0xff;
</code></pre>
</li>
<li>
<pre><code> v >>= 8;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>}</li>
<li>
<li>GetBN(self, bn);</li>
<li>if (!BN_bin2bn(bin, sizeof(BDIGIT)*RBIGNUM_LEN(str), bn)) {</li>
<li>
<pre><code> ossl_raise(eBNError, NULL);
</code></pre>
</li>
<li>}</li>
<li>if (!RBIGNUM_SIGN(str)) BN_set_negative(bn, 1);</li>
<li>return self;</li>
<li>}<br>
if (RTEST(rb_obj_is_kind_of(str, cBN))) {<br>
BIGNUM *other;</li>
</ul>
<p>diff --git a/test/openssl/test_bn.rb b/test/openssl/test_bn.rb<br>
index af1c72c..758cc54 100644<br>
--- a/test/openssl/test_bn.rb<br>
+++ b/test/openssl/test_bn.rb<br>
@@ -8,6 +8,13 @@ class OpenSSL::TestBN < Test::Unit::TestCase<br>
end</p>
<p>def test_integer_to_bn</p>
<ul>
<li>assert_equal(999.to_bn, OpenSSL::BN.new(999))</li>
<li>assert_equal((2 ** 107 - 1).to_bn, OpenSSL::BN.new(2 ** 107 - 1))</li>
<li>assert_equal(-999.to_bn, OpenSSL::BN.new(-999))</li>
<li>assert_equal((-(2 ** 107 - 1)).to_bn, OpenSSL::BN.new(-(2 ** 107 - 1)))</li>
<li>end</li>
<li>
<li>def test_integer_str_to_bn<br>
assert_equal(999.to_bn, OpenSSL::BN.new(999.to_s(16), 16))<br>
assert_equal((2 ** 107 - 1).to_bn, OpenSSL::BN.new((2 ** 107 - 1).to_s(16), 16))<br>
end</li>
</ul>
Ruby master - Bug #8203 (Closed): Rinda: recycled object
https://redmine.ruby-lang.org/issues/8203
2013-04-02T11:00:13Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>test-allで以下のメッセージが出ているんですが、これってなんですか?<br>
<a href="http://u32.rubyci.org/~chkbuild/ruby-trunk/log/20130402T010302Z.log.html.gz#test-all" class="external">http://u32.rubyci.org/~chkbuild/ruby-trunk/log/20130402T010302Z.log.html.gz#test-all</a></p>
<p>Rinda::TupleSpaceProxyTest#test_take_bug_8215 = /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:369:in <code>_id2ref': 0xda91ca76 is recycled object (RangeError) from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:369:in </code>to_obj'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1446:in <code>to_obj' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1748:in </code>to_obj'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1025:in <code>_load' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:590:in </code>load'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:590:in <code>block in load' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:586:in </code>synchronize'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:586:in <code>load' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:638:in </code>recv_reply'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:936:in <code>recv_reply' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1222:in </code>send_message'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1110:in <code>block (2 levels) in method_missing' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1197:in </code>open'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1109:in <code>block in method_missing' from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1132:in </code>with_friend'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/drb/drb.rb:1108:in <code>method_missing' from /home/chkbuild/build/20130402T010302Z/ruby/lib/rinda/rinda.rb:265:in </code>write'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/test/rinda/test_rinda.rb:506:in <code>block in test_take_bug_8215' from /home/chkbuild/build/20130402T010302Z/ruby/test/rinda/test_rinda.rb:502:in </code>fork'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/test/rinda/test_rinda.rb:502:in <code>test_take_bug_8215' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:858:in </code>run_test'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1301:in <code>run' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit/testcase.rb:17:in </code>run'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:919:in <code>block in _run_suite' from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:912:in </code>map'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:912:in <code>_run_suite' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:657:in </code>block in _run_suites'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:655:in <code>each' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:655:in </code>_run_suites'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:867:in <code>_run_anything' from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1060:in </code>run_tests'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1047:in <code>block in _run' from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1046:in </code>each'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1046:in <code>_run' from /home/chkbuild/build/20130402T010302Z/ruby/lib/minitest/unit.rb:1035:in </code>run'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:21:in <code>run' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:774:in </code>run'<br>
from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:834:in <code>run' from /home/chkbuild/build/20130402T010302Z/ruby/lib/test/unit.rb:838:in </code>run'<br>
from ./test/runner.rb:17:in `'<br>
1.42 s = .</p>
Ruby master - Bug #7589 (Closed): parallel test-all で test_settracefunc が SEGV
https://redmine.ruby-lang.org/issues/7589
2012-12-19T12:01:03Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>while make TESTS='-qv -j1 ruby/test_settracefunc.rb' test-all;do done としていると以下の通りSEGVします。</p>
<p>前略<br>
TestSetTraceFunc#test_tracepoint_exception_at_line = 0.00 s = .<br>
/home/naruse/ruby/lib/test/unit/parallel.rb:38: [BUG] Segmentation fault<br>
ruby 2.0.0dev (2012-12-19 trunk 38456) [x86_64-linux]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:0002 p:0014 s:0005 e:000004 BLOCK /home/naruse/ruby/lib/test/unit/parallel.rb:38 [FINISH]<br>
c:0001 p:---- s:0002 e:000001 TOP [FINISH]</p>
<p>-- Ruby level backtrace information ----------------------------------------<br>
/home/naruse/ruby/lib/test/unit/parallel.rb:38:in `block in _run_suite'</p>
<p>-- C level backtrace information -------------------------------------------<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1be874) [0x2b09de81b874] vm_dump.c:643<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x662a7) [0x2b09de6c32a7] error.c:306<br>
/home/naruse/ruby/libruby.so.2.0.0(rb_bug+0x108) [0x2b09de6c33e5] error.c:325<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1382f2) [0x2b09de7952f2] signal.c:649<br>
/lib/libpthread.so.0(+0xf8f0) [0x2b09deb188f0] ../nptl/sysdeps/pthread/funlockfile.c:30<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1c13e8) [0x2b09de81e3e8] vm_trace.c:263<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1c160f) [0x2b09de81e60f] vm_trace.c:309<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1aba95) [0x2b09de808a95]<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1baaca) [0x2b09de817aca] vm.c:1169<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1b9618) [0x2b09de816618] vm.c:636<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1b9869) [0x2b09de816869] vm.c:684<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1b9917) [0x2b09de816917] vm.c:703<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1c56cf) [0x2b09de8226cf]<br>
/home/naruse/ruby/libruby.so.2.0.0(+0x1c4111) [0x2b09de821111] thread_pthread.c:722<br>
/lib/libpthread.so.0(+0x69ca) [0x2b09deb0f9ca] pthread_create.c:300<br>
/lib/libc.so.6(clone+0x6d) [0x2b09df6d921d] parse.y:10551</p>
<p>-- Other runtime information -----------------------------------------------</p>
<ul>
<li>
<p>Loaded script: /home/naruse/ruby/lib/test/unit/parallel.rb: TestSetTraceFunc#test_tracepoint_thread</p>
</li>
<li>
<p>Loaded features:</p>
</li>
</ul>
<p>Some worker was crashed. It seems ruby interpreter's bug<br>
or, a bug of test/unit/parallel.rb. try again without -j<br>
option.</p>
<p>make: *** [yes-test-all] Error 1</p>
<p>以下のパッチを当てると落ちなくなるので、パイプの読み込み部分があやしそうですが……。</p>
<p>diff --git a/lib/test/unit/parallel.rb b/lib/test/unit/parallel.rb<br>
index d189183..b044792 100644<br>
--- a/lib/test/unit/parallel.rb<br>
+++ b/lib/test/unit/parallel.rb<br>
@@ -34,8 +34,13 @@ module Test</p>
<pre><code> th = Thread.new do
begin
</code></pre>
<ul>
<li>
<pre><code> while buf = (self.verbose ? i.gets : i.read(5))
</code></pre>
</li>
<li>
<pre><code> _report "p", buf
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> buf = i.read
</code></pre>
</li>
<li>
<pre><code> if self.verbose
</code></pre>
</li>
<li>
<pre><code> buf.each_line{|l|
</code></pre>
</li>
<li>
<pre><code> _report "p", l
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else
</code></pre>
</li>
<li>
<pre><code> raise
end
rescue IOError
rescue Errno::EPIPE
</code></pre>
</li>
</ul>
Backport193 - Backport #7587 (Closed): r35924
https://redmine.ruby-lang.org/issues/7587
2012-12-18T19:56:48Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>make -j したときにこけるので r35924 を backport してください</p>
Ruby master - Bug #7559 (Closed): Wrong line number with method call syntax
https://redmine.ruby-lang.org/issues/7559
2012-12-14T04:06:51Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>以下のような場合に表示される行数がおかしくなります。</p>
<p>def foo(*args)<br>
p caller[0][/\d+/].to_i #=> expected 4 but 8<br>
end<br>
foo "a<br>
b<br>
c<br>
d<br>
e"</p>
<p>def bar(a, b, line)<br>
p a<br>
p line #=> expected 14 but 19<br>
end<br>
def baz<br>
bar <strong>LINE</strong>, <<eom, <strong>LINE</strong><br>
a<br>
b<br>
c<br>
d<br>
eom<br>
end<br>
baz</p>
Ruby master - Bug #7302 (Closed): r37497 changes rb_enumeratorize without NEWS
https://redmine.ruby-lang.org/issues/7302
2012-11-07T19:53:08Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>r37497 [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Enumerable#size (Closed)" href="https://redmine.ruby-lang.org/issues/6636">#6636</a>] changed the prototype of rb_enumeratorize.<br>
It is public Ruby CAPI.</p>
<p>I think it shouldn't be changed and add another CAPI like rb_enumeratorize_with_size.<br>
At least a description should be add to NEWS</p>
Backport193 - Backport #7169 (Closed): r37169
https://redmine.ruby-lang.org/issues/7169
2012-10-16T09:43:05Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>以下をマージお願いします。</p>
<p>commit 78e3185a20d9307c98fecca6d3bacfb8f2c271b8<br>
Author: naruse <a href="mailto:naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e" class="email">naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</a><br>
Date: Sat Oct 13 01:03:41 2012</p>
<pre><code>use tty(1) to check if /dev/tty is usable or not
</code></pre>
<p><a href="http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=37169&view=revision" class="external">http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=37169&view=revision</a></p>
Ruby master - Feature #6767 (Closed): Utility method to get a duplicated string whose encoding is...
https://redmine.ruby-lang.org/issues/6767
2012-07-22T03:20:31Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>ある String を ASCII-8BIT にしたいことはしばしばあります。<br>
それだけならばまだ force_encoding しろよという話なのですが、<br>
<a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Bitwise string operations (Rejected)" href="https://redmine.ruby-lang.org/issues/6361">#6361</a> の例のように、バイナリ文字列にさらにバイナリ文字列を結合していく場合、<br>
毎行毎行 force_encoding を書いていくのにはつらいものがあります。</p>
<p>解決案としては、<br>
(1) バイナリリテラルの導入<br>
(2) dup.force_encoding(Encoding::ASCII_8BIT) する短いメソッドを追加<br>
(3) ASCII-8BIT に他のエンコーディングの文字列を結合した場合は暗黙に force_encoding<br>
が考えられます。</p>
<p>しかし、(1) は文法拡張なのでハードルが高く、(3) は方々で議論になっている通りです。<br>
よって、(2) が妥当ではないかと思います。</p>
<p>名前をまつもとさん提案の String#b としたパッチを以下の通り添付します。</p>
<p>diff --git a/string.c b/string.c<br>
index d038835..76cbc36 100644<br>
--- a/string.c<br>
+++ b/string.c<br>
@@ -601,7 +601,7 @@ rb_str_export_to_enc(VALUE str, rb_encoding *enc)<br>
}</p>
<p>static VALUE<br>
-str_replace_shared(VALUE str2, VALUE str)<br>
+str_replace_shared_without_enc(VALUE str2, VALUE str)<br>
{<br>
if (RSTRING_LEN(str) <= RSTRING_EMBED_LEN_MAX) {<br>
STR_SET_EMBED(str2);<br>
@@ -616,8 +616,14 @@ str_replace_shared(VALUE str2, VALUE str)<br>
RSTRING(str2)->as.heap.aux.shared = str;<br>
FL_SET(str2, ELTS_SHARED);<br>
}</p>
<ul>
<li>rb_enc_cr_str_exact_copy(str2, str);</li>
</ul>
<ul>
<li>return str2;<br>
+}</li>
</ul>
<p>+static VALUE<br>
+str_replace_shared(VALUE str2, VALUE str)<br>
+{</p>
<ul>
<li>str_replace_shared_without_enc(str2, str);</li>
<li>rb_enc_cr_str_exact_copy(str2, str);<br>
return str2;<br>
}</li>
</ul>
<p>@@ -7340,6 +7346,23 @@ rb_str_force_encoding(VALUE str, VALUE enc)</p>
<p>/*</p>
<ul>
<li>call-seq:</li>
</ul>
<ul>
<li>
<ul>
<li>
<pre><code>str.b -> str
</code></pre>
</li>
</ul>
</li>
<li>
<ul>
<li>
</ul>
</li>
<li>
<ul>
<li>Returns a copied string whose encoding is ASCII-8BIT.</li>
</ul>
</li>
<li>*/</li>
<li>
</ul>
<p>+static VALUE<br>
+rb_str_b(VALUE str)<br>
+{</p>
<ul>
<li>VALUE str2 = str_alloc(rb_cString);</li>
<li>str_replace_shared_without_enc(str2, str);</li>
<li>OBJ_INFECT(str2, str);</li>
<li>ENC_CODERANGE_SET(str2, ENC_CODERANGE_VALID);</li>
<li>return str2;<br>
+}</li>
<li>
</ul>
<p>+/*</p>
<ul>
<li>
<ul>
<li>
<p>call-seq:</p>
</li>
<li>
<pre><code>str.valid_encoding? -> true or false
</code></pre>
</li>
<li>
<li>
<p>Returns true for a string which encoded correctly.<br>
@@ -7969,6 +7992,7 @@ Init_String(void)</p>
<p>rb_define_method(rb_cString, "encoding", rb_obj_encoding, 0); /* in encoding.c */<br>
rb_define_method(rb_cString, "force_encoding", rb_str_force_encoding, 1);</p>
</li>
</ul>
</li>
<li>rb_define_method(rb_cString, "b", rb_str_b, 0);<br>
rb_define_method(rb_cString, "valid_encoding?", rb_str_valid_encoding_p, 0);<br>
rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);</li>
</ul>
<p>diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb<br>
index dfcaa94..3a4bca7 100644<br>
--- a/test/ruby/test_m17n.rb<br>
+++ b/test/ruby/test_m17n.rb<br>
@@ -1469,4 +1469,14 @@ class TestM17N < Test::Unit::TestCase<br>
yield(*strs)<br>
end<br>
end<br>
+</p>
<ul>
<li>def test_str_b</li>
<li>s = "\u3042"</li>
<li>assert_equal(a("\xE3\x81\x82"), s.b)</li>
<li>assert_equal(Encoding::ASCII_8BIT, s.b.encoding)</li>
<li>s.taint</li>
<li>assert_equal(true, s.b.tainted?)</li>
<li>s.untrust</li>
<li>assert_equal(true, s.b.untrusted?)</li>
<li>end<br>
end</li>
</ul>
Ruby master - Feature #6752 (Closed): Replacing ill-formed subsequencce
https://redmine.ruby-lang.org/issues/6752
2012-07-19T11:42:58Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
== 概要<br>
Stringになんらかの理由で不正なバイト列が含まれている時に、それを置換文字で置き換えたい。</p>
<p>== ユースケース<br>
実際に確認されているユースケースは以下の通りです。</p>
<ul>
<li>
<p>twitterのtitle</p>
</li>
<li>
<p>IRCのログ</p>
</li>
<li>
<p>ニコニコ動画の API</p>
</li>
<li>
<p>Webクローリング<br>
これらの不正なバイト列の生成過程は、おそらく、バイト単位で文字列を切り詰めた時に末尾が切れて、<br>
末尾がおかしい不正な文字列が作られます。(前二者)<br>
これをコンテナに入れたり結合することによって、途中にも混ざった文字列が作られます。(後二者)</p>
</li>
<li>
<p><a href="https://twitter.com/takahashim/status/18974040397" class="external">https://twitter.com/takahashim/status/18974040397</a></p>
</li>
<li>
<p><a href="https://twitter.com/n0kada/status/215674740705210368" class="external">https://twitter.com/n0kada/status/215674740705210368</a></p>
</li>
<li>
<p><a href="https://twitter.com/n0kada/status/215686490070585346" class="external">https://twitter.com/n0kada/status/215686490070585346</a></p>
</li>
<li>
<p><a href="https://twitter.com/hajimehoshi/status/215671146769682432" class="external">https://twitter.com/hajimehoshi/status/215671146769682432</a></p>
</li>
<li>
<p><a href="http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/" class="external">http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/</a></p>
</li>
<li>
<p><a href="http://stackoverflow.com/questions/2982677/ruby-1-9-invalid-byte-sequence-in-utf-8" class="external">http://stackoverflow.com/questions/2982677/ruby-1-9-invalid-byte-sequence-in-utf-8</a></p>
</li>
</ul>
<p>== 必要な引数: 置換文字<br>
省略可能、String。<br>
デフォルトは、Unicode系ならU+FFFD、それ以外では「?」。<br>
デフォルトが空文字でない理由は、削除してしまうことで、従来は存在しなかったトークンを作れてしまい、<br>
上位のレイヤーの脆弱性に繋がるからです。<br>
<a href="http://unicode.org/reports/tr36/#UTF-8_Exploit" class="external">http://unicode.org/reports/tr36/#UTF-8_Exploit</a></p>
<p>== API<br>
--- str.encode(str.encoding, invalid: replace, [replace: "〓"])</p>
<ul>
<li>CSI的じゃなくて気持ち悪い</li>
<li>iconv でできるのは glibc iconv か GNU libiconv に //IGNORE つけた時で他はできない</li>
<li>実装上のメリットは後述の通り、直感に反してあまりない(と思う)</li>
</ul>
<p>== 別メソッド</p>
<ul>
<li>新しいメソッドである</li>
<li>fix/repair invalid/illegal bytes/sequence あたりの名前か</li>
</ul>
<p>== 実装<br>
=== 鬼車ベース<br>
int ret = rb_enc_precise_mbclen(p, e, enc); して、<br>
MBCLEN_INVALID_P(ret) が真な時、何バイト目が不正なのかわからないのが微妙。<br>
ONIGENC_CONSTRUCT_MBCLEN_INVALID() がバイト数を取らないのが原因なので、<br>
鬼車のエンコーディングモジュール全てに影響してしまうため、修正困難。<br>
不正なバイトはほとんど存在しないと仮定して、効率を犠牲にすれば回避は可能。</p>
<p>=== transcodeベース<br>
UCS正規化なglibc iconv, GNU libiconv, Perl Encodeなどと違って、<br>
CSIなtranscodeでは、自分自身に変換する場合、<br>
エンコーディングごとに「何もしない」変換モジュールを用意しないといけない。</p>
<p>とりあえず鬼車ベースのコンセプト実装とテストを添付しておきます。</p>
<p>diff --git a/string.c b/string.c<br>
index d038835..4808f15 100644<br>
--- a/string.c<br>
+++ b/string.c<br>
@@ -7426,6 +7426,199 @@ rb_str_ellipsize(VALUE str, long len)<br>
return ret;<br>
}</p>
<p>+/*</p>
<ul>
<li>
<ul>
<li>call-seq:</li>
</ul>
</li>
<li>
<ul>
<li>str.fix_invalid -> new_str</li>
</ul>
</li>
<li>
<ul>
<li>
</ul>
</li>
<li>
<ul>
<li>If the string is well-formed, it returns self.</li>
</ul>
</li>
<li>
<ul>
<li>If the string has invalid byte sequence, repair it with given replacement</li>
</ul>
</li>
<li>
<ul>
<li>character.</li>
</ul>
</li>
<li>*/<br>
+VALUE<br>
+rb_str_fix_invalid(VALUE str)<br>
+{</li>
<li>int cr = ENC_CODERANGE(str);</li>
<li>rb_encoding *enc;</li>
<li>if (cr == ENC_CODERANGE_7BIT || cr == ENC_CODERANGE_VALID)</li>
<li>return rb_str_dup(str);</li>
<li>
<li>enc = STR_ENC_GET(str);</li>
<li>if (rb_enc_asciicompat(enc)) {</li>
<li>const char *p = RSTRING_PTR(str);</li>
<li>const char *e = RSTRING_END(str);</li>
<li>const char *p1 = p;</li>
<li>/* 10 should be enough for the usual use case,</li>
<li>
<ul>
<li>fixing a wrongly chopped character at the end of the string</li>
</ul>
</li>
<li>*/</li>
<li>long room = 10;</li>
<li>VALUE buf = rb_str_buf_new(RSTRING_LEN(str) + room);</li>
<li>const char *rep;</li>
<li>if (enc == rb_utf8_encoding())</li>
<li>
<pre><code> rep = "\xEF\xBF\xBD";
</code></pre>
</li>
<li>else</li>
<li>
<pre><code> rep = "?";
</code></pre>
</li>
<li>cr = ENC_CODERANGE_7BIT;</li>
<li>
<li>p = search_nonascii(p, e);</li>
<li>if (!p) {</li>
<li>
<pre><code> p = e;
</code></pre>
</li>
<li>}</li>
<li>while (p < e) {</li>
<li>
<pre><code> int ret = rb_enc_precise_mbclen(p, e, enc);
</code></pre>
</li>
<li>
<pre><code> if (MBCLEN_CHARFOUND_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> if ((unsigned char)*p > 127) cr = ENC_CODERANGE_VALID;
</code></pre>
</li>
<li>
<pre><code> p += MBCLEN_CHARFOUND_LEN(ret);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_INVALID_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> const char *q;
</code></pre>
</li>
<li>
<pre><code> long clen = rb_enc_mbmaxlen(enc);
</code></pre>
</li>
<li>
<pre><code> if (p > p1) rb_str_buf_cat(buf, p1, p - p1);
</code></pre>
</li>
<li>
<pre><code> q = RSTRING_END(buf);
</code></pre>
</li>
<li>
<li>
<pre><code> if (e - p < clen) clen = e - p;
</code></pre>
</li>
<li>
<pre><code> if (clen < 3) {
</code></pre>
</li>
<li>
<pre><code> clen = 1;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> long len = RSTRING_LEN(buf);
</code></pre>
</li>
<li>
<pre><code> clen--;
</code></pre>
</li>
<li>
<pre><code> rb_str_buf_cat(buf, p, clen);
</code></pre>
</li>
<li>
<pre><code> for (; clen > 1; clen--) {
</code></pre>
</li>
<li>
<pre><code> ret = rb_enc_precise_mbclen(q, q + clen, enc);
</code></pre>
</li>
<li>
<pre><code> if (MBCLEN_NEEDMORE_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> break;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_INVALID_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> continue;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> rb_bug("shouldn't reach here '%s'", q);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> rb_str_set_len(buf, len);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> p += clen;
</code></pre>
</li>
<li>
<pre><code> p1 = p;
</code></pre>
</li>
<li>
<pre><code> rb_str_buf_cat2(buf, rep);
</code></pre>
</li>
<li>
<pre><code> p = search_nonascii(p, e);
</code></pre>
</li>
<li>
<pre><code> if (!p) {
</code></pre>
</li>
<li>
<pre><code> p = e;
</code></pre>
</li>
<li>
<pre><code> break;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_NEEDMORE_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> break;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> rb_bug("shouldn't reach here");
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>}</li>
<li>if (p1 < p) {</li>
<li>
<pre><code> rb_str_buf_cat(buf, p1, p - p1);
</code></pre>
</li>
<li>}</li>
<li>if (p < e) {</li>
<li>
<pre><code> rb_str_buf_cat2(buf, rep);
</code></pre>
</li>
<li>
<pre><code> cr = ENC_CODERANGE_VALID;
</code></pre>
</li>
<li>}</li>
<li>ENCODING_CODERANGE_SET(buf, rb_enc_to_index(enc), cr);</li>
<li>return buf;</li>
<li>}</li>
<li>else if (rb_enc_dummy_p(enc)) {</li>
<li>return rb_str_dup(str);</li>
<li>}</li>
<li>else {</li>
<li>/* ASCII incompatible */</li>
<li>const char *p = RSTRING_PTR(str);</li>
<li>const char *e = RSTRING_END(str);</li>
<li>const char *p1 = p;</li>
<li>/* 10 should be enough for the usual use case,</li>
<li>
<ul>
<li>fixing a wrongly chopped character at the end of the string</li>
</ul>
</li>
<li>*/</li>
<li>long room = 10;</li>
<li>VALUE buf = rb_str_buf_new(RSTRING_LEN(str) + room);</li>
<li>const char *rep;</li>
<li>long mbminlen = rb_enc_mbminlen(enc);</li>
<li>static rb_encoding *utf16be;</li>
<li>static rb_encoding *utf16le;</li>
<li>static rb_encoding *utf32be;</li>
<li>static rb_encoding *utf32le;</li>
<li>if (!utf16be) {</li>
<li>
<pre><code> utf16be = rb_enc_find("UTF-16BE");
</code></pre>
</li>
<li>
<pre><code> utf16le = rb_enc_find("UTF-16LE");
</code></pre>
</li>
<li>
<pre><code> utf32be = rb_enc_find("UTF-32BE");
</code></pre>
</li>
<li>
<pre><code> utf32le = rb_enc_find("UTF-32LE");
</code></pre>
</li>
<li>}</li>
<li>if (enc == utf16be) {</li>
<li>
<pre><code> rep = "\xFF\xFD";
</code></pre>
</li>
<li>}</li>
<li>else if (enc == utf16le) {</li>
<li>
<pre><code> rep = "\xFD\xFF";
</code></pre>
</li>
<li>}</li>
<li>else if (enc == utf32be) {</li>
<li>
<pre><code> rep = "\x00\x00\xFF\xFD";
</code></pre>
</li>
<li>}</li>
<li>else if (enc == utf32le) {</li>
<li>
<pre><code> rep = "\xFD\xFF\x00\x00";
</code></pre>
</li>
<li>}</li>
<li>else {</li>
<li>
<pre><code> rep = "?";
</code></pre>
</li>
<li>}</li>
<li>
<li>while (p < e) {</li>
<li>
<pre><code> int ret = rb_enc_precise_mbclen(p, e, enc);
</code></pre>
</li>
<li>
<pre><code> if (MBCLEN_CHARFOUND_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> p += MBCLEN_CHARFOUND_LEN(ret);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_INVALID_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> const char *q;
</code></pre>
</li>
<li>
<pre><code> long clen = rb_enc_mbmaxlen(enc);
</code></pre>
</li>
<li>
<pre><code> if (p > p1) rb_str_buf_cat(buf, p1, p - p1);
</code></pre>
</li>
<li>
<pre><code> q = RSTRING_END(buf);
</code></pre>
</li>
<li>
<li>
<pre><code> if (e - p < clen) clen = e - p;
</code></pre>
</li>
<li>
<pre><code> if (clen < mbminlen * 3) {
</code></pre>
</li>
<li>
<pre><code> clen = mbminlen;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> long len = RSTRING_LEN(buf);
</code></pre>
</li>
<li>
<pre><code> clen -= mbminlen;
</code></pre>
</li>
<li>
<pre><code> rb_str_buf_cat(buf, p, clen);
</code></pre>
</li>
<li>
<pre><code> for (; clen > mbminlen; clen-=mbminlen) {
</code></pre>
</li>
<li>
<pre><code> ret = rb_enc_precise_mbclen(q, q + clen, enc);
</code></pre>
</li>
<li>
<pre><code> if (MBCLEN_NEEDMORE_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> break;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_INVALID_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> continue;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> rb_bug("shouldn't reach here '%s'", q);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> rb_str_set_len(buf, len);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> p += clen;
</code></pre>
</li>
<li>
<pre><code> p1 = p;
</code></pre>
</li>
<li>
<pre><code> rb_str_buf_cat2(buf, rep);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (MBCLEN_NEEDMORE_P(ret)) {
</code></pre>
</li>
<li>
<pre><code> break;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else {
</code></pre>
</li>
<li>
<pre><code> rb_bug("shouldn't reach here");
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>}</li>
<li>if (p1 < p) {</li>
<li>
<pre><code> rb_str_buf_cat(buf, p1, p - p1);
</code></pre>
</li>
<li>}</li>
<li>if (p < e) {</li>
<li>
<pre><code> rb_str_buf_cat2(buf, rep);
</code></pre>
</li>
<li>}</li>
<li>ENCODING_CODERANGE_SET(buf, rb_enc_to_index(enc), ENC_CODERANGE_VALID);</li>
<li>return buf;</li>
<li>}<br>
+}</li>
<li>
</ul>
<p>/**********************************************************************</p>
<ul>
<li>Document-class: Symbol</li>
<li>
</ul>
<p>@@ -7882,6 +8075,7 @@ Init_String(void)<br>
rb_define_method(rb_cString, "getbyte", rb_str_getbyte, 1);<br>
rb_define_method(rb_cString, "setbyte", rb_str_setbyte, 2);<br>
rb_define_method(rb_cString, "byteslice", rb_str_byteslice, -1);</p>
<ul>
<li>
<p>rb_define_method(rb_cString, "fix_invalid", rb_str_fix_invalid, 0);</p>
<p>rb_define_method(rb_cString, "to_i", rb_str_to_i, -1);<br>
rb_define_method(rb_cString, "to_f", rb_str_to_f, 0);<br>
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb<br>
index 47f349c..2b0cfeb 100644<br>
--- a/test/ruby/test_string.rb<br>
+++ b/test/ruby/test_string.rb<br>
@@ -2031,6 +2031,29 @@ class TestString < Test::Unit::TestCase</p>
<p>assert_equal(u("\x82")+("\u3042"*9), ("\u3042"*10).byteslice(2, 28))<br>
end</p>
</li>
<li>
<li>
<p>def test_fix_invalid</p>
</li>
<li>
<p>assert_equal("\uFFFD\uFFFD\uFFFD", "\x80\x80\x80".fix_invalid)</p>
</li>
<li>
<p>assert_equal("\uFFFDA", "\xF4\x80\x80A".fix_invalid)</p>
</li>
<li>
<li>
<a name="exapmles-in-Unicode-610-D93b"></a>
<h1 >exapmles in Unicode 6.1.0 D93b<a href="#exapmles-in-Unicode-610-D93b" class="wiki-anchor">¶</a></h1>
</li>
<li>
<p>assert_equal("\x41\uFFFD\uFFFD\x41\uFFFD\x41",</p>
</li>
<li>
<pre><code> "\x41\xC0\xAF\x41\xF4\x80\x80\x41".fix_invalid)
</code></pre>
</li>
<li>
<p>assert_equal("\x41\uFFFD\uFFFD\uFFFD\x41",</p>
</li>
<li>
<pre><code> "\x41\xE0\x9F\x80\x41".fix_invalid)
</code></pre>
</li>
<li>
<p>assert_equal("\u0061\uFFFD\uFFFD\uFFFD\u0062\uFFFD\u0063\uFFFD\uFFFD\u0064",</p>
</li>
<li>
<pre><code> "\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64".fix_invalid)
</code></pre>
</li>
<li>
<li>
<p>assert_equal("abcdefghijklmnopqrstuvwxyz\u0061\uFFFD\uFFFD\uFFFD\u0062\uFFFD\u0063\uFFFD\uFFFD\u0064",</p>
</li>
<li>
<pre><code> "abcdefghijklmnopqrstuvwxyz\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64".fix_invalid)
</code></pre>
</li>
<li>
<li>
<p>assert_equal("\uFFFD\u3042".encode("UTF-16BE"),</p>
</li>
<li>
<pre><code> "\xD8\x00\x30\x42".force_encoding(Encoding::UTF_16BE).
</code></pre>
</li>
<li>
<pre><code> fix_invalid)
</code></pre>
</li>
<li>
<p>assert_equal("\uFFFD\u3042".encode("UTF-16LE"),</p>
</li>
<li>
<pre><code> "\x00\xD8\x42\x30".force_encoding(Encoding::UTF_16LE).
</code></pre>
</li>
<li>
<pre><code> fix_invalid)
</code></pre>
</li>
<li>
<p>end<br>
end</p>
</li>
</ul>
<p>class TestString2 < TestString<br>
=end</p>
Ruby master - Bug #6556 (Closed): ネストした配列の inspect で segv
https://redmine.ruby-lang.org/issues/6556
2012-06-08T00:36:42Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>./miniruby -e'10000.times.inject(x=[]){|a,|a<<(b=[]);b};x.inspect'<br>
で segv します。</p>
<p>% ./miniruby -e'10000.times.inject(x=[]){|a,|a<<(b=[]);b};x.inspect'|&less<br>
-e:1: [BUG] Segmentation fault<br>
ruby 2.0.0dev (2012-06-06 trunk 35950) [x86_64-freebsd9.0]</p>
<p>-- Control frame information -----------------------------------------------<br>
c:3116 p:---- s:6234 b:6234 l:006233 d:006233 CFUNC :inspect<br>
c:3115 p:---- s:6232 b:6232 l:006231 d:006231 CFUNC :inspect<br>
c:3114 p:---- s:6230 b:6230 l:006229 d:006229 CFUNC :inspect<br>
(中略)<br>
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :inspect<br>
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :inspect<br>
c:0003 p:0041 s:0007 b:0007 l:001458 d:002430 EVAL -e:1<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:0000 s:0002 b:0002 l:001458 d:001458 TOP</p>
<p>-e:1:in <code><main>' -e:1:in </code>inspect'<br>
-e:1:in <code>inspect' (中略) -e:1:in </code>inspect'<br>
-e:1:in `inspect'</p>
<p>-- C level backtrace information -------------------------------------------<br>
0x44c8bd <rb_warning+734> at /home/naruse/obj/ruby/miniruby ../../ruby/error.c:269<br>
0x44c9d8 <rb_bug+228> at /home/naruse/obj/ruby/miniruby ../../ruby/error.c:288<br>
0x518181 <ruby_posix_signal+352> at /home/naruse/obj/ruby/miniruby ../../ruby/signal.c:577<br>
0x800ca7723 <_pthread_sigmask+707> at /lib/libthr.so.3<br>
0x800ca7897 <_pthread_sigmask+1079> at /lib/libthr.so.3<br>
0x7ffffffff003</p>
<p>-- Other runtime information -----------------------------------------------</p>
<ul>
<li>
<p>Loaded script: -e</p>
</li>
<li>
<p>Loaded features:</p>
<p>0 enumerator.so</p>
</li>
</ul>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>zsh: abort (core dumped) ./miniruby -e'p 10000.times.inject(x=[]){|a,|a<<(b=[]);b};x.inspect'</p>
Ruby master - Bug #6405 (Closed): Re: [ruby-cvs:42717] ryan:r35541 (trunk): Imported minitest 2....
https://redmine.ruby-lang.org/issues/6405
2012-05-05T17:27:47Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>After r35541, test-all fails as following:</p>
<ol start="2">
<li>
<p>Error:<br>
test_equals_tilde(TestGemPlatform):<br>
TypeError: can't convert Gem::Platform to String<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/test/rubygems/test_gem_platform.rb:210:in <code>test_equals_tilde' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:633:in </code>block in _run_suites'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:631:in <code>each' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:631:in </code>_run_suites'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:21:in <code>run' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:682:in </code>run'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:714:in <code>run' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:718:in </code>run'<br>
./test/runner.rb:15:in `'</p>
</li>
<li>
<p>Error:<br>
test_dir(TestGemInstaller):<br>
TypeError: can't convert Regexp to String<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/test/rubygems/test_gem_installer.rb:1220:in <code>test_dir' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:633:in </code>block in _run_suites'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:631:in <code>each' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:631:in </code>_run_suites'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:21:in <code>run' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:682:in </code>run'<br>
/home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:714:in <code>run' /home/chkbuild/build/ruby-trunk/20120504T230101Z/ruby/lib/test/unit.rb:718:in </code>run'<br>
./test/runner.rb:15:in `'</p>
</li>
</ol>
<p>Why don't you run tests before commit.</p>
<p>(2012/05/05 6:46), <a href="mailto:ryan@ruby-lang.org" class="email">ryan@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>ryan 2012-05-05 06:46:01 +0900 (Sat, 05 May 2012)</p>
<p>New Revision: 35541</p>
<p><a href="http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35541" class="external">http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35541</a></p>
<p>Log:<br>
Imported minitest 2.12.1 (r7323)</p>
<p>Added files:<br>
trunk/test/minitest/metametameta.rb<br>
Modified files:<br>
trunk/ChangeLog<br>
trunk/lib/minitest/README.txt<br>
trunk/lib/minitest/autorun.rb<br>
trunk/lib/minitest/benchmark.rb<br>
trunk/lib/minitest/mock.rb<br>
trunk/lib/minitest/pride.rb<br>
trunk/lib/minitest/spec.rb<br>
trunk/lib/minitest/unit.rb<br>
trunk/test/minitest/test_minitest_benchmark.rb<br>
trunk/test/minitest/test_minitest_mock.rb<br>
trunk/test/minitest/test_minitest_spec.rb<br>
trunk/test/minitest/test_minitest_unit.rb</p>
</blockquote>
<p>--<br>
NARUSE, Yui <a href="mailto:naruse@airemix.jp" class="email">naruse@airemix.jp</a></p>
Ruby master - Bug #6272 (Closed): Rinda sticks on some tests
https://redmine.ruby-lang.org/issues/6272
2012-04-08T22:27:08Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Rindaが例えば以下のようにすると刺さります。</p>
<p>while [ yes ];do;make test-all TESTS='-v -n test_ruby_talk_264062 rinda/test_rinda.rb' RUBYOPT=-w;done</p>
<p>しばらく追ってみたところ、Rinda は Monitor#synchronize をすることで同期を守っているのですが、<br>
そのテストでは時刻を Rinda::MockClock で扱い、その中で Rinda::MockClock::MyTS を用いて時刻を配信しているのですが、<br>
この TupleSpace は複数のスレッドから触られるため、同一のスレッドからなら何度入ってもロックしない<br>
Monitor#synchronize でも、デッドロックしてしまうからっぽい気がします。</p>
Ruby master - Bug #6140 (Rejected): test
https://redmine.ruby-lang.org/issues/6140
2012-03-14T17:28:04Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Redmineを1.3.2にしたのでテスト</p>
Ruby master - Feature #5861 (Rejected): String#version_compare
https://redmine.ruby-lang.org/issues/5861
2012-01-08T07:54:53Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>バージョン番号っぽい文字列を比較するメソッド、String#version_compare を追加しませんか。<br>
"2.6.18".version_compare("2.6.3") #=> 1<br>
などと使います。</p>
<p>詳細な仕様は Gauche の gauche.version モジュールの version-compare 関数の仕様を丸パクリするのが良いと思います。<br>
提案している名前も Gauche そのままです。<br>
<a href="http://practical-scheme.net/gauche/man/gauche-refj_103.html" class="external">http://practical-scheme.net/gauche/man/gauche-refj_103.html</a></p>
<p>それなりにユースケースはある…というか今まさにテストを書いていて、<br>
Linux カーネルのバージョン番号を欲しくなったのですが、いかがでしょうか。</p>
Ruby master - Bug #5768 (Closed): TestRequire#test_race_exceptionで競合するケースがまだある
https://redmine.ruby-lang.org/issues/5768
2011-12-17T10:48:22Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>まだrequireで競合するケースが残っています。<br>
現在のテストだと確率的にしか起きませんが、以下の通り変更すると確実に起きるようになります。</p>
<p>diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb<br>
index 9186a6f..262a5ef 100644<br>
--- a/test/ruby/test_require.rb<br>
+++ b/test/ruby/test_require.rb<br>
@@ -352,7 +352,7 @@ class TestRequire < Test::Unit::TestCase<br>
TestRequire.scratch << :pre<br>
Thread.pass until t2 = TestRequire.scratch[1]<br>
Thread.pass until t2.stop?<br>
-open(<strong>FILE</strong>, "w") {|f| f.puts "TestRequire.scratch << :post"}<br>
+open(<strong>FILE</strong>, "w") {|f| f.puts "TestRequire.scratch << :post"; f.puts "t1,t2=TestRequire.scratch[1, 2];if Thread.current == t2; Thread.pass until t1.stopped?; end"}<br>
raise "con1"<br>
EOS<br>
tmp.close<br>
@@ -364,6 +364,7 @@ raise "con1"<br>
t2_res = nil</p>
<pre><code> t1 = Thread.new do
</code></pre>
<ul>
<li>
<pre><code> scratch << t1
begin
require(path)
rescue RuntimeError
</code></pre>
</li>
</ul>
<p>@@ -389,8 +390,8 @@ raise "con1"<br>
assert_nothing_raised(ThreadError, bug5754) {t1.join}<br>
assert_nothing_raised(ThreadError, bug5754) {t2.join}</p>
<ul>
<li>assert_equal(true, (t1_res ^ t2_res), bug5754)</li>
<li>assert_equal([:pre, t2, :post, :t2, :t1], scratch, bug5754)</li>
</ul>
<ul>
<li>assert_equal(true, (t1_res ^ t2_res), bug5754 + " t1:#{t1_res} t2:#{t2_res}")</li>
<li>assert_equal([:pre, t1, t2, :post, :t2, :t1], scratch, bug5754)<br>
ensure<br>
tmp.close(true) if tmp<br>
end</li>
</ul>
Ruby master - Bug #5691 (Closed): rb_path2class raises a NameError if a constant in the path exis...
https://redmine.ruby-lang.org/issues/5691
2011-11-30T22:21:39Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>An exception from rb_path2class differs on strange context.</p>
<p>% ./ruby -r./spec/rubyspec/optional/capi/ext/class_spec.so -e'CApiClassSpecs.new.rb_path2class("CApiClassSpecs::X")'<br>
-e:1:in <code>rb_path2class': undefined class/module CApiClassSpecs::X (ArgumentError) % ./ruby -r./spec/rubyspec/optional/capi/ext/class_spec.so -e'X=1;CApiClassSpecs.new.rb_path2class("CApiClassSpecs::X")' -e:1:in </code>rb_path2class': uninitialized constant CApiClassSpecs::X (NameError)</p>
Ruby master - Bug #5548 (Closed): OpenSSL::Engine can't load some old engines/new engines
https://redmine.ruby-lang.org/issues/5548
2011-11-02T11:20:11Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Current ext/openssl is missing a check for ENGINE_load_dynamic(),<br>
and doesn't have checks/functions for new engines.</p>
<p>diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb<br>
index 8d8cee3..8f13121 100644<br>
--- a/ext/openssl/extconf.rb<br>
+++ b/ext/openssl/extconf.rb<br>
@@ -118,6 +118,8 @@ if have_header("openssl/engine.h")<br>
have_func("ENGINE_get_digest")<br>
have_func("ENGINE_get_cipher")<br>
have_func("ENGINE_cleanup")<br>
+</p>
<ul>
<li>have_func("ENGINE_load_dynamic")<br>
have_func("ENGINE_load_4758cca")<br>
have_func("ENGINE_load_aep")<br>
have_func("ENGINE_load_atalla")<br>
@@ -126,6 +128,12 @@ if have_header("openssl/engine.h")<br>
have_func("ENGINE_load_nuron")<br>
have_func("ENGINE_load_sureware")<br>
have_func("ENGINE_load_ubsec")</li>
<li>have_func("ENGINE_load_padlock")</li>
<li>have_func("ENGINE_load_capi")</li>
<li>have_func("ENGINE_load_gmp")</li>
<li>have_func("ENGINE_load_gost")</li>
<li>have_func("ENGINE_load_cryptodev")</li>
<li>have_func("ENGINE_load_aesni")<br>
end<br>
have_func("DH_generate_parameters_ex")<br>
have_func("DSA_generate_parameters_ex")<br>
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c<br>
index 79f51b8..829680c 100644<br>
--- a/ext/openssl/ossl_engine.c<br>
+++ b/ext/openssl/ossl_engine.c<br>
@@ -64,29 +64,47 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)<br>
#if HAVE_ENGINE_LOAD_DYNAMIC<br>
OSSL_ENGINE_LOAD_IF_MATCH(dynamic);<br>
#endif<br>
-#if HAVE_ENGINE_LOAD_CSWIFT</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(cswift);<br>
+#if HAVE_ENGINE_LOAD_4758CCA</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(4758cca);<br>
#endif<br>
-#if HAVE_ENGINE_LOAD_CHIL</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(chil);<br>
+#if HAVE_ENGINE_LOAD_AEP</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(aep);<br>
#endif<br>
#if HAVE_ENGINE_LOAD_ATALLA<br>
OSSL_ENGINE_LOAD_IF_MATCH(atalla);<br>
#endif<br>
+#if HAVE_ENGINE_LOAD_CHIL</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(chil);<br>
+#endif<br>
+#if HAVE_ENGINE_LOAD_CSWIFT</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(cswift);<br>
+#endif<br>
#if HAVE_ENGINE_LOAD_NURON<br>
OSSL_ENGINE_LOAD_IF_MATCH(nuron);<br>
#endif<br>
+#if HAVE_ENGINE_LOAD_SUREWARE</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(sureware);<br>
+#endif<br>
#if HAVE_ENGINE_LOAD_UBSEC<br>
OSSL_ENGINE_LOAD_IF_MATCH(ubsec);<br>
#endif<br>
-#if HAVE_ENGINE_LOAD_AEP</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(aep);<br>
+#if HAVE_ENGINE_LOAD_PADLOCK</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(padlock);<br>
#endif<br>
-#if HAVE_ENGINE_LOAD_SUREWARE</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(sureware);<br>
+#if HAVE_ENGINE_LOAD_CAPI</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(capi);<br>
#endif<br>
-#if HAVE_ENGINE_LOAD_4758CCA</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(4758cca);<br>
+#if HAVE_ENGINE_LOAD_GMP</li>
</ul>
<ul>
<li>OSSL_ENGINE_LOAD_IF_MATCH(gmp);<br>
+#endif<br>
+#if HAVE_ENGINE_LOAD_GOST</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(gost);<br>
+#endif<br>
+#if HAVE_ENGINE_LOAD_CRYPTODEV</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(cryptodev);<br>
+#endif<br>
+#if HAVE_ENGINE_LOAD_AESNI</li>
<li>OSSL_ENGINE_LOAD_IF_MATCH(aesni);<br>
#endif<br>
#endif<br>
#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO</li>
</ul>
Ruby master - Bug #5526 (Closed): SEGV: ./ruby -rfiber -ve'f=Fiber.new{f.resume};f.transfer'
https://redmine.ruby-lang.org/issues/5526
2011-11-01T00:02:47Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>FreeBSD 9 にて、./ruby -rfiber -ve'f=Fiber.new{f.resume};f.transfer' で SEGV します。<br>
他のプラットフォームでも dead fiber call 例外なのはおかしくて、<br>
double resume 例外になるべきでしょう。</p>
Ruby master - Feature #5282 (Closed): test-all 結果の順序
https://redmine.ruby-lang.org/issues/5282
2011-09-06T20:21:56Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>現在 Failure と Error と Skip が混ざって結果が出てくるので、ソートして欲しい。</p>
<p>具体的な順番は、一瞬 Skip を最後にしたくなるのだが、通常 EF は数個でかつ末尾から見る訳なので、<br>
Skip Failure Error の順がよいのではなかろうか。</p>
<p>ついでに、一番最後に ruby -v を出力してくれるとうれしいです。</p>
Ruby master - Feature #5153 (Closed): Remove rb_add_suffix
https://redmine.ruby-lang.org/issues/5153
2011-08-03T12:11:46Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>rb_add_suffix in util.c is GPL and obsoleted code, so I want to remove it.</p>
<p>rb_add_suffix is drived from Perl's win32.c file and GPL/Artistic License.<br>
The code is used when ruby runs with -i (inplace option).<br>
Practically it works only when the renamed file can't create.<br>
(the validation is also a function of the code, but it is not essential)</p>
<p>But this behavior is Windows specific.<br>
On other environment, ruby simply skip the file with a warning "Can't rename %s to %s: %s, skipping file".<br>
I think Windows should follow this.</p>
Ruby master - Feature #5142 (Rejected): Remove ruby-mode.el from ruby's repo
https://redmine.ruby-lang.org/issues/5142
2011-08-02T10:46:33Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>ruby-mode.el は Emacs に添付されるようになりましたが、<br>
今も Ruby のリポジトリ内に misc/ruby-mode.el として存在し続けています。<br>
マスタが Ruby と Emacs の2つあるのも良くないですし、放置されているチケットも多いので、<br>
Ruby のリポジトリからは削除してしまいませんか。</p>
<p>なお、ruby-mode.el 以外の *.el についてはこのチケットの管轄外とします。</p>
Backport193 - Backport #5130 (Closed): Thread.pass sticks on OpenBSD
https://redmine.ruby-lang.org/issues/5130
2011-08-01T15:51:28Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
On OpenBSD 4.9, following script will stick.</p>
<p>./miniruby -ve'Thread.new{Thread.pass}'<br>
=end</p>
Ruby master - Bug #5114 (Closed): rake's tests imply the binary name of ruby
https://redmine.ruby-lang.org/issues/5114
2011-07-29T16:21:42Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>As Jeremy reported on <a href="/issues/5097">[ruby-core:38530]</a>, current rake tests imply the binary name of ruby as "ruby".<br>
They should use /#{Regexp.quote(RUBY)} -e/ as znz says on <a href="https://blade.ruby-lang.org/ruby-core/38579">[ruby-core:38579]</a>.</p>
Ruby master - Feature #5097 (Closed): Supported platforms of Ruby 1.9.3
https://redmine.ruby-lang.org/issues/5097
2011-07-26T11:52:57Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Let's decide the supported platforms.</p>
<p>== Background</p>
<p><a href="http://redmine.ruby-lang.org/projects/ruby-19/wiki/SupportedPlatforms" class="external">http://redmine.ruby-lang.org/projects/ruby-19/wiki/SupportedPlatforms</a></p>
<p>== Process</p>
<p>If you want to support a platform, please declare.<br>
But when a platform dependent bug is reported, it will be assigned to you.</p>
<p>== Current Maintainer</p>
<p>mswin32, mswin64 (Microsoft Windows):<br>
NAKAMURA Usaku (usa)<br>
mingw32 (Minimalist GNU for Windows):<br>
Nobuyoshi Nakada (nobu)<br>
IA-64 (Debian GNU/Linux):<br>
TAKANO Mitsuhiro (takano32)<br>
Symbian OS:<br>
Alexander Zavorine (azov)<br>
AIX:<br>
Yutaka Kanemoto (kanemoto)<br>
FreeBSD:<br>
Akinori MUSHA (knu)<br>
Solaris:<br>
Naohisa Goto<br>
RHEL, CentOS<br>
KOSAKI Motohiro</p>
<p>Platforms which doesn't have a maintainer are following:</p>
<ul>
<li>Debian</li>
<li>Ubuntu</li>
<li>Mac OS X (LLVM related issues)</li>
<li>cygwin (don't work)</li>
<li>NetBSD (works)</li>
<li>OpenBSD (it may not work)</li>
<li>DragonFlyBSD (don't work)</li>
</ul>
Ruby master - Bug #5094 (Closed): Supported platforms of Ruby 1.9.3
https://redmine.ruby-lang.org/issues/5094
2011-07-26T00:15:52Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>はい、リリース前恒例! サポートプラットフォーム決めのお時間がやって参りました。</p>
<p>前回は 1.9.1 リリース時だったわけですが、あれからずいぶんと経ったので、<br>
改めてサポートするプラットフォームを決めましょう。</p>
<p>== これまでのあらすじ</p>
<p><a href="http://redmine.ruby-lang.org/projects/ruby-19/wiki/SupportedPlatformsJa" class="external">http://redmine.ruby-lang.org/projects/ruby-19/wiki/SupportedPlatformsJa</a></p>
<p>== 決め方</p>
<p>サポートしたいプラットフォームがある方は宣言してください。<br>
ただし、当該プラットフォーム固有っぽいバグがあった場合、そのチケットをアサインする事があるので、<br>
覚悟を決めてから宣言してください。</p>
<p>いつでも「サポート終了!」は宣言できるので [要出典] お気軽にご応募くださいませ。</p>
<p>なお、1.9.3 のリリースのちょっと前あたりで一度締めとする予定です。</p>
<p>== 成瀬の提案</p>
<p>さて、前回のサポートプラットフォーム決めでいくつか反省があるので、ここに一つ提案を行います。</p>
<blockquote>
<p>なお、「メンテナがいる」とは明確なプラットフォームメンテナがいるもの(mswin32など)のほかに、「日々その環境でRubyを開発しているコミッタがいるもの」を含む。</p>
</blockquote>
<p>この後半を削ることを提案します。<br>
例として、Debian はいまだに lenny 32bit が対象になってしまっています。<br>
ようするに切るタイミングが決まらなかったという話で、<br>
こういうのはえいやで決める人がいるべきだろうと思うわけです。</p>
<p>== 現在のメンテナ</p>
<p>ちなみに現在のメンテナは以下の通りです。</p>
<p>mswin32, mswin64 (Microsoft Windows):<br>
NAKAMURA Usaku (usa)<br>
mingw32 (Minimalist GNU for Windows):<br>
Nobuyoshi Nakada (nobu)<br>
IA-64 (Debian GNU/Linux):<br>
TAKANO Mitsuhiro (takano32)<br>
Symbian OS:<br>
Alexander Zavorine (azov)<br>
AIX:<br>
Yutaka Kanemoto (kanemoto)<br>
FreeBSD:<br>
Akinori MUSHA (knu)<br>
Solaris:<br>
Naohisa Goto</p>
<p>逆にメンテナがいない主なプラットフォーム(と備考)は以下の通りです。</p>
<ul>
<li>Debian</li>
<li>Ubuntu</li>
<li>CentOS</li>
<li>Mac OS X (LLVM絡みが微妙)</li>
<li>cygwin (動かない)</li>
<li>NetBSD (動く)</li>
<li>OpenBSD (動かない気がする)</li>
<li>DragonFlyBSD (動かない)</li>
</ul>
Ruby master - Feature #4921 (Rejected): Remove intern.h
https://redmine.ruby-lang.org/issues/4921
2011-06-23T08:15:07Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>まず、intern.h って何者なんでしょう。<br>
推測としては internal の意だと思うんですが、その場合 include/ruby にいるのは<br>
よろしくないですし、一方で公開 API っぽいのが名実ともに多い気がします。</p>
<p>思うに 1.9 において、intern.h の中身は include/ruby/ruby.h か、<br>
最近新設された internal.h のどちらかにあるべきで、include/ruby/intern.h は<br>
もう必要ないのではないでしょうか。</p>
Ruby master - Bug #4815 (Closed): RubyGems test failed
https://redmine.ruby-lang.org/issues/4815
2011-06-02T12:04:59Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>Following tests are failed.<br>
This is because $LOAD_PATH includes the current directory which test-all is running,<br>
and top source directory of ruby has the directory named "missing".<br>
So test_execute_one_missing and test_execute_missing, they check the absence of "missing" directory, are failed.</p>
<ol start="29">
<li>
<p>Failure:<br>
test_execute_one_missing(TestGemCommandsWhichCommand) [/usr/home/chkbuild/build/ruby-trunk/20110602T010101Z/ruby/test/rubygems/test_gem_commands_which_command.rb:42]:<br>
--- expected<br>
+++ actual<br>
@@ -1,2 +1,3 @@<br>
"/usr/home/chkbuild/build/ruby-trunk/20110602T010101Z/tmp/test_rubygems_93491/gemhome/gems/foo_bar-2/lib/foo_bar.rb<br>
+/usr/home/chkbuild/build/ruby-trunk/20110602T010101Z/ruby/missing<br>
"</p>
</li>
<li>
<p>Failure:<br>
test_execute_missing(TestGemCommandsWhichCommand) [/usr/home/chkbuild/build/ruby-trunk/20110602T010101Z/ruby/test/rubygems/test_gem_commands_which_command.rb:51]:<br>
Gem::MockGemUi::TermError expected but nothing was raised.</p>
</li>
</ol>
Ruby master - Feature #4595 (Closed): TkPhotoImage documentation
https://redmine.ruby-lang.org/issues/4595
2011-04-22T12:12:22Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
以下のような pull request が来ています。</p>
<p>I have documented some method from TkPhotoImage, based on the original Tcl/Tk docs.</p>
<p><a href="https://github.com/ruby/ruby/pull/9" class="external">https://github.com/ruby/ruby/pull/9</a><br>
=end</p>
Ruby master - Bug #4455 (Closed): rubygem's test fails when source directory and build directory ...
https://redmine.ruby-lang.org/issues/4455
2011-03-01T23:12:35Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
In lib/rubygems/test_case.rb, it sets @project_dir as Dir.pwd.<br>
But the use cases of @project_dir are both top of source and build directory.<br>
It breaks when they differ.</p>
<p>This happens when:</p>
<p>cd $HOME<br>
mkdir bin-ruby<br>
svn co <a href="http://svn.ruby-lang.org/repos/ruby/trunk" class="external">http://svn.ruby-lang.org/repos/ruby/trunk</a> src-ruby<br>
cd ruby<br>
autoconf<br>
mkdir ../build-ruby<br>
cd ../build-ruby<br>
../ruby/configure --prefix=$HOME/bin-ruby<br>
make<br>
make install<br>
make test-all</p>
<p>The error messages are following:<br>
2) Failure:<br>
test_self_prefix(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:779]:<br>
Expected "/home/naruse/obj/ruby", not "/home/naruse/ruby".</p>
<ol start="3">
<li>
<p>Failure:<br>
test_self_prefix_libdir(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:786]:<br>
Expected "/home/naruse/ruby" to be nil.</p>
</li>
<li>
<p>Failure:<br>
test_self_find_files(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:655]:<br>
Expected ["/home/naruse/obj/ruby/test/rubygems/sff/discover.rb",<br>
"/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-2/lib/sff/discover.rb",<br>
"/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-1/lib/sff/discover.rb"], not ["/home/naruse/ruby/test/rubygems/sff/discover.rb",<br>
"/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-2/lib/sff/discover.rb",<br>
"/tmp/test-all/test_rubygems_56936/gemhome/gems/sff-1/lib/sff/discover.rb"].</p>
</li>
<li>
<p>Failure:<br>
test_self_prefix_sitelibdir(TestGem) [/home/naruse/ruby/test/rubygems/test_gem.rb:795]:<br>
Expected "/home/naruse/ruby" to be nil.</p>
</li>
<li>
<p>Error:<br>
test_execute_removes_executable(TestGemCommandsUninstallCommand):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:32:in `block (2 levels) in test_execute_removes_executable'
/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:31:in `block in test_execute_removes_executable'
/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:30:in `test_execute_removes_executable'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="7">
<li>
<p>Error:<br>
test_execute_prerelease(TestGemCommandsUninstallCommand):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/pre-2.b/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:100:in `block (2 levels) in test_execute_prerelease'
/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:99:in `block in test_execute_prerelease'
/home/naruse/ruby/test/rubygems/test_gem_commands_uninstall_command.rb:98:in `test_execute_prerelease'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="8">
<li>Error:<br>
test_class_build(TestGemExtRakeBuilder):<br>
Gem::InstallError: rake failed:</li>
</ol>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb</p>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/prefix RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/prefix<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:36:in `block (2 levels) in test_class_build'
/home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:34:in `chdir'
/home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:34:in `block in test_class_build'
/home/naruse/ruby/test/rubygems/test_gem_ext_rake_builder.rb:33:in `test_class_build'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="9">
<li>
<p>Error:<br>
test_install_ignore_dependencies(TestGemInstaller):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_installer.rb:698:in `block (2 levels) in test_install_ignore_dependencies'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:697:in `block in test_install_ignore_dependencies'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:696:in `test_install_ignore_dependencies'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="10">
<li>
<p>Error:<br>
test_install_with_no_prior_files(TestGemInstaller):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_installer.rb:594:in `block (2 levels) in test_install_with_no_prior_files'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:593:in `block in test_install_with_no_prior_files'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:592:in `test_install_with_no_prior_files'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="11">
<li>
<p>Error:<br>
test_install_check_dependencies_install_dir(TestGemInstaller):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2 for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome2/gems/a-2/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_installer.rb:673:in `block (2 levels) in test_install_check_dependencies_install_dir'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:672:in `block in test_install_check_dependencies_install_dir'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:671:in `test_install_check_dependencies_install_dir'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<ol start="12">
<li>
<p>Error:<br>
test_install(TestGemInstaller):<br>
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.</p>
<p>/home/naruse/obj/ruby/ruby mkrf_conf.rb --build_arg1 --build_arg2</p>
</li>
</ol>
<p>rake RUBYARCHDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib RUBYLIBDIR=/tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/lib<br>
/home/naruse/obj/ruby/rbconfig.rb:7: ruby lib version (1.9.3) doesn't match executable version (1.8.7) (RuntimeError)<br>
from /home/naruse/ruby/lib/rubygems.rb:36:in <code>require' from /home/naruse/ruby/lib/rubygems.rb:36 from /usr/local/bin/rake:9:in </code>require'<br>
from /usr/local/bin/rake:9</p>
<p>Gem files will remain installed in /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2 for inspection.<br>
Results logged to /tmp/test-all/test_rubygems_56936/gemhome/gems/a-2/ext/a/gem_make.out</p>
<pre><code>/home/naruse/ruby/test/rubygems/test_gem_installer.rb:560:in `block (2 levels) in test_install'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:559:in `block in test_install'
/home/naruse/ruby/test/rubygems/test_gem_installer.rb:558:in `test_install'
../../ruby/test/runner.rb:10:in `<main>'
</code></pre>
<p>=end</p>
Ruby master - Bug #4426 (Closed): rubygems/test_gem_gemcutter_utilities.rb fails
https://redmine.ruby-lang.org/issues/4426
2011-02-22T20:57:18Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
When run make RUBYOPT=-w TESTS='-v rubygems/test_gem_gemcutter_utilities.rb' test-all, it fails as following:</p>
<ol>
<li>
<p>Error:<br>
test_sign_in(TestGemGemcutterUtilities):<br>
NameError: uninitialized constant Gem::Command<br>
/home/naruse/ruby/test/rubygems/test_gem_gemcutter_utilities.rb:19:in `setup'</p>
</li>
<li>
<p>Error:<br>
test_sign_in_skips_with_existing_credentials(TestGemGemcutterUtilities):<br>
NameError: uninitialized constant Gem::Command<br>
/home/naruse/ruby/test/rubygems/test_gem_gemcutter_utilities.rb:19:in `setup'</p>
</li>
<li>
<p>Error:<br>
test_sign_in_with_bad_credentials(TestGemGemcutterUtilities):<br>
NameError: uninitialized constant Gem::Command<br>
/home/naruse/ruby/test/rubygems/test_gem_gemcutter_utilities.rb:19:in `setup'</p>
</li>
<li>
<p>Error:<br>
test_sign_in_with_host(TestGemGemcutterUtilities):<br>
NameError: uninitialized constant Gem::Command<br>
/home/naruse/ruby/test/rubygems/test_gem_gemcutter_utilities.rb:19:in `setup'</p>
</li>
<li>
<p>Error:<br>
test_sign_in_with_other_credentials_doesnt_overwrite_other_keys(TestGemGemcutterUtilities):<br>
NameError: uninitialized constant Gem::Command<br>
/home/naruse/ruby/test/rubygems/test_gem_gemcutter_utilities.rb:19:in `setup'<br>
=end</p>
</li>
</ol>
Ruby master - Bug #4376 (Closed): rdoc can't handle correctly the return value when the file has ...
https://redmine.ruby-lang.org/issues/4376
2011-02-07T13:11:12Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
From r30806 to r30813, make rdoc raises error on LANG=C environment like:<br>
<a href="http://59.106.172.211/~chkbuild/ruby-trunk/log/20110207T010100Z.log.html.gz" class="external">http://59.106.172.211/~chkbuild/ruby-trunk/log/20110207T010100Z.log.html.gz</a></p>
<p>This is because the encoding of output is set to US-ASCII, failed character<br>
encoding conversion on doc/re.rdoc, and wrongly treated nil as String.</p>
<p>The main bug is set to US-ASCII, so I fixed it in r30813.<br>
But nil treatment should be rdoc's bug, so I report this.</p>
<p>Generating RDoc documentation<br>
Parsing sources...<br>
unable to convert U+6771 from UTF-8 to US-ASCII for ../../ruby/doc/re.rdoc, skipping<br>
Before reporting this, could you check that the file you're documenting<br>
has proper syntax:</p>
<p>/home/naruse/local/ruby/bin/ruby -c ../../ruby/re.c</p>
<p>RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.</p>
<p>The internal error was:</p>
<pre><code> (NoMethodError) undefined method `sub' for nil:NilClass
</code></pre>
<p>/home/naruse/ruby/lib/rdoc/markup/pre_process.rb:126:in <code>include_file' /home/naruse/ruby/lib/rdoc/markup/pre_process.rb:76:in </code>block in handle'<br>
/home/naruse/ruby/lib/rdoc/markup/pre_process.rb:61:in <code>gsub!' /home/naruse/ruby/lib/rdoc/markup/pre_process.rb:61:in </code>handle'<br>
/home/naruse/ruby/lib/rdoc/parser/c.rb:867:in <code>look_for_directives_in' /home/naruse/ruby/lib/rdoc/parser/c.rb:516:in </code>find_class_comment'<br>
/home/naruse/ruby/lib/rdoc/parser/c.rb:687:in <code>handle_class_module' /home/naruse/ruby/lib/rdoc/parser/c.rb:204:in </code>block in do_classes'<br>
/home/naruse/ruby/lib/rdoc/parser/c.rb:199:in <code>scan' /home/naruse/ruby/lib/rdoc/parser/c.rb:199:in </code>do_classes'<br>
/home/naruse/ruby/lib/rdoc/parser/c.rb:987:in <code>scan' /home/naruse/ruby/lib/rdoc/rdoc.rb:322:in </code>parse_file'<br>
/home/naruse/ruby/lib/rdoc/rdoc.rb:367:in <code>block in parse_files' /home/naruse/ruby/lib/rdoc/rdoc.rb:365:in </code>map'<br>
/home/naruse/ruby/lib/rdoc/rdoc.rb:365:in <code>parse_files' /home/naruse/ruby/lib/rdoc/rdoc.rb:423:in </code>document'<br>
../../ruby/bin/rdoc:15:in <code><main>' uh-oh! RDoc had a problem: undefined method </code>sub' for nil:NilClass</p>
<p>run with --debug for full backtrace<br>
*** Error code 1</p>
<p>Stop in /home/naruse/obj/ruby.<br>
=end</p>
Backport187 - Backport #4171 (Closed): Warn Array#choice
https://redmine.ruby-lang.org/issues/4171
2010-12-19T18:26:40Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
Array#choice は Ruby 1.8.7 で入ったメソッドですが、1.9 ではなくなっているので、<br>
ruby_1_8 だけでなく、ruby_1_8_7 パッチリリースでも warning を出すようにしませんか。<br>
=end</p>
Ruby master - Bug #4163 (Closed): RubyGems uses deprecated API: YAML.quick_emit.
https://redmine.ruby-lang.org/issues/4163
2010-12-16T04:46:28Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
RubyGems::Specification#to_yaml uses depcrecated API: YAML.quick_emit,<br>
and it show many warnings on make test-all.<br>
/usr/home/chkbuild/build/ruby-trunk//ruby/lib/rubygems/specification.rb:706:in `to_yaml': YAML.quick_emit is deprecated<br>
=end</p>
Ruby master - Bug #4138 (Closed): Test Failure because of method redefined: test/irb/test_option.rb
https://redmine.ruby-lang.org/issues/4138
2010-12-09T03:51:04Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
test-all が以下のように失敗します。</p>
<ol start="2">
<li>Failure:<br>
test_end_of_option(TestIRB::TestOption) [/home/naruse/ruby/test/irb/test_option.rb:8]:<br>
<a href="/issues/4117">[ruby-core:33574]</a>.<br>
<[]> expected but was<br>
<["/home/naruse/ruby/lib/irb/ext/save-history.rb:29: warning: method redefined; discarding old save_history=",<br>
"/home/naruse/ruby/lib/irb/extend-command.rb:211: warning: previous definition of save_history= was here"]>.<br>
=end</li>
</ol>
Ruby master - Bug #4137 (Closed): Test Failure because of assigned but unused variable: ruby/test...
https://redmine.ruby-lang.org/issues/4137
2010-12-09T03:50:01Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
test-all が以下のように失敗します</p>
<ol start="3">
<li>Failure:<br>
test_shadowing_variable(TestRubyOptions) [/home/naruse/ruby/test/ruby/test_rubyoptions.rb:462]:<br>
<a href="/issues/4130">[ruby-dev:42718]</a>.<br>
<["-e:3: warning: shadowing outer local variable - a"]> expected but was<br>
<["-e:3: warning: shadowing outer local variable - a",<br>
"-e:3: warning: assigned but unused variable - a"]>.<br>
=end</li>
</ol>
Ruby master - Feature #3961 (Rejected): printfと精度指定と負の値と
https://redmine.ruby-lang.org/issues/3961
2010-10-18T18:01:01Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
printf が、フォーマットに精度指定しつつ負の値を与えた時の挙動が、<br>
Perl と必然性無く異なっていて不便です。</p>
<p>% ./ruby -e'printf("%#.8x", -1)'<br>
0x..ffffff</p>
<p>そもそもこの挙動は C 言語由来で、C の場合例えば以下の通りになります。</p>
<p>% cat test.c<br>
#include <stdio.h><br>
int main(void)<br>
{<br>
printf("%#x\n", -1);<br>
return 0;<br>
}<br>
% cc t.c && ./a.out<br>
0xffffffff</p>
<p>また、おそらく直接参考にしたであろう Perl では以下の通りです、<br>
% perl -e'printf("%#x",-1)'<br>
0xffffffffffffffff<br>
% perl -e'printf("%#.30x",-1)'<br>
0x00000000000000ffffffffffffffff<br>
つまり、Perl (の 64bit int 版) では、64bitで補数を取っています。</p>
<p>さて、Ruby の場合多倍長整数が組み込みなため、補数を取ると無限に続いてしまうから、<br>
% ./ruby -e'printf("%#x",-1)'<br>
0x..f<br>
と .. で略すのは理にかなっていると思います。</p>
<p>しかし、現在の Ruby は精度を指定した際にも..がついてしまうので、<br>
Perl のような動きを実現させる事ができません。<br>
% ./ruby -e'printf("%#.8x",-1)'<br>
0x..ffffff<br>
で、この .. っていらないと思うんです。</p>
<p>例えば浮動小数点数の場合には以下のように .. とか付けずにぶった切る訳で、<br>
無限大方向と無限小方向という違いはあれど、<br>
「Perlとかと同じ挙動にできない」というデメリットの方が大きいのではないでしょうか。<br>
% ./ruby -e'printf("%#.8f",10.0/3)'<br>
3.33333333</p>
<p>わたしの場合、CRuby 側の inspect が printf("%x", negative_value) などとしている部分の動作を<br>
RubySpec で Ruby で書く時に頭を抱えてしまいました。</p>
<p>というわけでパッチは例えば以下の通りです。</p>
<p>diff --git a/sprintf.c b/sprintf.c<br>
index 21509ea..0e97955 100644<br>
--- a/sprintf.c<br>
+++ b/sprintf.c<br>
@@ -844,7 +844,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)<br>
}<br>
else {<br>
s = nbuf;</p>
<ul>
<li>
<pre><code> if (v < 0) {
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> if (v < 0 && !(flags & FPREC0)) {
dots = 1;
}
snprintf(fbuf, sizeof(fbuf), "%%l%c", *p == 'X' ? 'x' : *p);
</code></pre>
</li>
</ul>
<p>@@ -892,7 +892,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)<br>
tmp1 = tmp = rb_big2str0(val, base, RBIGNUM_SIGN(val));<br>
s = RSTRING_PTR(tmp);<br>
if (*s == '-') {</p>
<ul>
<li>
<pre><code> dots = 1;
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> if (!(flags & FPREC0))
</code></pre>
</li>
<li>
<pre><code> dots = 1;
if (base == 10) {
rb_warning("negative number for %%u specifier");
}
</code></pre>
</li>
</ul>
<p>@@ -925,14 +926,11 @@ rb_str_format(int argc, const VALUE <em>argv, VALUE fmt)<br>
}<br>
}<br>
if (prefix && !prefix[1]) { /</em> octal */</p>
<ul>
<li>
<pre><code> if (dots) {
</code></pre>
</li>
<li>
<pre><code> prefix = 0;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> else if (len == 1 && *s == '0') {
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> if (len == 1 && *s == '0') {
len = 0;
if (flags & FPREC) prec--;
}
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> else if ((flags & FPREC) && (prec > len)) {
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> else if ((flags & FPREC) && (prec > len) && v >= 0) {
prefix = 0;
}
}
</code></pre>
</li>
</ul>
<p>diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb<br>
index 96a1b62..24b6a34 100644<br>
--- a/test/ruby/test_sprintf.rb<br>
+++ b/test/ruby/test_sprintf.rb<br>
@@ -24,12 +24,12 @@ class TestSprintf < Test::Unit::TestCase<br>
assert_equal("0000", sprintf("%.4b", 0))<br>
assert_equal("0001", sprintf("%.4b", 1))<br>
assert_equal("0010", sprintf("%.4b", 2))</p>
<ul>
<li>assert_equal("..11", sprintf("%.4b", -1))</li>
</ul>
<ul>
<li>
<p>assert_equal("1111", sprintf("%.4b", -1))</p>
<p>assert_equal(" 0000", sprintf("%6.4b", 0))<br>
assert_equal(" 0001", sprintf("%6.4b", 1))<br>
assert_equal(" 0010", sprintf("%6.4b", 2))</p>
</li>
</ul>
<ul>
<li>assert_equal(" ..11", sprintf("%6.4b", -1))</li>
</ul>
<ul>
<li>
<p>assert_equal(" 1111", sprintf("%6.4b", -1))</p>
<p>assert_equal(" 0", sprintf("%#4b", 0))<br>
assert_equal(" 0b1", sprintf("%#4b", 1))<br>
@@ -44,12 +44,12 @@ class TestSprintf < Test::Unit::TestCase<br>
assert_equal("0000", sprintf("%#.4b", 0))<br>
assert_equal("0b0001", sprintf("%#.4b", 1))<br>
assert_equal("0b0010", sprintf("%#.4b", 2))</p>
</li>
</ul>
<ul>
<li>assert_equal("0b..11", sprintf("%#.4b", -1))</li>
</ul>
<ul>
<li>
<p>assert_equal("0b1111", sprintf("%#.4b", -1))</p>
<p>assert_equal(" 0000", sprintf("%#6.4b", 0))<br>
assert_equal("0b0001", sprintf("%#6.4b", 1))<br>
assert_equal("0b0010", sprintf("%#6.4b", 2))</p>
</li>
</ul>
<ul>
<li>assert_equal("0b..11", sprintf("%#6.4b", -1))</li>
</ul>
<ul>
<li>
<p>assert_equal("0b1111", sprintf("%#6.4b", -1))</p>
<p>assert_equal("+0", sprintf("%+b", 0))<br>
assert_equal("+1", sprintf("%+b", 1))<br>
@@ -288,6 +288,8 @@ class TestSprintf < Test::Unit::TestCase<br>
b1 = (/../ =~ s1) != nil<br>
b2 = (/../ =~ s2) != nil<br>
assert(b1 == b2, "<a href="https://blade.ruby-lang.org/ruby-dev/33224">[ruby-dev:33224]</a>")</p>
</li>
<li>
<li>
<p>assert_equal("ffffffff", sprintf("%.8x", -1))<br>
end</p>
</li>
</ul>
<pre><code>def test_named
</code></pre>
<p>diff --git a/test/ruby/test_sprintf_comb.rb b/test/ruby/test_sprintf_comb.rb<br>
index 261732b..3105127 100644<br>
--- a/test/ruby/test_sprintf_comb.rb<br>
+++ b/test/ruby/test_sprintf_comb.rb<br>
@@ -190,7 +190,7 @@ class TestSprintfComb < Test::Unit::TestCase<br>
if digits.last != radix-1<br>
digits << (radix-1)<br>
end</p>
<ul>
<li>
<pre><code> sign = '..'
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> sign = '..' unless precision
else
sign = '-'
end
</code></pre>
</li>
</ul>
<p>@@ -222,8 +222,8 @@ class TestSprintfComb < Test::Unit::TestCase<br>
end<br>
end<br>
if type == 'o' && hs</p>
<ul>
<li>
<pre><code> if digits.empty? || digits.last != d
</code></pre>
</li>
<li>
<pre><code> digits << d
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> if digits.empty? || digits.last != 0
</code></pre>
</li>
<li>
<pre><code> prefix = '0'
end
</code></pre>
end<br>
=end</li>
</ul>
Ruby master - Bug #3816 (Closed): OpenSSL::BN#prime?の引数の取り扱いがおかしい
https://redmine.ruby-lang.org/issues/3816
2010-09-10T16:20:29Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
OpenSSL::BN#prime?を引数なしで呼ぶと以下の通り例外が出ます。</p>
<p>irb(main):001:0> require'openssl'=> trueirb(main):002:0> OpenSSL::BN.new("461166461445805738999").prime?<br>
TypeError: no implicit conversion from nil to integer<br>
from (irb):2:in <code>prime?' from (irb):2 from /home/naruse/local/ruby_1_9_2/bin/irb:12:in </code>'</p>
<p>コードを見るに、rb_scan_args の引数との比較が誤っているように見えるので、引数ありでもおかしいでしょう。<br>
以下の変更で直ります。</p>
<p>diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c<br>
index bec5135..6adc59f 100644<br>
--- a/ext/openssl/ossl_bn.c<br>
+++ b/ext/openssl/ossl_bn.c<br>
@@ -669,7 +669,7 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)<br>
VALUE vchecks;<br>
int checks = BN_prime_checks;</p>
<ul>
<li>if (rb_scan_args(argc, argv, "01", &vchecks) == 0) {</li>
</ul>
<ul>
<li>if (rb_scan_args(argc, argv, "01", &vchecks) == 1) {<br>
checks = NUM2INT(vchecks);<br>
}<br>
GetBN(self, bn);<br>
=end</li>
</ul>
Ruby master - Bug #3673 (Closed): PTY.getpty with IO.pipe doesn't finish on FreeBSD
https://redmine.ruby-lang.org/issues/3673
2010-08-10T10:53:16Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
以下のプログラムが FreeBSD で終了しません。<br>
(test/ruby/test_rubyoptions.rb の test_script_from_stdin より)<br>
Ubuntu 8.04 や Mac OS X 10.6 では終わることを確認しています。</p>
<p>require 'pty'<br>
#require 'timeout'<br>
s, w = IO.pipe<br>
PTY.getpty('./ruby', out: w) do |r, m|<br>
w.close<br>
#m.print("print 'abc'\n")<br>
m.print("\C-d")<br>
p s.read</p>
<a name="result-Timeouttimeout3-sread"></a>
<h1 >result = Timeout.timeout(3) {s.read}<a href="#result-Timeouttimeout3-sread" class="wiki-anchor">¶</a></h1>
<p>end<br>
puts :fin<br>
=end</p>
Ruby master - Bug #3672 (Closed): PTY.getpty with non exist program
https://redmine.ruby-lang.org/issues/3672
2010-08-10T10:48:52Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
存在しないプログラムを指定して PTY.getpty を呼ぶと [BUG] になります。<br>
PTY.getpty 側での対処と rb_fork_err 側での対処がありえますが、<br>
とりあえず後者側でも対処が必要でしょう。</p>
<p>% ./ruby -rpty -e'PTY.getpty"a"'<br>
-e:1: [BUG] rb_sys_fail(fork failed) - errno == 0<br>
ruby 1.9.3dev (2010-08-09 trunk 28938) [x86_64-freebsd8.1]</p>
<h2>-- control frame ----------<br>
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :getpty<br>
c:0003 p:0017 s:0006 b:0006 l:0024b8 d:0010e8 EVAL -e:1<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:0000 s:0002 b:0002 l:0024b8 d:0024b8 TOP</h2>
<p>-- Ruby level backtrace information ----------------------------------------<br>
-e:1:in <code><main>' -e:1:in </code>getpty'</p>
<p>[NOTE]<br>
You may have encountered a bug in the Ruby interpreter or extension libraries.<br>
Bug reports are welcome.<br>
For details: <a href="http://www.ruby-lang.org/bugreport.html" class="external">http://www.ruby-lang.org/bugreport.html</a></p>
<p>zsh: abort (core dumped) ./ruby -rpty -e'PTY.getpty"a"'<br>
=end</p>
Ruby master - Feature #3036 (Closed): String#encode(to, from, opt) の opt[:replace] に Hash
https://redmine.ruby-lang.org/issues/3036
2010-03-29T16:11:29Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
<a href="https://blade.ruby-lang.org/ruby-dev/40540">[ruby-dev:40540]</a> の String#encode(to, from, opt) の opt[:replace] に Hash の話を、<br>
別にチケットとして起こしておきます</p>
<p>String#encode(to, from, opt) の opt[:replace] に Hash を与えられるようにして、<br>
そこに、変換元 encoding の文字 => 変換先の文字、という未定義文字の fallback 変換表を与えられるようにする、<br>
というものを今考えています。<br>
これだと例えば、<br>
fallbacks = {<br>
?¥uE6AD => "[ふくろ]",<br>
?¥u{1F4BA} => "[いす]"<br>
}<br>
"¥u{3042 E6AD 1F4BA}".encode("UTF8-KDDI", replace: fallbacks) #=> "あ[ふくろ][いす]"<br>
=end</p>
Ruby master - Feature #2969 (Closed): String#to_f が -h.hhh±pd を解釈できるように
https://redmine.ruby-lang.org/issues/2969
2010-03-16T04:01:03Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
C99 の printf には a という指定子があります。</p>
<pre><code> aA The argument is printed in style ‘[-h.hhh±pd]’ where there is
one digit before the hexadecimal point and the number after
is equal to the precision specification for the argument;
when the precision is missing, enough digits are produced to
convey the argument's exact double-precision floating-point
representation. The values ∞ and NaN are printed as ‘inf’
and ‘nan’, respectively.
</code></pre>
<p>これを使うと、以下のような形で整形されます。<br>
-0.0 #=> "-0x0p+0"<br>
729.0/10 #=> "0x1.239999999999ap+6"<br>
Math.log(3) #=> "0x1.193ea7aad030ap+0"<br>
Math.exp(100) #=> "0x1.3494a9b171bf5p+144"</p>
<p>この形式の利点は、複雑な浮動小数点数を比較的少ない文字数で正確に表せることと、<br>
仮数部が16進であるため丸めが起きていることを説明する際に便利な点が挙げられます。</p>
<p>で、この形式を使っているのですが、RubyのString#to_f で解釈してくれず悲しくなるので、<br>
解釈できるようにしませんか。<br>
パッチは以下の通りです。</p>
<p>diff --git a/util.c b/util.c<br>
index 5ebc5f3..e361d51 100644<br>
--- a/util.c<br>
+++ b/util.c<br>
@@ -2106,6 +2106,44 @@ ruby_strtod(const char *s00, char **se)<br>
}<br>
break2:<br>
if (*s == '0') {</p>
<ul>
<li>
<pre><code> if (s[1] == 'x') {
</code></pre>
</li>
<li>
<pre><code> static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
</code></pre>
</li>
<li>
<pre><code> s0 = ++s;
</code></pre>
</li>
<li>
<pre><code> adj = 0;
</code></pre>
</li>
<li>
<li>
<pre><code> while (*++s && (s1 = strchr(hexdigit, *s))) {
</code></pre>
</li>
<li>
<pre><code> adj *= 16;
</code></pre>
</li>
<li>
<pre><code> adj += (s1 - hexdigit) & 15;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<li>
<pre><code> if (*s == '.') {
</code></pre>
</li>
<li>
<pre><code> aadj = 1.;
</code></pre>
</li>
<li>
<pre><code> while (*++s && (s1 = strchr(hexdigit, *s))) {
</code></pre>
</li>
<li>
<pre><code> aadj /= 16;
</code></pre>
</li>
<li>
<pre><code> adj += aadj * ((s1 - hexdigit) & 15);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<li>
<pre><code> if (*s != 'p') {
</code></pre>
</li>
<li>
<pre><code> s = s0;
</code></pre>
</li>
<li>
<pre><code> goto ret;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<li>
<pre><code> dsign = 0x2C - *++s; /* +: 2B, -: 2D */
</code></pre>
</li>
<li>
<pre><code> if (abs(dsign) != 1) {
</code></pre>
</li>
<li>
<pre><code> s = s0;
</code></pre>
</li>
<li>
<pre><code> goto ret;
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<li>
<pre><code> for (nd = 0, s++; (c = *s) >= '0' && c <= '9'; s++) {
</code></pre>
</li>
<li>
<pre><code> nd *= 10;
</code></pre>
</li>
<li>
<pre><code> nd += c;
</code></pre>
</li>
<li>
<pre><code> nd -= '0';
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<li>
<pre><code> dval(rv) = ldexp(adj, nd * dsign);
</code></pre>
</li>
<li>
<pre><code> goto ret;
</code></pre>
</li>
<li>
<pre><code> }
nz0 = 1;
while (*++s == '0') ;
if (!*s)
</code></pre>
</li>
</ul>
<p>diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb<br>
index 64205f6..72d3242 100644<br>
--- a/test/ruby/test_string.rb<br>
+++ b/test/ruby/test_string.rb<br>
@@ -1381,10 +1381,24 @@ class TestString < Test::Unit::TestCase<br>
end</p>
<pre><code>def test_to_f
</code></pre>
<ul>
<li>assert_equal(0.0, S("0.0").to_f)</li>
<li>assert_equal(?0, S("0.0").to_f.to_s[0])</li>
<li>assert_equal(-0.0, S("-0.0").to_f)</li>
<li>assert_equal(?-, S("-0.0").to_f.to_s[0])<br>
assert_equal(344.3, S("344.3").to_f)<br>
assert_equal(5.9742e24, S("5.9742e24").to_f)<br>
assert_equal(98.6, S("98.6 degrees").to_f)<br>
assert_equal(0.0, S("degrees 100.0").to_f)</li>
<li>assert_equal(0.0, S("0x0p+0").to_f)</li>
<li>assert_equal(?0, S("0x0p+0").to_f.to_s[0])</li>
<li>assert_equal(-0.0, S("-0x0p+0").to_f)</li>
<li>assert_equal(?-, S("-0x0p+0").to_f.to_s[0])</li>
<li>assert_equal(1.0, S("0x1p+0").to_f)</li>
<li>assert_equal(?1, S("0x1p+0").to_f.to_s[0])</li>
<li>assert_equal(1024.0, S("0x1p+10").to_f)</li>
<li>assert_equal(0.0009765625, S("0x1p-10").to_f)</li>
<li>assert_equal(2.6881171418161356e+43, S("0x1.3494a9b171bf5p+144").to_f)</li>
<li>assert_equal(-3.720075976020836e-44, S("-0x1.a8c1f14e2af5dp-145").to_f)<br>
end</li>
</ul>
<pre><code>def test_to_i
</code></pre>
<p>=end</p>
Ruby master - Feature #2968 (Rejected): 数値の正負を返すメソッド
https://redmine.ruby-lang.org/issues/2968
2010-03-16T03:38:54Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
数値の正負を返すメソッドが欲しいです。<br>
主たる想定用途は 0.0 と -0.0 を区別したいときです。<br>
これは、0.0 > -0.0 や 0.0 == -0.0 では知ることができません。<br>
とりあえず flo.to_s[0] == ?- で知ることができますが、これではあんまりです。</p>
<p>悩みどころはいつもの通りメソッド名ですが、</p>
<ul>
<li>Numeric#positive? と Numeric#negative?</li>
<li>Numeric#sign -> 負で -1、正で 1</li>
<li>Numeric#sign? -> 負で true, 正で false (signbit(3) に習う)<br>
あたりでしょうか。</li>
</ul>
<p>いかがでしょう。<br>
=end</p>
Ruby master - Feature #2835 (Closed): String#encodeに置換文字列のみを与えたら未定義向けとみなす
https://redmine.ruby-lang.org/issues/2835
2010-03-03T21:53:11Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
Ruby 1.9 もおおむね完成してからそろそろ 3 年が経つのですが、<br>
気付いた事として、String#encode(to, from, opt) の opt に :replace を指定した時は、<br>
ほとんどの場合 :undef => :replace も指定するという事があります。</p>
<p>よくよく考えれば、不正なバイト列を続行したいという事は少ないし、推奨されず、<br>
ゆえに置換文字列を指定する場合はたいてい未定義文字を置き換えたい場合な訳です。</p>
<p>以下のパッチは、:invalid => :replace がしているされている場合以外に、<br>
(つまり、不正なバイト列向けに置換文字列が指定されている可能性がある場合以外)<br>
置換文字列を指定している場合、:undef => :replace とみなします。</p>
<p>想定ケースでは :undef => :replace と書かなくてすむので楽な上に、<br>
楽な方法に誘導する事で、よく考えずに {:invalid => :replace, :undef => :replace}<br>
と書いてしまう人を減らせるので一石二鳥だと思うのですが、いかがでしょう。</p>
<p>diff --git a/transcode.c b/transcode.c<br>
index d511547..9d6a886 100644<br>
--- a/transcode.c<br>
+++ b/transcode.c<br>
@@ -2394,6 +2394,11 @@ econv_opts(VALUE opt)<br>
rb_raise(rb_eArgError, "unknown value for undefined character option");<br>
}</p>
<ul>
<li>v = rb_hash_aref(opt, sym_replace);</li>
<li>if (!NIL_P(v) && !(ecflags & ECONV_INVALID_REPLACE)) {</li>
<li>
<pre><code> ecflags |= ECONV_UNDEF_REPLACE;
</code></pre>
</li>
<li>}</li>
<li>v = rb_hash_aref(opt, sym_xml);<br>
if (!NIL_P(v)) {<br>
if (v==sym_text) {<br>
=end</li>
</ul>
Ruby 1.8 - Bug #2761 (Closed): weird behaviour of readline on OSX 10.6
https://redmine.ruby-lang.org/issues/2761
2010-02-19T05:36:42Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
Hi,</p>
<p>You seems to use Ruby 1.8.x.<br>
So can you try following?</p>
<a name="Index-extreadlinereadlinec"></a>
<h1 >Index: ext/readline/readline.c<a href="#Index-extreadlinereadlinec" class="wiki-anchor">¶</a></h1>
<p>--- ext/readline/readline.c (revision 26664)<br>
+++ ext/readline/readline.c (working copy)<br>
@@ -833,6 +833,12 @@<br>
#ifdef HAVE_RL_EVENT_HOOK<br>
rl_event_hook = readline_event;<br>
#endif<br>
+#ifdef HAVE_RL_CATCH_SIGNALS</p>
<ul>
<li>rl_catch_signals = 0;<br>
+#endif<br>
+#ifdef HAVE_RL_CATCH_SIGWINCH</li>
<li>rl_catch_sigwinch = 0;<br>
+#endif<br>
#ifdef HAVE_RL_CLEAR_SIGNALS<br>
rl_clear_signals();<br>
#endif<br>
Index: ext/readline/extconf.rb<br>
===================================================================<br>
--- ext/readline/extconf.rb (revision 26664)<br>
+++ ext/readline/extconf.rb (working copy)<br>
@@ -59,6 +59,9 @@<br>
have_readline_var("rl_attempted_completion_over")<br>
have_readline_var("rl_library_version")<br>
have_readline_var("rl_event_hook")<br>
+# workaround for native windows.<br>
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_sigwinch")<br>
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && have_readline_var("rl_catch_signals")<br>
have_readline_func("rl_cleanup_after_signal")<br>
have_readline_func("rl_clear_signals")<br>
have_readline_func("rl_vi_editing_mode")</li>
</ul>
<p>(2010/02/19 4:59), Andrew Eberbach wrote:</p>
<blockquote>
<p>Hi</p>
<p>I've been noticing that irb (and as a result script/console in rails)<br>
don't behave correctly with Control C. Nothing would happen when I hit<br>
control C until I hit enter or a few more keys and then it would clear<br>
the line and show a ^C and reset to the prompt. This doesn't happen on<br>
Linux and it didn't happen on 10.5</p>
<p>If there's a long running process in irb hitting control c works as<br>
expected but not if it's just sitting at a prompt.</p>
<p>I played around with the ext/readline.c and found that if I put a</p>
<p>rl_catch_signals = 0;</p>
<p>(see <a href="http://tiswww.case.edu/php/chet/readline/readline.html" class="external">http://tiswww.case.edu/php/chet/readline/readline.html</a>)</p>
<p>in Init_readline()</p>
<p>Then everything works as normal. Should this be added as a patch?<br>
Reading the readline docs it seems to me that what's happening is the<br>
internal readline handler gets stuck sending SIGINT back to the ruby<br>
process even though there's a trap("SIGINT") defined. Any ideas?</p>
<p>Andrew</p>
</blockquote>
<p>--<br>
NARUSE, Yui <a href="mailto:naruse@airemix.jp" class="email">naruse@airemix.jp</a><br>
=end</p>
Ruby master - Feature #2635 (Rejected): Unbundle rdoc
https://redmine.ruby-lang.org/issues/2635
2010-01-23T23:20:56Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
The rdoc in trunk is outdated and not maintained,<br>
and latest rdoc is in gen.</p>
<p>I think Ruby 1.9 shouldn't bundle such old rdoc.<br>
People who needs rdoc should install from gem.<br>
=end</p>
Ruby master - Feature #2586 (Rejected): openssl: Load root certificates on Windows
https://redmine.ruby-lang.org/issues/2586
2010-01-10T15:27:08Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
On Unix, ext/openssl can use the system's root certificates.<br>
But on Windows root certificates are not provided as files.</p>
<p>By this patch, OpenSSL::X509::Store#set_default_paths can load<br>
root certificates bundled with Windows.<br>
=end</p>
Backport191 - Backport #2477 (Closed): String#split should be ASCII sensitive
https://redmine.ruby-lang.org/issues/2477
2009-12-14T15:51:40Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
If r24544 is backported, r24934 is also worth backported.</p>
<p>Author: naruse <a href="mailto:naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e" class="email">naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</a><br>
Date: Tue Sep 15 05:27:29 2009 +0000</p>
<pre><code> Use rb_isspace for ASCII-incompatible strings.
* string.c (rb_str_split_m): use rb_isspace when the string
may be ASCII-incompatible.
(rb_str_lstrip_bang): ditto.
(rb_str_rstrip_bang): ditto.
</code></pre>
<p>=end</p>
Ruby master - Feature #2454 (Rejected): OpenSSL has no maintainer
https://redmine.ruby-lang.org/issues/2454
2009-12-08T00:54:31Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
OpenSSL is famous security library and Ruby has a wrapper for it.<br>
But it has no maintainer now.<br>
We, aren't familiar with this security related library, don't want maintain this.<br>
This situation prevent merging path for OpenSSL 1.0 and other requests.</p>
<p>So anyone can maintain ext/openssl or review patches for ext/openssl?<br>
=end</p>
Ruby master - Bug #2386 (Closed): r25230 causes SEGV arround Marshal
https://redmine.ruby-lang.org/issues/2386
2009-11-20T07:54:42Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
以下のコミット以降、後述の現象が発生するそうです。</p>
<p>Author: nobu <a href="mailto:nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e" class="email">nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</a><br>
Date: Sun Oct 4 10:30:56 2009 +0000</p>
<pre><code>* marshal.c (struct {dump,load}_arg): manage with dfree, instead
of using local variable which may be moved by context switch.
<a href="https://blade.ruby-lang.org/ruby-dev/39425">[ruby-dev:39425]</a>
</code></pre>
<p><a href="http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25230" class="external">http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25230</a></p>
<hr>
<p>けいじゅ@いしつかです.</p>
<p>最新版のrubyで以下のメッセージが出るようになってしまったのですが, これ<br>
はどのような意味でしょうか?</p>
<p>% ruby -v<br>
ruby 1.9.2dev (2009-11-19 trunk 25848) [i686-linux]</p>
<p>each: method `to_s' called on hidden object (0x9438e48)</p>
<p>また, これを調べていたら: 以下のようなSEGVも発生するようになってしまい<br>
ました... なんか, 関係あるでしょうか?</p>
<a name="rubyのバージョンは微妙に違います"></a>
<h1 >rubyのバージョンは微妙に違います.<a href="#rubyのバージョンは微妙に違います" class="wiki-anchor">¶</a></h1>
<p>/usr/local/apps/rubyware/ruby-1.9.2-20091118/lib/ruby/1.9.1/delegate.rb:265: [BUG] Segmentation fault<br>
ruby 1.9.2dev (2009-11-18 trunk 25846) [i686-linux]</p>
<h2>-- control frame ----------<br>
c:0037 p:---- s:0130 b:0130 l:000129 d:000129 CFUNC :write<br>
c:0036 p:0026 s:0126 b:0126 l:000768 d:000125 LAMBDA /usr/local/apps/rubyware/ruby-1.9.2-20091118/lib/ruby/1.9.1/delegate.rb:265<br>
c:0035 p:---- s:0121 b:0121 l:000120 d:000120 FINISH<br>
c:0034 p:---- s:0119 b:0119 l:000118 d:000118 CFUNC :dump<br>
c:0033 p:0062 s:0114 b:0114 l:000ba8 d:000113 BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:863<br>
c:0032 p:0050 s:0110 b:0110 l:000109 d:000109 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:849<br>
c:0031 p:0011 s:0105 b:0105 l:000ba8 d:000ba8 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:859<br>
c:0030 p:0079 s:0101 b:0101 l:000095 d:000100 BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:787<br>
c:0029 p:0019 s:0099 b:0099 l:000098 d:000098 METHOD <a href="internal:prelude" class="external">internal:prelude</a>:8<br>
c:0028 p:0013 s:0096 b:0096 l:000095 d:000095 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:780<br>
c:0027 p:0015 s:0092 b:0092 l:000091 d:000091 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:303<br>
c:0026 p:0118 s:0088 b:0088 l:001e8c d:000087 BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-group-by.rb:56<br>
c:0025 p:---- s:0083 b:0083 l:000082 d:000082 FINISH<br>
c:0024 p:---- s:0081 b:0081 l:000080 d:000080 CFUNC :call<br>
c:0023 p:0014 s:0077 b:0077 l:0011ec d:000076 BLOCK test/testc.rb:3196<br>
c:0022 p:---- s:0074 b:0074 l:000073 d:000073 FINISH<br>
c:0021 p:---- s:0072 b:0072 l:000071 d:000071 CFUNC :each<br>
c:0020 p:0032 s:0069 b:0069 l:0011ec d:00263c BLOCK test/testc.rb:3195<br>
c:0019 p:---- s:0065 b:0065 l:000064 d:000064 FINISH<br>
c:0018 p:---- s:0063 b:0063 l:000062 d:000062 CFUNC :each<br>
c:0017 p:0017 s:0060 b:0060 l:000059 d:000059 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/nfile.rb:78<br>
c:0016 p:0073 s:0056 b:0056 l:000055 d:000055 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:156<br>
c:0015 p:0011 s:0051 b:0051 l:0011ec d:00074c BLOCK test/testc.rb:3188<br>
c:0014 p:---- s:0047 b:0047 l:000046 d:000046 FINISH<br>
c:0013 p:---- s:0045 b:0045 l:000044 d:000044 CFUNC :yield<br>
c:0012 p:0014 s:0040 b:0040 l:0000dc d:000039 BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/block-source.rb:81<br>
c:0011 p:0021 s:0038 b:0038 l:000037 d:000037 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/stdout.rb:35<br>
c:0010 p:0014 s:0034 b:0034 l:0000dc d:0000dc METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/block-source.rb:80<br>
c:0009 p:0043 s:0029 b:0029 l:000028 d:000028 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-each-substream-mapper.rb:26<br>
c:0008 p:0073 s:0025 b:0025 l:000024 d:000024 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:156<br>
c:0007 p:0137 s:0020 b:0020 l:001e8c d:001f2c BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-group-by.rb:47<br>
c:0006 p:---- s:0016 b:0016 l:000015 d:000015 FINISH<br>
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC :call<br>
c:0004 p:0012 s:0011 b:0011 l:000010 d:000010 METHOD /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:143<br>
c:0003 p:0077 s:0007 b:0007 l:0020f8 d:000006 BLOCK /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:125<br>
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH<br>
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP</h2>
<p>/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:125:in <code>block in start' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:143:in </code>basic_start'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:143:in <code>call' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-group-by.rb:47:in </code>block in start_export'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:156:in <code>each' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-each-substream-mapper.rb:26:in </code>basic_each'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/block-source.rb:80:in <code>yield19' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/stdout.rb:35:in </code>replace_stdout'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/block-source.rb:81:in <code>block in yield19' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/share/block-source.rb:81:in </code>yield'<br>
test/testc.rb:3188:in <code>block in context' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/njob.rb:156:in </code>each'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/nfile.rb:78:in <code>basic_each' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/nfile.rb:78:in </code>each'<br>
test/testc.rb:3195:in <code>block (2 levels) in context' test/testc.rb:3195:in </code>each'<br>
test/testc.rb:3196:in <code>block (3 levels) in context' test/testc.rb:3196:in </code>call'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/n-group-by.rb:56:in <code>block (2 levels) in start_export' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:303:in </code>push'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:780:in <code>push' <internal:prelude>:8:in </code>synchronize'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:787:in <code>block in push' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:859:in </code>store_2ndmemory'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:849:in <code>open_2ndmemory' /home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:863:in </code>block in store_2ndmemory'<br>
/home/keiju/public/a.research/fairy/git/fairy/lib/fairy/node/port.rb:863:in <code>dump' /usr/local/apps/rubyware/ruby-1.9.2-20091118/lib/ruby/1.9.1/delegate.rb:265:in </code>block in delegating_block'<br>
/usr/local/apps/rubyware/ruby-1.9.2-20091118/lib/ruby/1.9.1/delegate.rb:265:in `write'</p>
<p>-- C level backtrace information -------------------------------------------<br>
fairy processor --node 45566 --id 0(rb_vm_bugreport+0xb5) [0x81621a5]<br>
fairy processor --node 45566 --id 0 [0x819f3ce]<br>
fairy processor --node 45566 --id 0(rb_bug+0x28) [0x819f468]<br>
fairy processor --node 45566 --id 0 [0x80f71e5]<br>
[0xb801c40c]<br>
fairy processor --node 45566 --id 0(rb_funcall+0xe1) [0x815ee81]<br>
fairy processor --node 45566 --id 0(rb_obj_as_string+0x81) [0x8103811]<br>
fairy processor --node 45566 --id 0 [0x8079378]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_vm_invoke_proc+0x81) [0x8159b61]<br>
fairy processor --node 45566 --id 0 [0x815aab5]<br>
fairy processor --node 45566 --id 0(rb_funcall+0x18e) [0x815ef2e]<br>
fairy processor --node 45566 --id 0(rb_io_write+0x29) [0x80712a9]<br>
fairy processor --node 45566 --id 0 [0x8089f38]<br>
fairy processor --node 45566 --id 0 [0x814d71d]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_vm_invoke_proc+0x81) [0x8159b61]<br>
fairy processor --node 45566 --id 0 [0x8062ec4]<br>
fairy processor --node 45566 --id 0 [0x814d71d]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_yield+0x4f) [0x816103f]<br>
fairy processor --node 45566 --id 0(rb_ary_each+0x41) [0x81716a1]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_yield+0x4f) [0x816103f]<br>
fairy processor --node 45566 --id 0 [0x8082bf8]<br>
fairy processor --node 45566 --id 0 [0x814d71d]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_vm_invoke_proc+0x81) [0x8159b61]<br>
fairy processor --node 45566 --id 0 [0x8062ec4]<br>
fairy processor --node 45566 --id 0 [0x814d71d]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_vm_invoke_proc+0x81) [0x8159b61]<br>
fairy processor --node 45566 --id 0 [0x8062ec4]<br>
fairy processor --node 45566 --id 0 [0x814d71d]<br>
fairy processor --node 45566 --id 0 [0x8151689]<br>
fairy processor --node 45566 --id 0 [0x8152bbd]<br>
fairy processor --node 45566 --id 0 [0x815511d]<br>
fairy processor --node 45566 --id 0 [0x8159399]<br>
fairy processor --node 45566 --id 0(rb_vm_invoke_proc+0x81) [0x8159b61]<br>
fairy processor --node 45566 --id 0 [0x81682ed]<br>
fairy processor --node 45566 --id 0 [0x81683a1]<br>
/lib/i686/cmov/libpthread.so.0 [0xb7fe84b5]<br>
/lib/i686/cmov/libc.so.6(clone+0x5e) [0xb7efea5e]</p>
<p>--<br>
NARUSE, Yui <a href="mailto:naruse@airemix.jp" class="email">naruse@airemix.jp</a><br>
=end</p>
Ruby master - Feature #2340 (Rejected): Removing YAML/Syck
https://redmine.ruby-lang.org/issues/2340
2009-11-06T17:16:10Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
YAML and Syck is a _why's product and widely used bundled library of Ruby.<br>
But they are not maintained for 2 years and no more by _why.<br>
And they support only YAML 1.0, not 1.1 and 1.2.<br>
So YAML/Syck considered harmful.<br>
=end</p>
Ruby master - Bug #2327 (Closed): String#upto で beg が非英数の時破壊的変更がその後に影響する
https://redmine.ruby-lang.org/issues/2327
2009-11-04T00:02:15Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
String の場合、upto のブロックパラメータを破壊的に変更することが出来ますが、<br>
非英数の際にこれがその後の挙動に影響を与えることがあります。</p>
<p>irb(main):001:0> "1".upto("9"){|x|print x;x.replace("9")}<br>
123456789=> "1"<br>
irb(main):002:0> "a".upto("z"){|x|print x;x.replace("z")}<br>
abcdefghijklmnopqrstuvwxyz=> "a"<br>
irb(main):003:0> "\u3041".upto("\u3093"){|x|print x;x.replace("\u3093")}<br>
ぁ=> "ん"<br>
irb(main):004:0> s="\u3041";s.upto("\u3093"){|x|print x;x.replace("\u3093")}<br>
ぁ=> "ん"</p>
<p>以上のように、"ぁ"のみで終わってしまったり、戻り値が変わってしまったりします。<br>
=end</p>
Ruby master - Feature #2102 (Closed): String#inspect as default_internal encoding
https://redmine.ruby-lang.org/issues/2102
2009-09-16T01:11:37Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
String#inspect の結果は特定のエンコーディングに揃えるようにしませんか。</p>
<p>現在の inspect は異なるエンコーディングを持つ文字列でも何も考えず結合を試み、<br>
結果 EncodingCompatibilityError が上がったとしても気にしない、<br>
というものになっています。</p>
<p>しかし、inspect は irb や p など、とりあえずオブジェクトの中身を概観したい、<br>
という時に使われるものなのに、異なるエンコーディングがあるくらいで、<br>
例外になってしまうは正直不便です。</p>
<p>添付のパッチでは、</p>
<ul>
<li>default_internal が設定されていればそれを、設定されていなければ default_external を用いる。<br>
ただし、そのエンコーディングが ASCII compatible でない場合は US-ASCII を用いる。<br>
(以下 inspect のエンコーディングと呼ぶ)</li>
<li>String#inspect の結果は、その String のエンコーディングが、<br>
inspect のエンコーディングと同じ場合はこれまでと同様。</li>
<li>異なる場合、String 内の非 US-ASCII 文字は \xXX 形式でエスケープする。</li>
<li>String 以外の inspect はこれまでと同様。<br>
としています。<br>
これにより、inspect 結果のエンコーディングが一定になるので例外が上がることがなくなります。</li>
</ul>
<p>動作の例を示すと、inspect のエンコーディングが UTF-8 の場合、<br>
"あ".encode("UTF-16BE").inspect</p>
<a name="before-gt-0B"></a>
<h1 >before => "0B"<a href="#before-gt-0B" class="wiki-anchor">¶</a></h1>
<a name="after-gt-x30x42"></a>
<h1 >after => "\x30\x42"<a href="#after-gt-x30x42" class="wiki-anchor">¶</a></h1>
<p>"い".encode("UTF-8").inspect</p>
<a name="before-gt-い"></a>
<h1 >before => "い"<a href="#before-gt-い" class="wiki-anchor">¶</a></h1>
<a name="after-gt-い"></a>
<h1 >after => "い"<a href="#after-gt-い" class="wiki-anchor">¶</a></h1>
<p>"う".encode("EUC-JP").inspect</p>
<a name="before-gt-注-EUC-JP-で生のう"></a>
<h1 >before => "��" (注: EUC-JP で生の「う」)<a href="#before-gt-注-EUC-JP-で生のう" class="wiki-anchor">¶</a></h1>
<a name="after-gt-xA4xA6"></a>
<h1 >after => "\xA4\xA6"<a href="#after-gt-xA4xA6" class="wiki-anchor">¶</a></h1>
<p>["あ".encode("UTF-16BE"), "い".encode("UTF-8"), "う".encode("EUC-JP")].inspect</p>
<a name="beforegt-EncodingCompatibilityError"></a>
<h1 >before=> EncodingCompatibilityError<a href="#beforegt-EncodingCompatibilityError" class="wiki-anchor">¶</a></h1>
<a name="after-gt-x30x42-い-xA4xA6"></a>
<h1 >after => ["\x30\x42", "い", "\xA4\xA6"]<a href="#after-gt-x30x42-い-xA4xA6" class="wiki-anchor">¶</a></h1>
<p>どうでしょうか?</p>
<p>diff --git a/string.c b/string.c<br>
index aa36c37..b8d862c 100644<br>
--- a/string.c<br>
+++ b/string.c<br>
@@ -1739,6 +1739,12 @@ str_buf_cat(VALUE str, const char *ptr, long len)<br>
return str;<br>
}</p>
<p>+static VALUE<br>
+str_buf_cat2(VALUE str, const char *ptr)<br>
+{</p>
<ul>
<li>return str_buf_cat(str, ptr, strlen(ptr));<br>
+}</li>
<li>
</ul>
<p>VALUE<br>
rb_str_buf_cat(VALUE str, const char *ptr, long len)<br>
{<br>
@@ -4237,13 +4243,6 @@ str_cat_char(VALUE str, unsigned int c, rb_encoding *enc)<br>
rb_enc_str_buf_cat(str, s, n, enc);<br>
}</p>
<p>-static void<br>
-prefix_escape(VALUE str, unsigned int c, rb_encoding *enc)<br>
-{</p>
<ul>
<li>str_cat_char(str, '\', enc);</li>
<li>str_cat_char(str, c, enc);<br>
-}</li>
<li>
</ul>
<p>/*</p>
<ul>
<li>call-seq:</li>
<li>str.inspect => string<br>
@@ -4262,10 +4261,13 @@ rb_str_inspect(VALUE str)<br>
rb_encoding *enc = STR_ENC_GET(str);<br>
char *p, *pend;<br>
VALUE result = rb_str_buf_new(0);</li>
</ul>
<ul>
<li>rb_encoding *resenc = rb_default_internal_encoding();</li>
<li>
<li>if (resenc == NULL) resenc = rb_default_external_encoding();</li>
<li>if (!rb_enc_asciicompat(resenc)) resenc = rb_usascii_encoding();</li>
<li>rb_enc_associate(result, resenc);</li>
<li>str_buf_cat2(result, """);</li>
</ul>
<ul>
<li>if (!rb_enc_asciicompat(enc)) enc = rb_usascii_encoding();</li>
<li>rb_enc_associate(result, enc);</li>
<li>str_cat_char(result, '"', enc);<br>
p = RSTRING_PTR(str); pend = RSTRING_END(str);<br>
while (p < pend) {<br>
unsigned int c, cc;<br>
@@ -4278,8 +4280,7 @@ rb_str_inspect(VALUE str)<br>
goto escape_codepoint;<br>
}<br>
n = MBCLEN_CHARFOUND_LEN(n);</li>
<li>
<li>c = rb_enc_codepoint_len(p, pend, &n, enc);</li>
</ul>
<ul>
<li>c = rb_enc_mbc_to_codepoint(p, pend, enc);<br>
p += n;<br>
if (c == '"'|| c == '\' ||<br>
(c == '#' &&<br>
@@ -4287,51 +4288,49 @@ rb_str_inspect(VALUE str)<br>
MBCLEN_CHARFOUND_P(rb_enc_precise_mbclen(p,pend,enc)) &&<br>
(cc = rb_enc_codepoint(p,pend,enc),<br>
(cc == '$' || cc == '@' || cc == '{')))) {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, c, enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\");
</code></pre>
</li>
<li>
<pre><code> str_buf_cat(result, p - n, n);
</code></pre>
}<br>
else if (c == '\n') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'n', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\n");
</code></pre>
}<br>
else if (c == '\r') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'r', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\r");
</code></pre>
}<br>
else if (c == '\t') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 't', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\t");
</code></pre>
}<br>
else if (c == '\f') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'f', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\f");
</code></pre>
}<br>
else if (c == '\013') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'v', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\v");
</code></pre>
}<br>
else if (c == '\010') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'b', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\b");
</code></pre>
}<br>
else if (c == '\007') {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'a', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\a");
</code></pre>
}<br>
else if (c == 033) {</li>
</ul>
<ul>
<li>
<pre><code> prefix_escape(result, 'e', enc);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code> str_buf_cat2(result, "\\e");
</code></pre>
}</li>
</ul>
<ul>
<li>else if (rb_enc_isprint(c, enc)) {</li>
<li>
<pre><code> rb_enc_str_buf_cat(result, p-n, n, enc);
</code></pre>
</li>
</ul>
<ul>
<li>else if ((enc == resenc && rb_enc_isprint(c, enc)) || rb_enc_isascii(c, enc)) {</li>
<li>
<pre><code> str_buf_cat(result, p-n, n);
</code></pre>
}<br>
else {</li>
</ul>
<ul>
<li>
<pre><code> char buf[5];
</code></pre>
</li>
<li>
<pre><code> char *s;
char *q;
</code></pre>
</li>
<li>escape_codepoint:<br>
for (q = p-n; q < p; q++) {</li>
<li>
<pre><code> s = buf;
</code></pre>
</li>
<li>
<pre><code> sprintf(buf, "\\x%02X", *q & 0377);
</code></pre>
</li>
<li>
<pre><code> while (*s) {
</code></pre>
</li>
<li>
<pre><code> str_cat_char(result, *s++, enc);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
</ul>
<p>+#define BACKESC_BUFSIZE 5</p>
<ul>
<li>
<pre><code> char buf[BACKESC_BUFSIZE];
</code></pre>
</li>
<li>
<pre><code> sprintf(buf, "\\x%02X", *q & 0377);
</code></pre>
</li>
<li>
<pre><code> str_buf_cat(result, buf, BACKESC_BUFSIZE - 1);
</code></pre>
</li>
</ul>
<p>+#undef BACKESC_BUFSIZE</p>
<ul>
<li>
<pre><code> }
</code></pre>
}<br>
}</li>
</ul>
<ul>
<li>str_cat_char(result, '"', enc);</li>
</ul>
<ul>
<li>
<p>str_buf_cat2(result, """);</p>
<p>OBJ_INFECT(result, str);<br>
return result;<br>
=end</p>
</li>
</ul>
Ruby master - Feature #2093 (Closed): String#stripの対象は\sか[:space:]か
https://redmine.ruby-lang.org/issues/2093
2009-09-13T02:24:49Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
現在、String#strip は rb_enc_isspace を使っています。<br>
つまり、[:space:] にマッチするものを落とすため、<br>
例えばいわゆる全角空白等も切り落とす対象になっています。</p>
<p>しかし、他の Ruby core API は ASCII を意識した動きをすることが多く、<br>
strip はちょっと予想を裏切る動作になっています。</p>
<p>なんとなくただの修正漏れのように感じるのですがどうでしょう?<br>
=end</p>
Ruby master - Feature #2017 (Rejected): String#/(sep)
https://redmine.ruby-lang.org/issues/2017
2009-08-31T02:35:22Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
String#/(separator) を String#join(separator) の alias として追加しませんか?</p>
<p>以前から、Array#*(sep) との対称性から String#/(sep) の採用は求められてきました。<br>
しかし、対称性だけでは根拠が弱く、入ることなく今に至っています。</p>
<p>今回は、String#split の出現頻度を調べてみました。<br>
Rubyのソースで調べてみると、<br>
% grep split **/<em>.rb|wc -l<br>
1096<br>
% grep gsub **/</em>.rb|wc -l<br>
617<br>
% grep push **/<em>.rb|wc -l<br>
732<br>
% grep to_i **/</em>.rb|wc -l<br>
1034<br>
% grep to_s **/<em>.rb|wc -l<br>
2414<br>
% grep each **/</em>.rb|wc -l<br>
4752<br>
という結果の通り、each や to_s には負けるものの、to_i に並び、<br>
高順位が予想された gsub をも越える使用頻度を誇っています。</p>
<p>これだけの頻度ならば / を割り当てるに足と思うのですが、いかがでしょうか。<br>
もし何かに String#/ をあてるならば、String#split 以外になる可能性は低いように思います。<br>
=end</p>
Ruby master - Feature #1951 (Closed): openのBOM指定拡張
https://redmine.ruby-lang.org/issues/1951
2009-08-18T23:47:15Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>#747と#802で議論された、openのBOM指定拡張ですが、現在の仕様は、</p>
<ul>
<li>BOMを捨てる</li>
<li>BOMを見てencodingを設定する<br>
という2つの機能が混在しています。</li>
</ul>
<p>このために、たとえば「<code>UTF-8-BOM</code>」という指定でも、<br>
BOMがUTF-16LEを示していた場合には実際に返ってくるStringはUTF-16LEになってしまいます。</p>
<p>この問題に対する解決案として、</p>
<ul>
<li>UTF-*-BOM はBOMを捨てるだけ。別のencodingだった場合は例外</li>
<li>
<code>BOM|UTF-*</code>を追加、これが現在の<code>UTF-*-BOM</code>相当の動作 (BOMを見る OR <code>UTF-*</code>と指定、というイメージ)<br>
というものを考えています。</li>
</ul>
<p>皆さんはどのように思われますか?</p>
Ruby master - Feature #1949 (Closed): Warn needless escaped characters
https://redmine.ruby-lang.org/issues/1949
2009-08-18T22:25:48Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
正規表現内での不必要なエスケープに警告を出しませんか。</p>
<p>動機としては、/\uXXXX/の非互換性の話があります。</p>
<p>これは、Ruby 1.8において、不必要なエスケープであった/\u/が、<br>
Ruby 1.9においては\uXXXXという構文が追加されたがために、<br>
エラーが出たり意味が変わってしまったりしたという話でした。</p>
<p>このような不幸な出来事は、/\u/と書いたら警告を出すようにしていたら、<br>
未然に防ぐことができたり、被害を減らすことができたかもしれません。</p>
<p>将来また別のエスケープ記法が追加される事は十分あり得る話だと思います。<br>
その際に同じ不幸を繰り返さないように、警告を出すようにしませんか。</p>
<p>具体的には、文字クラス外の<br>
g, i, j, k, l, m, o, p, q, y, E, F, H, I, J, K, L, N, O, P, Q, R, T, U, V, X, Y<br>
と、文字クラス内の<br>
g, i, j, k, l, m, o, p, q, y, z, A, B, E, F, G, H, I, J, K, L, N, O, P, Q, R, T, U, V, X, Y, Z<br>
あたりになるでしょうか。</p>
<p>なお、現状では警告が出ないが、すでにエスケープ記法として用いている、<br>
/\p/あたりは議論の余地のあるところかもしれません。<br>
=end</p>
Ruby master - Bug #1433 (Closed): test_sprintf_p fails
https://redmine.ruby-lang.org/issues/1433
2009-05-05T09:52:09Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
test_sprintf_p(TestM17N) [/home/naruse/git/ruby/test/ruby/test_m17n.rb:773]:<br>
<#<a href="Encoding:US-ASCII" class="external">Encoding:US-ASCII</a>> expected but was<br>
<#<a href="Encoding:ASCII-8BIT" class="external">Encoding:ASCII-8BIT</a>>.</p>
<p>1.9.1のパッチリリースのblocking bugである本件ですが、<br>
これはテスト側を動作に合わせるべきだと思っています。</p>
<p>この部分を最後に修正したのはうささんのようですが、どう思われますか。<br>
あと他の方も。<br>
=end</p>
Ruby master - Bug #527 (Closed): test_execopts_pgroup(TestProcess) fails on NetBSD
https://redmine.ruby-lang.org/issues/527
2008-08-31T15:54:10Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
以下のテストが NetBSD 4.99.72 i386 にて失敗します。</p>
<p>test_execopts_pgroup(TestProcess) [/home/naruse/src/ruby-trunk/test/ruby/test_process.rb:141]:<br>
<a href="Errno::EPERM" class="external">Errno::EPERM</a> exception expected but none was thrown.<br>
=end</p>
Ruby master - Bug #525 (Closed): test_convert(TestBignum) on NETBSD
https://redmine.ruby-lang.org/issues/525
2008-08-31T14:42:12Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
NetBSD 4.99.72 i386 にて、test/ruby/test_bignum.rb が以下のとおり失敗します。</p>
<h2>test_convert(TestBignum) [/home/naruse/src/ruby-trunk/test/ruby/test_bignum.rb:199]:<br>
<a href="Errno::EINVAL" class="external">Errno::EINVAL</a> exception expected but was<br>
Class: <br>
Message: <"bignum too big to convert into <code>unsigned long'"> ---Backtrace--- /home/naruse/src/ruby-trunk/test/ruby/test_bignum.rb:201:in </code>wait'<br>
/home/naruse/src/ruby-trunk/test/ruby/test_bignum.rb:201:in <code>block in test_convert' /home/naruse/src/ruby-trunk/test/ruby/test_bignum.rb:199:in </code>test_convert'</h2>
<p>=end</p>
Ruby master - Bug #368 (Closed): 境界における Math.atanh 等の動作
https://redmine.ruby-lang.org/issues/368
2008-07-28T02:53:11Z
naruse (Yui NARUSE)
naruse@airemix.jp
<p>=begin<br>
現在の Ruby trunk では、FreeBSD 7 において、<br>
test/ruby/test_math.rb は以下のように失敗します。</p>
<p>y% ruby19 test/ruby/test_math.rb<br>
Loaded suite test/ruby/test_math<br>
Started<br>
......F...........FFF.....<br>
Finished in 0.036791548 seconds.</p>
<ol>
<li>
<p>Failure:<br>
test_atanh(TestMath) [test/ruby/test_math.rb:97]:<br>
<[Errno::EDOM, Errno::ERANGE]> exception expected but none was thrown.</p>
</li>
<li>
<p>Failure:<br>
test_log(TestMath) [test/ruby/test_math.rb:113]:<br>
<[Errno::EDOM, Errno::ERANGE]> exception expected but none was thrown.</p>
</li>
<li>
<p>Failure:<br>
test_log10(TestMath) [test/ruby/test_math.rb:129]:<br>
<[Errno::EDOM, Errno::ERANGE]> exception expected but none was thrown.</p>
</li>
<li>
<p>Failure:<br>
test_log2(TestMath) [test/ruby/test_math.rb:121]:<br>
<[Errno::EDOM, Errno::ERANGE]> exception expected but none was thrown.</p>
</li>
</ol>
<p>26 tests, 126 assertions, 4 failures, 0 errors</p>
<p>これらの原因はいずれも境界における定義の違いに由来しているものと思わます。</p>
<p>例えば、NetBSD4 だと atanh のマニュアルには以下のようにあり、<br>
atanh(1) は NaN となります。</p>
<p>RETURN VALUES<br>
If |x|>=1, atanh(x) and atanhf(x) return +inf, -inf or NaN, and sets the<br>
global variable errno to EDOM.</p>
<p>しかし、FreeBSD7 では以下のようになっており、atanh(1) は infinity を返します。</p>
<p>RETURN VALUES<br>
The atanh() and the atanhf() functions return the inverse hyperbolic tan-<br>
gent of x if successful. If the argument has absolute value 1, a divide-<br>
by-zero exception is raised and an infinity is returned. If |x| > 1, an<br>
invalid exception is raised and an NaN is returned.</p>
<p>参考:<br>
<a href="http://www.hiroshima-cu.ac.jp/japanese/IPC/hunet99/sun/WorkShop/ja/html_docs/common-tools/numerical_comp_guide/standard.doc.html" class="external">http://www.hiroshima-cu.ac.jp/japanese/IPC/hunet99/sun/WorkShop/ja/html_docs/common-tools/numerical_comp_guide/standard.doc.html</a><br>
=end</p>