* error.c (builtin_types), signal.c (siglist), st.c (primes),

struct.c (ref_func), time.c (months): constified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-04-26 08:30:22 +00:00
parent 61234dab9c
commit e615e3ce30
6 changed files with 23 additions and 13 deletions

View File

@ -1,3 +1,8 @@
Sat Apr 26 17:30:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (builtin_types), signal.c (siglist), st.c (primes),
struct.c (ref_func), time.c (months): constified.
Sat Apr 26 13:00:41 2008 Tanaka Akira <akr@fsij.org> Sat Apr 26 13:00:41 2008 Tanaka Akira <akr@fsij.org>
* lib/open3.rb: double fork is replaced by spawn with Process.detach. * lib/open3.rb: double fork is replaced by spawn with Process.detach.

View File

@ -238,7 +238,7 @@ rb_compile_bug(const char *file, int line, const char *fmt, ...)
abort(); abort();
} }
static struct types { static const struct types {
int type; int type;
const char *name; const char *name;
} builtin_types[] = { } builtin_types[] = {
@ -263,20 +263,21 @@ static struct types {
{T_MATCH, "MatchData"}, /* data of $~ */ {T_MATCH, "MatchData"}, /* data of $~ */
{T_NODE, "Node"}, /* internal use: syntax tree node */ {T_NODE, "Node"}, /* internal use: syntax tree node */
{T_UNDEF, "undef"}, /* internal use: #undef; should not happen */ {T_UNDEF, "undef"}, /* internal use: #undef; should not happen */
{-1, 0}
}; };
void void
rb_check_type(VALUE x, int t) rb_check_type(VALUE x, int t)
{ {
struct types *type = builtin_types; const struct types *type = builtin_types;
const struct types *const typeend = builtin_types +
sizeof(builtin_types) / sizeof(builtin_types[0]);
if (x == Qundef) { if (x == Qundef) {
rb_bug("undef leaked to the Ruby space"); rb_bug("undef leaked to the Ruby space");
} }
if (TYPE(x) != t) { if (TYPE(x) != t) {
while (type->type >= 0) { while (type < typeend) {
if (type->type == t) { if (type->type == t) {
const char *etype; const char *etype;

View File

@ -36,7 +36,7 @@
# endif # endif
#endif #endif
static struct signals { static const struct signals {
const char *signm; const char *signm;
int signo; int signo;
} siglist [] = { } siglist [] = {
@ -178,7 +178,7 @@ static struct signals {
static int static int
signm2signo(const char *nm) signm2signo(const char *nm)
{ {
struct signals *sigs; const struct signals *sigs;
for (sigs = siglist; sigs->signm; sigs++) for (sigs = siglist; sigs->signm; sigs++)
if (strcmp(sigs->signm, nm) == 0) if (strcmp(sigs->signm, nm) == 0)
@ -189,7 +189,7 @@ signm2signo(const char *nm)
static const char* static const char*
signo2signm(int no) signo2signm(int no)
{ {
struct signals *sigs; const struct signals *sigs;
for (sigs = siglist; sigs->signm; sigs++) for (sigs = siglist; sigs->signm; sigs++)
if (sigs->signo == no) if (sigs->signo == no)
@ -381,7 +381,9 @@ static struct {
VALUE cmd; VALUE cmd;
} trap_list[NSIG]; } trap_list[NSIG];
static rb_atomic_t trap_pending_list[NSIG]; static rb_atomic_t trap_pending_list[NSIG];
#if 0
static char rb_trap_accept_nativethreads[NSIG]; static char rb_trap_accept_nativethreads[NSIG];
#endif
rb_atomic_t rb_trap_pending; rb_atomic_t rb_trap_pending;
rb_atomic_t rb_trap_immediate; rb_atomic_t rb_trap_immediate;
int rb_prohibit_interrupt = 1; int rb_prohibit_interrupt = 1;
@ -417,7 +419,9 @@ ruby_signal(int signum, sighandler_t handler)
{ {
struct sigaction sigact, old; struct sigaction sigact, old;
#if 0
rb_trap_accept_nativethreads[signum] = 0; rb_trap_accept_nativethreads[signum] = 0;
#endif
sigemptyset(&sigact.sa_mask); sigemptyset(&sigact.sa_mask);
#ifdef SA_SIGINFO #ifdef SA_SIGINFO
@ -443,8 +447,8 @@ posix_signal(int signum, sighandler_t handler)
} }
#else /* !POSIX_SIGNAL */ #else /* !POSIX_SIGNAL */
#define ruby_signal(sig,handler) (rb_trap_accept_nativethreads[sig] = 0, signal((sig),(handler))) #define ruby_signal(sig,handler) (/* rb_trap_accept_nativethreads[sig] = 0,*/ signal((sig),(handler)))
#ifdef HAVE_NATIVETHREAD #if 0 /* def HAVE_NATIVETHREAD */
static sighandler_t static sighandler_t
ruby_nativethread_signal(int signum, sighandler_t handler) ruby_nativethread_signal(int signum, sighandler_t handler)
{ {
@ -938,7 +942,7 @@ static VALUE
sig_list(void) sig_list(void)
{ {
VALUE h = rb_hash_new(); VALUE h = rb_hash_new();
struct signals *sigs; const struct signals *sigs;
for (sigs = siglist; sigs->signm; sigs++) { for (sigs = siglist; sigs->signm; sigs++) {
rb_hash_aset(h, rb_str_new2(sigs->signm), INT2FIX(sigs->signo)); rb_hash_aset(h, rb_str_new2(sigs->signm), INT2FIX(sigs->signo));

2
st.c
View File

@ -82,7 +82,7 @@ static void rehash(st_table *);
/* /*
Table of prime numbers 2^n+a, 2<=n<=30. Table of prime numbers 2^n+a, 2<=n<=30.
*/ */
static long primes[] = { static const long primes[] = {
8 + 3, 8 + 3,
16 + 3, 16 + 3,
32 + 5, 32 + 5,

View File

@ -127,7 +127,7 @@ static VALUE rb_struct_ref9(VALUE obj) {return RSTRUCT_PTR(obj)[9];}
#define N_REF_FUNC (sizeof(ref_func) / sizeof(ref_func[0])) #define N_REF_FUNC (sizeof(ref_func) / sizeof(ref_func[0]))
static VALUE (*ref_func[])(VALUE) = { static VALUE (*const ref_func[])(VALUE) = {
rb_struct_ref0, rb_struct_ref0,
rb_struct_ref1, rb_struct_ref1,
rb_struct_ref2, rb_struct_ref2,

2
time.c
View File

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