summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-09 11:57:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-09 11:57:31 +0000
commit8c2d4076f0e54c9229bc8380e569832d32af1d41 (patch)
treed39273106e1cdb6555372c7732c02b5430b16483 /transcode.c
parent8bf5284c1e280e55678bed140fae940703aa8047 (diff)
* transcode.c (rb_econv_open0): make it static.
(rb_econv_open): place decorators at last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/transcode.c b/transcode.c
index 238001939f..b4be8e3531 100644
--- a/transcode.c
+++ b/transcode.c
@@ -878,7 +878,7 @@ trans_open_i(const char *sname, const char *dname, int depth, void *arg)
toarg->entries[depth] = get_transcoder_entry(sname, dname);
}
-rb_econv_t *
+static rb_econv_t *
rb_econv_open0(const char *sname, const char *dname, int ecflags)
{
transcoder_entry_t **entries = NULL;
@@ -943,8 +943,8 @@ rb_econv_t *
rb_econv_open(const char *sname, const char *dname, int ecflags)
{
rb_econv_t *ec;
- int num_encoders, num_decoders;
- const char *encoders[4], *decoders[1];
+ int num_decorators;
+ const char *decorators[6];
int i;
if ((ecflags & ECONV_CRLF_NEWLINE_ENCODER) &&
@@ -959,40 +959,34 @@ rb_econv_open(const char *sname, const char *dname, int ecflags)
(ecflags & ECONV_XML_ATTR_CONTENT_ENCODER))
return NULL;
- num_encoders = 0;
- if (ecflags & ECONV_CRLF_NEWLINE_ENCODER)
- if (!(encoders[num_encoders++] = "crlf_newline"))
- return NULL;
- if (ecflags & ECONV_CR_NEWLINE_ENCODER)
- if (!(encoders[num_encoders++] = "cr_newline"))
- return NULL;
+ num_decorators = 0;
+
if (ecflags & ECONV_XML_TEXT_ENCODER)
- if (!(encoders[num_encoders++] = "xml-text-escaped"))
+ if (!(decorators[num_decorators++] = "xml-text-escaped"))
return NULL;
if (ecflags & ECONV_XML_ATTR_CONTENT_ENCODER)
- if (!(encoders[num_encoders++] = "xml-attr-content-escaped"))
+ if (!(decorators[num_decorators++] = "xml-attr-content-escaped"))
return NULL;
if (ecflags & ECONV_XML_ATTR_QUOTE_ENCODER)
- if (!(encoders[num_encoders++] = "xml-attr-quoted"))
+ if (!(decorators[num_decorators++] = "xml-attr-quoted"))
return NULL;
- num_decoders = 0;
+ if (ecflags & ECONV_CRLF_NEWLINE_ENCODER)
+ if (!(decorators[num_decorators++] = "crlf_newline"))
+ return NULL;
+ if (ecflags & ECONV_CR_NEWLINE_ENCODER)
+ if (!(decorators[num_decorators++] = "cr_newline"))
+ return NULL;
if (ecflags & ECONV_UNIVERSAL_NEWLINE_DECODER)
- if (!(decoders[num_decoders++] = "universal_newline"))
+ if (!(decorators[num_decorators++] = "universal_newline"))
return NULL;
ec = rb_econv_open0(sname, dname, ecflags & ECONV_ERROR_HANDLER_MASK);
if (!ec)
return NULL;
- for (i = 0; i < num_decoders; i++)
- if (rb_econv_decorate_at_last(ec, decoders[i]) == -1) {
- rb_econv_close(ec);
- return NULL;
- }
-
- for (i = num_encoders-1; 0 <= i; i--)
- if (rb_econv_decorate_at_first(ec, encoders[i]) == -1) {
+ for (i = 0; i < num_decorators; i++)
+ if (rb_econv_decorate_at_last(ec, decorators[i]) == -1) {
rb_econv_close(ec);
return NULL;
}