* file.c (apply2files): stricter callback definition.

* file.c (rb_path_check): constified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-09-12 15:02:46 +00:00
parent 7877b56572
commit ef86852451
3 changed files with 31 additions and 37 deletions

View File

@ -1,3 +1,9 @@
Tue Sep 13 00:02:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (apply2files): stricter callback definition.
* file.c (rb_path_check): constified.
Mon Sep 12 20:53:06 2005 GOTOU Yuuzou <gotoyuzo@notwork.org> Mon Sep 12 20:53:06 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* test/openssl/test_pkcs7.rb (test_enveloped): skip this test * test/openssl/test_pkcs7.rb (test_enveloped): skip this test

60
file.c
View File

@ -97,7 +97,7 @@ rb_get_path(VALUE obj)
} }
static long static long
apply2files(void (*func) (/* ??? */), VALUE vargs, void *arg) apply2files(void (*func)(const char *, void *), VALUE vargs, void *arg)
{ {
long i; long i;
VALUE path; VALUE path;
@ -1275,9 +1275,7 @@ test_grpowned(VALUE obj, VALUE fname)
#if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX) #if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX)
static VALUE static VALUE
check3rdbyte(fname, mode) check3rdbyte(VALUE fname, int mode)
VALUE fname;
int mode;
{ {
struct stat st; struct stat st;
@ -1358,7 +1356,7 @@ rb_file_s_size(VALUE klass, VALUE fname)
} }
static VALUE static VALUE
rb_file_ftype(struct stat *st) rb_file_ftype(const struct stat *st)
{ {
char *t; char *t;
@ -1561,9 +1559,9 @@ rb_file_ctime(VALUE obj)
} }
static void static void
chmod_internal(const char *path, int mode) chmod_internal(const char *path, void *mode)
{ {
if (chmod(path, mode) < 0) if (chmod(path, (int)mode) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -1633,11 +1631,9 @@ rb_file_chmod(VALUE obj, VALUE vmode)
#if defined(HAVE_LCHMOD) #if defined(HAVE_LCHMOD)
static void static void
lchmod_internal(path, mode) lchmod_internal(const char *path, void *mode)
const char *path;
int mode;
{ {
if (lchmod(path, mode) < 0) if (lchmod(path, (int)mode) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -1652,9 +1648,7 @@ lchmod_internal(path, mode)
*/ */
static VALUE static VALUE
rb_file_s_lchmod(argc, argv) rb_file_s_lchmod(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE vmode; VALUE vmode;
VALUE rest; VALUE rest;
@ -1681,8 +1675,9 @@ struct chown_args {
}; };
static void static void
chown_internal(const char *path, struct chown_args *args) chown_internal(const char *path, void *arg)
{ {
struct chown_args *args = arg;
if (chown(path, args->owner, args->group) < 0) if (chown(path, args->owner, args->group) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -1767,10 +1762,9 @@ rb_file_chown(VALUE obj, VALUE owner, VALUE group)
#if defined(HAVE_LCHOWN) && !defined(__CHECKER__) #if defined(HAVE_LCHOWN) && !defined(__CHECKER__)
static void static void
lchown_internal(path, args) lchown_internal(const char *path, void *arg)
const char *path;
struct chown_args *args;
{ {
struct chown_args *args = arg;
if (lchown(path, args->owner, args->group) < 0) if (lchown(path, args->owner, args->group) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -1788,9 +1782,7 @@ lchown_internal(path, args)
*/ */
static VALUE static VALUE
rb_file_s_lchown(argc, argv) rb_file_s_lchown(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE o, g, rest; VALUE o, g, rest;
struct chown_args arg; struct chown_args arg;
@ -1827,10 +1819,9 @@ struct timeval rb_time_timeval(VALUE time);
#if defined(HAVE_UTIMES) && !defined(__CHECKER__) #if defined(HAVE_UTIMES) && !defined(__CHECKER__)
static void static void
utime_internal(path, tvp) utime_internal(const char *path, void *arg)
char *path;
struct timeval tvp[];
{ {
struct timeval *tvp = arg;
if (utimes(path, tvp) < 0) if (utimes(path, tvp) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -1845,9 +1836,7 @@ utime_internal(path, tvp)
*/ */
static VALUE static VALUE
rb_file_s_utime(argc, argv) rb_file_s_utime(int argc, VALUE *argv)
int argc;
VALUE *argv;
{ {
VALUE atime, mtime, rest; VALUE atime, mtime, rest;
struct timeval tvp[2]; struct timeval tvp[2];
@ -1872,8 +1861,9 @@ struct utimbuf {
#endif #endif
static void static void
utime_internal(const char *path, struct utimbuf *utp) utime_internal(const char *path, void *arg)
{ {
struct utimbuf *utp = arg;
if (utime(path, utp) < 0) if (utime(path, utp) < 0)
rb_sys_fail(path); rb_sys_fail(path);
} }
@ -2014,7 +2004,7 @@ rb_file_s_readlink(VALUE klass, VALUE path)
} }
static void static void
unlink_internal(const char *path) unlink_internal(const char *path, void *arg)
{ {
if (unlink(path) < 0) if (unlink(path) < 0)
rb_sys_fail(path); rb_sys_fail(path);
@ -3841,8 +3831,7 @@ is_absolute_path(const char *path)
#ifndef DOSISH #ifndef DOSISH
static int static int
path_check_1(path) path_check_1(VALUE path)
VALUE path;
{ {
struct stat st; struct stat st;
char *p0 = StringValueCStr(path); char *p0 = StringValueCStr(path);
@ -3882,10 +3871,10 @@ path_check_1(path)
#endif #endif
int int
rb_path_check(char *path) rb_path_check(const char *path)
{ {
#ifndef DOSISH #ifndef DOSISH
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;
@ -3910,8 +3899,7 @@ rb_path_check(char *path)
#if defined(__MACOS__) || defined(riscos) #if defined(__MACOS__) || defined(riscos)
static int static int
is_macos_native_path(path) is_macos_native_path(const char *path)
const char *path;
{ {
if (strchr(path, ':')) return 1; if (strchr(path, ':')) return 1;
return 0; return 0;
@ -3919,7 +3907,7 @@ is_macos_native_path(path)
#endif #endif
static int static int
file_load_ok(char *file) file_load_ok(const char *file)
{ {
FILE *f; FILE *f;

View File

@ -323,7 +323,7 @@ VALUE rb_hash_aref _((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