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/branches/ruby_1_8@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-05-31 09:28:20 +00:00
parent f3c0922a5a
commit 1378795e08
23 changed files with 111 additions and 104 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 15:58:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat May 31 15:58:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in, configure.in (warnflags): defaulted to -Wall * Makefile.in, configure.in (warnflags): defaulted to -Wall

2
dir.c
View file

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

View file

@ -259,7 +259,7 @@ rb_check_type(x, t)
if (TYPE(x) != t) { if (TYPE(x) != t) {
while (type->type >= 0) { while (type->type >= 0) {
if (type->type == t) { if (type->type == t) {
char *etype; const char *etype;
if (NIL_P(x)) { if (NIL_P(x)) {
etype = "nil"; etype = "nil";
@ -500,7 +500,7 @@ rb_check_backtrace(bt)
VALUE bt; VALUE bt;
{ {
long i; long i;
static char *err = "backtrace must be Array of String"; static const char err[] = "backtrace must be Array of String";
if (!NIL_P(bt)) { if (!NIL_P(bt)) {
int t = TYPE(bt); int t = TYPE(bt);
@ -729,7 +729,7 @@ name_err_mesg_to_str(obj)
mesg = ptr[0]; mesg = ptr[0];
if (NIL_P(mesg)) return Qnil; if (NIL_P(mesg)) return Qnil;
else { else {
char *desc = 0; const char *desc = 0;
VALUE d = 0, args[3]; VALUE d = 0, args[3];
obj = ptr[1]; obj = ptr[1];
@ -883,7 +883,7 @@ syserr_initialize(argc, argv, self)
#if !defined(_WIN32) && !defined(__VMS) #if !defined(_WIN32) && !defined(__VMS)
char *strerror(); char *strerror();
#endif #endif
char *err; const char *err;
VALUE mesg, error; VALUE mesg, error;
VALUE klass = rb_obj_class(self); VALUE klass = rb_obj_class(self);

58
eval.c
View file

@ -1103,8 +1103,8 @@ static void scope_dup _((struct SCOPE *));
} while (0) } while (0)
static VALUE rb_eval _((VALUE,NODE*)); static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int)); static VALUE eval _((VALUE,VALUE,VALUE,const char*,int));
static NODE *compile _((VALUE, char*, int)); static NODE *compile _((VALUE, const char*, int));
static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int)); static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
@ -1227,7 +1227,7 @@ error_print()
{ {
VALUE errat = Qnil; /* OK */ VALUE errat = Qnil; /* OK */
volatile VALUE eclass, e; volatile VALUE eclass, e;
char *einfo; const char *einfo;
long elen; long elen;
if (NIL_P(ruby_errinfo)) return; if (NIL_P(ruby_errinfo)) return;
@ -2032,7 +2032,7 @@ void
rb_frozen_class_p(klass) rb_frozen_class_p(klass)
VALUE klass; VALUE klass;
{ {
char *desc = "something(?!)"; const char *desc = "something(?!)";
if (OBJ_FROZEN(klass)) { if (OBJ_FROZEN(klass)) {
if (FL_TEST(klass, FL_SINGLETON)) if (FL_TEST(klass, FL_SINGLETON))
@ -2070,7 +2070,7 @@ rb_undef(klass, id)
} }
body = search_method(klass, id, &origin); body = search_method(klass, id, &origin);
if (!body || !body->nd_body) { if (!body || !body->nd_body) {
char *s0 = " class"; const char *s0 = " class";
VALUE c = klass; VALUE c = klass;
if (FL_TEST(c, FL_SINGLETON)) { if (FL_TEST(c, FL_SINGLETON)) {
@ -2322,9 +2322,9 @@ rb_copy_node_scope(node, rval)
#define MATCH_DATA *rb_svar(node->nd_cnt) #define MATCH_DATA *rb_svar(node->nd_cnt)
static char* is_defined _((VALUE, NODE*, char*)); static const char* is_defined _((VALUE, NODE*, char*));
static char* static const char*
arg_defined(self, node, buf, type) arg_defined(self, node, buf, type)
VALUE self; VALUE self;
NODE *node; NODE *node;
@ -2351,7 +2351,7 @@ arg_defined(self, node, buf, type)
return type; return type;
} }
static char* static const char*
is_defined(self, node, buf) is_defined(self, node, buf)
VALUE self; VALUE self;
NODE *node; /* OK */ NODE *node; /* OK */
@ -2671,27 +2671,27 @@ set_trace_func(obj, trace)
return trace; return trace;
} }
static char * static const char *
get_event_name(rb_event_t event) get_event_name(rb_event_t event)
{ {
switch (event) { switch (event) {
case RUBY_EVENT_LINE: case RUBY_EVENT_LINE:
return "line"; return "line";
case RUBY_EVENT_CLASS: case RUBY_EVENT_CLASS:
return "class"; return "class";
case RUBY_EVENT_END: case RUBY_EVENT_END:
return "end"; return "end";
case RUBY_EVENT_CALL: case RUBY_EVENT_CALL:
return "call"; return "call";
case RUBY_EVENT_RETURN: case RUBY_EVENT_RETURN:
return "return"; return "return";
case RUBY_EVENT_C_CALL: case RUBY_EVENT_C_CALL:
return "c-call"; return "c-call";
case RUBY_EVENT_C_RETURN: case RUBY_EVENT_C_RETURN:
return "c-return"; return "c-return";
case RUBY_EVENT_RAISE: case RUBY_EVENT_RAISE:
return "raise"; return "raise";
default: default:
return "unknown"; return "unknown";
} }
} }
@ -2708,7 +2708,7 @@ call_trace_func(event, node, self, id, klass)
struct FRAME *prev; struct FRAME *prev;
NODE *node_save; NODE *node_save;
VALUE srcfile; VALUE srcfile;
char *event_name; const char *event_name;
if (!trace_func) return; if (!trace_func) return;
if (tracing) return; if (tracing) return;
@ -4136,7 +4136,7 @@ rb_eval(self, n)
case NODE_DEFINED: case NODE_DEFINED:
{ {
char buf[20]; char buf[20];
char *desc = is_defined(self, node->nd_head, buf); const char *desc = is_defined(self, node->nd_head, buf);
if (desc) result = rb_str_new2(desc); if (desc) result = rb_str_new2(desc);
else result = Qnil; else result = Qnil;
@ -4804,7 +4804,7 @@ proc_jump_error(state, result)
VALUE result; VALUE result;
{ {
char mesg[32]; char mesg[32];
char *statement; const char *statement;
switch (state) { switch (state) {
case TAG_BREAK: case TAG_BREAK:
@ -5638,7 +5638,7 @@ rb_method_missing(argc, argv, obj)
{ {
ID id; ID id;
VALUE exc = rb_eNoMethodError; VALUE exc = rb_eNoMethodError;
char *format = 0; const char *format = 0;
NODE *cnode = ruby_current_node; NODE *cnode = ruby_current_node;
if (argc == 0 || !SYMBOL_P(argv[0])) { if (argc == 0 || !SYMBOL_P(argv[0])) {
@ -6448,7 +6448,7 @@ rb_frame_this_func()
static NODE* static NODE*
compile(src, file, line) compile(src, file, line)
VALUE src; VALUE src;
char *file; const char *file;
int line; int line;
{ {
NODE *node; NODE *node;
@ -6468,7 +6468,7 @@ compile(src, file, line)
static VALUE static VALUE
eval(self, src, scope, file, line) eval(self, src, scope, file, line)
VALUE self, src, scope; VALUE self, src, scope;
char *file; const char *file;
int line; int line;
{ {
struct BLOCK *data = NULL; struct BLOCK *data = NULL;
@ -6629,7 +6629,7 @@ rb_f_eval(argc, argv, self)
VALUE self; VALUE self;
{ {
VALUE src, scope, vfile, vline; VALUE src, scope, vfile, vline;
char *file = "(eval)"; const char *file = "(eval)";
int line = 1; int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline); rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
@ -6783,7 +6783,7 @@ specific_eval(argc, argv, klass, self)
return yield_under(klass, self, Qundef); return yield_under(klass, self, Qundef);
} }
else { else {
char *file = "(eval)"; const char *file = "(eval)";
int line = 1; int line = 1;
if (argc == 0) { if (argc == 0) {
@ -9014,7 +9014,7 @@ proc_to_s(self)
{ {
struct BLOCK *data; struct BLOCK *data;
NODE *node; NODE *node;
char *cname = rb_obj_classname(self); const char *cname = rb_obj_classname(self);
const int w = (sizeof(VALUE) * CHAR_BIT) / 4; const int w = (sizeof(VALUE) * CHAR_BIT) / 4;
long len = strlen(cname)+6+w; /* 6:tags 16:addr */ long len = strlen(cname)+6+w; /* 6:tags 16:addr */
VALUE str; VALUE str;
@ -9748,7 +9748,7 @@ method_inspect(method)
struct METHOD *data; struct METHOD *data;
VALUE str; VALUE str;
const char *s; const char *s;
char *sharp = "#"; const char *sharp = "#";
Data_Get_Struct(method, struct METHOD, data); Data_Get_Struct(method, struct METHOD, data);
str = rb_str_buf_new2("#<"); str = rb_str_buf_new2("#<");
@ -12923,7 +12923,7 @@ static VALUE
rb_thread_inspect(thread) rb_thread_inspect(thread)
VALUE thread; VALUE thread;
{ {
char *cname = rb_obj_classname(thread); const char *cname = rb_obj_classname(thread);
rb_thread_t th = rb_thread_check(thread); rb_thread_t th = rb_thread_check(thread);
const char *status = thread_status_name(th->status); const char *status = thread_status_name(th->status);
VALUE str; VALUE str;

2
file.c
View file

@ -1495,7 +1495,7 @@ static VALUE
rb_file_ftype(st) rb_file_ftype(st)
struct stat *st; struct stat *st;
{ {
char *t; const char *t;
if (S_ISREG(st->st_mode)) { if (S_ISREG(st->st_mode)) {
t = "file"; t = "file";

View file

@ -467,7 +467,7 @@ VALUE rb_struct_alloc _((VALUE, VALUE));
VALUE rb_struct_aref _((VALUE, VALUE)); VALUE rb_struct_aref _((VALUE, VALUE));
VALUE rb_struct_aset _((VALUE, VALUE, VALUE)); VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
VALUE rb_struct_getmember _((VALUE, ID)); VALUE rb_struct_getmember _((VALUE, ID));
VALUE rb_struct_iv_get _((VALUE, char*)); VALUE rb_struct_iv_get _((VALUE, const char*));
VALUE rb_struct_s_members _((VALUE)); VALUE rb_struct_s_members _((VALUE));
VALUE rb_struct_members _((VALUE)); VALUE rb_struct_members _((VALUE));
/* time.c */ /* time.c */

29
io.c
View file

@ -1000,7 +1000,8 @@ rb_io_inspect(obj)
VALUE obj; VALUE obj;
{ {
rb_io_t *fptr; rb_io_t *fptr;
char *buf, *cname, *st = ""; char *buf;
const char *cname, *st = "";
long len; long len;
fptr = RFILE(rb_io_taint_check(obj))->fptr; fptr = RFILE(rb_io_taint_check(obj))->fptr;
@ -1703,7 +1704,7 @@ rb_io_getline(rs, io)
} }
else { else {
int c, newline; int c, newline;
char *rsptr; const char *rsptr;
long rslen; long rslen;
int rspara = 0; int rspara = 0;
@ -2705,7 +2706,7 @@ rb_io_binmode(io)
return io; return io;
} }
char* const char*
rb_io_flags_mode(flags) rb_io_flags_mode(flags)
int flags; int flags;
{ {
@ -2858,7 +2859,7 @@ rb_io_mode_modenum(mode)
#define MODENUM_MAX 4 #define MODENUM_MAX 4
static char* static const char*
rb_io_modenum_mode(flags) rb_io_modenum_mode(flags)
int flags; int flags;
{ {
@ -3005,7 +3006,7 @@ rb_file_sysopen_internal(io, fname, flags, mode)
{ {
rb_io_t *fptr; rb_io_t *fptr;
int fd; int fd;
char *m; const char *m;
MakeOpenFile(io, fptr); MakeOpenFile(io, fptr);
@ -3123,12 +3124,12 @@ rb_io_unbuffered(fptr)
rb_io_synchronized(fptr); rb_io_synchronized(fptr);
} }
static VALUE pipe_open(VALUE pstr, char *pname, char *mode); static VALUE pipe_open(VALUE pstr, const char *pname, const char *mode);
static VALUE static VALUE
pipe_open(pstr, pname, mode) pipe_open(pstr, pname, mode)
VALUE pstr; VALUE pstr;
char *pname, *mode; const char *pname, *mode;
{ {
int modef = rb_io_mode_flags(mode); int modef = rb_io_mode_flags(mode);
rb_io_t *fptr; rb_io_t *fptr;
@ -3350,7 +3351,7 @@ rb_io_s_popen(argc, argv, klass)
VALUE *argv; VALUE *argv;
VALUE klass; VALUE klass;
{ {
char *mode; const char *mode;
VALUE pname, pmode, port; VALUE pname, pmode, port;
if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) { if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
@ -3388,7 +3389,7 @@ rb_open_file(argc, argv, io)
VALUE io; VALUE io;
{ {
VALUE fname, vmode, perm; VALUE fname, vmode, perm;
char *path, *mode; const char *path, *mode;
int flags, fmode; int flags, fmode;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm); rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
@ -3606,7 +3607,7 @@ rb_io_check_io(io)
return rb_check_convert_type(io, T_FILE, "IO", "to_io"); return rb_check_convert_type(io, T_FILE, "IO", "to_io");
} }
static char* static const char*
rb_io_mode_string(fptr) rb_io_mode_string(fptr)
rb_io_t *fptr; rb_io_t *fptr;
{ {
@ -3626,7 +3627,7 @@ io_reopen(io, nfile)
VALUE io, nfile; VALUE io, nfile;
{ {
rb_io_t *fptr, *orig; rb_io_t *fptr, *orig;
char *mode; const char *mode;
int fd, fd2; int fd, fd2;
off_t pos = 0; off_t pos = 0;
@ -3742,7 +3743,7 @@ rb_io_reopen(argc, argv, file)
VALUE file; VALUE file;
{ {
VALUE fname, nmode; VALUE fname, nmode;
char *mode; const char *mode;
rb_io_t *fptr; rb_io_t *fptr;
rb_secure(4); rb_secure(4);
@ -3805,7 +3806,7 @@ rb_io_init_copy(dest, io)
{ {
rb_io_t *fptr, *orig; rb_io_t *fptr, *orig;
int fd; int fd;
char *mode; const char *mode;
io = rb_io_get_io(io); io = rb_io_get_io(io);
if (dest == io) return dest; if (dest == io) return dest;
@ -4425,7 +4426,7 @@ rb_io_s_new(argc, argv, klass)
VALUE klass; VALUE klass;
{ {
if (rb_block_given_p()) { 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", rb_warn("%s::new() does not take block; use %s::open() instead",
cname, cname); cname, cname);

View file

@ -1,4 +1,4 @@
struct kwtable {char *name; int id[2]; enum lex_state state;}; struct kwtable {const char *name; int id[2]; enum lex_state state;};
%% %%
__LINE__, {k__LINE__, k__LINE__}, EXPR_END __LINE__, {k__LINE__, k__LINE__}, EXPR_END
__FILE__, {k__FILE__, k__FILE__}, EXPR_END __FILE__, {k__FILE__, k__FILE__}, EXPR_END

2
lex.c
View file

@ -1,6 +1,6 @@
/* C code produced by gperf version 2.7.2 */ /* C code produced by gperf version 2.7.2 */
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' ./keywords */ /* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' ./keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;}; struct kwtable {const char *name; int id[2]; enum lex_state state;};
#define TOTAL_KEYWORDS 40 #define TOTAL_KEYWORDS 40
#define MIN_WORD_LENGTH 2 #define MIN_WORD_LENGTH 2

View file

@ -338,7 +338,7 @@ w_symbol(id, arg)
ID id; ID id;
struct dump_arg *arg; struct dump_arg *arg;
{ {
char *sym = rb_id2name(id); const char *sym = rb_id2name(id);
st_data_t num; st_data_t num;
if (st_lookup(arg->symbols, id, &num)) { if (st_lookup(arg->symbols, id, &num)) {
@ -381,7 +381,7 @@ w_extended(klass, arg, check)
struct dump_arg *arg; struct dump_arg *arg;
int check; int check;
{ {
char *path; const char *path;
if (check && FL_TEST(klass, FL_SINGLETON)) { if (check && FL_TEST(klass, FL_SINGLETON)) {
if (RCLASS(klass)->m_tbl->num_entries || if (RCLASS(klass)->m_tbl->num_entries ||
@ -948,7 +948,7 @@ r_symbol(arg)
return r_symreal(arg); return r_symreal(arg);
} }
static char* static const char*
r_unique(arg) r_unique(arg)
struct load_arg *arg; struct load_arg *arg;
{ {

View file

@ -2776,7 +2776,7 @@ static VALUE
fix_id2name(fix) fix_id2name(fix)
VALUE fix; VALUE fix;
{ {
char *name = rb_id2name(FIX2UINT(fix)); const char *name = rb_id2name(FIX2UINT(fix));
if (name) return rb_str_new2(name); if (name) return rb_str_new2(name);
return Qnil; return Qnil;
} }

View file

@ -314,7 +314,7 @@ VALUE
rb_any_to_s(obj) rb_any_to_s(obj)
VALUE obj; VALUE obj;
{ {
char *cname = rb_obj_classname(obj); const char *cname = rb_obj_classname(obj);
size_t len; size_t len;
VALUE str; VALUE str;
@ -341,7 +341,7 @@ inspect_i(id, value, str)
VALUE str; VALUE str;
{ {
VALUE str2; VALUE str2;
char *ivname; const char *ivname;
/* need not to show internal data */ /* need not to show internal data */
if (CLASS_OF(value) == 0) return ST_CONTINUE; if (CLASS_OF(value) == 0) return ST_CONTINUE;
@ -397,9 +397,8 @@ rb_obj_inspect(obj)
&& ROBJECT(obj)->iv_tbl->num_entries > 0) { && ROBJECT(obj)->iv_tbl->num_entries > 0) {
VALUE str; VALUE str;
size_t len; size_t len;
char *c; const char *c = rb_obj_classname(obj);
c = rb_obj_classname(obj);
if (rb_inspecting_p(obj)) { if (rb_inspecting_p(obj)) {
len = strlen(c)+10+16+1; len = strlen(c)+10+16+1;
str = rb_str_new(0, len); /* 10:tags 16:addr 1:nul */ str = rb_str_new(0, len); /* 10:tags 16:addr 1:nul */
@ -1161,7 +1160,7 @@ sym_inspect(sym)
VALUE sym; VALUE sym;
{ {
VALUE str; VALUE str;
char *name; const char *name;
ID id = SYM2ID(sym); ID id = SYM2ID(sym);
name = rb_id2name(id); name = rb_id2name(id);

20
pack.c
View file

@ -366,7 +366,7 @@ num2i32(x)
#endif #endif
static const char toofew[] = "too few arguments"; static const char toofew[] = "too few arguments";
static void encodes _((VALUE,char*,long,int)); static void encodes _((VALUE,const char*,long,int));
static void qpencode _((VALUE,VALUE,long)); static void qpencode _((VALUE,VALUE,long));
static int uv_to_utf8 _((char*,unsigned long)); static int uv_to_utf8 _((char*,unsigned long));
@ -441,13 +441,13 @@ static VALUE
pack_pack(ary, fmt) pack_pack(ary, fmt)
VALUE ary, fmt; VALUE ary, fmt;
{ {
static char *nul10 = "\0\0\0\0\0\0\0\0\0\0"; static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0";
static char *spc10 = " "; static const char spc10[] = " ";
char *p, *pend; char *p, *pend;
VALUE res, from, associates = 0; VALUE res, from, associates = 0;
char type; char type;
long items, len, idx, plen; long items, len, idx, plen;
char *ptr; const char *ptr;
#ifdef NATINT_PACK #ifdef NATINT_PACK
int natint; /* native integer */ int natint; /* native integer */
#endif #endif
@ -1004,21 +1004,21 @@ pack_pack(ary, fmt)
return res; return res;
} }
static char uu_table[] = static const char uu_table[] =
"`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"; "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
static char b64_table[] = static const char b64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static void static void
encodes(str, s, len, type) encodes(str, s, len, type)
VALUE str; VALUE str;
char *s; const char *s;
long len; long len;
int type; int type;
{ {
char *buff = ALLOCA_N(char, len * 4 / 3 + 6); char *buff = ALLOCA_N(char, len * 4 / 3 + 6);
long i = 0; long i = 0;
char *trans = type == 'u' ? uu_table : b64_table; const char *trans = type == 'u' ? uu_table : b64_table;
int padding; int padding;
if (type == 'u') { if (type == 'u') {
@ -1304,7 +1304,7 @@ static VALUE
pack_unpack(str, fmt) pack_unpack(str, fmt)
VALUE str, fmt; VALUE str, fmt;
{ {
static char *hexdigits = "0123456789abcdef0123456789ABCDEFx"; static const char hexdigits[] = "0123456789abcdef0123456789ABCDEFx";
char *s, *send; char *s, *send;
char *p, *pend; char *p, *pend;
VALUE ary; VALUE ary;
@ -1338,7 +1338,7 @@ pack_unpack(str, fmt)
} }
star = 0; star = 0;
if (*p == '_' || *p == '!') { if (*p == '_' || *p == '!') {
char *natstr = "sSiIlL"; static const char natstr[] = "sSiIlL";
if (strchr(natstr, type)) { if (strchr(natstr, type)) {
#ifdef NATINT_PACK #ifdef NATINT_PACK

10
parse.y
View file

@ -4524,7 +4524,7 @@ yylex()
} }
if (lex_state != EXPR_DOT) { if (lex_state != EXPR_DOT) {
struct kwtable *kw; const struct kwtable *kw;
/* See if it is a reserved word. */ /* See if it is a reserved word. */
kw = rb_reserved_word(tok(), toklen()); kw = rb_reserved_word(tok(), toklen());
@ -5178,7 +5178,7 @@ static void
void_expr0(node) void_expr0(node)
NODE *node; NODE *node;
{ {
char *useless = 0; const char *useless = 0;
if (!RTEST(ruby_verbose)) return; if (!RTEST(ruby_verbose)) return;
@ -5945,7 +5945,7 @@ rb_parser_while_loop(chop, split)
static struct { static struct {
ID token; ID token;
char *name; const char *name;
} op_tbl[] = { } op_tbl[] = {
{tDOT2, ".."}, {tDOT2, ".."},
{tDOT3, "..."}, {tDOT3, "..."},
@ -6193,11 +6193,11 @@ rb_intern(name)
return id; return id;
} }
char * const char *
rb_id2name(id) rb_id2name(id)
ID id; ID id;
{ {
char *name; const char *name;
st_data_t data; st_data_t data;
if (id < tLAST_TOKEN) { if (id < tLAST_TOKEN) {

9
re.c
View file

@ -595,7 +595,7 @@ static VALUE
rb_reg_kcode_m(re) rb_reg_kcode_m(re)
VALUE re; VALUE re;
{ {
char *kcode; const char *kcode;
if (FL_TEST(re, KCODE_FIXED)) { if (FL_TEST(re, KCODE_FIXED)) {
switch (RBASIC(re)->flags & KCODE_MASK) { switch (RBASIC(re)->flags & KCODE_MASK) {
@ -1340,7 +1340,7 @@ match_string(match)
static VALUE static VALUE
match_inspect(VALUE match) match_inspect(VALUE match)
{ {
char *cname = rb_obj_classname(match); const char *cname = rb_obj_classname(match);
VALUE str; VALUE str;
int i; int i;
struct re_registers *regs = RMATCH(match)->regs; struct re_registers *regs = RMATCH(match)->regs;
@ -1477,8 +1477,9 @@ rb_reg_regcomp(str)
case_cache = ruby_ignorecase; case_cache = ruby_ignorecase;
kcode_cache = reg_kcode; kcode_cache = reg_kcode;
return reg_cache = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, reg_cache = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, ruby_ignorecase);
ruby_ignorecase); RB_GC_GUARD(save_str);
return reg_cache;
} }
static int static int

2
ruby.c
View file

@ -65,7 +65,7 @@ static VALUE do_loop = Qfalse, do_print = Qfalse;
static VALUE do_check = Qfalse, do_line = Qfalse; static VALUE do_check = Qfalse, do_line = Qfalse;
static VALUE do_split = Qfalse; static VALUE do_split = Qfalse;
static char *script; static const char *script;
static int origargc; static int origargc;
static char **origargv; static char **origargv;

6
ruby.h
View file

@ -538,11 +538,11 @@ void rb_gc_register_address _((VALUE*));
void rb_gc_unregister_address _((VALUE*)); void rb_gc_unregister_address _((VALUE*));
ID rb_intern _((const char*)); ID rb_intern _((const char*));
char *rb_id2name _((ID)); const char *rb_id2name _((ID));
ID rb_to_id _((VALUE)); ID rb_to_id _((VALUE));
char *rb_class2name _((VALUE)); const char *rb_class2name _((VALUE));
char *rb_obj_classname _((VALUE)); const char *rb_obj_classname _((VALUE));
void rb_p _((VALUE)); void rb_p _((VALUE));

View file

@ -36,7 +36,7 @@
#endif #endif
static struct signals { static struct signals {
char *signm; const char *signm;
int signo; int signo;
} siglist [] = { } siglist [] = {
{"EXIT", 0}, {"EXIT", 0},
@ -186,7 +186,7 @@ signm2signo(nm)
return 0; return 0;
} }
static char* static const char*
signo2signm(no) signo2signm(no)
int no; int no;
{ {
@ -327,7 +327,7 @@ rb_f_kill(argc, argv)
int negative = 0; int negative = 0;
int sig; int sig;
int i; int i;
char *s; const char *s;
rb_secure(2); rb_secure(2);
if (argc < 2) if (argc < 2)
@ -706,7 +706,7 @@ trap(arg)
sighandler_t func, oldfunc; sighandler_t func, oldfunc;
VALUE command, oldcmd; VALUE command, oldcmd;
int sig = -1; int sig = -1;
char *s; const char *s;
func = sighandler; func = sighandler;
command = arg->cmd; command = arg->cmd;

View file

@ -545,7 +545,8 @@ rb_str_associated(str)
return Qfalse; return Qfalse;
} }
static char *null_str = ""; static const char null_str[] = "";
#define null_str ((char *)null_str)
VALUE VALUE
rb_string_value(ptr) rb_string_value(ptr)
@ -4480,7 +4481,7 @@ rb_str_crypt(str, salt)
{ {
extern char *crypt(); extern char *crypt();
VALUE result; VALUE result;
char *s; const char *s;
StringValue(salt); StringValue(salt);
if (RSTRING(salt)->len < 2) if (RSTRING(salt)->len < 2)
@ -4607,7 +4608,8 @@ rb_str_justify(argc, argv, str, jflag)
VALUE w; VALUE w;
long width, flen = 0; long width, flen = 0;
VALUE res; VALUE res;
char *p, *pend, *f = " "; char *p, *pend;
const char *f = " ";
long n; long n;
VALUE pad; VALUE pad;
@ -4633,7 +4635,7 @@ rb_str_justify(argc, argv, str, jflag)
} }
} }
else { else {
char *q = f; const char *q = f;
while (p + flen <= pend) { while (p + flen <= pend) {
memcpy(p,f,flen); memcpy(p,f,flen);
p += flen; p += flen;

View file

@ -20,7 +20,7 @@ static VALUE struct_alloc _((VALUE));
VALUE VALUE
rb_struct_iv_get(c, name) rb_struct_iv_get(c, name)
VALUE c; VALUE c;
char *name; const char *name;
{ {
ID id; ID id;
@ -470,7 +470,7 @@ static VALUE
inspect_struct(s) inspect_struct(s)
VALUE s; VALUE s;
{ {
char *cname = rb_class2name(rb_obj_class(s)); const char *cname = rb_class2name(rb_obj_class(s));
VALUE str, members; VALUE str, members;
long i; long i;
@ -481,7 +481,7 @@ inspect_struct(s)
for (i=0; i<RSTRUCT(s)->len; i++) { for (i=0; i<RSTRUCT(s)->len; i++) {
VALUE slot; VALUE slot;
ID id; ID id;
char *p; const char *p;
if (i > 0) { if (i > 0) {
rb_str_cat2(str, ", "); rb_str_cat2(str, ", ");
@ -517,7 +517,7 @@ rb_struct_inspect(s)
VALUE s; VALUE s;
{ {
if (rb_inspecting_p(s)) { if (rb_inspecting_p(s)) {
char *cname = rb_class2name(rb_obj_class(s)); const char *cname = rb_class2name(rb_obj_class(s));
size_t len = strlen(cname) + 14; size_t len = strlen(cname) + 14;
VALUE str = rb_str_new(0, len); VALUE str = rb_str_new(0, len);

4
time.c
View file

@ -171,7 +171,7 @@ time_timeval(time, interval)
int interval; int interval;
{ {
struct timeval t; struct timeval t;
char *tstr = interval ? "time interval" : "time"; const char *tstr = interval ? "time interval" : "time";
#ifndef NEGATIVE_TIME_T #ifndef NEGATIVE_TIME_T
interval = 1; interval = 1;
@ -279,7 +279,7 @@ time_s_at(argc, argv, klass)
return t; return t;
} }
static char *months [12] = { static const char months[][4] = {
"jan", "feb", "mar", "apr", "may", "jun", "jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec", "jul", "aug", "sep", "oct", "nov", "dec",
}; };

2
util.c
View file

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

View file

@ -195,7 +195,7 @@ rb_class_path(klass)
return path; return path;
} }
else { else {
char *s = "Class"; const char *s = "Class";
size_t len; size_t len;
if (TYPE(klass) == T_MODULE) { if (TYPE(klass) == T_MODULE) {
@ -294,14 +294,14 @@ rb_class_name(klass)
return rb_class_path(rb_class_real(klass)); return rb_class_path(rb_class_real(klass));
} }
char * const char *
rb_class2name(klass) rb_class2name(klass)
VALUE klass; VALUE klass;
{ {
return RSTRING(rb_class_name(klass))->ptr; return RSTRING(rb_class_name(klass))->ptr;
} }
char * const char *
rb_obj_classname(obj) rb_obj_classname(obj)
VALUE obj; VALUE obj;
{ {
@ -789,7 +789,7 @@ rb_f_global_variables()
{ {
VALUE ary = rb_ary_new(); VALUE ary = rb_ary_new();
char buf[4]; char buf[4];
char *s = "&`'+123456789"; const char *s = "&`'+123456789";
st_foreach(rb_global_tbl, gvar_i, ary); st_foreach(rb_global_tbl, gvar_i, ary);
if (!NIL_P(rb_backref_get())) { if (!NIL_P(rb_backref_get())) {
@ -1653,7 +1653,7 @@ mod_av_set(klass, id, val, isconst)
VALUE val; VALUE val;
int isconst; int isconst;
{ {
char *dest = isconst ? "constant" : "class variable"; const char *dest = isconst ? "constant" : "class variable";
if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4) if (!OBJ_TAINTED(klass) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest); rb_raise(rb_eSecurityError, "Insecure: can't set %s", dest);