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

Merge changes from ruby_1_8 to reduce warnings and potentially improve

security.

* mkconfig.rb: hide build path from rbconfig.rb.

* util.c (ruby_strtod, dtoa): initialize more variables for error
  handling.

* io.c (rscheck), marshal.c (w_nbyte, w_bytes, w_unique),
  (path2class, path2module): constified.

* pack.c (pack_unpack), process.c (rb_syswait): suppress warnings.

* suppress warnings on cygwin, mingw and mswin.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@16863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2008-06-06 10:39:57 +00:00
parent 23a434b363
commit 2b785b0f3e
24 changed files with 159 additions and 94 deletions

View file

@ -1,3 +1,17 @@
Fri Jun 6 19:34:22 2008 Akinori MUSHA <knu@iDaemons.org>
* mkconfig.rb: hide build path from rbconfig.rb.
* util.c (ruby_strtod, dtoa): initialize more variables for error
handling.
* io.c (rscheck), marshal.c (w_nbyte, w_bytes, w_unique),
(path2class, path2module): constified.
* pack.c (pack_unpack), process.c (rb_syswait): suppress warnings.
* suppress warnings on cygwin, mingw and mswin.
Fri Jun 6 19:23:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Jun 6 19:23:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (file_expand_path): fix for non-existent files and SFN of * file.c (file_expand_path): fix for non-existent files and SFN of

24
dln.c
View file

@ -1689,31 +1689,31 @@ static char fbuf[MAXPATHLEN];
static char * static char *
dln_find_1(fname, path, exe_flag) dln_find_1(fname, path, exe_flag)
char *fname; const char *fname;
char *path; const char *path;
int exe_flag; /* non 0 if looking for executable. */ int exe_flag; /* non 0 if looking for executable. */
{ {
register char *dp; register const char *dp;
register char *ep; register const char *ep;
register char *bp; register char *bp;
struct stat st; struct stat st;
#ifdef __MACOS__ #ifdef __MACOS__
const char* mac_fullpath; const char* mac_fullpath;
#endif #endif
if (!fname) return fname; if (!fname) return (char *)fname;
if (fname[0] == '/') return fname; if (fname[0] == '/') return (char *)fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0) if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname; return (char *)fname;
if (exe_flag && strchr(fname, '/')) return fname; if (exe_flag && strchr(fname, '/')) return (char *)fname;
#ifdef DOSISH #ifdef DOSISH
if (fname[0] == '\\') return fname; if (fname[0] == '\\') return (char *)fname;
# ifdef DOSISH_DRIVE_LETTER # ifdef DOSISH_DRIVE_LETTER
if (strlen(fname) > 2 && fname[1] == ':') return fname; if (strlen(fname) > 2 && fname[1] == ':') return (char *)fname;
# endif # endif
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0) if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname; return (char *)fname;
if (exe_flag && strchr(fname, '\\')) return fname; if (exe_flag && strchr(fname, '\\')) return (char *)fname;
#endif #endif
for (dp = path;; dp = ++ep) { for (dp = path;; dp = ++ep) {

30
file.c
View file

@ -2320,6 +2320,10 @@ rb_file_s_umask(argc, argv)
#define USE_NTFS 0 #define USE_NTFS 0
#endif #endif
#ifdef DOSISH_DRIVE_LETTER
#include <ctype.h>
#endif
#if USE_NTFS #if USE_NTFS
#define istrailinggabage(x) ((x) == '.' || (x) == ' ') #define istrailinggabage(x) ((x) == '.' || (x) == ' ')
#else #else
@ -2532,7 +2536,7 @@ file_expand_path(fname, dname, result)
if (s[0] == '~') { if (s[0] == '~') {
if (isdirsep(s[1]) || s[1] == '\0') { if (isdirsep(s[1]) || s[1] == '\0') {
char *dir = getenv("HOME"); const char *dir = getenv("HOME");
if (!dir) { if (!dir) {
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s); rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s);
@ -2888,9 +2892,9 @@ rb_file_s_basename(argc, argv)
VALUE *argv; VALUE *argv;
{ {
VALUE fname, fext, basename; VALUE fname, fext, basename;
char *name, *p; const char *name, *p;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
char *root; const char *root;
#endif #endif
int f, n; int f, n;
@ -3100,7 +3104,7 @@ rb_file_join(ary, sep)
long len, i; long len, i;
int taint = 0; int taint = 0;
VALUE result, tmp; VALUE result, tmp;
char *name, *tail; const char *name, *tail;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0); if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
if (OBJ_TAINTED(ary)) taint = 1; if (OBJ_TAINTED(ary)) taint = 1;
@ -4285,7 +4289,7 @@ path_check_0(fpath, execpath)
int execpath; int execpath;
{ {
struct stat st; struct stat st;
char *p0 = StringValueCStr(fpath); const char *p0 = StringValueCStr(fpath);
char *p = 0, *s; char *p = 0, *s;
if (!is_absolute_path(p0)) { if (!is_absolute_path(p0)) {
@ -4324,7 +4328,7 @@ path_check_0(fpath, execpath)
static int static int
fpath_check(path) fpath_check(path)
char *path; const char *path;
{ {
#if ENABLE_PATH_CHECK #if ENABLE_PATH_CHECK
return path_check_0(rb_str_new2(path), Qfalse); return path_check_0(rb_str_new2(path), Qfalse);
@ -4335,10 +4339,10 @@ fpath_check(path)
int int
rb_path_check(path) rb_path_check(path)
char *path; const char *path;
{ {
#if ENABLE_PATH_CHECK #if ENABLE_PATH_CHECK
char *p0, *p, *pend; const char *p0, *p, *pend;
const char sep = PATH_SEP_CHAR; const char sep = PATH_SEP_CHAR;
if (!path) return 1; if (!path) return 1;
@ -4373,7 +4377,7 @@ is_macos_native_path(path)
static int static int
file_load_ok(file) file_load_ok(file)
char *file; const char *file;
{ {
FILE *f; FILE *f;
@ -4391,8 +4395,8 @@ rb_find_file_ext(filep, ext)
VALUE *filep; VALUE *filep;
const char * const *ext; const char * const *ext;
{ {
char *path, *found; const char *path, *found;
char *f = RSTRING(*filep)->ptr; const char *f = RSTRING(*filep)->ptr;
VALUE fname; VALUE fname;
long i, j; long i, j;
@ -4447,8 +4451,8 @@ rb_find_file(path)
VALUE path; VALUE path;
{ {
VALUE tmp; VALUE tmp;
char *f = StringValueCStr(path); const char *f = StringValueCStr(path);
char *lpath; const char *lpath;
if (f[0] == '~') { if (f[0] == '~') {
path = rb_file_expand_path(path, Qnil); path = rb_file_expand_path(path, Qnil);

View file

@ -277,7 +277,7 @@ VALUE rb_hash_lookup _((VALUE, VALUE));
VALUE rb_hash_aset _((VALUE, VALUE, VALUE)); VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
VALUE rb_hash_delete_if _((VALUE)); VALUE rb_hash_delete_if _((VALUE));
VALUE rb_hash_delete _((VALUE,VALUE)); VALUE rb_hash_delete _((VALUE,VALUE));
int rb_path_check _((char*)); int rb_path_check _((const char*));
int rb_env_path_tainted _((void)); int rb_env_path_tainted _((void));
/* io.c */ /* io.c */
#define rb_defout rb_stdout #define rb_defout rb_stdout

13
io.c
View file

@ -50,6 +50,9 @@
#elif defined(HAVE_SYS_FCNTL_H) #elif defined(HAVE_SYS_FCNTL_H)
#include <sys/fcntl.h> #include <sys/fcntl.h>
#endif #endif
#ifdef __CYGWIN__
#include <io.h>
#endif
#if !HAVE_OFF_T && !defined(off_t) #if !HAVE_OFF_T && !defined(off_t)
# define off_t long # define off_t long
@ -429,7 +432,10 @@ static int
wsplit_p(rb_io_t *fptr) wsplit_p(rb_io_t *fptr)
{ {
FILE *f = GetWriteFile(fptr); FILE *f = GetWriteFile(fptr);
#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
int r; int r;
#endif
if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) { if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
struct stat buf; struct stat buf;
if (fstat(fileno(f), &buf) == 0 && if (fstat(fileno(f), &buf) == 0 &&
@ -1675,7 +1681,7 @@ rb_io_getline_fast(fptr, delim)
static int static int
rscheck(rsptr, rslen, rs) rscheck(rsptr, rslen, rs)
char *rsptr; const char *rsptr;
long rslen; long rslen;
VALUE rs; VALUE rs;
{ {
@ -4522,7 +4528,10 @@ next_argv()
FILE *fr = rb_fopen(fn, "r"); FILE *fr = rb_fopen(fn, "r");
if (ruby_inplace_mode) { if (ruby_inplace_mode) {
struct stat st, st2; struct stat st;
#ifndef NO_SAFE_RENAME
struct stat st2;
#endif
VALUE str; VALUE str;
FILE *fw; FILE *fw;

View file

@ -130,7 +130,7 @@ static void w_long _((long, struct dump_arg*));
static void static void
w_nbyte(s, n, arg) w_nbyte(s, n, arg)
char *s; const char *s;
int n; int n;
struct dump_arg *arg; struct dump_arg *arg;
{ {
@ -153,7 +153,7 @@ w_byte(c, arg)
static void static void
w_bytes(s, n, arg) w_bytes(s, n, arg)
char *s; const char *s;
int n; int n;
struct dump_arg *arg; struct dump_arg *arg;
{ {
@ -354,7 +354,7 @@ w_symbol(id, arg)
static void static void
w_unique(s, arg) w_unique(s, arg)
char *s; const char *s;
struct dump_arg *arg; struct dump_arg *arg;
{ {
if (s[0] == '#') { if (s[0] == '#') {
@ -991,7 +991,7 @@ r_ivar(obj, arg)
static VALUE static VALUE
path2class(path) path2class(path)
char *path; const char *path;
{ {
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);
@ -1003,7 +1003,7 @@ path2class(path)
static VALUE static VALUE
path2module(path) path2module(path)
char *path; const char *path;
{ {
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);

View file

@ -32,7 +32,7 @@ extern double atanh _((double));
#endif #endif
#ifndef HAVE_CRYPT #ifndef HAVE_CRYPT
extern char *crypt _((char *, char *)); extern char *crypt _((const char *, const char *));
#endif #endif
#ifndef HAVE_DUP2 #ifndef HAVE_DUP2

View file

@ -107,13 +107,15 @@ static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93";
#define LARGEDATA #define LARGEDATA
#endif #endif
int des_setkey(), des_cipher();
/* compile with "-DSTATIC=int" when profiling */ /* compile with "-DSTATIC=int" when profiling */
#ifndef STATIC #ifndef STATIC
#define STATIC static #define STATIC static
#endif #endif
STATIC init_des(), init_perm(), permute(); STATIC void init_des(), init_perm(), permute();
#ifdef DEBUG #ifdef DEBUG
STATIC prtab(); STATIC void prtab();
#endif #endif
/* ==================================== */ /* ==================================== */
@ -299,7 +301,7 @@ typedef union {
#define PERM3264(d,d0,d1,cpp,p) \ #define PERM3264(d,d0,d1,cpp,p) \
{ C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); } { C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); }
STATIC STATIC void
permute(cp, out, p, chars_in) permute(cp, out, p, chars_in)
unsigned char *cp; unsigned char *cp;
C_block *out; C_block *out;
@ -377,46 +379,62 @@ static unsigned char PC2[] = { /* permuted choice table 2 */
}; };
static unsigned char S[8][64] = { /* 48->32 bit substitution tables */ static unsigned char S[8][64] = { /* 48->32 bit substitution tables */
{
/* S[1] */ /* S[1] */
14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
},
{
/* S[2] */ /* S[2] */
15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
},
{
/* S[3] */ /* S[3] */
10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
},
{
/* S[4] */ /* S[4] */
7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
},
{
/* S[5] */ /* S[5] */
2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
},
{
/* S[6] */ /* S[6] */
12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
},
{
/* S[7] */ /* S[7] */
4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
},
{
/* S[8] */ /* S[8] */
13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11, 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
},
}; };
static unsigned char P32Tr[] = { /* 32-bit permutation function */ static unsigned char P32Tr[] = { /* 32-bit permutation function */
@ -580,6 +598,7 @@ static C_block KS[KS_SIZE];
/* /*
* Set up the key schedule from the key. * Set up the key schedule from the key.
*/ */
int
des_setkey(key) des_setkey(key)
register const char *key; register const char *key;
{ {
@ -614,6 +633,7 @@ des_setkey(key)
* NOTE: the performance of this routine is critically dependent on your * NOTE: the performance of this routine is critically dependent on your
* compiler and machine architecture. * compiler and machine architecture.
*/ */
int
des_cipher(in, out, salt, num_iter) des_cipher(in, out, salt, num_iter)
const char *in; const char *in;
char *out; char *out;
@ -734,7 +754,7 @@ des_cipher(in, out, salt, num_iter)
* Initialize various tables. This need only be done once. It could even be * Initialize various tables. This need only be done once. It could even be
* done at compile time, if the compiler were capable of that sort of thing. * done at compile time, if the compiler were capable of that sort of thing.
*/ */
STATIC STATIC void
init_des() init_des()
{ {
register int i, j; register int i, j;
@ -878,7 +898,7 @@ init_des()
* *
* "perm" must be all-zeroes on entry to this routine. * "perm" must be all-zeroes on entry to this routine.
*/ */
STATIC STATIC void
init_perm(perm, p, chars_in, chars_out) init_perm(perm, p, chars_in, chars_out)
C_block perm[64/CHUNKBITS][1<<CHUNKBITS]; C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
unsigned char p[64]; unsigned char p[64];
@ -902,6 +922,7 @@ init_perm(perm, p, chars_in, chars_out)
/* /*
* "setkey" routine (for backwards compatibility) * "setkey" routine (for backwards compatibility)
*/ */
int
setkey(key) setkey(key)
register const char *key; register const char *key;
{ {
@ -922,6 +943,7 @@ setkey(key)
/* /*
* "encrypt" routine (for backwards compatibility) * "encrypt" routine (for backwards compatibility)
*/ */
int
encrypt(block, flag) encrypt(block, flag)
register char *block; register char *block;
int flag; int flag;
@ -950,7 +972,7 @@ encrypt(block, flag)
} }
#ifdef DEBUG #ifdef DEBUG
STATIC STATIC void
prtab(s, t, num_rows) prtab(s, t, num_rows)
char *s; char *s;
unsigned char *t; unsigned char *t;

View file

@ -75,6 +75,7 @@ File.foreach "config.status" do |line|
next if /^\$ac_\w+$/ =~ val next if /^\$ac_\w+$/ =~ val
next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name next if $install_name and /^RUBY_INSTALL_NAME$/ =~ name
next if $so_name and /^RUBY_SO_NAME$/ =~ name next if $so_name and /^RUBY_SO_NAME$/ =~ name
next if /^(?:X|(?:MINI|RUN)RUBY$)/ =~ name
if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val if /^program_transform_name$/ =~ name and /^s(\\?.)(.*)\1$/ =~ val
next if $install_name next if $install_name
sep = %r"#{Regexp.quote($1)}" sep = %r"#{Regexp.quote($1)}"

10
pack.c
View file

@ -1884,8 +1884,8 @@ pack_unpack(str, fmt)
case 'P': case 'P':
if (sizeof(char *) <= send - s) { if (sizeof(char *) <= send - s) {
VALUE tmp = Qnil;
char *t; char *t;
VALUE tmp;
memcpy(&t, s, sizeof(char *)); memcpy(&t, s, sizeof(char *));
s += sizeof(char *); s += sizeof(char *);
@ -1915,9 +1915,6 @@ pack_unpack(str, fmt)
rb_raise(rb_eArgError, "non associated pointer"); rb_raise(rb_eArgError, "non associated pointer");
} }
} }
else {
tmp = Qnil;
}
rb_ary_push(ary, tmp); rb_ary_push(ary, tmp);
} }
break; break;
@ -1929,7 +1926,7 @@ pack_unpack(str, fmt)
if (send - s < sizeof(char *)) if (send - s < sizeof(char *))
break; break;
else { else {
VALUE tmp; VALUE tmp = Qnil;
char *t; char *t;
memcpy(&t, s, sizeof(char *)); memcpy(&t, s, sizeof(char *));
@ -1954,9 +1951,6 @@ pack_unpack(str, fmt)
rb_raise(rb_eArgError, "non associated pointer"); rb_raise(rb_eArgError, "non associated pointer");
} }
} }
else {
tmp = Qnil;
}
rb_ary_push(ary, tmp); rb_ary_push(ary, tmp);
} }
} }

View file

@ -5891,6 +5891,10 @@ int
ruby_parser_stack_on_heap() ruby_parser_stack_on_heap()
{ {
#if defined(YYMALLOC) #if defined(YYMALLOC)
(void)rb_parser_realloc;
(void)rb_parser_calloc;
(void)nodetype;
(void)nodeline;
return Qfalse; return Qfalse;
#else #else
return Qtrue; return Qtrue;

View file

@ -1024,9 +1024,11 @@ int
rb_proc_exec(str) rb_proc_exec(str)
const char *str; const char *str;
{ {
#ifndef _WIN32
const char *s = str; const char *s = str;
char *ss, *t; char *ss, *t;
char **argv, **a; char **argv, **a;
#endif
while (*str && ISSPACE(*str)) while (*str && ISSPACE(*str))
str++; str++;
@ -1089,7 +1091,9 @@ proc_spawn_v(argv, prog)
char **argv; char **argv;
char *prog; char *prog;
{ {
#if defined(__human68k__)
char *extension; char *extension;
#endif
int status; int status;
if (!prog) if (!prog)
@ -1405,12 +1409,12 @@ rb_syswait(pid)
{ {
static int overriding; static int overriding;
#ifdef SIGHUP #ifdef SIGHUP
RETSIGTYPE (*hfunc)_((int)); RETSIGTYPE (*hfunc)_((int)) = 0;
#endif #endif
#ifdef SIGQUIT #ifdef SIGQUIT
RETSIGTYPE (*qfunc)_((int)); RETSIGTYPE (*qfunc)_((int)) = 0;
#endif #endif
RETSIGTYPE (*ifunc)_((int)); RETSIGTYPE (*ifunc)_((int)) = 0;
int status; int status;
int i, hooked = Qfalse; int i, hooked = Qfalse;
@ -1650,7 +1654,9 @@ rb_f_sleep(argc, argv)
static VALUE static VALUE
proc_getpgrp() proc_getpgrp()
{ {
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
int pgrp; int pgrp;
#endif
rb_secure(2); rb_secure(2);
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) #if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)

4
re.c
View file

@ -623,7 +623,7 @@ make_regexp(s, len, flags)
int flags; int flags;
{ {
Regexp *rp; Regexp *rp;
char *err; const char *err;
/* Handle escaped characters first. */ /* Handle escaped characters first. */
@ -846,7 +846,7 @@ rb_reg_prepare_re(re)
} }
if (need_recompile) { if (need_recompile) {
char *err; const char *err;
if (FL_TEST(re, KCODE_FIXED)) if (FL_TEST(re, KCODE_FIXED))
rb_kcode_set_option(re); rb_kcode_set_option(re);

10
regex.c
View file

@ -164,7 +164,7 @@ static void store_jump _((char*, int, char*));
static void insert_jump _((int, char*, char*, char*)); static void insert_jump _((int, char*, char*, char*));
static void store_jump_n _((char*, int, char*, unsigned)); static void store_jump_n _((char*, int, char*, unsigned));
static void insert_jump_n _((int, char*, char*, char*, unsigned)); static void insert_jump_n _((int, char*, char*, char*, unsigned));
static void insert_op _((int, char*, char*)); /*static void insert_op _((int, char*, char*));*/
static void insert_op_2 _((int, char*, char*, int, int)); static void insert_op_2 _((int, char*, char*, int, int));
static int memcmp_translate _((unsigned char*, unsigned char*, int)); static int memcmp_translate _((unsigned char*, unsigned char*, int));
@ -508,6 +508,7 @@ utf8_firstbyte(c)
#endif #endif
} }
#if 0
static void static void
print_mbc(c) print_mbc(c)
unsigned int c; unsigned int c;
@ -538,6 +539,7 @@ print_mbc(c)
printf("%c%c", (int)(c >> BYTEWIDTH), (int)(c &0xff)); printf("%c%c", (int)(c >> BYTEWIDTH), (int)(c &0xff));
} }
} }
#endif
/* If the buffer isn't allocated when it comes in, use this. */ /* If the buffer isn't allocated when it comes in, use this. */
#define INIT_BUF_SIZE 28 #define INIT_BUF_SIZE 28
@ -752,6 +754,7 @@ is_in_list(c, b)
return is_in_list_sbc(c, b) || (current_mbctype ? is_in_list_mbc(c, b) : 0); return is_in_list_sbc(c, b) || (current_mbctype ? is_in_list_mbc(c, b) : 0);
} }
#if 0
static void static void
print_partial_compiled_pattern(start, end) print_partial_compiled_pattern(start, end)
unsigned char *start; unsigned char *start;
@ -1006,6 +1009,7 @@ print_compiled_pattern(bufp)
print_partial_compiled_pattern(buffer, buffer + bufp->used); print_partial_compiled_pattern(buffer, buffer + bufp->used);
} }
#endif
static char* static char*
calculate_must_string(start, end) calculate_must_string(start, end)
@ -1208,7 +1212,7 @@ read_special(p, pend, pp)
the `struct re_pattern_buffer' that bufp pointed to, after the `struct re_pattern_buffer' that bufp pointed to, after
re_compile_pattern returns. */ re_compile_pattern returns. */
char * const char *
re_compile_pattern(pattern, size, bufp) re_compile_pattern(pattern, size, bufp)
const char *pattern; const char *pattern;
int size; int size;
@ -2580,6 +2584,7 @@ insert_jump_n(op, from, to, current_end, n)
} }
#if 0
/* Open up space at location THERE, and insert operation OP. /* Open up space at location THERE, and insert operation OP.
CURRENT_END gives the end of the storage in use, so CURRENT_END gives the end of the storage in use, so
we know how much data to copy up. we know how much data to copy up.
@ -2599,6 +2604,7 @@ insert_op(op, there, current_end)
there[0] = (char)op; there[0] = (char)op;
} }
#endif
/* Open up space at location THERE, and insert operation OP followed by /* Open up space at location THERE, and insert operation OP followed by

View file

@ -184,7 +184,7 @@ typedef struct
#ifdef __STDC__ #ifdef __STDC__
extern char *re_compile_pattern (const char *, int, struct re_pattern_buffer *); extern const char *re_compile_pattern (const char *, int, struct re_pattern_buffer *);
void re_free_pattern (struct re_pattern_buffer *); void re_free_pattern (struct re_pattern_buffer *);
/* Is this really advertised? */ /* Is this really advertised? */
extern int re_adjust_startpos (struct re_pattern_buffer *, const char*, int, int, int); extern int re_adjust_startpos (struct re_pattern_buffer *, const char*, int, int, int);
@ -205,7 +205,7 @@ extern int re_exec (const char *);
#else /* !__STDC__ */ #else /* !__STDC__ */
extern char *re_compile_pattern (); extern const char *re_compile_pattern ();
void re_free_regexp (); void re_free_regexp ();
/* Is this really advertised? */ /* Is this really advertised? */
extern int re_adjust_startpos (); extern int re_adjust_startpos ();

7
ruby.c
View file

@ -809,6 +809,9 @@ proc_options(argc, argv)
} }
else { else {
script = argv[0]; script = argv[0];
#if defined DOSISH || defined __CYGWIN__
translate_char(argv[0], '\\', '/');
#endif
if (script[0] == '\0') { if (script[0] == '\0') {
script = "-"; script = "-";
} }
@ -825,10 +828,10 @@ proc_options(argc, argv)
if (!script) script = argv[0]; if (!script) script = argv[0];
script = ruby_sourcefile = rb_source_filename(script); script = ruby_sourcefile = rb_source_filename(script);
script_node = NEW_NEWLINE(0); script_node = NEW_NEWLINE(0);
}
#if defined DOSISH || defined __CYGWIN__ #if defined DOSISH || defined __CYGWIN__
translate_char(script, '\\', '/'); translate_char(ruby_sourcefile, '\\', '/');
#endif #endif
}
argc--; argv++; argc--; argv++;
} }
} }

View file

@ -685,11 +685,13 @@ struct trap_arg {
VALUE sig, cmd; VALUE sig, cmd;
}; };
#if USE_TRAP_MASK
# ifdef HAVE_SIGPROCMASK # ifdef HAVE_SIGPROCMASK
static sigset_t trap_last_mask; static sigset_t trap_last_mask;
# else # else
static int trap_last_mask; static int trap_last_mask;
# endif # endif
#endif
static RETSIGTYPE sigexit _((int)); static RETSIGTYPE sigexit _((int));
static RETSIGTYPE static RETSIGTYPE
@ -991,6 +993,7 @@ install_nativethread_sighandler(signum, handler)
#endif #endif
#endif #endif
#if defined(SIGCLD) || defined(SIGCHLD)
static void static void
init_sigchld(sig) init_sigchld(sig)
int sig; int sig;
@ -1032,6 +1035,7 @@ init_sigchld(sig)
trap_last_mask = mask; trap_last_mask = mask;
#endif #endif
} }
#endif
/* /*
* Many operating systems allow signals to be sent to running * Many operating systems allow signals to be sent to running

View file

@ -718,7 +718,7 @@ rb_f_sprintf(argc, argv)
fval = RFLOAT(rb_Float(val))->value; fval = RFLOAT(rb_Float(val))->value;
#if defined(_WIN32) && !defined(__BORLANDC__) #if defined(_WIN32) && !defined(__BORLANDC__)
if (isnan(fval) || isinf(fval)) { if (isnan(fval) || isinf(fval)) {
char *expr; const char *expr;
if (isnan(fval)) { if (isnan(fval)) {
expr = "NaN"; expr = "NaN";

View file

@ -4479,7 +4479,7 @@ static VALUE
rb_str_crypt(str, salt) rb_str_crypt(str, salt)
VALUE str, salt; VALUE str, salt;
{ {
extern char *crypt(); extern char *crypt _((const char *, const char*));
VALUE result; VALUE result;
const char *s; const char *s;

5
time.c
View file

@ -759,7 +759,10 @@ make_time_t(tptr, utc_p)
int utc_p; int utc_p;
{ {
time_t t; time_t t;
struct tm *tmp, buf; #ifdef NEGATIVE_TIME_T
struct tm *tmp;
#endif
struct tm buf;
buf = *tptr; buf = *tptr;
if (utc_p) { if (utc_p) {
#if defined(HAVE_TIMEGM) #if defined(HAVE_TIMEGM)

23
util.c
View file

@ -6,7 +6,7 @@
$Date$ $Date$
created at: Fri Mar 10 17:22:34 JST 1995 created at: Fri Mar 10 17:22:34 JST 1995
Copyright (C) 1993-2003 Yukihiro Matsumoto Copyright (C) 1993-2008 Yukihiro Matsumoto
**********************************************************************/ **********************************************************************/
@ -21,6 +21,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include "missing/file.h" #include "missing/file.h"
#endif #endif
#if defined(__CYGWIN32__) || defined(_WIN32)
#include <io.h>
#endif
#include "util.h" #include "util.h"
#ifndef HAVE_STRING_H #ifndef HAVE_STRING_H
@ -50,7 +53,7 @@ scan_hex(start, len, retlen)
int len; int len;
int *retlen; int *retlen;
{ {
static char hexdigit[] = "0123456789abcdef0123456789ABCDEF"; static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
register const char *s = start; register const char *s = start;
register unsigned long retval = 0; register unsigned long retval = 0;
char *tmp; char *tmp;
@ -149,8 +152,8 @@ scan_hex(start, len, retlen)
static int valid_filename(char *s); static int valid_filename(char *s);
static char suffix1[] = ".$$$"; static const char suffix1[] = ".$$$";
static char suffix2[] = ".~~~"; static const char suffix2[] = ".~~~";
#define ext (&buf[1000]) #define ext (&buf[1000])
@ -228,6 +231,12 @@ fallback:
} }
#if defined(__CYGWIN32__) || defined(_WIN32) #if defined(__CYGWIN32__) || defined(_WIN32)
#if defined __CYGWIN32__ || defined __MINGW32__
extern int _open(const char *, int, ...);
extern int _close(int);
extern int _unlink(const char *);
#endif
static int static int
valid_filename(char *s) valid_filename(char *s)
{ {
@ -2103,6 +2112,7 @@ ruby_strtod(const char *s00, char **se)
const char *s2; const char *s2;
#endif #endif
errno = 0;
sign = nz0 = nz = 0; sign = nz0 = nz = 0;
dval(rv) = 0.; dval(rv) = 0.;
for (s = s00;;s++) for (s = s00;;s++)
@ -2282,7 +2292,7 @@ ret0:
#endif #endif
dval(rv) = tens[k - 9] * dval(rv) + z; dval(rv) = tens[k - 9] * dval(rv) + z;
} }
bd0 = 0; bd0 = bb = bd = bs = delta = 0;
if (nd <= DBL_DIG if (nd <= DBL_DIG
#ifndef RND_PRODQUOT #ifndef RND_PRODQUOT
#ifndef Honor_FLT_ROUNDS #ifndef Honor_FLT_ROUNDS
@ -3208,7 +3218,7 @@ dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
int denorm; int denorm;
ULong x; ULong x;
#endif #endif
Bigint *b, *b1, *delta, *mlo, *mhi, *S; Bigint *b, *b1, *delta, *mlo = 0, *mhi = 0, *S;
double d2, ds, eps; double d2, ds, eps;
char *s, *s0; char *s, *s0;
#ifdef Honor_FLT_ROUNDS #ifdef Honor_FLT_ROUNDS
@ -3561,7 +3571,6 @@ bump_up:
m2 = b2; m2 = b2;
m5 = b5; m5 = b5;
mhi = mlo = 0;
if (leftright) { if (leftright) {
i = i =
#ifndef Sudden_Underflow #ifndef Sudden_Underflow

View file

@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-06-06" #define RUBY_RELEASE_DATE "2008-06-06"
#define RUBY_VERSION_CODE 187 #define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20080606 #define RUBY_RELEASE_CODE 20080606
#define RUBY_PATCHLEVEL 8 #define RUBY_PATCHLEVEL 9
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_MINOR 8

View file

@ -21,6 +21,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <ctype.h>
#include <windows.h> #include <windows.h>
#include <winbase.h> #include <winbase.h>
@ -208,7 +209,7 @@ rb_w32_map_errno(DWORD winerr)
#define map_errno rb_w32_map_errno #define map_errno rb_w32_map_errno
static char *NTLoginName; static const char *NTLoginName;
#ifdef WIN95 #ifdef WIN95
static DWORD Win32System = (DWORD)-1; static DWORD Win32System = (DWORD)-1;
@ -448,10 +449,6 @@ init_env(void)
void void
NtInitialize(int *argc, char ***argv) NtInitialize(int *argc, char ***argv)
{ {
WORD version;
int ret;
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
static void set_pioinfo_extra(void); static void set_pioinfo_extra(void);
@ -490,7 +487,7 @@ NtInitialize(int *argc, char ***argv)
char * char *
getlogin() getlogin()
{ {
return NTLoginName; return (char *)NTLoginName;
} }
#define MAXCHILDNUM 256 /* max num of child processes */ #define MAXCHILDNUM 256 /* max num of child processes */
@ -505,15 +502,6 @@ static struct ChildRecord {
for (v = ChildRecord; v < ChildRecord + sizeof(ChildRecord) / sizeof(ChildRecord[0]); ++v) for (v = ChildRecord; v < ChildRecord + sizeof(ChildRecord) / sizeof(ChildRecord[0]); ++v)
#define END_FOREACH_CHILD } while (0) #define END_FOREACH_CHILD } while (0)
static struct ChildRecord *
FindFirstChildSlot(void)
{
FOREACH_CHILD(child) {
if (child->pid) return child;
} END_FOREACH_CHILD;
return NULL;
}
static struct ChildRecord * static struct ChildRecord *
FindChildSlot(rb_pid_t pid) FindChildSlot(rb_pid_t pid)
{ {
@ -665,7 +653,7 @@ rb_w32_get_osfhandle(int fh)
} }
rb_pid_t rb_pid_t
pipe_exec(char *cmd, int mode, FILE **fpr, FILE **fpw) pipe_exec(const char *cmd, int mode, FILE **fpr, FILE **fpw)
{ {
struct ChildRecord* child; struct ChildRecord* child;
HANDLE hReadIn, hReadOut; HANDLE hReadIn, hReadOut;
@ -804,7 +792,7 @@ pipe_exec(char *cmd, int mode, FILE **fpr, FILE **fpw)
extern VALUE rb_last_status; extern VALUE rb_last_status;
int int
do_spawn(int mode, char *cmd) do_spawn(int mode, const char *cmd)
{ {
struct ChildRecord *child; struct ChildRecord *child;
DWORD exitcode; DWORD exitcode;
@ -841,7 +829,7 @@ do_spawn(int mode, char *cmd)
} }
int int
do_aspawn(int mode, char *prog, char **argv) do_aspawn(int mode, const char *prog, char **argv)
{ {
char *cmd, *p, *q, *s, **t; char *cmd, *p, *q, *s, **t;
int len, n, bs, quote; int len, n, bs, quote;
@ -1211,7 +1199,7 @@ skipspace(char *ptr)
int int
rb_w32_cmdvector(const char *cmd, char ***vec) rb_w32_cmdvector(const char *cmd, char ***vec)
{ {
int cmdlen, globbing, len, i; int globbing, len;
int elements, strsz, done; int elements, strsz, done;
int slashes, escape; int slashes, escape;
char *ptr, *base, *buffer, *cmdline; char *ptr, *base, *buffer, *cmdline;
@ -3936,9 +3924,7 @@ int
rb_w32_utime(const char *path, struct utimbuf *times) rb_w32_utime(const char *path, struct utimbuf *times)
{ {
HANDLE hFile; HANDLE hFile;
SYSTEMTIME st;
FILETIME atime, mtime; FILETIME atime, mtime;
struct tm *tm;
struct stat stat; struct stat stat;
int ret = 0; int ret = 0;

View file

@ -160,7 +160,7 @@ struct timezone {
#endif #endif
extern void NtInitialize(int *, char ***); extern void NtInitialize(int *, char ***);
extern int rb_w32_cmdvector(const char *, char ***); extern int rb_w32_cmdvector(const char *, char ***);
extern rb_pid_t pipe_exec(char *, int, FILE **, FILE **); extern rb_pid_t pipe_exec(const char *, int, FILE **, FILE **);
extern int flock(int fd, int oper); extern int flock(int fd, int oper);
extern int rb_w32_accept(int, struct sockaddr *, int *); extern int rb_w32_accept(int, struct sockaddr *, int *);
extern int rb_w32_bind(int, struct sockaddr *, int); extern int rb_w32_bind(int, struct sockaddr *, int);
@ -206,8 +206,8 @@ extern int chown(const char *, int, int);
extern int link(char *, char *); extern int link(char *, char *);
extern int gettimeofday(struct timeval *, struct timezone *); extern int gettimeofday(struct timeval *, struct timezone *);
extern rb_pid_t waitpid (rb_pid_t, int *, int); extern rb_pid_t waitpid (rb_pid_t, int *, int);
extern int do_spawn(int, char *); extern int do_spawn(int, const char *);
extern int do_aspawn(int, char *, char **); extern int do_aspawn(int, const char *, char **);
extern int kill(int, int); extern int kill(int, int);
extern int fcntl(int, int, ...); extern int fcntl(int, int, ...);
extern rb_pid_t rb_w32_getpid(void); extern rb_pid_t rb_w32_getpid(void);