mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (io_getc): fix incomplete character immediately before EOF
with newline converter. [ruby-dev:41024] run test only when "Create Shortcut (&S)" menu is found. * lib/rexml/parsers/xpathparser.rb (PathExpr): ditto. * lib/matrix.rb (Vector#each): make Vector enumerable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2976ec58a4
commit
4131d6176a
3 changed files with 67 additions and 43 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,8 @@
|
|||
Wed Apr 21 15:13:10 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* io.c (io_getc): fix incomplete character immediately before EOF
|
||||
with newline converter. [ruby-dev:41024]
|
||||
|
||||
Wed Apr 21 13:44:54 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (regexp): check each fragments. [ruby-core:27374]
|
||||
|
@ -623,6 +628,14 @@ Tue Apr 6 23:01:35 2010 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
|||
* thread.c (do_select): Use UNINITIALIZED_VAR() instead FAKE_FD_ZERO().
|
||||
Also, remove FAKE_FD_ZERO completely. [Feature #3018]
|
||||
|
||||
Tue Apr 6 14:53:17 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* include/ruby/win32.h: check definition existence before defining
|
||||
errno macros.
|
||||
|
||||
* win32/win32.c (errmap): define winsock errors mappings.
|
||||
these are VC++10 support. see [ruby-core:29278]
|
||||
|
||||
Tue Apr 6 21:55:25 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* configure.in: test localtime(3) overflow. [ruby-dev:40910]
|
||||
|
@ -634,14 +647,6 @@ Tue Apr 6 21:55:25 2010 Tanaka Akira <akr@fsij.org>
|
|||
(rb_gmtime_r2): call rb_gmtime_r and validate the result if there
|
||||
is overflow problem.
|
||||
|
||||
Tue Apr 6 14:53:17 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* include/ruby/win32.h: check definition existence before defining
|
||||
errno macros.
|
||||
|
||||
* win32/win32.c (errmap): define winsock errors mappings.
|
||||
these are VC++10 support. see [ruby-core:29278]
|
||||
|
||||
Tue Apr 6 11:21:23 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* template/fake.rb.in: hooks for extconf.rb.
|
||||
|
|
12
io.c
12
io.c
|
@ -2756,15 +2756,15 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
|
|||
}
|
||||
|
||||
if (more_char(fptr) == MORE_CHAR_FINISHED) {
|
||||
if (fptr->cbuf_len == 0) {
|
||||
clear_readconv(fptr);
|
||||
if (fptr->cbuf_len == 0)
|
||||
return Qnil;
|
||||
}
|
||||
/* return an unit of an incomplete character just before EOF */
|
||||
r = rb_enc_mbclen(fptr->cbuf+fptr->cbuf_off,
|
||||
fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
|
||||
read_enc);
|
||||
io_shift_cbuf(fptr, r, &str);
|
||||
str = io_enc_str(str, fptr);
|
||||
str = rb_enc_str_new(fptr->cbuf+fptr->cbuf_off, 1, read_enc);
|
||||
fptr->cbuf_off += 1;
|
||||
fptr->cbuf_len -= 1;
|
||||
if (fptr->cbuf_len == 0) clear_readconv(fptr);
|
||||
ENC_CODERANGE_SET(str, ENC_CODERANGE_BROKEN);
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -400,6 +400,25 @@ EOT
|
|||
}
|
||||
end
|
||||
|
||||
def test_getc_newlineconv_invalid
|
||||
with_tmpdir {
|
||||
src = "\xE3\x81"
|
||||
generate_file('tmp', src)
|
||||
defext = Encoding.default_external
|
||||
Encoding.default_external = Encoding::UTF_8
|
||||
open("tmp", "rt") {|f|
|
||||
p f.read;f.rewind
|
||||
s = f.getc
|
||||
assert_equal(false, s.valid_encoding?)
|
||||
assert_equal("\xE3".force_encoding("UTF-8"), s)
|
||||
s = f.getc
|
||||
assert_equal(false, s.valid_encoding?)
|
||||
assert_equal("\x81".force_encoding("UTF-8"), s)
|
||||
}
|
||||
Encoding.default_external = defext
|
||||
}
|
||||
end
|
||||
|
||||
def test_ungetc_stateful_conversion
|
||||
with_tmpdir {
|
||||
src = "before \e$B\x23\x30\x23\x31\e(B after".force_encoding("iso-2022-jp")
|
||||
|
|
Loading…
Reference in a new issue