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

* file.c (rb_file_chown): integer conversion should be prior to

GetOpenFile().  [ruby-dev:24947]

* file.c (rb_file_truncate): ditto.

* file.c (rb_file_s_truncate): ditto.

* dir.c (dir_seek): use NUM2OFFT().

* misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-22 15:26:02 +00:00
parent d9d5c88cf3
commit f50136a311
4 changed files with 33 additions and 11 deletions

View file

@ -1,3 +1,16 @@
Tue Nov 23 00:10:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* file.c (rb_file_chown): integer conversion should be prior to
GetOpenFile(). [ruby-dev:24947]
* file.c (rb_file_truncate): ditto.
* file.c (rb_file_s_truncate): ditto.
* dir.c (dir_seek): use NUM2OFFT().
* misc/ruby-mode.el (ruby-non-block-do-re): [ruby-core:03719]
Mon Nov 22 22:33:02 2004 Dave Thomas <dave@pragprog.com> Mon Nov 22 22:33:02 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names * lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names

2
dir.c
View file

@ -600,7 +600,7 @@ dir_seek(dir, pos)
VALUE dir, pos; VALUE dir, pos;
{ {
struct dir_data *dirp; struct dir_data *dirp;
off_t p = NUM2LONG(pos); off_t p = NUM2OFFT(pos);
GetDIR(dir, dirp); GetDIR(dir, dirp);
#ifdef HAVE_SEEKDIR #ifdef HAVE_SEEKDIR

27
file.c
View file

@ -1829,15 +1829,18 @@ rb_file_chown(obj, owner, group)
VALUE obj, owner, group; VALUE obj, owner, group;
{ {
OpenFile *fptr; OpenFile *fptr;
int o, g;
rb_secure(2); rb_secure(2);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
o = NUM2INT(owner);
g = NUM2INT(group);
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) || defined(__EMX__) #if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) || defined(__EMX__)
if (!fptr->path) return Qnil; if (!fptr->path) return Qnil;
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1) if (chown(fptr->path, o, g) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#else #else
if (fchown(fileno(fptr->f), NUM2INT(owner), NUM2INT(group)) == -1) if (fchown(fileno(fptr->f), o, g) == -1)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#endif #endif
@ -2916,11 +2919,13 @@ static VALUE
rb_file_s_truncate(klass, path, len) rb_file_s_truncate(klass, path, len)
VALUE klass, path, len; VALUE klass, path, len;
{ {
rb_secure(2); off_t pos;
FilePathValue(path);
rb_secure(2);
pos = NUM2OFFT(len);
FilePathValue(path);
#ifdef HAVE_TRUNCATE #ifdef HAVE_TRUNCATE
if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0) if (truncate(StringValueCStr(path), pos) < 0)
rb_sys_fail(RSTRING(path)->ptr); rb_sys_fail(RSTRING(path)->ptr);
#else #else
# ifdef HAVE_CHSIZE # ifdef HAVE_CHSIZE
@ -2936,7 +2941,7 @@ rb_file_s_truncate(klass, path, len)
rb_sys_fail(RSTRING(path)->ptr); rb_sys_fail(RSTRING(path)->ptr);
} }
# endif # endif
if (chsize(tmpfd, NUM2OFFT(len)) < 0) { if (chsize(tmpfd, pos) < 0) {
close(tmpfd); close(tmpfd);
rb_sys_fail(RSTRING(path)->ptr); rb_sys_fail(RSTRING(path)->ptr);
} }
@ -2969,8 +2974,10 @@ rb_file_truncate(obj, len)
{ {
OpenFile *fptr; OpenFile *fptr;
FILE *f; FILE *f;
off_t pos;
rb_secure(2); rb_secure(2);
pos = NUM2OFFT(len);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
if (!(fptr->mode & FMODE_WRITABLE)) { if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing"); rb_raise(rb_eIOError, "not opened for writing");
@ -2979,11 +2986,11 @@ rb_file_truncate(obj, len)
fflush(f); fflush(f);
fseeko(f, (off_t)0, SEEK_CUR); fseeko(f, (off_t)0, SEEK_CUR);
#ifdef HAVE_TRUNCATE #ifdef HAVE_TRUNCATE
if (ftruncate(fileno(f), NUM2OFFT(len)) < 0) if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
#else #else
# ifdef HAVE_CHSIZE # ifdef HAVE_CHSIZE
if (chsize(fileno(f), NUM2OFFT(len)) < 0) if (chsize(fileno(f), pos) < 0)
rb_sys_fail(fptr->path); rb_sys_fail(fptr->path);
# else # else
rb_notimplement(); rb_notimplement();
@ -3070,15 +3077,17 @@ rb_file_flock(obj, operation)
{ {
#ifndef __CHECKER__ #ifndef __CHECKER__
OpenFile *fptr; OpenFile *fptr;
int op;
rb_secure(2); rb_secure(2);
op = NUM2INT(operation);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
if (fptr->mode & FMODE_WRITABLE) { if (fptr->mode & FMODE_WRITABLE) {
fflush(GetWriteFile(fptr)); fflush(GetWriteFile(fptr));
} }
retry: retry:
if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) { if (flock(fileno(fptr->f), op) < 0) {
switch (errno) { switch (errno) {
case EAGAIN: case EAGAIN:
case EACCES: case EACCES:

View file

@ -18,7 +18,7 @@
) )
(defconst ruby-non-block-do-re (defconst ruby-non-block-do-re
"\\(while\\|until\\|for\\|rescue\\)\\>" "\\(while\\|until\\|for\\|rescue\\)\\>[^_]"
) )
(defconst ruby-indent-beg-re (defconst ruby-indent-beg-re