Permalink
Browse files

RSTRING_PTR() returns (char *) instead of (const char *) like CRuby b…

…ecause the compiling fails with some C extension libraries
  • Loading branch information...
1 parent 542dc07 commit a1087cc8be54cbd08babd61abfcd4635292abbf9 @Watson1978 Watson1978 committed Aug 18, 2012
Showing with 17 additions and 17 deletions.
  1. +3 −3 ext/socket/socket.c
  2. +7 −7 file.c
  3. +1 −1 include/ruby/ruby.h
  4. +1 −1 parse.y
  5. +1 −1 process.c
  6. +3 −3 string.c
  7. +1 −1 time.c
View
@@ -311,7 +311,7 @@ constant_arg(VALUE arg, int (*str_to_int)(char*, int, int*), const char *errmsg)
arg = tmp;
str:
rb_check_safe_obj(arg);
- ptr = (char *)RSTRING_PTR(arg);
+ ptr = RSTRING_PTR(arg);
if (str_to_int(ptr, RSTRING_LEN(arg), &ret) == -1)
rb_raise(rb_eSocket, "%s: %s", errmsg, ptr);
}
@@ -5289,7 +5289,7 @@ addrinfo_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
VALUE afamily = rb_ary_entry(sockaddr_ary, 0);
int af;
StringValue(afamily);
- if (family_to_int((char *)RSTRING_PTR(afamily), RSTRING_LENINT(afamily), &af) == -1)
+ if (family_to_int(RSTRING_PTR(afamily), RSTRING_LENINT(afamily), &af) == -1)
rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily));
switch (af) {
case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */
@@ -6346,7 +6346,7 @@ static char *
sockaddr_string_value_ptr(volatile VALUE *v)
{
sockaddr_string_value(v);
- return (char *)RSTRING_PTR(*v);
+ return RSTRING_PTR(*v);
}
static VALUE
View
@@ -2504,7 +2504,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
}
else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') {
if (*prefixlenp < RSTRING_LEN(*resolvedp)) {
- char *resolved_names = (char *)RSTRING_PTR(*resolvedp) + *prefixlenp;
+ char *resolved_names = RSTRING_PTR(*resolvedp) + *prefixlenp;
char *lastsep = rb_path_last_separator(resolved_names);
long len = lastsep ? lastsep - resolved_names : 0;
rb_str_set_len(*resolvedp, *prefixlenp + len);
@@ -2530,7 +2530,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
struct stat sbuf;
int ret;
VALUE testpath2 = rb_str_encode_ospath(testpath);
- ret = lstat((char *)RSTRING_PTR(testpath2), &sbuf);
+ ret = lstat(RSTRING_PTR(testpath2), &sbuf);
if (ret == -1) {
if (errno == ENOENT) {
if (strict || !last || *unresolved_firstsep)
@@ -2549,7 +2549,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
long link_prefixlen;
rb_hash_aset(loopcheck, testpath, ID2SYM(resolving));
link = rb_file_s_readlink(rb_cFile, 0, testpath);
- link_prefix = (char *)RSTRING_PTR(link);
+ link_prefix = RSTRING_PTR(link);
link_names = skiproot(link_prefix);
link_prefixlen = link_names - link_prefix;
if (link_prefixlen == 0) {
@@ -2596,15 +2596,15 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict)
basedir = rb_str_dup_frozen(basedir);
}
- ptr = (char *)RSTRING_PTR(unresolved_path);
+ ptr = RSTRING_PTR(unresolved_path);
path_names = skiproot(ptr);
if (ptr != path_names) {
resolved = rb_str_new(ptr, path_names - ptr);
goto root_found;
}
if (!NIL_P(basedir)) {
- ptr = (char *)RSTRING_PTR(basedir);
+ ptr = RSTRING_PTR(basedir);
basedir_names = skiproot(ptr);
if (ptr != basedir_names) {
resolved = rb_str_new(ptr, basedir_names - ptr);
@@ -2613,12 +2613,12 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict)
}
curdir = ruby_getcwd();
- ptr = (char *)RSTRING_PTR(curdir);
+ ptr = RSTRING_PTR(curdir);
curdir_names = skiproot(ptr);
resolved = rb_str_new(ptr, curdir_names - ptr);
root_found:
- prefixptr = (char *)RSTRING_PTR(resolved);
+ prefixptr = RSTRING_PTR(resolved);
prefixlen = RSTRING_LEN(resolved);
ptr = chompdirsep(prefixptr);
if (*ptr) {
View
@@ -468,7 +468,7 @@ int rb_class_ismeta(VALUE klass);
#define ELTS_SHARED FL_USER2
-const char *rb_str_cstr(VALUE);
+char *rb_str_cstr(VALUE);
long rb_str_clen(VALUE);
#define RSTRING_PTR(str) (rb_str_cstr((VALUE)str))
#define RSTRING_LEN(str) (rb_str_clen((VALUE)str))
View
@@ -10208,7 +10208,7 @@ ripper_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
parser_initialize(parser);
GC_WB(&parser->parser_ruby_sourcefile_string, fname);
- parser->parser_ruby_sourcefile = (char *)RSTRING_PTR(fname);
+ parser->parser_ruby_sourcefile = RSTRING_PTR(fname);
parser->parser_ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
return Qnil;
View
@@ -1031,7 +1031,7 @@ rb_proc_exec_n(int argc, VALUE *argv, const char *prog)
args = ALLOCA_N(char*, argc+1);
for (i=0; i<argc; i++) {
- args[i] = (char *)RSTRING_PTR(argv[i]);
+ args[i] = RSTRING_PTR(argv[i]);
}
args[i] = 0;
if (args[0]) {
View
@@ -6555,7 +6555,7 @@ rb_str_new_cstr(const char *ptr)
}
-const char *
+char *
rb_str_cstr(VALUE str)
{
if (IS_RSTR(str)) {
@@ -6565,7 +6565,7 @@ rb_str_cstr(VALUE str)
str_ensure_null_terminator(RSTR(str));
return RSTR(str)->bytes;
}
- return nsstr_cstr(str);
+ return (char*)nsstr_cstr(str);
}
long
@@ -6594,7 +6594,7 @@ char *
rb_string_value_ptr(volatile VALUE *ptr)
{
VALUE str = rb_string_value(ptr);
- return (char*)rb_str_cstr(str);
+ return rb_str_cstr(str);
}
VALUE
View
@@ -2110,7 +2110,7 @@ utc_offset_arg(VALUE arg)
VALUE tmp;
if (!NIL_P(tmp = rb_check_string_type(arg))) {
int n;
- char *s = (char*)RSTRING_PTR(tmp);
+ char *s = RSTRING_PTR(tmp);
if (!rb_enc_str_asciicompat_p(tmp) ||
RSTRING_LEN(tmp) != 6 ||
(s[0] != '+' && s[0] != '-') ||

0 comments on commit a1087cc

Please sign in to comment.