1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-12-06 09:04:03 +00:00
parent 4263bb432a
commit dee96209bf
23 changed files with 177 additions and 82 deletions

View file

@ -1,3 +1,42 @@
Mon Dec 6 15:55:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* numeric.c (fix_rshift): Fix -1 >> 32 returned 0. (-1 is true)
* numeric.c (fix_rshift): Fix 1 >> -1 returned 0. (2 is true)
Mon Dec 6 11:47:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* sprintf.c (rb_f_sprintf): formatted string must be tainted if
any of parameters is tainted.
* file.c (rb_file_s_expand_path): expanded file path need not to
be tainted always.
Sun Dec 5 20:25:29 1999 Katsuhiro Ueno <unnie@blue.sky.or.jp>
* eval.c (Init_Proc): simple typo.
* gc.c (add_heap): sizeof(RVALUE*), not sizeof(RVALUE).
Sat Dec 4 01:40:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* regex.c (re_search): adjust startpos for multibyte match unless
the first pattern is forced byte match.
* bignum.c (rb_big_rand): should not use rand/random where drand48
may be available. RANDOM_NUMBER should be provided from outside.
Fri Dec 3 09:54:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* ruby.c (moreswitches): there may be trailing garbage at #!
line.
* eval.c (rb_f_require): should check require 'feature.o' too.
Thu Dec 2 11:58:15 1999 Koji Arai <JCA02266@nifty.ne.jp>
* eval.c (rb_thread_loading): should maintain loading_tbl.
Thu Dec 2 10:21:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_thread_loading_done): wrong parameter to st_delete().

View file

@ -1255,20 +1255,17 @@ rb_big_abs(x)
*/
VALUE
rb_big_rand(max)
rb_big_rand(max, rand)
VALUE max;
double rand;
{
struct RBignum *v;
VALUE v;
long len;
len = RBIGNUM(max)->len;
v = RBIGNUM(bignew(len,1));
v = bignew(len,1);
while (len--) {
#ifdef HAVE_RANDOM
BDIGITS(v)[len] = random();
#else
BDIGITS(v)[len] = rand();
#endif
BDIGITS(v)[len] = ((USHORT)~0) * rand;
}
return rb_big_mod((VALUE)v, max);

4
configure vendored
View file

@ -3641,7 +3641,7 @@ else
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x;
typedef int charset[2]; const charset x = {0,0};
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
@ -3783,7 +3783,7 @@ else
int
main()
{
if (-1==(-1>>1))
if (-1==(-1>>(unsigned)1))
return 0;
return 1;
}

View file

@ -260,7 +260,7 @@ AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
int
main()
{
if (-1==(-1>>1))
if (-1==(-1>>(unsigned)1))
return 0;
return 1;
}

9
eval.c
View file

@ -3303,6 +3303,7 @@ static VALUE
rb_f_loop()
{
for (;;) { rb_yield_0(Qnil, 0, 0, Qfalse); }
return Qnil; /* dummy */
}
static VALUE
@ -4861,6 +4862,7 @@ rb_f_require(obj, fname)
ext = strrchr(buf, '.');
strcpy(ext, DLEXT);
file = feature = buf;
if (rb_provided(feature)) return Qfalse;
}
file = find_file(file);
if (file) goto load_dyna;
@ -6020,7 +6022,7 @@ Init_Proc()
rb_define_global_function("lambda", rb_f_lambda, 0);
rb_define_global_function("binding", rb_f_binding, 0);
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_method(CLASS_OF(rb_cMethod), "new");
rb_undef_method(CLASS_OF(rb_cBinding), "new");
rb_define_method(rb_cBinding, "clone", bind_clone, 0);
rb_cMethod = rb_define_class("Method", rb_cObject);
@ -7361,10 +7363,13 @@ static int
rb_thread_loading(feature)
const char *feature;
{
if (!rb_provided(feature)) return Qfalse; /* need to load */
if (!loading_tbl) {
loading_tbl = st_init_strtable();
}
if (!rb_provided(feature)) {
st_insert(loading_tbl, feature, 0);
return Qfalse; /* need to load */
}
while (st_lookup(loading_tbl, feature, 0)) {
CHECK_INTS;
rb_thread_schedule();

View file

@ -2131,6 +2131,8 @@ class TkTextWin<TkWindow
end
class TkListbox<TkTextWin
include Scrollable
WidgetClassNames['Listbox'] = self
def TkListbox.to_eval
'Listbox'

View file

@ -129,6 +129,7 @@ end
class TkCanvas<TkWindow
include TkTreatCItemFont
include Scrollable
WidgetClassName = 'Canvas'.freeze
WidgetClassNames[WidgetClassName] = self

80
file.c
View file

@ -1176,12 +1176,14 @@ rb_file_s_expand_path(argc, argv)
VALUE fname, dname;
char *s, *p;
char buf[MAXPATHLEN+2];
int tainted = 0;
rb_scan_args(argc, argv, "11", &fname, &dname);
s = STR2CSTR(fname);
p = buf;
if (s[0] == '~') {
tainted = 1;
if (isdirsep(s[1]) || s[1] == '\0') {
char *dir = getenv("HOME");
@ -1224,9 +1226,11 @@ rb_file_s_expand_path(argc, argv)
else if (!isdirsep(*s)) {
if (argc == 2) {
dname = rb_file_s_expand_path(1, &dname);
if (OBJ_TAINTED(dname)) tainted = 1;
strcpy(buf, RSTRING(dname)->ptr);
}
else {
tainted = 1;
#ifdef HAVE_GETCWD
getcwd(buf, MAXPATHLEN);
#else
@ -1286,7 +1290,9 @@ rb_file_s_expand_path(argc, argv)
if (p == buf || !isdirsep(*p)) p++;
*p = '\0';
return rb_tainted_str_new2(buf);
fname = rb_str_new2(buf);
if (tainted) OBJ_TAINT(fname);
return fname;
}
static int
@ -1758,18 +1764,18 @@ static VALUE
rb_stat_r(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
if (rb_stat_owned(obj))
return mode & S_IRUSR ? Qtrue : Qfalse;
return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
if (rb_stat_grpowned(obj))
return mode & S_IRGRP ? Qtrue : Qfalse;
return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IROTH)) return Qfalse;
if (!(st->st_mode & S_IROTH)) return Qfalse;
#endif
return Qtrue;
}
@ -1778,18 +1784,18 @@ static VALUE
rb_stat_R(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
if (rb_stat_rowned(obj))
return mode & S_IRUSR ? Qtrue : Qfalse;
return st->st_mode & S_IRUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
if (group_member(get_stat(obj)->st_gid))
return mode & S_IRGRP ? Qtrue : Qfalse;
return st->st_mode & S_IRGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IROTH)) return Qfalse;
if (!(st->st_mode & S_IROTH)) return Qfalse;
#endif
return Qtrue;
}
@ -1798,18 +1804,18 @@ static VALUE
rb_stat_w(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
#ifdef S_IWUSR
if (rb_stat_owned(obj))
return mode & S_IWUSR ? Qtrue : Qfalse;
return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
#ifdef S_IWGRP
if (rb_stat_grpowned(obj))
return mode & S_IWGRP ? Qtrue : Qfalse;
return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IWOTH)) return Qfalse;
#ifdef S_IWOTH
if (!(st->st_mode & S_IWOTH)) return Qfalse;
#endif
return Qtrue;
}
@ -1818,18 +1824,18 @@ static VALUE
rb_stat_W(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
#ifdef S_IWUSR
if (rb_stat_rowned(obj))
return mode & S_IWUSR ? Qtrue : Qfalse;
return st->st_mode & S_IWUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
#ifdef S_IWGRP
if (group_member(get_stat(obj)->st_gid))
return mode & S_IWGRP ? Qtrue : Qfalse;
return st->st_mode & S_IWGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IWOTH)) return Qfalse;
#ifdef S_IWOTH
if (!(st->st_mode & S_IWOTH)) return Qfalse;
#endif
return Qtrue;
}
@ -1838,18 +1844,18 @@ static VALUE
rb_stat_x(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
#ifdef S_IXUSR
if (rb_stat_owned(obj))
return mode & S_IXUSR ? Qtrue : Qfalse;
return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
#ifdef S_IXGRP
if (rb_stat_grpowned(obj))
return mode & S_IXGRP ? Qtrue : Qfalse;
return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IXOTH)) return Qfalse;
#ifdef S_IXOTH
if (!(st->st_mode & S_IXOTH)) return Qfalse;
#endif
return Qtrue;
}
@ -1858,18 +1864,18 @@ static VALUE
rb_stat_X(obj)
VALUE obj;
{
mode_t mode = get_stat(obj)->st_mode;
struct stat *st = get_stat(obj);
#ifdef S_IRUSR
#ifdef S_IXUSR
if (rb_stat_rowned(obj))
return mode & S_IXUSR ? Qtrue : Qfalse;
return st->st_mode & S_IXUSR ? Qtrue : Qfalse;
#endif
#ifdef S_IRGRP
#ifdef S_IXGRP
if (group_member(get_stat(obj)->st_gid))
return mode & S_IXGRP ? Qtrue : Qfalse;
return st->st_mode & S_IXGRP ? Qtrue : Qfalse;
#endif
#ifdef S_IROTH
if (!(mode & S_IXOTH)) return Qfalse;
#ifdef S_IXOTH
if (!(st->st_mode & S_IXOTH)) return Qfalse;
#endif
return Qtrue;
}

4
gc.c
View file

@ -242,8 +242,8 @@ add_heap()
/* Realloc heaps */
heaps_length += HEAPS_INCREMENT;
heaps = (heaps_used>0)?
(RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE)):
(RVALUE**)malloc(heaps_length*sizeof(RVALUE));
(RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)):
(RVALUE**)malloc(heaps_length*sizeof(RVALUE*));
if (heaps == 0) rb_fatal("can't alloc memory");
}

2
hash.c
View file

@ -895,7 +895,7 @@ env_delete(obj, name)
if (strcmp(nam, "PATH") == 0 && !OBJ_TAINTED(name)) {
path_tainted = 0;
}
return rb_str_new2(val);
return rb_tainted_str_new2(val);
}
return Qnil;
}

View file

@ -57,7 +57,7 @@ VALUE rb_big_and _((VALUE, VALUE));
VALUE rb_big_or _((VALUE, VALUE));
VALUE rb_big_xor _((VALUE, VALUE));
VALUE rb_big_lshift _((VALUE, VALUE));
VALUE rb_big_rand _((VALUE));
VALUE rb_big_rand _((VALUE, double));
/* class.c */
VALUE rb_class_new _((VALUE));
VALUE rb_singleton_class_new _((VALUE));

View file

@ -4,7 +4,7 @@
require 'rbconfig'
require 'find'
include Config
CONFIG = Config::MAKEFILE_CONFIG
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]

View file

@ -63,6 +63,7 @@ coerce_rescue(x)
STR2CSTR(rb_inspect(x[1])):
rb_class2name(CLASS_OF(x[1])),
rb_class2name(CLASS_OF(x[0])));
return Qnil; /* dummy */
}
static void
@ -657,6 +658,7 @@ fail_to_integer(val)
{
rb_raise(rb_eTypeError, "failed to convert %s into Integer",
rb_class2name(CLASS_OF(val)));
return Qnil; /* dummy */
}
long
@ -1169,12 +1171,10 @@ fix_rshift(x, y)
long i, val;
i = NUM2LONG(y);
if (i < sizeof(long) * 8) {
val = RSHIFT(FIX2LONG(x), i);
return INT2FIX(val);
}
return INT2FIX(0);
if (i < 0)
return fix_lshift(x, INT2FIX(-i));
val = RSHIFT(FIX2LONG(x), i);
return INT2FIX(val);
}
static VALUE

View file

@ -598,6 +598,7 @@ static VALUE
rb_class_s_inherited()
{
rb_raise(rb_eTypeError, "can't make subclass of Class");
return Qnil; /* dummy */
}
static VALUE

View file

@ -505,6 +505,7 @@ rb_f_exec(argc, argv)
proc_exec_n(argc, argv, prog);
}
rb_sys_fail(RSTRING(argv[0])->ptr);
return Qnil; /* dummy */
}
static VALUE

View file

@ -126,13 +126,12 @@ rb_f_rand(obj, vmax)
long val, max;
switch (TYPE(vmax)) {
case T_BIGNUM:
return rb_big_rand(vmax);
case T_FLOAT:
if (RFLOAT(vmax)->value > LONG_MAX || RFLOAT(vmax)->value < LONG_MIN)
return rb_big_rand(rb_dbl2big(RFLOAT(vmax)->value));
break;
if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN)
break;
/* fall through */
case T_BIGNUM:
return rb_big_rand(vmax, RANDOM_NUMBER);
}
max = NUM2LONG(vmax);

View file

@ -30,6 +30,7 @@ static VALUE
range_failed()
{
rb_raise(rb_eArgError, "bad value for range");
return Qnil; /* dummy */
}
static VALUE

37
regex.c
View file

@ -396,6 +396,7 @@ re_set_syntax(syntax)
long syntax;
{
/* obsolete */
return 0;
}
@ -2272,9 +2273,9 @@ re_compile_pattern(pattern, size, bufp)
}
if (!(bufp->options & RE_OPTIMIZE_NO_BM)) {
bufp->must_skip = (int *) xmalloc((1 << BYTEWIDTH)*sizeof(int));
bm_init_skip(bufp->must_skip, bufp->must+1,
bm_init_skip(bufp->must_skip, (unsigned char*)bufp->must+1,
(unsigned char)bufp->must[0],
MAY_TRANSLATE()?translate:0);
(unsigned char*)(MAY_TRANSLATE()?translate:0));
}
}
@ -2626,6 +2627,7 @@ re_compile_fastmap(bufp)
fastmap[translate[p[2]]] = 2;
else
fastmap[p[2]] = 2;
bufp->options |= RE_OPTIMIZE_BMATCH;
}
else if (TRANSLATE_P())
fastmap[translate[p[1]]] = 1;
@ -2828,8 +2830,10 @@ re_compile_fastmap(bufp)
while (beg <= end) {
/* NOTE: Charset for multi-byte chars might contain
single-byte chars. We must reject them. */
if (c < 0x100)
if (c < 0x100) {
fastmap[beg] = 2;
bufp->options |= RE_OPTIMIZE_BMATCH;
}
else if (ismbchar(beg))
fastmap[beg] = 1;
beg++;
@ -2950,6 +2954,33 @@ re_search(bufp, string, size, startpos, range, regs)
re_compile_fastmap(bufp);
}
/* Adjust startpos for mbc string */
if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) {
int i = 0;
if (range > 0) {
while (i<size) {
i += mbclen(string[i]);
if (startpos <= i) {
startpos = i;
break;
}
}
}
else {
int w;
while (i<size) {
w = mbclen(string[i]);
if (startpos < i + w) {
startpos = i;
break;
}
i += w;
}
}
}
/* If the search isn't to be a backwards one, don't waste time in a
search for a pattern that must be anchored. */
if (bufp->used>0) {

View file

@ -77,6 +77,7 @@
#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
#define RE_OPTIMIZE_EXACTN (RE_OPTIMIZE_ANCHOR<<1)
#define RE_OPTIMIZE_NO_BM (RE_OPTIMIZE_EXACTN<<1)
#define RE_OPTIMIZE_BMATCH (RE_OPTIMIZE_NO_BM<<1)
/* For multi-byte char support */
#define MBCTYPE_ASCII 0

19
ruby.c
View file

@ -289,6 +289,7 @@ process_sflag()
rb_ary_shift(rb_argv);
}
}
sflag = 0;
}
static void proc_options _((int argc, char **argv));
@ -303,8 +304,10 @@ moreswitches(s)
argc = 2; argv[0] = argv[2] = 0;
while (*s && !ISSPACE(*s))
s++;
argv[1] = ALLOCA_N(char, s - p + 2);
sprintf(argv[1], "-%s", p);
argv[1] = ALLOCA_N(char, s-p+2);
argv[1][0] = '-';
strncpy(argv[1]+1, p, s-p);
argv[1][s-p+1] = '\0';
proc_options(argc, argv);
while (*s && ISSPACE(*s))
s++;
@ -450,13 +453,16 @@ proc_options(argc, argv)
break;
case 'F':
rb_fs = rb_str_new2(s+1);
if (*++s) {
rb_fs = rb_str_new2(s);
}
break;
case 'K':
s++;
rb_set_kcode(s);
s++;
if (*++s) {
rb_set_kcode(s);
s++;
}
goto reswitch;
case 'T':
@ -634,7 +640,6 @@ proc_options(argc, argv)
}
process_sflag();
sflag = 0;
xflag = 0;
}

View file

@ -172,10 +172,12 @@ rb_f_sprintf(argc, argv)
int width, prec, flags = FNONE;
int nextarg = 0;
int tainted = 0;
VALUE tmp;
VALUE str;
fmt = GETARG();
if (OBJ_TAINTED(fmt)) tainted = 1;
p = str2cstr(fmt, &blen);
end = p + blen;
blen = 0;
@ -318,6 +320,7 @@ rb_f_sprintf(argc, argv)
int len;
str = rb_obj_as_string(arg);
if (OBJ_TAINTED(str)) tainted = 1;
len = RSTRING(str)->len;
if (flags&FPREC) {
if (prec < len) {
@ -651,6 +654,7 @@ rb_f_sprintf(argc, argv)
result = rb_str_new(buf, blen);
free(buf);
if (tainted) OBJ_TAINT(result);
return result;
}

View file

@ -128,7 +128,7 @@ rb_str_to_str(str)
}
static void
rb_str_assign(str, str2)
rb_str_become(str, str2)
VALUE str, str2;
{
if (str == str2) return;
@ -422,7 +422,9 @@ rb_str_concat(str1, str2)
}
}
if (TYPE(str2) != T_STRING) str2 = rb_str_to_str(str2);
return rb_str_cat(str1, RSTRING(str2)->ptr, RSTRING(str2)->len);
str1 = rb_str_cat(str1, RSTRING(str2)->ptr, RSTRING(str2)->len);
if (OBJ_TAINTED(str2)) OBJ_TAINT(str1);
return str1;
}
int
@ -746,7 +748,7 @@ rb_str_succ_bang(str)
VALUE str;
{
rb_str_modify(str);
rb_str_assign(str, rb_str_succ(str));
rb_str_become(str, rb_str_succ(str));
return str;
}

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.0"
#define RUBY_RELEASE_DATE "1999-12-02"
#define RUBY_RELEASE_DATE "1999-12-06"
#define RUBY_VERSION_CODE 150
#define RUBY_RELEASE_CODE 19991202
#define RUBY_RELEASE_CODE 19991206