Permalink
Browse files

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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7@16863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 68dbfd1 commit 95c01b72a33a29677c712f2aaafc6a3e3183b902 @knu knu committed Jun 6, 2008
Showing with 159 additions and 94 deletions.
  1. +14 −0 ChangeLog
  2. +12 −12 dln.c
  3. +17 −13 file.c
  4. +1 −1 intern.h
  5. +11 −2 io.c
  6. +5 −5 marshal.c
  7. +1 −1 missing.h
  8. +28 −6 missing/crypt.c
  9. +1 −0 mkconfig.rb
  10. +2 −8 pack.c
  11. +4 −0 parse.y
  12. +9 −3 process.c
  13. +2 −2 re.c
  14. +8 −2 regex.c
  15. +2 −2 regex.h
  16. +5 −2 ruby.c
  17. +4 −0 signal.c
  18. +1 −1 sprintf.c
  19. +1 −1 string.c
  20. +4 −1 time.c
  21. +16 −7 util.c
  22. +1 −1 version.h
  23. +7 −21 win32/win32.c
  24. +3 −3 win32/win32.h
View
@@ -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>
* file.c (file_expand_path): fix for non-existent files and SFN of
View
@@ -1689,31 +1689,31 @@ static char fbuf[MAXPATHLEN];
static char *
dln_find_1(fname, path, exe_flag)
- char *fname;
- char *path;
+ const char *fname;
+ const char *path;
int exe_flag; /* non 0 if looking for executable. */
{
- register char *dp;
- register char *ep;
+ register const char *dp;
+ register const char *ep;
register char *bp;
struct stat st;
#ifdef __MACOS__
const char* mac_fullpath;
#endif
- if (!fname) return fname;
- if (fname[0] == '/') return fname;
+ if (!fname) return (char *)fname;
+ if (fname[0] == '/') return (char *)fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
- return fname;
- if (exe_flag && strchr(fname, '/')) return fname;
+ return (char *)fname;
+ if (exe_flag && strchr(fname, '/')) return (char *)fname;
#ifdef DOSISH
- if (fname[0] == '\\') return fname;
+ if (fname[0] == '\\') return (char *)fname;
# ifdef DOSISH_DRIVE_LETTER
- if (strlen(fname) > 2 && fname[1] == ':') return fname;
+ if (strlen(fname) > 2 && fname[1] == ':') return (char *)fname;
# endif
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
- return fname;
- if (exe_flag && strchr(fname, '\\')) return fname;
+ return (char *)fname;
+ if (exe_flag && strchr(fname, '\\')) return (char *)fname;
#endif
for (dp = path;; dp = ++ep) {
View
@@ -2320,6 +2320,10 @@ rb_file_s_umask(argc, argv)
#define USE_NTFS 0
#endif
+#ifdef DOSISH_DRIVE_LETTER
+#include <ctype.h>
+#endif
+
#if USE_NTFS
#define istrailinggabage(x) ((x) == '.' || (x) == ' ')
#else
@@ -2532,7 +2536,7 @@ file_expand_path(fname, dname, result)
if (s[0] == '~') {
if (isdirsep(s[1]) || s[1] == '\0') {
- char *dir = getenv("HOME");
+ const char *dir = getenv("HOME");
if (!dir) {
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 fname, fext, basename;
- char *name, *p;
+ const char *name, *p;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
- char *root;
+ const char *root;
#endif
int f, n;
@@ -3100,7 +3104,7 @@ rb_file_join(ary, sep)
long len, i;
int taint = 0;
VALUE result, tmp;
- char *name, *tail;
+ const char *name, *tail;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
if (OBJ_TAINTED(ary)) taint = 1;
@@ -4285,7 +4289,7 @@ path_check_0(fpath, execpath)
int execpath;
{
struct stat st;
- char *p0 = StringValueCStr(fpath);
+ const char *p0 = StringValueCStr(fpath);
char *p = 0, *s;
if (!is_absolute_path(p0)) {
@@ -4324,7 +4328,7 @@ path_check_0(fpath, execpath)
static int
fpath_check(path)
- char *path;
+ const char *path;
{
#if ENABLE_PATH_CHECK
return path_check_0(rb_str_new2(path), Qfalse);
@@ -4335,10 +4339,10 @@ fpath_check(path)
int
rb_path_check(path)
- char *path;
+ const char *path;
{
#if ENABLE_PATH_CHECK
- char *p0, *p, *pend;
+ const char *p0, *p, *pend;
const char sep = PATH_SEP_CHAR;
if (!path) return 1;
@@ -4373,7 +4377,7 @@ is_macos_native_path(path)
static int
file_load_ok(file)
- char *file;
+ const char *file;
{
FILE *f;
@@ -4391,8 +4395,8 @@ rb_find_file_ext(filep, ext)
VALUE *filep;
const char * const *ext;
{
- char *path, *found;
- char *f = RSTRING(*filep)->ptr;
+ const char *path, *found;
+ const char *f = RSTRING(*filep)->ptr;
VALUE fname;
long i, j;
@@ -4447,8 +4451,8 @@ rb_find_file(path)
VALUE path;
{
VALUE tmp;
- char *f = StringValueCStr(path);
- char *lpath;
+ const char *f = StringValueCStr(path);
+ const char *lpath;
if (f[0] == '~') {
path = rb_file_expand_path(path, Qnil);
View
@@ -277,7 +277,7 @@ VALUE rb_hash_lookup _((VALUE, VALUE));
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
VALUE rb_hash_delete_if _((VALUE));
VALUE rb_hash_delete _((VALUE,VALUE));
-int rb_path_check _((char*));
+int rb_path_check _((const char*));
int rb_env_path_tainted _((void));
/* io.c */
#define rb_defout rb_stdout
View
@@ -50,6 +50,9 @@
#elif defined(HAVE_SYS_FCNTL_H)
#include <sys/fcntl.h>
#endif
+#ifdef __CYGWIN__
+#include <io.h>
+#endif
#if !HAVE_OFF_T && !defined(off_t)
# define off_t long
@@ -429,7 +432,10 @@ static int
wsplit_p(rb_io_t *fptr)
{
FILE *f = GetWriteFile(fptr);
+#if defined(HAVE_FCNTL) && defined(F_GETFL) && defined(O_NONBLOCK)
int r;
+#endif
+
if (!(fptr->mode & FMODE_WSPLIT_INITIALIZED)) {
struct stat buf;
if (fstat(fileno(f), &buf) == 0 &&
@@ -1675,7 +1681,7 @@ rb_io_getline_fast(fptr, delim)
static int
rscheck(rsptr, rslen, rs)
- char *rsptr;
+ const char *rsptr;
long rslen;
VALUE rs;
{
@@ -4522,7 +4528,10 @@ next_argv()
FILE *fr = rb_fopen(fn, "r");
if (ruby_inplace_mode) {
- struct stat st, st2;
+ struct stat st;
+#ifndef NO_SAFE_RENAME
+ struct stat st2;
+#endif
VALUE str;
FILE *fw;
View
@@ -130,7 +130,7 @@ static void w_long _((long, struct dump_arg*));
static void
w_nbyte(s, n, arg)
- char *s;
+ const char *s;
int n;
struct dump_arg *arg;
{
@@ -153,7 +153,7 @@ w_byte(c, arg)
static void
w_bytes(s, n, arg)
- char *s;
+ const char *s;
int n;
struct dump_arg *arg;
{
@@ -354,7 +354,7 @@ w_symbol(id, arg)
static void
w_unique(s, arg)
- char *s;
+ const char *s;
struct dump_arg *arg;
{
if (s[0] == '#') {
@@ -991,7 +991,7 @@ r_ivar(obj, arg)
static VALUE
path2class(path)
- char *path;
+ const char *path;
{
VALUE v = rb_path2class(path);
@@ -1003,7 +1003,7 @@ path2class(path)
static VALUE
path2module(path)
- char *path;
+ const char *path;
{
VALUE v = rb_path2class(path);
View
@@ -32,7 +32,7 @@ extern double atanh _((double));
#endif
#ifndef HAVE_CRYPT
-extern char *crypt _((char *, char *));
+extern char *crypt _((const char *, const char *));
#endif
#ifndef HAVE_DUP2
Oops, something went wrong. Retry.

0 comments on commit 95c01b7

Please sign in to comment.