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

* variable.c (rb_set_class_path): do not set path if

* lib/cgi.rb (CGI::QueryExtension): give extended string, not a
  delegater object.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-01-19 09:19:31 +00:00
parent 8e877fc517
commit 22c005569b
11 changed files with 196 additions and 115 deletions

195
ChangeLog
View file

@ -24,6 +24,13 @@ Mon Jan 19 06:49:07 2004 Tadayoshi Funaba <tadf@dotrb.org>
* sample/cal.rb: added a class, anyway.
Mon Jan 19 01:08:39 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_set_class_path): do not set path if
* lib/cgi.rb (CGI::QueryExtension): give extended string, not a
delegater object.
Sun Jan 18 23:59:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/charset_alias.rb: prefer us_EN locale encodings or
@ -119,6 +126,17 @@ Wed Jan 14 09:32:02 2004 NAKAMURA Usaku <usa@ruby-lang.org>
* MANIFEST: add test/net/test_httpheader.rb. (commit miss?)
Wed Jan 14 00:58:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (Init_Proc): move SystemStackError from under
StandardError to Exception. [ruby-talk:89782]
Tue Jan 13 18:03:02 2004 Ian Macdonald <ian@caliban.org>
* file.c (rb_stat_wr, rb_stat_ww): New functions
implementing new methods (File::Stat#world_readable?,
File::Stat#world_writable?).
Tue Jan 13 16:53:25 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/rubyext.c: omission of Date library code caused
@ -128,6 +146,11 @@ Tue Jan 13 16:50:03 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: use $0 as the default application class name.
Tue Jan 13 14:48:00 2004 Ian Macdonald <ian@caliban.org>
* lib/pathname.rb: New methods (Pathname#world_readable?,
Pathname#world_writable?).
Tue Jan 13 14:48:01 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (primary): allow no "when" case. [ruby-dev:22578]
@ -3410,6 +3433,92 @@ Thu Oct 9 06:43:33 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_start_0, rb_thread_raise, rb_callcc): save
variables across THREAD_SAVE_CONTEXT.
Thu Oct 9 12:05:46 2003 Eric Sunshine <sunshine@sunshineco.com>
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
Wed Oct 8 22:19:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit.rb: removed installation instructions.
@ -4404,92 +4513,6 @@ Wed Sep 10 22:41:54 2003 Tietew <tietew@tietew.net>
* eval.c (win32_get_exception_list): avoid VC7 warning.
[ruby-win32:577]
Thu Oct 9 12:05:46 2003 Eric Sunshine <sunshine@sunshineco.com>
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (struct tag): dst should be VALUE.

View file

@ -177,7 +177,6 @@ rb_define_class_id(id, super)
if (!super) super = rb_cObject;
klass = rb_class_new(super);
rb_name_class(klass, id);
rb_make_metaclass(klass, RBASIC(super)->klass);
return klass;
@ -228,6 +227,7 @@ rb_define_class(name, super)
}
klass = rb_define_class_id(id, super);
st_add_direct(rb_class_tbl, id, klass);
rb_name_class(klass, id);
rb_const_set(rb_cObject, id, klass);
rb_class_inherited(super, klass);

View file

@ -396,7 +396,7 @@ exc_to_s(exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
@ -435,11 +435,11 @@ exc_inspect(exc)
klass = CLASS_OF(exc);
exc = rb_obj_as_string(exc);
if (RSTRING(exc)->len == 0) {
return rb_str_dup(rb_class_path(klass));
return rb_str_dup(rb_class_name(klass));
}
str = rb_str_buf_new2("#<");
klass = rb_class_path(klass);
klass = rb_class_name(klass);
rb_str_buf_append(str, klass);
rb_str_buf_cat(str, ": ", 2);
rb_str_buf_append(str, exc);
@ -641,7 +641,7 @@ name_err_to_s(exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc));
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
if (str != mesg) {
rb_iv_set(exc, "mesg", mesg = str);

4
eval.c
View file

@ -1131,7 +1131,7 @@ error_print()
else {
VALUE epath;
epath = rb_class_path(eclass);
epath = rb_class_name(eclass);
if (elen == 0) {
warn_print(": ");
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
@ -9060,7 +9060,7 @@ Init_Proc()
exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
rb_global_variable(&exception_error);
rb_eSysStackError = rb_define_class("SystemStackError", rb_eStandardError);
rb_eSysStackError = rb_define_class("SystemStackError", rb_eException);
sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
OBJ_TAINT(sysstack_error);
rb_global_variable(&sysstack_error);

66
file.c
View file

@ -1046,12 +1046,7 @@ test_wr(obj, fname)
if (rb_stat(fname, &st) < 0) return Qnil;
if ((st.st_mode & (S_IROTH)) == S_IROTH) {
#ifdef __BORLANDC__
return UINT2NUM((unsigned short)(st.st_mode &
(S_IRUGO|S_IWUGO|S_IXUGO)));
#else
return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
#endif
}
#endif
return Qnil;
@ -1114,12 +1109,7 @@ test_ww(obj, fname)
if (rb_stat(fname, &st) < 0) return Qfalse;
if ((st.st_mode & (S_IWOTH)) == S_IWOTH) {
#ifdef __BORLANDC__
return UINT2NUM((unsigned short)(st.st_mode &
(S_IRUGO|S_IWUGO|S_IXUGO)));
#else
return UINT2NUM(st.st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
#endif
}
#endif
return Qnil;
@ -3576,6 +3566,33 @@ rb_stat_R(obj)
return Qtrue;
}
/*
* call-seq:
* stat.world_readable? => fixnum or nil
*
* If <i>stat</i> is readable by others, returns an integer
* representing the file permission bits of <i>stat</i>. Returns
* <code>nil</code> otherwise. The meaning of the bits is platform
* dependent; on Unix systems, see <code>stat(2)</code>.
*
* m = File.stat("/etc/passwd").world_readable? # => 420
* sprintf("%o", m) # => "644"
*/
static VALUE
rb_stat_wr(obj)
VALUE obj;
{
#ifdef S_IROTH
if ((get_stat(obj)->st_mode & (S_IROTH)) == S_IROTH) {
return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
else {
return Qnil;
}
#endif
}
/*
* call-seq:
* stat.writable? -> true or false
@ -3638,6 +3655,33 @@ rb_stat_W(obj)
return Qtrue;
}
/*
* call-seq:
* stat.world_writable? => fixnum or nil
*
* If <i>stat</i> is writable by others, returns an integer
* representing the file permission bits of <i>stat</i>. Returns
* <code>nil</code> otherwise. The meaning of the bits is platform
* dependent; on Unix systems, see <code>stat(2)</code>.
*
* m = File.stat("/tmp").world_writable? # => 511
* sprintf("%o", m) # => "777"
*/
static VALUE
rb_stat_ww(obj)
VALUE obj;
{
#ifdef S_IROTH
if ((get_stat(obj)->st_mode & (S_IWOTH)) == S_IWOTH) {
return UINT2NUM(get_stat(obj)->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
else {
return Qnil;
}
#endif
}
/*
* call-seq:
* stat.executable? => true or false
@ -4248,8 +4292,10 @@ Init_File()
rb_define_method(rb_cStat, "directory?", rb_stat_d, 0);
rb_define_method(rb_cStat, "readable?", rb_stat_r, 0);
rb_define_method(rb_cStat, "readable_real?", rb_stat_R, 0);
rb_define_method(rb_cStat, "world_readable?", rb_stat_wr, 0);
rb_define_method(rb_cStat, "writable?", rb_stat_w, 0);
rb_define_method(rb_cStat, "writable_real?", rb_stat_W, 0);
rb_define_method(rb_cStat, "world_writable?", rb_stat_ww, 0);
rb_define_method(rb_cStat, "executable?", rb_stat_x, 0);
rb_define_method(rb_cStat, "executable_real?", rb_stat_X, 0);
rb_define_method(rb_cStat, "file?", rb_stat_f, 0);

View file

@ -437,6 +437,7 @@ VALUE rb_class_path _((VALUE));
void rb_set_class_path _((VALUE, VALUE, const char*));
VALUE rb_path2class _((const char*));
void rb_name_class _((VALUE, ID));
VALUE rb_class_name _((VALUE));
void rb_autoload _((VALUE, ID, const char*));
void rb_autoload_load _((VALUE, ID));
VALUE rb_autoload_p _((VALUE, ID));

View file

@ -1125,17 +1125,16 @@ class CGI
@multipart
end
class Value < DelegateClass(String) # :nodoc:
def initialize(str, params)
module Value # :nodoc:
def set_params(params)
@params = params
super(str)
end
def [](idx, *args)
if args.size == 0
warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
self
@params[idx]
else
self.to_s[idx,*args]
super[idx,*args]
end
end
def first
@ -1165,7 +1164,10 @@ class CGI
Tempfile.new("CGI")
end
else
Value.new(value || "", params)
str = if value then value.dup else "" end
str.extend(Value)
str.set_params(params)
str
end
end

View file

@ -720,7 +720,7 @@ class Pathname # * FileTest *
def readable?() FileTest.readable?(@path) end
# See <tt>FileTest.readable_world?</tt>.
def readable_world?() FileTest.readable_world?(@path) end
def world_readable?() FileTest.world_readable?(@path) end
# See <tt>FileTest.readable_real?</tt>.
def readable_real?() FileTest.readable_real?(@path) end
@ -747,7 +747,7 @@ class Pathname # * FileTest *
def writable?() FileTest.writable?(@path) end
# See <tt>FileTest.writable_world?</tt>.
def writable_world?() FileTest.writable_world?(@path) end
def world_writable?() FileTest.world_writable?(@path) end
# See <tt>FileTest.writable_real?</tt>.
def writable_real?() FileTest.writable_real?(@path) end

View file

@ -1229,7 +1229,7 @@ rb_mod_to_s(klass)
return s;
}
return rb_str_dup(rb_class_path(klass));
return rb_str_dup(rb_class_name(klass));
}
/*

View file

@ -2181,6 +2181,7 @@ re_compile_pattern(pattern, size, bufp)
unfetch_interval:
/* If an invalid interval, match the characters as literals. */
re_warning("regexp has invalid interval");
p = beg_interval;
beg_interval = 0;
@ -2363,6 +2364,8 @@ re_compile_pattern(pattern, size, bufp)
default:
if (c == ']')
re_warning("regexp has `]' without escape");
else if (c == '}')
re_warning("regexp has `}' without escape");
normal_char: /* Expects the character in `c'. */
had_mbchar = 0;
if (ismbchar(c)) {

View file

@ -146,7 +146,6 @@ classname(klass)
{
VALUE path = Qnil;
klass = rb_class_real(klass);
if (!klass) klass = rb_cObject;
if (ROBJECT(klass)->iv_tbl) {
if (!st_lookup(ROBJECT(klass)->iv_tbl, classpath, &path)) {
@ -281,11 +280,18 @@ rb_name_class(klass, id)
rb_iv_set(klass, "__classid__", ID2SYM(id));
}
VALUE
rb_class_name(klass)
VALUE klass;
{
return rb_class_path(rb_class_real(klass));
}
char *
rb_class2name(klass)
VALUE klass;
{
return RSTRING(rb_class_path(klass))->ptr;
return RSTRING(rb_class_name(klass))->ptr;
}
char *
@ -1193,7 +1199,7 @@ uninitialized_constant(klass, id)
{
if (klass && klass != rb_cObject)
rb_name_error(id, "uninitialized constant %s::%s",
RSTRING(rb_class_path(klass))->ptr,
rb_class2name(klass),
rb_id2name(id));
else {
rb_name_error(id, "uninitialized constant %s", rb_id2name(id));