diff --git a/ChangeLog b/ChangeLog index a91da7a725..161baa7f84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed May 14 17:15:11 2008 NAKAMURA Usaku + + * 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 * 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 { diff --git a/version.h b/version.h index 0925987762..3774b3e551 100644 --- a/version.h +++ b/version.h @@ -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[];