summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-07 22:44:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-07 22:44:27 +0000
commit6572bd3ce9bce5199bbebfe78b2b61290b0308a7 (patch)
tree939e9ee35f7e2032e7ecbe11af70ca5c6e2a4840 /transcode.c
parent7dc427f7ed18574470dea3c6c28c27d4134ec395 (diff)
* transcode.c (rb_declare_transcoder, load_transcoder_entry): no
longer need to limit the length of transcoder library name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/transcode.c b/transcode.c
index 44bed8b2d2..7caad0f87c 100644
--- a/transcode.c
+++ b/transcode.c
@@ -227,15 +227,13 @@ declare_transcoder(const char *sname, const char *dname, const char *lib)
entry->lib = lib;
}
-#define MAX_TRANSCODER_LIBNAME_LEN 64
static const char transcoder_lib_prefix[] = "enc/trans/";
void
rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib)
{
- if (!lib || strlen(lib) > MAX_TRANSCODER_LIBNAME_LEN) {
- rb_raise(rb_eArgError, "invalid library name - %s",
- lib ? lib : "(null)");
+ if (!lib) {
+ rb_raise(rb_eArgError, "invalid library name - (null)");
}
declare_transcoder(enc1, enc2, lib);
}
@@ -367,18 +365,14 @@ load_transcoder_entry(transcoder_entry_t *entry)
return entry->transcoder;
if (entry->lib) {
- const char *lib = entry->lib;
- size_t len = strlen(lib);
- size_t total_len = sizeof(transcoder_lib_prefix) - 1 + len;
- char *path;
- VALUE fn;
+ const char *const lib = entry->lib;
+ const size_t len = strlen(lib);
+ const size_t total_len = sizeof(transcoder_lib_prefix) - 1 + len;
+ const VALUE fn = rb_str_new(0, total_len);
+ char *const path = RSTRING_PTR(fn);
entry->lib = NULL;
- if (len > MAX_TRANSCODER_LIBNAME_LEN)
- return NULL;
- fn = rb_str_new(0, total_len);
- path = RSTRING_PTR(fn);
memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1);
memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len);
rb_str_set_len(fn, total_len);