Skip to content

Commit

Permalink
* string.c (rb_str_replace): swap arguments of OBJ_INFECT.
Browse files Browse the repository at this point in the history
* eval.c (rb_thread_schedule): should not select a thread which is
  not yet initialized.

* time.c (time_plus): wrong boundary check.

* time.c (time_minus): ditto.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Dec 18, 2001
1 parent 389789c commit 80a71ef
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 77 deletions.
34 changes: 34 additions & 0 deletions ChangeLog
@@ -1,3 +1,12 @@
Mon Dec 17 18:53:49 2001 K.Kosako <kosako@sofnec.co.jp>

* string.c (rb_str_replace): swap arguments of OBJ_INFECT.

Tue Dec 18 01:02:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_thread_schedule): should not select a thread which is
not yet initialized.

Mon Dec 17 16:52:20 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> Mon Dec 17 16:52:20 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>


* intern.h: add prototypes. * intern.h: add prototypes.
Expand All @@ -22,6 +31,12 @@ Mon Dec 17 16:52:20 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>


* ruby.c (require_libraries): ditto. * ruby.c (require_libraries): ditto.


Mon Dec 17 15:41:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* time.c (time_plus): wrong boundary check.

* time.c (time_minus): ditto.

Mon Dec 17 15:19:32 2001 Tanaka Akira <akr@m17n.org> Mon Dec 17 15:19:32 2001 Tanaka Akira <akr@m17n.org>


* time.c: new method `gmtoff', `gmt_offset' and `utc_offset'. * time.c: new method `gmtoff', `gmt_offset' and `utc_offset'.
Expand Down Expand Up @@ -49,8 +64,16 @@ Mon Dec 17 15:19:32 2001 Tanaka Akira <akr@m17n.org>


* missing/strftime.c: fix overflow by tm_year + 1900. * missing/strftime.c: fix overflow by tm_year + 1900.


Mon Dec 17 00:02:04 2001 Guy Decoux <ts@moulon.inra.fr>

<<<<<<< ChangeLog
* variable.c (find_class_path): should initialize iv_tbl if it's
NULL.

=======
* lib/time.rb: use Time#utc_offset. * lib/time.rb: use Time#utc_offset.


>>>>>>> 1.655
Fri Dec 14 04:23:36 2001 Minero Aoki <aamine@loveruby.net> Fri Dec 14 04:23:36 2001 Minero Aoki <aamine@loveruby.net>


* lib/net/pop.rb: new method Net::POP3.APOP * lib/net/pop.rb: new method Net::POP3.APOP
Expand All @@ -66,6 +89,17 @@ Fri Dec 14 04:23:36 2001 Minero Aoki <aamine@loveruby.net>


* lib/net/http.rb: ditto. * lib/net/http.rb: ditto.


Fri Dec 14 00:16:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>

* class.c (rb_define_class): should return the existing class if
the class is already defined and its superclass is ideintical to
the specified superclass.

* class.c (rb_define_class_under): ditto.

* class.c (rb_define_module): should return the existing module if
the module is already defined.

Thu Dec 13 09:52:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org> Thu Dec 13 09:52:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>


* time.c (time_new_internal): avoid loop to calculate negative * time.c (time_new_internal): avoid loop to calculate negative
Expand Down
1 change: 1 addition & 0 deletions ToDo
Expand Up @@ -98,6 +98,7 @@ Standard Libraries
* remove dependency on MAXPATHLEN. * remove dependency on MAXPATHLEN.
* pointer share mechanism similar to one in String for Array. * pointer share mechanism similar to one in String for Array.
* deprecate Array#indexes, and Array#indices. * deprecate Array#indexes, and Array#indices.
* require "1.6" etc. by /usr/lib/ruby/1.6/1.6.rb ;-)


Extension Libraries Extension Libraries


Expand Down
16 changes: 14 additions & 2 deletions class.c
Expand Up @@ -170,7 +170,13 @@ rb_define_class(name, super)
id = rb_intern(name); id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) { if (rb_const_defined(rb_cObject, id)) {
klass = rb_const_get(rb_cObject, id); klass = rb_const_get(rb_cObject, id);
rb_name_error(id, "%s is already defined", name); if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", name);
}
if (rb_class_real(RCLASS(klass)->super) != super) {
rb_name_error(id, "%s is already defined", name);
}
return klass;
} }
klass = rb_define_class_id(id, super); klass = rb_define_class_id(id, super);
st_add_direct(rb_class_tbl, id, klass); st_add_direct(rb_class_tbl, id, klass);
Expand All @@ -190,7 +196,13 @@ rb_define_class_under(outer, name, super)
id = rb_intern(name); id = rb_intern(name);
if (rb_const_defined_at(outer, id)) { if (rb_const_defined_at(outer, id)) {
klass = rb_const_get(outer, id); klass = rb_const_get(outer, id);
rb_name_error(id, "%s is already defined", name); if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", name);
}
if (rb_class_real(RCLASS(klass)->super) != super) {
rb_name_error(id, "%s is already defined", name);
}
return klass;
} }
klass = rb_define_class_id(id, super); klass = rb_define_class_id(id, super);
rb_const_set(outer, id, klass); rb_const_set(outer, id, klass);
Expand Down
2 changes: 1 addition & 1 deletion eval.c
Expand Up @@ -7732,7 +7732,7 @@ rb_thread_schedule()
next = th; next = th;
break; break;
} }
if (th->status == THREAD_RUNNABLE) { if (th->status == THREAD_RUNNABLE && th->stk_ptr) {
if (!next || next->priority < th->priority) if (!next || next->priority < th->priority)
next = th; next = th;
} }
Expand Down
12 changes: 6 additions & 6 deletions ext/Win32API/Win32API.c
Expand Up @@ -64,8 +64,8 @@ Win32API_initialize(self, dllname, proc, import, export)
int len; int len;
int ex; int ex;


Check_SafeStr(dllname); SafeStringValue(dllname);
Check_SafeStr(proc); SafeStringValue(proc);
hdll = LoadLibrary(RSTRING(dllname)->ptr); hdll = LoadLibrary(RSTRING(dllname)->ptr);
if (!hdll) if (!hdll)
rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr); rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
Expand All @@ -90,7 +90,7 @@ Win32API_initialize(self, dllname, proc, import, export)
case T_ARRAY: case T_ARRAY:
ptr = RARRAY(import)->ptr; ptr = RARRAY(import)->ptr;
for (i = 0, len = RARRAY(import)->len; i < len; i++) { for (i = 0, len = RARRAY(import)->len; i < len; i++) {
Check_SafeStr(ptr[i]); SafeStringValue(ptr[i]);
switch (*(char *)RSTRING(ptr[i])->ptr) { switch (*(char *)RSTRING(ptr[i])->ptr) {
case 'N': case 'n': case 'L': case 'l': case 'N': case 'n': case 'L': case 'l':
rb_ary_push(a_import, INT2FIX(_T_NUMBER)); rb_ary_push(a_import, INT2FIX(_T_NUMBER));
Expand All @@ -105,7 +105,7 @@ Win32API_initialize(self, dllname, proc, import, export)
} }
break; break;
default: default:
Check_SafeStr(import); SafeStringValue(import);
s = RSTRING(import)->ptr; s = RSTRING(import)->ptr;
for (i = 0, len = RSTRING(import)->len; i < len; i++) { for (i = 0, len = RSTRING(import)->len; i < len; i++) {
switch (*s++) { switch (*s++) {
Expand All @@ -127,7 +127,7 @@ Win32API_initialize(self, dllname, proc, import, export)
if (NIL_P(export)) { if (NIL_P(export)) {
ex = _T_VOID; ex = _T_VOID;
} else { } else {
Check_SafeStr(export); SafeStringValue(export);
switch (*RSTRING(export)->ptr) { switch (*RSTRING(export)->ptr) {
case 'V': case 'v': case 'V': case 'v':
ex = _T_VOID; ex = _T_VOID;
Expand Down Expand Up @@ -228,7 +228,7 @@ Win32API_Call(argc, argv, obj)
} else if (FIXNUM_P(str)){ } else if (FIXNUM_P(str)){
pParam = (char *)NUM2ULONG(str); pParam = (char *)NUM2ULONG(str);
} else { } else {
Check_Type(str, T_STRING); StringValue(str);
rb_str_modify(str); rb_str_modify(str);
pParam = RSTRING(str)->ptr; pParam = RSTRING(str)->ptr;
} }
Expand Down
4 changes: 2 additions & 2 deletions ext/etc/etc.c
Expand Up @@ -117,7 +117,7 @@ etc_getpwnam(obj, nam)
#ifdef HAVE_GETPWENT #ifdef HAVE_GETPWENT
struct passwd *pwd; struct passwd *pwd;


Check_Type(nam, T_STRING); StringValue(nam);
pwd = getpwnam(RSTRING(nam)->ptr); pwd = getpwnam(RSTRING(nam)->ptr);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING(nam)->ptr); if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING(nam)->ptr);
return setup_passwd(pwd); return setup_passwd(pwd);
Expand Down Expand Up @@ -194,7 +194,7 @@ etc_getgrnam(obj, nam)
#ifdef HAVE_GETGRENT #ifdef HAVE_GETGRENT
struct group *grp; struct group *grp;


Check_Type(nam, T_STRING); StringValue(nam);
grp = getgrnam(RSTRING(nam)->ptr); grp = getgrnam(RSTRING(nam)->ptr);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING(nam)->ptr); if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING(nam)->ptr);
return setup_group(grp); return setup_group(grp);
Expand Down
29 changes: 14 additions & 15 deletions ext/socket/socket.c
Expand Up @@ -561,7 +561,7 @@ ip_addrsetup(host, port)
else { else {
char *name; char *name;


Check_SafeStr(host); SafeStringValue(host);
name = RSTRING(host)->ptr; name = RSTRING(host)->ptr;
if (*name == 0) { if (*name == 0) {
mkinetaddr(INADDR_ANY, hbuf, sizeof(hbuf)); mkinetaddr(INADDR_ANY, hbuf, sizeof(hbuf));
Expand Down Expand Up @@ -793,7 +793,7 @@ load_addr_info(h, serv, type, res)
int error; int error;


if (!NIL_P(h)) { if (!NIL_P(h)) {
Check_SafeStr(h); SafeStringValue(h);
host = RSTRING(h)->ptr; host = RSTRING(h)->ptr;
} }
else { else {
Expand All @@ -804,7 +804,7 @@ load_addr_info(h, serv, type, res)
portp = pbuf; portp = pbuf;
} }
else { else {
Check_SafeStr(serv); SafeStringValue(serv);
if (RSTRING(serv)->len >= sizeof(pbuf)) if (RSTRING(serv)->len >= sizeof(pbuf))
rb_raise(rb_eArgError, "servicename too long (%d)", RSTRING(serv)->len); rb_raise(rb_eArgError, "servicename too long (%d)", RSTRING(serv)->len);
strcpy(pbuf, RSTRING(serv)->ptr); strcpy(pbuf, RSTRING(serv)->ptr);
Expand Down Expand Up @@ -918,10 +918,9 @@ tcp_s_open(argc, argv, class)
&remote_host, &remote_serv, &remote_host, &remote_serv,
&local_host, &local_serv); &local_host, &local_serv);


Check_SafeStr(remote_host); SafeStringValue(remote_host);

if (!NIL_P(local_host)) { if (!NIL_P(local_host)) {
Check_SafeStr(local_host); SafeStringValue(local_host);
} }


return open_inet(class, remote_host, remote_serv, return open_inet(class, remote_host, remote_serv,
Expand All @@ -940,7 +939,7 @@ socks_s_open(class, host, serv)
init = 1; init = 1;
} }


Check_SafeStr(host); SafeStringValue(host);
return open_inet(class, host, serv, Qnil, Qnil, INET_SOCKS); return open_inet(class, host, serv, Qnil, Qnil, INET_SOCKS);
} }


Expand Down Expand Up @@ -1150,23 +1149,23 @@ tcp_accept(sock)
static VALUE static VALUE
open_unix(class, path, server) open_unix(class, path, server)
VALUE class; VALUE class;
struct RString *path; VALUE path;
int server; int server;
{ {
struct sockaddr_un sockaddr; struct sockaddr_un sockaddr;
int fd, status; int fd, status;
VALUE sock; VALUE sock;
OpenFile *fptr; OpenFile *fptr;


Check_SafeStr(path); SafeStringValue(path);
fd = ruby_socket(AF_UNIX, SOCK_STREAM, 0); fd = ruby_socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) { if (fd < 0) {
rb_sys_fail("socket(2)"); rb_sys_fail("socket(2)");
} }


MEMZERO(&sockaddr, struct sockaddr_un, 1); MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX; sockaddr.sun_family = AF_UNIX;
strncpy(sockaddr.sun_path, path->ptr, sizeof(sockaddr.sun_path)-1); strncpy(sockaddr.sun_path, RSTRING(path)->ptr, sizeof(sockaddr.sun_path)-1);
sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0'; sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0';


if (server) { if (server) {
Expand All @@ -1189,7 +1188,7 @@ open_unix(class, path, server)


sock = sock_new(class, fd); sock = sock_new(class, fd);
GetOpenFile(sock, fptr); GetOpenFile(sock, fptr);
fptr->path = strdup(path->ptr); fptr->path = strdup(RSTRING(path)->ptr);


return sock; return sock;
} }
Expand Down Expand Up @@ -1466,7 +1465,7 @@ setup_domain_and_type(domain, dv, type, tv)
char *ptr; char *ptr;


if (TYPE(domain) == T_STRING) { if (TYPE(domain) == T_STRING) {
Check_SafeStr(domain); SafeStringValue(domain);
ptr = RSTRING(domain)->ptr; ptr = RSTRING(domain)->ptr;
if (strcmp(ptr, "AF_INET") == 0) if (strcmp(ptr, "AF_INET") == 0)
*dv = AF_INET; *dv = AF_INET;
Expand Down Expand Up @@ -1515,7 +1514,7 @@ setup_domain_and_type(domain, dv, type, tv)
*dv = NUM2INT(domain); *dv = NUM2INT(domain);
} }
if (TYPE(type) == T_STRING) { if (TYPE(type) == T_STRING) {
Check_SafeStr(type); SafeStringValue(type);
ptr = RSTRING(type)->ptr; ptr = RSTRING(type)->ptr;
if (strcmp(ptr, "SOCK_STREAM") == 0) if (strcmp(ptr, "SOCK_STREAM") == 0)
*tv = SOCK_STREAM; *tv = SOCK_STREAM;
Expand Down Expand Up @@ -1597,7 +1596,7 @@ sock_connect(sock, addr)
OpenFile *fptr; OpenFile *fptr;
int fd; int fd;


Check_Type(addr, T_STRING); StringValue(addr);
rb_str_modify(addr); rb_str_modify(addr);


GetOpenFile(sock, fptr); GetOpenFile(sock, fptr);
Expand All @@ -1615,7 +1614,7 @@ sock_bind(sock, addr)
{ {
OpenFile *fptr; OpenFile *fptr;


Check_Type(addr, T_STRING); StringValue(addr);
rb_str_modify(addr); rb_str_modify(addr);


GetOpenFile(sock, fptr); GetOpenFile(sock, fptr);
Expand Down
2 changes: 1 addition & 1 deletion ext/syslog/syslog.c
Expand Up @@ -62,7 +62,7 @@ static VALUE cSyslog_open(int argc, VALUE *argv, VALUE self)
fac = INT2NUM(LOG_USER); fac = INT2NUM(LOG_USER);
} }


Check_SafeStr(ident); SafeStringValue(ident);
syslog_ident = ident; syslog_ident = ident;
syslog_options = opt; syslog_options = opt;
syslog_facility = fac; syslog_facility = fac;
Expand Down
2 changes: 1 addition & 1 deletion file.c
Expand Up @@ -1908,7 +1908,7 @@ rb_stat_init(obj, fname)
{ {
struct stat st, *nst; struct stat st, *nst;


Check_SafeStr(fname); SafeStringValue(fname);


if (stat(RSTRING(fname)->ptr, &st) == -1) { if (stat(RSTRING(fname)->ptr, &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr); rb_sys_fail(RSTRING(fname)->ptr);
Expand Down
8 changes: 4 additions & 4 deletions misc/ruby-mode.el
Expand Up @@ -680,22 +680,22 @@ An end of a defun is found by moving forward from the beginning of one."
("\\(#\\)[{$@]" 1 (1 . nil)) ("\\(#\\)[{$@]" 1 (1 . nil))
;; the last $' in the string ,'...$' is not variable ;; the last $' in the string ,'...$' is not variable
;; the last ?' in the string ,'...?' is not ascii code ;; the last ?' in the string ,'...?' is not ascii code
("\\(^\\|[[\\s <+(,=]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*[\\?\\$]\\('\\)" ("\\(^\\|[[\\s <+(,=]\\)\\('\\)[^'\n\\\\]*\\(\\\\.[^'\n\\\\]*\\)*[?$]\\('\\)"
(2 (7 . nil)) (2 (7 . nil))
(4 (7 . nil))) (4 (7 . nil)))
;; the last $` in the string ,`...$` is not variable ;; the last $` in the string ,`...$` is not variable
;; the last ?` in the string ,`...?` is not ascii code ;; the last ?` in the string ,`...?` is not ascii code
("\\(^\\|[[\\s <+(,=]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*[\\?\\$]\\(`\\)" ("\\(^\\|[[\\s <+(,=]\\)\\(`\\)[^`\n\\\\]*\\(\\\\.[^`\n\\\\]*\\)*[?$]\\(`\\)"
(2 (7 . nil)) (2 (7 . nil))
(4 (7 . nil))) (4 (7 . nil)))
;; the last $" in the string ,"...$" is not variable ;; the last $" in the string ,"...$" is not variable
;; the last ?" in the string ,"...?" is not ascii code ;; the last ?" in the string ,"...?" is not ascii code
("\\(^\\|[[\\s <+(,=]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*[\\?\\$]\\(\"\\)" ("\\(^\\|[[\\s <+(,=]\\)\\(\"\\)[^\"\n\\\\]*\\(\\\\.[^\"\n\\\\]*\\)*[?$]\\(\"\\)"
(2 (7 . nil)) (2 (7 . nil))
(4 (7 . nil))) (4 (7 . nil)))
;; $' $" $` .... are variables ;; $' $" $` .... are variables
;; ?' ?" ?` are ascii codes ;; ?' ?" ?` are ascii codes
("[\\?\\$][#\"'`]" 0 (1 . nil)) ("[?$][#\"'`]" 0 (1 . nil))
;; regexps ;; regexps
("\\(^\\|[=(,~?:;]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)" ("\\(^\\|[=(,~?:;]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
(4 (7 . ?/)) (4 (7 . ?/))
Expand Down

0 comments on commit 80a71ef

Please sign in to comment.