summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-22 15:29:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-22 15:29:52 +0000
commit39080991ab143d36afd40f3f6f547de571f98df7 (patch)
tree3bd7aa4308df0efc028494bc5e2965128a9b5991
parente2242e7e2a3df11808445a87f091e43e9ce37963 (diff)
* 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] * dir.c (dir_seek): should retrieve dir_data after NUM2INT(). [ruby-dev:24941] * string.c (rb_str_splice): should place index wrapping after possible modification. [ruby-dev:24940] * eval.c (error_print): nicer traceback at interrupt. [ruby-core:03774] * string.c (str_gsub): internal buffer should not be listed by ObjectSpace.each_object() by String#gsub. [ruby-dev:24931] * lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise exception if data corresponding to session specified from the client does not exist. * string.c (str_gsub): internal buffer should not be listed by ObjectSpace.each_object(). [ruby-dev:24919] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog54
-rw-r--r--configure.in3
-rw-r--r--dir.c5
-rw-r--r--eval.c1
-rw-r--r--file.c24
-rw-r--r--io.c3
-rw-r--r--lib/cgi/session.rb17
-rw-r--r--lib/cgi/session/pstore.rb5
-rw-r--r--regex.c4
-rw-r--r--rubyio.h4
-rw-r--r--string.c12
11 files changed, 109 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c90253..6b5963e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,26 @@
+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>
* lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Don't use names
of variables or constants when oarsing 'require'
+Mon Nov 22 00:13:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_seek): should retrieve dir_data after NUM2INT().
+ [ruby-dev:24941]
+
Sat Nov 20 23:57:33 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/README (et al): Add a new directive, :section:, and
@@ -16,12 +34,10 @@ Sat Nov 20 23:56:54 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/options.rb (Options::parse): Force --inline-source if
--one-file option given
-Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+Sat Nov 20 23:55:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * test/ruby/test_stringchar.rb (test_bang): added.
-
- * string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
- (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
+ * string.c (rb_str_splice): should place index wrapping after
+ possible modification. [ruby-dev:24940]
Tue Nov 20 13:26:03 2004 NARUSE, Yui <naruse@ruby-lang.org>
@@ -33,6 +49,34 @@ Tue Nov 20 05:34:24 2004 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/test.rb: add test for mime encode/decode
+Sat Nov 20 01:37:34 2004 Johan Holmberg <holmberg@iar.se>
+
+ * eval.c (error_print): nicer traceback at interrupt.
+ [ruby-core:03774]
+
+Sat Nov 20 00:07:16 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_gsub): internal buffer should not be listed by
+ ObjectSpace.each_object() by String#gsub. [ruby-dev:24931]
+
+Fri Nov 19 01:20:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
+ exception if data corresponding to session specified from the
+ client does not exist.
+
+Fri Nov 19 00:59:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_gsub): internal buffer should not be listed by
+ ObjectSpace.each_object(). [ruby-dev:24919]
+
+Thu Nov 18 18:41:08 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * test/ruby/test_stringchar.rb (test_bang): added.
+
+ * string.c (rb_str_upcase_bang, rb_str_capitalize_bang)
+ (rb_str_swapcase_bang): missing rb_str_modify(). [ruby-dev:24915]
+
Thu Nov 18 00:21:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (proc_getpgrp): prohibit for $SAFE=2.
diff --git a/configure.in b/configure.in
index 1f3723c..14f752d 100644
--- a/configure.in
+++ b/configure.in
@@ -530,6 +530,9 @@ else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi
+AC_CHECK_HEADERS(stdio_ext.h)
+AC_CHECK_FUNCS(__fpending)
+
AC_MSG_CHECKING(read count field in FILE structures)
AC_CACHE_VAL(rb_cv_fcnt,
[for fcnt in dnl
diff --git a/dir.c b/dir.c
index e83435b..8447630 100644
--- a/dir.c
+++ b/dir.c
@@ -466,10 +466,11 @@ dir_seek(dir, pos)
VALUE dir, pos;
{
struct dir_data *dirp;
+ off_t p = NUM2OFFT(pos);
-#ifdef HAVE_SEEKDIR
GetDIR(dir, dirp);
- seekdir(dirp->dir, NUM2INT(pos));
+#ifdef HAVE_SEEKDIR
+ seekdir(dirp->dir, p);
return dir;
#else
rb_notimplement();
diff --git a/eval.c b/eval.c
index f32e44c..d7d6477 100644
--- a/eval.c
+++ b/eval.c
@@ -1146,6 +1146,7 @@ error_print()
if (elen == 0) {
warn_print(": ");
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
+ warn_print("\n");
}
else {
char *tail = 0;
diff --git a/file.c b/file.c
index 066745c..c1f26ab 100644
--- a/file.c
+++ b/file.c
@@ -1744,15 +1744,18 @@ rb_file_chown(obj, owner, group)
VALUE obj, owner, group;
{
OpenFile *fptr;
+ int o, g;
rb_secure(2);
GetOpenFile(obj, fptr);
+ o = NUM2INT(owner);
+ g = NUM2INT(group);
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) || defined(__EMX__)
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);
#else
- if (fchown(fileno(fptr->f), NUM2INT(owner), NUM2INT(group)) == -1)
+ if (fchown(fileno(fptr->f), o, g) == -1)
rb_sys_fail(fptr->path);
#endif
@@ -2804,11 +2807,14 @@ static VALUE
rb_file_s_truncate(klass, path, len)
VALUE klass, path, len;
{
+ off_t pos;
+
rb_secure(2);
+ pos = NUM2OFFT(len);
SafeStringValue(path);
#ifdef HAVE_TRUNCATE
- if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
+ if (truncate(StringValueCStr(path), pos) < 0)
rb_sys_fail(RSTRING(path)->ptr);
#else
# ifdef HAVE_CHSIZE
@@ -2824,7 +2830,7 @@ rb_file_s_truncate(klass, path, len)
rb_sys_fail(RSTRING(path)->ptr);
}
# endif
- if (chsize(tmpfd, NUM2OFFT(len)) < 0) {
+ if (chsize(tmpfd, pos) < 0) {
close(tmpfd);
rb_sys_fail(RSTRING(path)->ptr);
}
@@ -2857,8 +2863,10 @@ rb_file_truncate(obj, len)
{
OpenFile *fptr;
FILE *f;
+ off_t pos;
rb_secure(2);
+ pos = NUM2OFFT(len);
GetOpenFile(obj, fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
@@ -2867,11 +2875,11 @@ rb_file_truncate(obj, len)
fflush(f);
fseeko(f, (off_t)0, SEEK_CUR);
#ifdef HAVE_TRUNCATE
- if (ftruncate(fileno(f), NUM2OFFT(len)) < 0)
+ if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
- if (chsize(fileno(f), NUM2OFFT(len)) < 0)
+ if (chsize(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
@@ -2958,15 +2966,17 @@ rb_file_flock(obj, operation)
{
#ifndef __CHECKER__
OpenFile *fptr;
+ int op;
rb_secure(2);
+ op = NUM2INT(operation);
GetOpenFile(obj, fptr);
if (fptr->mode & FMODE_WRITABLE) {
fflush(GetWriteFile(fptr));
}
retry:
- if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) {
+ if (flock(fileno(fptr->f), op) < 0) {
switch (errno) {
case EAGAIN:
case EACCES:
diff --git a/io.c b/io.c
index 29077a6..6b8122f 100644
--- a/io.c
+++ b/io.c
@@ -126,6 +126,9 @@ static VALUE lineno = INT2FIX(0);
# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
# define READ_DATA_PENDING_PTR(fp) ((fp)->_gptr)
# endif
+#elif defined(HAVE___FPENDING)
+# define READ_DATA_PENDING(fp) (__fpending(fp) > 0)
+# define READ_DATA_PENDING_COUNT(fp) (__fpending(fp))
#elif defined(FILE_COUNT)
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 66ab8fd..0342f84 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -156,7 +156,7 @@ class CGI
class Session
# The id of this session.
- attr_reader :session_id
+ attr_reader :session_id, :new_session
def Session::callback(dbman) #:nodoc:
Proc.new{
@@ -170,7 +170,7 @@ class CGI
# a random number, and a constant string. This routine
# is used internally for automatically generated
# session ids.
- def Session::create_new_id
+ def create_new_id
require 'digest/md5'
md5 = Digest::MD5::new
now = Time::now
@@ -179,8 +179,10 @@ class CGI
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
+ @new_session = true
md5.hexdigest[0,16]
end
+ private :create_new_id
# Create a new CGI::Session object for +request+.
#
@@ -239,6 +241,7 @@ class CGI
# end
#
def initialize(request, option={})
+ @new_session = false
session_key = option['session_key'] || '_session_id'
id = option['session_id']
unless id
@@ -367,6 +370,9 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
@path = dir+"/"+prefix+md5+suffix
unless File::exist? @path
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
end
@@ -433,7 +439,12 @@ class CGI
# currently recognised.
def initialize(session, option=nil)
@session_id = session.session_id
- GLOBAL_HASH_TABLE[@session_id] ||= {}
+ unless GLOBAL_HASH_TABLE.key?(@session_id)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
+ GLOBAL_HASH_TABLE[@session_id] = {}
+ end
end
# Restore session state.
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index 10f3e8f..e65a2a9 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -61,7 +61,10 @@ class CGI
md5 = Digest::MD5.hexdigest(id)[0,16]
path = dir+"/"+prefix+md5
path.untaint
- unless File::exist? path
+ unless File::exist?(path)
+ unless session.new_session
+ raise RuntimeError, "uninitialized session"
+ end
@hash = {}
end
@p = ::PStore.new(path)
diff --git a/regex.c b/regex.c
index 193e10f..9e64af5 100644
--- a/regex.c
+++ b/regex.c
@@ -1011,8 +1011,8 @@ calculate_must_string(start, end)
{
int mcnt;
int max = 0;
- char *p = start;
- char *pend = end;
+ unsigned char *p = start;
+ unsigned char *pend = end;
char *must = 0;
if (start == NULL) return 0;
diff --git a/rubyio.h b/rubyio.h
index 3fe3282..63fcf74 100644
--- a/rubyio.h
+++ b/rubyio.h
@@ -16,6 +16,10 @@
#include <stdio.h>
#include <errno.h>
+#if defined(HAVE_STDIO_EXT_H)
+#include <stdio_ext.h>
+#endif
+
typedef struct OpenFile {
FILE *f; /* stdio ptr for read/write */
FILE *f2; /* additional ptr for rw pipes */
diff --git a/string.c b/string.c
index acfd6f4..8615bf5 100644
--- a/string.c
+++ b/string.c
@@ -1625,6 +1625,10 @@ rb_str_splice(str, beg, len, val)
VALUE val;
{
if (len < 0) rb_raise(rb_eIndexError, "negative length %ld", len);
+
+ StringValue(val);
+ rb_str_modify(str);
+
if (RSTRING(str)->len < beg) {
out_of_range:
rb_raise(rb_eIndexError, "index %ld out of string", beg);
@@ -1639,8 +1643,6 @@ rb_str_splice(str, beg, len, val)
len = RSTRING(str)->len - beg;
}
- StringValue(val);
- rb_str_modify(str);
if (len < RSTRING(val)->len) {
/* expand string */
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
@@ -2070,7 +2072,7 @@ str_gsub(argc, argv, str, bang)
}
blen = RSTRING(str)->len + 30; /* len + margin */
- dest = rb_str_new5(str, 0, blen);
+ dest = str_new(0, 0, blen);
buf = RSTRING(dest)->ptr;
bp = buf;
sp = cp = RSTRING(str)->ptr;
@@ -2086,6 +2088,9 @@ str_gsub(argc, argv, str, bang)
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
str_mod_check(str, sp, slen);
if (bang) str_frozen_check(str);
+ if (val == dest) { /* paranoid chack [ruby-dev:24827] */
+ rb_raise(rb_eRuntimeError, "block should not cheat");
+ }
rb_backref_set(match);
}
else {
@@ -2147,6 +2152,7 @@ str_gsub(argc, argv, str, bang)
RSTRING(dest)->len = 0;
}
else {
+ RBASIC(dest)->klass = rb_obj_class(str);
OBJ_INFECT(dest, str);
str = dest;
}