* ruby.c (proc_options): removed "-*-" support for #! line.
* io.c (rb_io_s_sysopen): new method to get a raw file descriptor. [new] * ext/socket/socket.c (tcp_sysaccept): new method to return an accepted socket fd (integer). [new] * ext/socket/socket.c (unix_sysaccept,sock_sysaccept): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
730d8f1d32
commit
6e87a54aec
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Thu May 23 09:13:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* ruby.c (proc_options): removed "-*-" support for #! line.
|
||||||
|
|
||||||
|
* io.c (rb_io_s_sysopen): new method to get a raw file
|
||||||
|
descriptor. [new]
|
||||||
|
|
||||||
|
* ext/socket/socket.c (tcp_sysaccept): new method to return an
|
||||||
|
accepted socket fd (integer). [new]
|
||||||
|
|
||||||
|
* ext/socket/socket.c (unix_sysaccept,sock_sysaccept): ditto.
|
||||||
|
|
||||||
Wed May 22 21:26:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Wed May 22 21:26:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* ruby.c (proc_options): -T consumes digits only.
|
* ruby.c (proc_options): -T consumes digits only.
|
||||||
|
8
doc/NEWS
8
doc/NEWS
@ -1,3 +1,11 @@
|
|||||||
|
: IO::sysopen
|
||||||
|
|
||||||
|
a new method to get a raw file descriptor.
|
||||||
|
|
||||||
|
: TCPServer#accept, UNIXServer#accept, Socket#accept
|
||||||
|
|
||||||
|
new methods to return an accepted socket fd.
|
||||||
|
|
||||||
: Date and DateTime
|
: Date and DateTime
|
||||||
|
|
||||||
lib/date.rb now provides both Date and DateTime.
|
lib/date.rb now provides both Date and DateTime.
|
||||||
|
@ -1134,6 +1134,7 @@ s_accept(klass, fd, sockaddr, len)
|
|||||||
}
|
}
|
||||||
rb_sys_fail(0);
|
rb_sys_fail(0);
|
||||||
}
|
}
|
||||||
|
if (!klass) return INT2NUM(fd2);
|
||||||
return init_sock(rb_obj_alloc(klass), fd2);
|
return init_sock(rb_obj_alloc(klass), fd2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,6 +1152,19 @@ tcp_accept(sock)
|
|||||||
(struct sockaddr*)&from, &fromlen);
|
(struct sockaddr*)&from, &fromlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
tcp_sysaccept(sock)
|
||||||
|
VALUE sock;
|
||||||
|
{
|
||||||
|
OpenFile *fptr;
|
||||||
|
struct sockaddr_storage from;
|
||||||
|
socklen_t fromlen;
|
||||||
|
|
||||||
|
GetOpenFile(sock, fptr);
|
||||||
|
fromlen = sizeof(from);
|
||||||
|
return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UN_H
|
#ifdef HAVE_SYS_UN_H
|
||||||
static VALUE
|
static VALUE
|
||||||
init_unixsock(sock, path, server)
|
init_unixsock(sock, path, server)
|
||||||
@ -1574,6 +1588,19 @@ unix_accept(sock)
|
|||||||
(struct sockaddr*)&from, &fromlen);
|
(struct sockaddr*)&from, &fromlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
unix_sysaccept(sock)
|
||||||
|
VALUE sock;
|
||||||
|
{
|
||||||
|
OpenFile *fptr;
|
||||||
|
struct sockaddr_un from;
|
||||||
|
socklen_t fromlen;
|
||||||
|
|
||||||
|
GetOpenFile(sock, fptr);
|
||||||
|
fromlen = sizeof(struct sockaddr_un);
|
||||||
|
return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
unixaddr(sockaddr)
|
unixaddr(sockaddr)
|
||||||
struct sockaddr_un *sockaddr;
|
struct sockaddr_un *sockaddr;
|
||||||
@ -1836,6 +1863,21 @@ sock_accept(sock)
|
|||||||
return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
|
return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
sock_sysaccept(sock)
|
||||||
|
VALUE sock;
|
||||||
|
{
|
||||||
|
OpenFile *fptr;
|
||||||
|
VALUE sock2;
|
||||||
|
char buf[1024];
|
||||||
|
socklen_t len = sizeof buf;
|
||||||
|
|
||||||
|
GetOpenFile(sock, fptr);
|
||||||
|
sock2 = s_accept(0,fileno(fptr->f),(struct sockaddr*)buf,&len);
|
||||||
|
|
||||||
|
return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GETHOSTNAME
|
#ifdef HAVE_GETHOSTNAME
|
||||||
static VALUE
|
static VALUE
|
||||||
sock_gethostname(obj)
|
sock_gethostname(obj)
|
||||||
@ -2322,6 +2364,7 @@ Init_socket()
|
|||||||
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);
|
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);
|
||||||
rb_define_global_const("TCPserver", rb_cTCPServer);
|
rb_define_global_const("TCPserver", rb_cTCPServer);
|
||||||
rb_define_method(rb_cTCPServer, "accept", tcp_accept, 0);
|
rb_define_method(rb_cTCPServer, "accept", tcp_accept, 0);
|
||||||
|
rb_define_method(rb_cTCPServer, "sysaccept", tcp_sysaccept, 0);
|
||||||
rb_define_method(rb_cTCPServer, "initialize", tcp_svr_init, -1);
|
rb_define_method(rb_cTCPServer, "initialize", tcp_svr_init, -1);
|
||||||
rb_define_method(rb_cTCPServer, "listen", sock_listen, 1);
|
rb_define_method(rb_cTCPServer, "listen", sock_listen, 1);
|
||||||
|
|
||||||
@ -2349,6 +2392,7 @@ Init_socket()
|
|||||||
rb_define_global_const("UNIXserver", rb_cUNIXServer);
|
rb_define_global_const("UNIXserver", rb_cUNIXServer);
|
||||||
rb_define_method(rb_cUNIXServer, "initialize", unix_svr_init, 1);
|
rb_define_method(rb_cUNIXServer, "initialize", unix_svr_init, 1);
|
||||||
rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
|
rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
|
||||||
|
rb_define_method(rb_cUNIXServer, "sysaccept", unix_sysaccept, 0);
|
||||||
rb_define_method(rb_cUNIXServer, "listen", sock_listen, 1);
|
rb_define_method(rb_cUNIXServer, "listen", sock_listen, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2359,6 +2403,7 @@ Init_socket()
|
|||||||
rb_define_method(rb_cSocket, "bind", sock_bind, 1);
|
rb_define_method(rb_cSocket, "bind", sock_bind, 1);
|
||||||
rb_define_method(rb_cSocket, "listen", sock_listen, 1);
|
rb_define_method(rb_cSocket, "listen", sock_listen, 1);
|
||||||
rb_define_method(rb_cSocket, "accept", sock_accept, 0);
|
rb_define_method(rb_cSocket, "accept", sock_accept, 0);
|
||||||
|
rb_define_method(rb_cSocket, "sysaccept", sock_sysaccept, 0);
|
||||||
|
|
||||||
rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1);
|
rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1);
|
||||||
|
|
||||||
|
30
io.c
30
io.c
@ -1966,7 +1966,7 @@ rb_open_file(argc, argv, io)
|
|||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE io;
|
VALUE io;
|
||||||
{
|
{
|
||||||
VALUE fname, vmode, file, perm;
|
VALUE fname, vmode, perm;
|
||||||
char *path, *mode;
|
char *path, *mode;
|
||||||
int flags, fmode;
|
int flags, fmode;
|
||||||
|
|
||||||
@ -1978,11 +1978,11 @@ rb_open_file(argc, argv, io)
|
|||||||
flags = FIXNUM_P(vmode) ? NUM2INT(vmode) : rb_io_mode_modenum(StringValuePtr(vmode));
|
flags = FIXNUM_P(vmode) ? NUM2INT(vmode) : rb_io_mode_modenum(StringValuePtr(vmode));
|
||||||
fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
|
fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
|
||||||
|
|
||||||
file = rb_file_sysopen_internal(io, path, flags, fmode);
|
rb_file_sysopen_internal(io, path, flags, fmode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
|
mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
|
||||||
file = rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
|
rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
|
||||||
}
|
}
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
@ -2002,6 +2002,29 @@ rb_io_s_open(argc, argv, klass)
|
|||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_io_s_sysopen(argc, argv)
|
||||||
|
int argc;
|
||||||
|
VALUE *argv;
|
||||||
|
{
|
||||||
|
VALUE fname, vmode, perm;
|
||||||
|
int flags, fmode, fd;
|
||||||
|
|
||||||
|
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||||
|
SafeStringValue(fname);
|
||||||
|
|
||||||
|
if (NIL_P(vmode)) flags = O_RDONLY;
|
||||||
|
else if (FIXNUM_P(vmode)) flags = NUM2INT(vmode);
|
||||||
|
else {
|
||||||
|
flags = rb_io_mode_modenum(StringValuePtr(vmode));
|
||||||
|
}
|
||||||
|
if (NIL_P(perm)) fmode = 0666;
|
||||||
|
else fmode = NUM2INT(perm);
|
||||||
|
|
||||||
|
fd = rb_sysopen(RSTRING(fname)->ptr, flags, fmode);
|
||||||
|
return INT2NUM(fd);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_open(argc, argv)
|
rb_f_open(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -3706,6 +3729,7 @@ Init_IO()
|
|||||||
rb_define_singleton_method(rb_cIO, "allocate", rb_io_s_alloc, 0);
|
rb_define_singleton_method(rb_cIO, "allocate", rb_io_s_alloc, 0);
|
||||||
rb_define_singleton_method(rb_cIO, "new", rb_io_s_new, -1);
|
rb_define_singleton_method(rb_cIO, "new", rb_io_s_new, -1);
|
||||||
rb_define_singleton_method(rb_cIO, "open", rb_io_s_open, -1);
|
rb_define_singleton_method(rb_cIO, "open", rb_io_s_open, -1);
|
||||||
|
rb_define_singleton_method(rb_cIO, "sysopen", rb_io_s_sysopen, -1);
|
||||||
rb_define_singleton_method(rb_cIO, "for_fd", rb_class_new_instance, -1);
|
rb_define_singleton_method(rb_cIO, "for_fd", rb_class_new_instance, -1);
|
||||||
rb_define_singleton_method(rb_cIO, "popen", rb_io_s_popen, -1);
|
rb_define_singleton_method(rb_cIO, "popen", rb_io_s_popen, -1);
|
||||||
rb_define_singleton_method(rb_cIO, "foreach", rb_io_s_foreach, -1);
|
rb_define_singleton_method(rb_cIO, "foreach", rb_io_s_foreach, -1);
|
||||||
|
@ -781,9 +781,10 @@ An end of a defun is found by moving forward from the beginning of one."
|
|||||||
'(lambda ()
|
'(lambda ()
|
||||||
(make-local-variable 'font-lock-defaults)
|
(make-local-variable 'font-lock-defaults)
|
||||||
(make-local-variable 'font-lock-keywords)
|
(make-local-variable 'font-lock-keywords)
|
||||||
(make-local-variable 'font-lock-syntactic-keywords)
|
(make-local-variable 'font-lock-syntax-table)
|
||||||
(setq font-lock-defaults '((ruby-font-lock-keywords) nil nil))
|
(setq font-lock-defaults '((ruby-font-lock-keywords) nil nil))
|
||||||
(setq font-lock-keywords ruby-font-lock-keywords)
|
(setq font-lock-keywords ruby-font-lock-keywords)
|
||||||
|
(setq font-lock-syntax-table ruby-font-lock-syntax-table)
|
||||||
(setq font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)))))
|
(setq font-lock-syntactic-keywords ruby-font-lock-syntactic-keywords)))))
|
||||||
|
|
||||||
(defun ruby-font-lock-docs (limit)
|
(defun ruby-font-lock-docs (limit)
|
||||||
@ -812,6 +813,11 @@ An end of a defun is found by moving forward from the beginning of one."
|
|||||||
t)
|
t)
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
(defvar ruby-font-lock-syntax-table
|
||||||
|
(let* ((tbl (copy-syntax-table ruby-mode-syntax-table)))
|
||||||
|
(modify-syntax-entry ?_ "w" tbl)
|
||||||
|
tbl))
|
||||||
|
|
||||||
(defvar ruby-font-lock-keywords
|
(defvar ruby-font-lock-keywords
|
||||||
(list
|
(list
|
||||||
(cons (concat
|
(cons (concat
|
||||||
@ -855,10 +861,10 @@ An end of a defun is found by moving forward from the beginning of one."
|
|||||||
"yield"
|
"yield"
|
||||||
)
|
)
|
||||||
"\\|")
|
"\\|")
|
||||||
"\\)\\>\\([^_]\\|$\\)")
|
"\\)\\>")
|
||||||
2)
|
2)
|
||||||
;; variables
|
;; variables
|
||||||
'("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\b\\([^_]\\|$\\)"
|
'("\\(^\\|[^_:.@$]\\|\\.\\.\\)\\b\\(nil\\|self\\|true\\|false\\)\\>"
|
||||||
2 font-lock-variable-name-face)
|
2 font-lock-variable-name-face)
|
||||||
;; variables
|
;; variables
|
||||||
'("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
|
'("\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"
|
||||||
|
14
ruby.c
14
ruby.c
@ -561,6 +561,7 @@ proc_options(argc, argv)
|
|||||||
s += numlen;
|
s += numlen;
|
||||||
}
|
}
|
||||||
rb_set_safe_level(v);
|
rb_set_safe_level(v);
|
||||||
|
s += numlen;
|
||||||
}
|
}
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
|
|
||||||
@ -572,7 +573,7 @@ proc_options(argc, argv)
|
|||||||
ruby_incpush(argv[1]);
|
ruby_incpush(argv[1]);
|
||||||
argc--,argv++;
|
argc--,argv++;
|
||||||
}
|
}
|
||||||
break;
|
goto reswitch;
|
||||||
|
|
||||||
case '0':
|
case '0':
|
||||||
{
|
{
|
||||||
@ -624,11 +625,6 @@ proc_options(argc, argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '*':
|
|
||||||
case ' ':
|
|
||||||
if (s[1] == '-') s+=2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: invalid option -%c (-h will show valid options)\n",
|
fprintf(stderr, "%s: invalid option -%c (-h will show valid options)\n",
|
||||||
origargv[0], *s);
|
origargv[0], *s);
|
||||||
@ -657,10 +653,12 @@ proc_options(argc, argv)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (s && *s) {
|
while (s && *s) {
|
||||||
while (ISSPACE(*s)) s++;
|
|
||||||
if (*s == '-') {
|
if (*s == '-') {
|
||||||
s++;
|
s++;
|
||||||
if (ISSPACE(*s)) continue;
|
if (ISSPACE(*s)) {
|
||||||
|
do {s++;} while (ISSPACE(*s));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!*s) break;
|
if (!*s) break;
|
||||||
if (!strchr("IdvwrK", *s))
|
if (!strchr("IdvwrK", *s))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.7.2"
|
#define RUBY_VERSION "1.7.2"
|
||||||
#define RUBY_RELEASE_DATE "2002-05-22"
|
#define RUBY_RELEASE_DATE "2002-05-23"
|
||||||
#define RUBY_VERSION_CODE 172
|
#define RUBY_VERSION_CODE 172
|
||||||
#define RUBY_RELEASE_CODE 20020522
|
#define RUBY_RELEASE_CODE 20020523
|
||||||
|
Loading…
x
Reference in New Issue
Block a user