From 87c49c92b35c5bf45c4cd211a8877771b622c8c4 Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Mon, 2 Jul 2012 20:50:52 +0900 Subject: [PATCH] Correctly spec rb_str_new_cstr as 1.9-only CAPI Currently, rb_str_new_cstr is spec'ed as a function available under both 1.8 CAPI and 1.9 CAPI in spec/ruby/optional/capi/ext/rubyspec.h. This is not true. As a version guard is correctly used in spec/ruby/optional/capi/string_spec.rb, it is only declared under 1.9 CAPI, not under 1.8 CAPI. In 1.8 mode, rb_str_new_cstr specs are only compiled, not run, thanks to the version guard. So, there is no spec failures. However, this commit suppresses the following warning from clang: spec/ruby/optional/capi/ext/string_spec.c:165:12: warning: implicit declaration of function 'rb_str_new_cstr' is invalid in C99 [-Wimplicit-function-declaration] return rb_str_new_cstr(NULL); ^ 1 warning generated. Also, #undefs aren't needed in spec/ruby/optional/capi/ext/mri.h, because rb_str_new_cstr is now correctly declared only in 1.9 CAPI. --- spec/ruby/optional/capi/ext/mri.h | 2 -- spec/ruby/optional/capi/ext/rubyspec.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/ruby/optional/capi/ext/mri.h b/spec/ruby/optional/capi/ext/mri.h index 9567990e1d..5b58310123 100644 --- a/spec/ruby/optional/capi/ext/mri.h +++ b/spec/ruby/optional/capi/ext/mri.h @@ -18,12 +18,10 @@ #undef HAVE_RBIGNUM_POSITIVE_P #undef HAVE_RBIGNUM_NEGATIVE_P #undef HAVE_RB_STR_SET_LEN -#undef HAVE_RB_STR_NEW_CSTR #endif #ifdef RUBY_VERSION_IS_1_8_EX_1_9 #undef HAVE_RB_THREAD_BLOCKING_REGION -#undef HAVE_RB_STR_NEW_CSTR #undef HAVE_RB_RATIONAL #undef HAVE_RB_RATIONAL1 #undef HAVE_RB_RATIONAL2 diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h index c04dfe4d10..bbb930c099 100644 --- a/spec/ruby/optional/capi/ext/rubyspec.h +++ b/spec/ruby/optional/capi/ext/rubyspec.h @@ -199,6 +199,7 @@ #define HAVE_RB_ENC_TO_INDEX 1 #define HAVE_RB_OBJ_ENCODING 1 +#define HAVE_RB_STR_NEW_CSTR 1 #define HAVE_RB_USASCII_STR_NEW 1 #define HAVE_RB_USASCII_STR_NEW_CSTR 1 #define HAVE_RB_EXTERNAL_STR_NEW 1 @@ -432,7 +433,6 @@ #define HAVE_RB_STR_INTERN 1 #define HAVE_RB_STR_LEN 1 #define HAVE_RB_STR_NEW 1 -#define HAVE_RB_STR_NEW_CSTR 1 #define HAVE_RB_STR_NEW2 1 #define HAVE_RB_STR_NEW3 1 #define HAVE_RB_STR_NEW4 1