From 3e75a0a7638887519610ca4c96ee7b23e4592d9b Mon Sep 17 00:00:00 2001 From: tadf Date: Mon, 25 Aug 2008 14:47:33 +0000 Subject: * lib/date/format.rb(strftime): can print with given arbitrary precision. * lib/date/format.rb(strftime): optional flags and filed width should also affect %[nt]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/date/format.rb | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0024654fb8..a5d9cad7bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Aug 25 23:38:17 2008 Tadayoshi Funaba + + * lib/date/format.rb(strftime): can print with given arbitrary + precision. + + * lib/date/format.rb(strftime): optional flags and filed width + should also affect %[nt]. + Mon Aug 25 23:01:17 2008 Yukihiro Matsumoto * compile.c (defined_expr): default defined? should return diff --git a/lib/date/format.rb b/lib/date/format.rb index 46d2147b89..baba8dcbf6 100644 --- a/lib/date/format.rb +++ b/lib/date/format.rb @@ -257,13 +257,17 @@ class Date when 'j'; emit_n(yday, 3, f) when 'k'; emit_a(hour, 2, f) when 'L' - emit_n((sec_fraction / MILLISECONDS_IN_SECOND).floor, 3, f) + w = f[:w] || 3 + u = 10**w + emit_n((sec_fraction * u).floor, w, f) when 'l'; emit_a((hour % 12).nonzero? || 12, 2, f) when 'M', 'OM'; emit_n(min, 2, f) when 'm', 'Om'; emit_n(mon, 2, f) when 'N' - emit_n((sec_fraction / NANOSECONDS_IN_SECOND).floor, 9, f) - when 'n'; "\n" + w = f[:w] || 9 + u = 10**w + emit_n((sec_fraction * u).floor, w, f) + when 'n'; emit_a("\n", 0, f) when 'P'; emit_ad(strftime('%p').downcase, 0, f) when 'p'; emit_au(if hour < 12 then 'AM' else 'PM' end, 0, f) when 'Q' @@ -281,7 +285,7 @@ class Date else emit_a(strftime('%H:%M:%S'), 0, f) end - when 't'; "\t" + when 't'; emit_a("\t", 0, f) when 'U', 'W', 'OU', 'OW' emit_n(if c[-1,1] == 'U' then wnum0 else wnum1 end, 2, f) when 'u', 'Ou'; emit_n(cwday, 1, f) -- cgit v1.2.3 From 87746352f4463bcd4815b2287b3bea3d6b0710f0 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 25 Aug 2008 14:58:01 +0000 Subject: * win32.c (init_stdhandle): set binmode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ win32/win32.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index a5d9cad7bf..22090fd3a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 25 23:56:42 2008 NAKAMURA Usaku + + * win32.c (init_stdhandle): set binmode. + Mon Aug 25 23:38:17 2008 Tadayoshi Funaba * lib/date/format.rb(strftime): can print with given arbitrary diff --git a/win32/win32.c b/win32/win32.c index 04a11f3fb8..29088d2f29 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1796,12 +1796,21 @@ init_stdhandle(void) if (fileno(stdin) < 0) { stdin->_file = open_null(0); } + else { + setmode(fileno(stdin), O_BINARY); + } if (fileno(stdout) < 0) { stdout->_file = open_null(1); } + else { + setmode(fileno(stdout), O_BINARY); + } if (fileno(stderr) < 0) { stderr->_file = open_null(2); } + else { + setmode(fileno(stderr), O_BINARY); + } if (nullfd >= 0 && !keep) close(nullfd); setvbuf(stderr, NULL, _IONBF, 0); } -- cgit v1.2.3 From 04860263899b34e3f7efea4a845c8b80523eca9e Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 25 Aug 2008 15:01:36 +0000 Subject: * transcode.c (rb_econv_open): make last_tc NULL if there are only additional transcoders. (econv_description): extracted from rb_econv_open_exc. (rb_econv_open_exc): use econv_description. (econv_inspect): use econv_description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 +++++++ transcode.c | 71 +++++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22090fd3a9..60402f9c47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Aug 25 23:59:36 2008 Tanaka Akira + + * transcode.c (rb_econv_open): make last_tc NULL if there are only + additional transcoders. + (econv_description): extracted from rb_econv_open_exc. + (rb_econv_open_exc): use econv_description. + (econv_inspect): use econv_description. + Mon Aug 25 23:56:42 2008 NAKAMURA Usaku * win32.c (init_stdhandle): set binmode. diff --git a/transcode.c b/transcode.c index 600756c48a..098ea3995d 100644 --- a/transcode.c +++ b/transcode.c @@ -745,6 +745,7 @@ rb_econv_open(const char *from, const char *to, rb_econv_option_t *opts) { transcoder_entry_t **entries = NULL; int num_trans; + int num_additional; static rb_econv_t *ec; int flags = opts ? opts->flags : 0; @@ -761,6 +762,7 @@ rb_econv_open(const char *from, const char *to, rb_econv_option_t *opts) return NULL; } + num_additional = 0; if (flags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER)) { const char *name = (flags & ECONV_CRLF_NEWLINE_ENCODER) ? "crlf_newline" : "cr_newline"; transcoder_entry_t *e = get_transcoder_entry("", name); @@ -775,6 +777,7 @@ rb_econv_open(const char *from, const char *to, rb_econv_option_t *opts) MEMMOVE(entries+1, entries, transcoder_entry_t *, num_trans); entries[0] = e; num_trans++; + num_additional++; } if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { @@ -784,6 +787,7 @@ rb_econv_open(const char *from, const char *to, rb_econv_option_t *opts) return NULL; } entries[num_trans++] = e; + num_additional++; } ec = rb_econv_open_by_transcoder_entries(num_trans, entries); @@ -798,15 +802,13 @@ rb_econv_open(const char *from, const char *to, rb_econv_option_t *opts) ec->source_encoding_name = from; ec->destination_encoding_name = to; - if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { - if (ec->num_trans == 1) { - ec->last_tc = NULL; - ec->last_trans_index = -1; - } - else { - ec->last_tc = ec->elems[ec->num_trans-2].tc; - ec->last_trans_index = ec->num_trans-2; - } + if (num_trans == num_additional) { + ec->last_tc = NULL; + ec->last_trans_index = -1; + } + else if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { + ec->last_tc = ec->elems[ec->num_trans-2].tc; + ec->last_trans_index = ec->num_trans-2; } return ec; @@ -1483,29 +1485,30 @@ rb_econv_binmode(rb_econv_t *ec) } } -VALUE -rb_econv_open_exc(const char *senc, const char *denc, rb_econv_option_t *opts) +static VALUE +econv_description(const char *senc, const char *denc, rb_econv_option_t *opts, VALUE mesg) { int flags = opts ? opts->flags : 0; - VALUE mesg, exc; - int noenc = 0; - mesg = rb_str_new_cstr("code converter open failed ("); - if (*senc == '\0' || *denc == '\0') { - if (*senc != '\0') - rb_str_cat2(mesg, senc); - else if (*denc != '\0') + int has_description = 0; + + if (NIL_P(mesg)) + mesg = rb_str_new(NULL, 0); + + if (*senc != '\0' || *denc != '\0') { + if (*senc == '\0') rb_str_cat2(mesg, denc); + else if (*denc == '\0') + rb_str_cat2(mesg, senc); else - noenc = 1; - } - else { - rb_str_catf(mesg, "%s to %s", senc, denc); + rb_str_catf(mesg, "%s to %s", senc, denc); + has_description = 1; } + if (flags & (ECONV_UNIVERSAL_NEWLINE_DECODER| ECONV_CRLF_NEWLINE_ENCODER| ECONV_CR_NEWLINE_ENCODER)) { const char *pre = ""; - if (!noenc) + if (has_description) rb_str_cat2(mesg, " with "); if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { rb_str_cat2(mesg, pre); pre = ","; @@ -1519,7 +1522,21 @@ rb_econv_open_exc(const char *senc, const char *denc, rb_econv_option_t *opts) rb_str_cat2(mesg, pre); pre = ","; rb_str_cat2(mesg, "CR-newline"); } + has_description = 1; } + if (!has_description) { + rb_str_cat2(mesg, "no-conversion"); + } + + return mesg; +} + +VALUE +rb_econv_open_exc(const char *senc, const char *denc, rb_econv_option_t *opts) +{ + VALUE mesg, exc; + mesg = rb_str_new_cstr("code converter open failed ("); + econv_description(senc, denc, opts, mesg); rb_str_cat2(mesg, ")"); exc = rb_exc_new3(rb_eNoConverter, mesg); return exc; @@ -2110,9 +2127,11 @@ econv_inspect(VALUE self) else { const char *sname = ec->source_encoding_name; const char *dname = ec->destination_encoding_name; - if (*sname == '\0') sname = "(none)"; - if (*dname == '\0') dname = "(none)"; - return rb_sprintf("#<%s: %s to %s>", cname, sname, dname); + VALUE str; + str = rb_sprintf("#<%s: ", cname); + econv_description(sname, dname, &ec->opts, str); + rb_str_cat2(str, ">"); + return str; } } -- cgit v1.2.3 From 1913c0e857253ddbed217e0bdbfae55796a30afe Mon Sep 17 00:00:00 2001 From: svn Date: Mon, 25 Aug 2008 15:01:40 +0000 Subject: * 2008-08-26 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version.h b/version.h index 40f4a0f46c..b537a0f8e8 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-08-25" +#define RUBY_RELEASE_DATE "2008-08-26" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080825 +#define RUBY_RELEASE_CODE 20080826 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 25 +#define RUBY_RELEASE_DAY 26 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- cgit v1.2.3 From 4e573bf068bfe7859af293a4210c5b5c65fa86ba Mon Sep 17 00:00:00 2001 From: mame Date: Mon, 25 Aug 2008 15:03:14 +0000 Subject: * ext/bigdecimal/bigdecimal.c (VpMult): fix double free. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ ext/bigdecimal/bigdecimal.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 60402f9c47..e4a44a61ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Aug 26 00:02:49 2008 Yusuke Endoh + + * ext/bigdecimal/bigdecimal.c (VpMult): fix double free. + Mon Aug 25 23:59:36 2008 Tanaka Akira * transcode.c (rb_econv_open): make last_tc NULL if there are only diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 213d9ea149..e8da7cc415 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -3165,7 +3165,7 @@ VpMult(Real *c, Real *a, Real *b) c->exponent = a->exponent; /* set exponent */ if(!AddExponent(c,b->exponent)) { - VpFree(c); + if(w) VpFree(c); return 0; } VpSetSign(c,VpGetSign(a)*VpGetSign(b)); /* set sign */ -- cgit v1.2.3 From 72eaacaa15256ab95c3b52ea386f88586fb9da40 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 25 Aug 2008 15:04:53 +0000 Subject: "t" for Kernel#open described. Encoding and Encoding::Converted described. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- doc/NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/NEWS b/doc/NEWS index 729354df2d..6441c3a72d 100644 --- a/doc/NEWS +++ b/doc/NEWS @@ -51,6 +51,7 @@ Incompatible (Trivial) o Dir.exist? * IO operations o Non-blocking IO + o Kernel#open takes "t" for newline conversion o Kernel#open takes encoding specified o IO#initialize now accepts an IO argument o StringIO#readpartial @@ -112,6 +113,8 @@ Compatible an enumerator. * Regexp#match, String#match o Regexp#match, String#match + * Encoding + * Encoding::Converter * Fiber: coroutines/micro-threads * Array o Array#delete returns a deleted element rather than a given -- cgit v1.2.3