From debeb7db7734b86ce75648ac99d144ff953ad189 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 5 Sep 2008 11:16:28 +0000 Subject: [PATCH] * enc/trans/newline.trans (universal_newline_finish): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ enc/trans/newline.trans | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d16c96ccc5..a975d06347 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Sep 5 20:12:23 2008 Tanaka Akira + + * enc/trans/newline.trans (universal_newline_finish): new function. + Fri Sep 5 20:07:37 2008 Tanaka Akira * include/ruby/io.h (rb_io_mode_modenum): moved from diff --git a/enc/trans/newline.trans b/enc/trans/newline.trans index 90fb26eeb9..9e5229f9a6 100644 --- a/enc/trans/newline.trans +++ b/enc/trans/newline.trans @@ -41,7 +41,7 @@ universal_newline_init(void *statep) } static int -fun_so_universal_newline(void *statep, const unsigned char* s, size_t l, unsigned char* o) +fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigned char *o) { unsigned char *sp = statep; int len; @@ -75,6 +75,16 @@ fun_so_universal_newline(void *statep, const unsigned char* s, size_t l, unsigne return len; } +static int +universal_newline_finish(void *statep, unsigned char *o) +{ + unsigned char *sp = statep; + if (STATE == JUST_AFTER_CR) + NEWLINES_MET |= MET_CR; + STATE = NORMAL; + return 0; +} + static const rb_transcoder rb_universal_newline = { "universal_newline", "", universal_newline, @@ -84,7 +94,8 @@ rb_universal_newline = { 1, /* max_output */ stateful_decoder, /* stateful_type */ 2, universal_newline_init, universal_newline_init, /* state_size, state_init, state_fini */ - NULL, NULL, NULL, fun_so_universal_newline + NULL, NULL, NULL, fun_so_universal_newline, + universal_newline_finish }; static const rb_transcoder