Skip to content

Commit

Permalink
Correctly spec rb_str_new_cstr as 1.9-only CAPI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryoqun committed Jul 2, 2012
1 parent 1c079a8 commit 87c49c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 0 additions & 2 deletions spec/ruby/optional/capi/ext/mri.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/optional/capi/ext/rubyspec.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 87c49c9

Please sign in to comment.