diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-14 08:16:51 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-14 08:16:51 +0000 |
commit | e9d69ca0cea5e963022631d5940b3722d4d4eb51 (patch) | |
tree | dad65ba21d3dd52a77dadb29e294f17eff2bdab1 | |
parent | d37d14c0a53d0541790743dda3cfbb6e40fee797 (diff) |
* ext/tk/tkutil/extronf.rb: check stdndup() because it's not standard
function of C.
* ext/tk/tkutil/tkutil.c (cbsubst_table_setup): use malloc() and
strncpy() instead of strndup() if not available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ext/tk/tkutil/extconf.rb | 1 | ||||
-rw-r--r-- | ext/tk/tkutil/tkutil.c | 9 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 21 insertions, 3 deletions
@@ -1,3 +1,11 @@ +Wed May 14 17:15:11 2008 NAKAMURA Usaku <[email protected]> + + * ext/tk/tkutil/extronf.rb: check stdndup() because it's not standard + function of C. + + * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): use malloc() and + strncpy() instead of strndup() if not available. + Wed May 14 09:52:02 2008 Hidetoshi NAGAI <[email protected]> * ext/tk/tkutil/tkutil.c: improve handling callback-subst-keys. diff --git a/ext/tk/tkutil/extconf.rb b/ext/tk/tkutil/extconf.rb index 51f775619c..015bc3a45e 100644 --- a/ext/tk/tkutil/extconf.rb +++ b/ext/tk/tkutil/extconf.rb @@ -8,5 +8,6 @@ end if has_tk require 'mkmf' have_func("rb_obj_instance_exec", "ruby.h") + have_func("strndup", "string.h") create_makefile('tkutil') end diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index e83e3085d4..d6c70db22e 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -1522,8 +1522,17 @@ cbsubst_table_setup(argc, argv, self) chr = (unsigned char)(0x80 + idx); subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]); +#if HAVE_STRNDUP subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]), RSTRING_LEN(RARRAY_PTR(inf)[0])); +#else + subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1); + if (subst_inf->key[chr]) { + strncpy(subst_inf->key[chr], RSTRING_PTR(RARRAY_PTR(inf)[0]), + RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1); + subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0'; + } +#endif if (TYPE(RARRAY_PTR(inf)[1]) == T_STRING) { subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1])); } else { @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-05-13" +#define RUBY_RELEASE_DATE "2008-05-14" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20080513 +#define RUBY_RELEASE_CODE 20080514 #define RUBY_PATCHLEVEL 5000 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 13 +#define RUBY_RELEASE_DAY 14 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; |