1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* suppress warnings with -Wwrite-string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-05-31 09:28:20 +00:00
parent 1b039e2a92
commit 075530a685
31 changed files with 65 additions and 61 deletions

View file

@ -1,3 +1,7 @@
Sat May 31 18:28:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* suppress warnings with -Wwrite-string.
Sat May 31 18:26:33 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_delete_if): should return enumerator if no block

View file

@ -134,7 +134,7 @@ static int iseq_set_optargs_table(rb_iseq_t *iseq);
*/
static void
verify_list(ISEQ_ARG_DECLARE char *info, LINK_ANCHOR *anchor)
verify_list(ISEQ_ARG_DECLARE const char *info, LINK_ANCHOR *anchor)
{
#if CPDEBUG
int flag = 0;
@ -2302,7 +2302,7 @@ static int
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
NODE *node, LABEL **lfinish, VALUE needstr)
{
char *estr = 0;
const char *estr = 0;
enum node_type type;
switch (type = nd_type(node)) {

2
dir.c
View file

@ -458,7 +458,7 @@ dir_inspect(VALUE dir)
Data_Get_Struct(dir, struct dir_data, dirp);
if (dirp->path) {
char *c = rb_obj_classname(dir);
const char *c = rb_obj_classname(dir);
int len = strlen(c) + strlen(dirp->path) + 4;
VALUE s = rb_str_new(0, len);
snprintf(RSTRING_PTR(s), len+1, "#<%s:%s>", c, dirp->path);

2
eval.c
View file

@ -326,7 +326,7 @@ rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
void
rb_frozen_class_p(VALUE klass)
{
char *desc = "something(?!)";
const char *desc = "something(?!)";
if (OBJ_FROZEN(klass)) {
if (FL_TEST(klass, FL_SINGLETON))

View file

@ -69,7 +69,7 @@ error_print(void)
VALUE errat = Qnil; /* OK */
VALUE errinfo = GET_THREAD()->errinfo;
volatile VALUE eclass, e;
char *einfo;
const char *einfo;
long elen;
if (NIL_P(errinfo))
@ -188,7 +188,7 @@ ruby_error_print(void)
void
rb_print_undef(VALUE klass, ID id, int scope)
{
char *v;
const char *v;
switch (scope) {
default:

View file

@ -583,7 +583,7 @@ VALUE rb_struct_iv_get(VALUE, const char*);
VALUE rb_struct_s_members(VALUE);
VALUE rb_struct_members(VALUE);
VALUE rb_struct_alloc_noinit(VALUE);
VALUE rb_struct_define_without_accessor(char *, VALUE, rb_alloc_func_t, ...);
VALUE rb_struct_define_without_accessor(const char *, VALUE, rb_alloc_func_t, ...);
/* thread.c */
typedef void rb_unblock_function_t(void *);
typedef VALUE rb_blocking_function_t(void *);

View file

@ -778,8 +778,8 @@ VALUE rb_id2str(ID);
rb_intern(str))
#endif
char *rb_class2name(VALUE);
char *rb_obj_classname(VALUE);
const char *rb_class2name(VALUE);
const char *rb_obj_classname(VALUE);
void rb_p(VALUE);

View file

@ -775,7 +775,7 @@ defined
(VALUE val)
{
VALUE klass;
char *expr_type = 0;
const char *expr_type = 0;
val = Qnil;
switch (type) {

8
io.c
View file

@ -1248,7 +1248,7 @@ static VALUE
rb_io_inspect(VALUE obj)
{
rb_io_t *fptr;
char *cname;
const char *cname;
const char *st = "";
fptr = RFILE(rb_io_taint_check(obj))->fptr;
@ -5057,7 +5057,7 @@ static VALUE
rb_io_s_new(int argc, VALUE *argv, VALUE klass)
{
if (rb_block_given_p()) {
char *cname = rb_class2name(klass);
const char *cname = rb_class2name(klass);
rb_warn("%s::new() does not take block; use %s::open() instead",
cname, cname);
@ -6345,9 +6345,9 @@ struct copy_stream_struct {
int close_src;
int close_dst;
off_t total;
char *syserr;
const char *syserr;
int error_no;
char *notimp;
const char *notimp;
rb_fdset_t fds;
rb_thread_t *th;
};

2
iseq.c
View file

@ -774,7 +774,7 @@ ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
return len;
}
static char *
static const char *
catch_type(int type)
{
switch (type) {

View file

@ -1,5 +1,5 @@
%{
struct kwtable {char *name; int id[2]; enum lex_state_e state;};
struct kwtable {const char *name; int id[2]; enum lex_state_e state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
%}

View file

@ -30,7 +30,7 @@ error "gperf generated tables don't work with this execution character set. Plea
#line 1 "keywords"
struct kwtable {char *name; int id[2]; enum lex_state_e state;};
struct kwtable {const char *name; int id[2]; enum lex_state_e state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
#line 7 "keywords"

View file

@ -1,5 +1,5 @@
%{
struct kwtable {char *name; int id[2]; enum lex_state_e state;};
struct kwtable {const char *name; int id[2]; enum lex_state_e state;};
const struct kwtable *rb_reserved_word(const char *, unsigned int);
#ifndef RIPPER
%}

View file

@ -414,7 +414,7 @@ hash_each(VALUE key, VALUE value, struct dump_call_arg *arg)
static void
w_extended(VALUE klass, struct dump_arg *arg, int check)
{
char *path;
const char *path;
if (check && FL_TEST(klass, FL_SINGLETON)) {
if (RCLASS_M_TBL(klass)->num_entries ||

2
math.c
View file

@ -35,7 +35,7 @@ to_flo(VALUE x)
} while (0)
static void
domain_check(double x, char *msg)
domain_check(double x, const char *msg)
{
while(1) {
if (errno) {

View file

@ -217,7 +217,7 @@ typedef struct __sFILE {
* I/O descriptors for __sfvwrite().
*/
struct __siov {
void *iov_base;
const void *iov_base;
size_t iov_len;
};
struct __suio {
@ -422,7 +422,7 @@ BSD__uqtoa(register u_quad_t val, char *endp, int base, int octzero, char *xdigs
* use the given digits.
*/
static char *
BSD__ultoa(register u_long val, char *endp, int base, int octzero, char *xdigs)
BSD__ultoa(register u_long val, char *endp, int base, int octzero, const char *xdigs)
{
register char *cp = endp;
register long sval;
@ -523,10 +523,10 @@ static int exponent __P((char *, int, int));
static int
BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
{
register char *fmt; /* format string */
register const char *fmt; /* format string */
register int ch; /* character from fmt */
register int n; /* handy integer (short term usage) */
register char *cp; /* handy char pointer (short term usage) */
register const char *cp;/* handy char pointer (short term usage) */
register struct __siov *iovp;/* for PRINT macro */
register int flags; /* flags as above */
int ret; /* return value accumulator */
@ -550,12 +550,13 @@ BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
int fieldsz; /* field size expanded by sign, etc */
int realsz; /* field size expanded by dprec */
int size; /* size of converted field or string */
char *xdigs = 0; /* digits for [xX] conversion */
const char *xdigs = 0; /* digits for [xX] conversion */
#define NIOV 8
struct __suio uio; /* output information: summary */
struct __siov iov[NIOV];/* ... and individual io vectors */
char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
char ox[2]; /* space for 0x hex-prefix */
char *const ebuf = buf + sizeof(buf);
/*
* Choose PADSIZE to trade efficiency vs. size. If larger printf
@ -616,7 +617,7 @@ BSD_vfprintf(FILE *fp, const char *fmt0, va_list ap)
fp->_file >= 0)
return (BSD__sbprintf(fp, fmt0, ap));
fmt = (char *)fmt0;
fmt = fmt0;
uio.uio_iov = iovp = iov;
uio.uio_resid = 0;
uio.uio_iovcnt = 0;
@ -720,7 +721,8 @@ reswitch: switch (ch) {
goto rflag;
#endif /* _HAVE_SANE_QUAD_ */
case 'c':
*(cp = buf) = va_arg(ap, int);
cp = buf;
*buf = (char)va_arg(ap, int);
size = 1;
sign = '\0';
break;
@ -868,7 +870,7 @@ fp_begin: _double = va_arg(ap, double);
* NUL in the first `prec' characters, and
* strlen() will go further.
*/
char *p = (char *)memchr(cp, 0, prec);
const char *p = (char *)memchr(cp, 0, prec);
if (p != NULL) {
size = p - cp;
@ -930,28 +932,27 @@ number: if ((dprec = prec) >= 0)
* explicit precision of zero is no characters.''
* -- ANSI X3J11
*/
cp = buf + BUF;
#ifdef _HAVE_SANE_QUAD_
if (flags & QUADINT) {
if (uqval != 0 || prec != 0)
cp = BSD__uqtoa(uqval, cp, base,
cp = BSD__uqtoa(uqval, ebuf, base,
flags & ALT, xdigs);
} else
#else /* _HAVE_SANE_QUAD_ */
#endif /* _HAVE_SANE_QUAD_ */
{
if (ulval != 0 || prec != 0)
cp = BSD__ultoa(ulval, cp, base,
cp = BSD__ultoa(ulval, ebuf, base,
flags & ALT, xdigs);
}
size = buf + BUF - cp;
size = ebuf - cp;
break;
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0')
goto done;
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
*buf = ch;
size = 1;
sign = '\0';
break;

View file

@ -298,7 +298,7 @@ rb_obj_init_copy(VALUE obj, VALUE orig)
VALUE
rb_any_to_s(VALUE obj)
{
char *cname = rb_obj_classname(obj);
const char *cname = rb_obj_classname(obj);
VALUE str;
str = rb_sprintf("#<%s:%p>", cname, (void*)obj);
@ -387,9 +387,8 @@ rb_obj_inspect(VALUE obj)
if (has_ivar) {
VALUE str;
char *c;
const char *c = rb_obj_classname(obj);
c = rb_obj_classname(obj);
str = rb_sprintf("-<%s:%p", c, (void*)obj);
return rb_exec_recursive(inspect_obj, obj, str);
}
@ -1916,7 +1915,7 @@ rb_convert_type(VALUE val, int type, const char *tname, const char *method)
if (TYPE(val) == type) return val;
v = convert_type(val, tname, method, Qtrue);
if (TYPE(v) != type) {
char *cname = rb_obj_classname(val);
const char *cname = rb_obj_classname(val);
rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
cname, tname, cname, method, rb_obj_classname(v));
}
@ -1933,7 +1932,7 @@ rb_check_convert_type(VALUE val, int type, const char *tname, const char *method
v = convert_type(val, tname, method, Qfalse);
if (NIL_P(v)) return Qnil;
if (TYPE(v) != type) {
char *cname = rb_obj_classname(val);
const char *cname = rb_obj_classname(val);
rb_raise(rb_eTypeError, "can't convert %s to %s (%s#%s gives %s)",
cname, tname, cname, method, rb_obj_classname(v));
}
@ -1949,7 +1948,7 @@ rb_to_integer(VALUE val, const char *method)
if (FIXNUM_P(val)) return val;
v = convert_type(val, "Integer", method, Qtrue);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
char *cname = rb_obj_classname(val);
const char *cname = rb_obj_classname(val);
rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)",
cname, cname, method, rb_obj_classname(v));
}

4
pack.c
View file

@ -475,7 +475,7 @@ pack_pack(VALUE ary, VALUE fmt)
continue;
}
if (*p == '_' || *p == '!') {
const char *natstr = "sSiIlL";
static const char natstr[] = "sSiIlL";
if (strchr(natstr, type)) {
#ifdef NATINT_PACK
@ -1335,7 +1335,7 @@ pack_unpack(VALUE str, VALUE fmt)
}
star = 0;
if (*p == '_' || *p == '!') {
const char *natstr = "sSiIlL";
static const char natstr[] = "sSiIlL";
if (strchr(natstr, type)) {
#ifdef NATINT_PACK

4
proc.c
View file

@ -661,7 +661,7 @@ proc_to_s(VALUE self)
{
VALUE str = 0;
rb_proc_t *proc;
char *cname = rb_obj_classname(self);
const char *cname = rb_obj_classname(self);
rb_iseq_t *iseq;
const char *is_lambda;
@ -1417,7 +1417,7 @@ method_inspect(VALUE method)
struct METHOD *data;
VALUE str;
const char *s;
char *sharp = "#";
const char *sharp = "#";
Data_Get_Struct(method, struct METHOD, data);
str = rb_str_buf_new2("#<");

2
re.c
View file

@ -1753,7 +1753,7 @@ match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end,
static VALUE
match_inspect(VALUE match)
{
char *cname = rb_obj_classname(match);
const char *cname = rb_obj_classname(match);
VALUE str;
int i;
struct re_registers *regs = RMATCH_REGS(match);

View file

@ -41,7 +41,7 @@
extern UChar*
onig_error_code_to_format(int code)
{
char *p;
const char *p;
if (code >= 0) return (UChar* )0;

2
ruby.c
View file

@ -89,7 +89,7 @@ struct cmdline_options {
int verbose;
int yydebug;
unsigned int dump;
char *script;
const char *script;
VALUE script_name;
VALUE e_script;
struct {

View file

@ -5914,7 +5914,8 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
VALUE w;
long width, len, flen = 1, fclen = 1;
VALUE res;
char *p, *f = " ";
char *p;
const char *f = " ";
long n, llen, rlen;
volatile VALUE pad;
int singlebyte = 1;

View file

@ -223,7 +223,7 @@ rb_struct_alloc_noinit(VALUE klass)
}
VALUE
rb_struct_define_without_accessor(char *class_name, VALUE super, rb_alloc_func_t alloc, ...)
rb_struct_define_without_accessor(const char *class_name, VALUE super, rb_alloc_func_t alloc, ...)
{
VALUE klass;
va_list ar;
@ -479,7 +479,7 @@ rb_struct_each_pair(VALUE s)
static VALUE
inspect_struct(VALUE s, VALUE dummy, int recur)
{
char *cname = rb_class2name(rb_obj_class(s));
const char *cname = rb_class2name(rb_obj_class(s));
VALUE str, members;
long i;

View file

@ -1471,7 +1471,7 @@ rb_thread_safe_level(VALUE thread)
static VALUE
rb_thread_inspect(VALUE thread)
{
char *cname = rb_obj_classname(thread);
const char *cname = rb_obj_classname(thread);
rb_thread_t *th;
const char *status;
VALUE str;
@ -2491,7 +2491,7 @@ VALUE
rb_mutex_unlock(VALUE self)
{
mutex_t *mutex;
char *err = NULL;
const char *err = NULL;
GetMutexPtr(self, mutex);
native_mutex_lock(&mutex->lock);
@ -3039,7 +3039,7 @@ thread_set_trace_func_m(VALUE obj, VALUE trace)
return trace;
}
static char *
static const char *
get_event_name(rb_event_flag_t event)
{
switch (event) {

2
time.c
View file

@ -333,7 +333,7 @@ time_s_at(int argc, VALUE *argv, VALUE klass)
return t;
}
static const char *const months[] = {
static const char const months[][4] = {
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec",
};

2
util.c
View file

@ -3202,7 +3202,7 @@ rv_alloc(int i)
}
static char *
nrv_alloc(char *s, char **rve, int n)
nrv_alloc(const char *s, char **rve, int n)
{
char *rv, *t;

View file

@ -270,13 +270,13 @@ rb_class_name(VALUE klass)
return rb_class_path(rb_class_real(klass));
}
char *
const char *
rb_class2name(VALUE klass)
{
return RSTRING_PTR(rb_class_name(klass));
}
char *
const char *
rb_obj_classname(VALUE obj)
{
return rb_class2name(CLASS_OF(obj));

View file

@ -576,7 +576,6 @@ VALUE rb_make_backtrace(void);
void
rb_vm_bugreport(void)
{
rb_thread_t *th = GET_THREAD();
VALUE bt;
if (GET_THREAD()->vm) {

View file

@ -293,7 +293,7 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
{
ID id;
VALUE exc = rb_eNoMethodError;
char *format = 0;
const char *format = 0;
rb_thread_t *th = GET_THREAD();
int last_call_status = th->method_missing_reason;
if (argc == 0 || !SYMBOL_P(argv[0])) {
@ -773,7 +773,7 @@ VALUE
rb_f_eval(int argc, VALUE *argv, VALUE self)
{
VALUE src, scope, vfile, vline;
char *file = "(eval)";
const char *file = "(eval)";
int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
@ -925,7 +925,7 @@ specific_eval(int argc, VALUE *argv, VALUE klass, VALUE self)
return yield_under(klass, self, Qundef);
}
else {
char *file = "(eval)";
const char *file = "(eval)";
int line = 1;
if (argc == 0) {

View file

@ -484,7 +484,7 @@ rb_undef(VALUE klass, ID id)
}
body = search_method(klass, id, &origin);
if (!body || !body->nd_body) {
char *s0 = " class";
const char *s0 = " class";
VALUE c = klass;
if (FL_TEST(c, FL_SINGLETON)) {