mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* transcode_data.h: return output functions ssize_t.
* transcode.c (transcode_restartable0): don't need to cast the result of output functions. * enc/trans/newline.trans: follow the type change. * enc/trans/escape.trans: ditto. * enc/trans/utf_16_32.trans: ditto. * enc/trans/iso2022.trans: ditto. * enc/trans/japanese.trans: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a3c8c0adec
commit
c767be3039
8 changed files with 44 additions and 28 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
Mon Sep 15 03:33:10 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode_data.h: return output functions ssize_t.
|
||||
|
||||
* transcode.c (transcode_restartable0): don't need to cast the result
|
||||
of output functions.
|
||||
|
||||
* enc/trans/newline.trans: follow the type change.
|
||||
|
||||
* enc/trans/escape.trans: ditto.
|
||||
|
||||
* enc/trans/utf_16_32.trans: ditto.
|
||||
|
||||
* enc/trans/iso2022.trans: ditto.
|
||||
|
||||
* enc/trans/japanese.trans: ditto.
|
||||
|
||||
Mon Sep 15 03:04:29 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode_data.h: output function takes output buffer size.
|
||||
|
|
|
@ -43,7 +43,7 @@ escape_xml_attr_quote_init(void *statep)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_escape_xml_attr_quote(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
@ -56,7 +56,7 @@ fun_so_escape_xml_attr_quote(void *statep, const unsigned char *s, size_t l, uns
|
|||
return n;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
escape_xml_attr_quote_finish(void *statep, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
|
|
@ -70,7 +70,7 @@ fun_si_iso2022jp_decoder(void *statep, const unsigned char *s, size_t l)
|
|||
return (VALUE)INVALID;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_iso2022jp_decoder(void *statep, const unsigned char *s, size_t l, unsigned char* o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
@ -119,7 +119,7 @@ rb_iso2022jp_decoder = {
|
|||
NULL, fun_si_iso2022jp_decoder, NULL, fun_so_iso2022jp_decoder
|
||||
};
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_iso2022jp_encoder(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
@ -172,7 +172,7 @@ iso2022jp_encoder_reset_sequence_size(void *statep)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
finish_iso2022jp_encoder(void *statep, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
@ -203,7 +203,7 @@ rb_iso2022jp_encoder = {
|
|||
iso2022jp_encoder_reset_sequence_size, finish_iso2022jp_encoder
|
||||
};
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_stateless_iso2022jp_to_eucjp(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
o[0] = s[1];
|
||||
|
@ -223,7 +223,7 @@ rb_stateless_iso2022jp_to_eucjp = {
|
|||
NULL, NULL, NULL, fun_so_stateless_iso2022jp_to_eucjp,
|
||||
};
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_eucjp_to_stateless_iso2022jp(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
o[0] = EMACS_MULE_LEADING_CODE_JISX0208_1983;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<%= transcode_generated_code %>
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_eucjp2sjis(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (s[0] == 0x8e) {
|
||||
|
@ -40,7 +40,7 @@ fun_so_eucjp2sjis(void *statep, const unsigned char *s, size_t l, unsigned char
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_sjis2eucjp(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (l == 1) {
|
||||
|
|
|
@ -40,7 +40,7 @@ universal_newline_init(void *statep)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
@ -75,7 +75,7 @@ fun_so_universal_newline(void *statep, const unsigned char *s, size_t l, unsigne
|
|||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
universal_newline_finish(void *statep, unsigned char *o, size_t osize)
|
||||
{
|
||||
unsigned char *sp = statep;
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
<%= transcode_generated_code %>
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_from_utf_16be(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!s[0] && s[1]<0x80) {
|
||||
|
@ -65,7 +65,7 @@ fun_so_from_utf_16be(void *statep, const unsigned char *s, size_t l, unsigned ch
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_to_utf_16be(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!(s[0]&0x80)) {
|
||||
|
@ -93,7 +93,7 @@ fun_so_to_utf_16be(void *statep, const unsigned char *s, size_t l, unsigned char
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_from_utf_16le(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!s[1] && s[0]<0x80) {
|
||||
|
@ -121,7 +121,7 @@ fun_so_from_utf_16le(void *statep, const unsigned char *s, size_t l, unsigned ch
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_to_utf_16le(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!(s[0]&0x80)) {
|
||||
|
@ -149,7 +149,7 @@ fun_so_to_utf_16le(void *statep, const unsigned char *s, size_t l, unsigned char
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_from_utf_32be(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!s[1]) {
|
||||
|
@ -178,7 +178,7 @@ fun_so_from_utf_32be(void *statep, const unsigned char *s, size_t l, unsigned ch
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_to_utf_32be(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
o[0] = 0;
|
||||
|
@ -204,7 +204,7 @@ fun_so_to_utf_32be(void *statep, const unsigned char *s, size_t l, unsigned char
|
|||
return 4;
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_from_utf_32le(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
if (!s[2]) {
|
||||
|
@ -233,7 +233,7 @@ fun_so_from_utf_32le(void *statep, const unsigned char *s, size_t l, unsigned ch
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static ssize_t
|
||||
fun_so_to_utf_32le(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
|
||||
{
|
||||
o[3] = 0;
|
||||
|
|
11
transcode.c
11
transcode.c
|
@ -604,11 +604,10 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
|||
case FUNio:
|
||||
SUSPEND_OBUF(13);
|
||||
if (tr->max_output <= out_stop - out_p)
|
||||
out_p += (VALUE)(*tr->func_io)(TRANSCODING_STATE(tc),
|
||||
next_info,
|
||||
out_p, out_stop - out_p);
|
||||
out_p += tr->func_io(TRANSCODING_STATE(tc),
|
||||
next_info, out_p, out_stop - out_p);
|
||||
else {
|
||||
writebuf_len = (VALUE)(*tr->func_io)(TRANSCODING_STATE(tc),
|
||||
writebuf_len = tr->func_io(TRANSCODING_STATE(tc),
|
||||
next_info,
|
||||
TRANSCODING_WRITEBUF(tc), TRANSCODING_WRITEBUF_SIZE(tc));
|
||||
writebuf_off = 0;
|
||||
|
@ -625,13 +624,13 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos,
|
|||
SUSPEND_OBUF(14);
|
||||
if (tr->max_output <= out_stop - out_p) {
|
||||
char_start = transcode_char_start(tc, *in_pos, inchar_start, in_p, &char_len);
|
||||
out_p += (VALUE)(*tr->func_so)(TRANSCODING_STATE(tc),
|
||||
out_p += tr->func_so(TRANSCODING_STATE(tc),
|
||||
char_start, (size_t)char_len,
|
||||
out_p, out_stop - out_p);
|
||||
}
|
||||
else {
|
||||
char_start = transcode_char_start(tc, *in_pos, inchar_start, in_p, &char_len);
|
||||
writebuf_len = (VALUE)(*tr->func_so)(TRANSCODING_STATE(tc),
|
||||
writebuf_len = tr->func_so(TRANSCODING_STATE(tc),
|
||||
char_start, (size_t)char_len,
|
||||
TRANSCODING_WRITEBUF(tc), TRANSCODING_WRITEBUF_SIZE(tc));
|
||||
writebuf_off = 0;
|
||||
|
|
|
@ -84,9 +84,9 @@ struct rb_transcoder {
|
|||
int (*state_fini_func)(void*); /* ret==0:success ret!=0:failure(errno) */
|
||||
VALUE (*func_ii)(void*, VALUE); /* info -> info */
|
||||
VALUE (*func_si)(void*, const unsigned char*, size_t); /* start -> info */
|
||||
int (*func_io)(void*, VALUE, const unsigned char*, size_t); /* info -> output */
|
||||
int (*func_so)(void*, const unsigned char*, size_t, unsigned char*, size_t); /* start -> output */
|
||||
int (*finish_func)(void*, unsigned char*, size_t); /* -> output */
|
||||
ssize_t (*func_io)(void*, VALUE, const unsigned char*, size_t); /* info -> output */
|
||||
ssize_t (*func_so)(void*, const unsigned char*, size_t, unsigned char*, size_t); /* start -> output */
|
||||
ssize_t (*finish_func)(void*, unsigned char*, size_t); /* -> output */
|
||||
int (*resetsize_func)(void*); /* -> len */
|
||||
int (*resetstate_func)(void*, unsigned char*, size_t); /* -> output */
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue