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

* signal.c (sigexit): call rb_thread_signal_exit() instead of

rb_exit().  [ruby-dev:26347]

* eval.c (rb_thread_signal_exit): a new function to exit on main
  thread.

* eval.c (rb_thread_switch): exit status should be retrieved from
  ruby_errinfo.

* eval.c (rb_f_exit): ensure exit(0) should call
  exit(EXIT_SUCCESS).

* missing/mkdir.c: remove. [ruby-core:05177]

* hash.c (env_aset): do not treat nil as key-removing value.
  [ruby-list:40865]

* parse.y (method_call): allow aref expression ([]) to take a
  block.

* parse.y (block_dup_check): a function to check duplication of
  a block argument and an actual block.

* lib/delegate.rb (SimpleDelegator::__setobj__): need check for
  recursive delegation.  [ruby-core:04940]

* lib/cgi.rb: add underscore aliases CGI::escape_html,
  CGI::unescape_html, CGI::escape_element, CGI::unescape_element.
  [ruby-core:05058]

* misc/ruby-mode.el (ruby-expr-beg): fix looking point drift.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2005-06-12 16:56:06 +00:00
parent 4169e76d14
commit 8db3dc39d6
13 changed files with 146 additions and 170 deletions

View file

@ -1,8 +1,21 @@
Mon Jun 13 01:54:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* signal.c (sigexit): call rb_thread_signal_exit() instead of
rb_exit(). [ruby-dev:26347]
* eval.c (rb_thread_signal_exit): a new function to exit on main
thread.
* eval.c (rb_thread_switch): exit status should be retrieved from
ruby_errinfo.
* eval.c (rb_f_exit): ensure exit(0) should call
exit(EXIT_SUCCESS).
Mon Jun 13 01:20:02 2005 Tanaka Akira <akr@m17n.org>
* eval.c (rb_gc_mark_threads): curr_thread may not be part of the
thread list.
[ruby-dev:26312]
thread list. [ruby-dev:26312]
Sat Jun 11 22:34:44 2005 Minero Aoki <aamine@loveruby.net>
@ -13,6 +26,10 @@ Fri Jun 10 23:55:17 2005 Tanaka Akira <akr@m17n.org>
* eval.c (unknown_node): show more information. [ruby-dev:26196]
Fri Jun 10 23:35:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* missing/mkdir.c: remove. [ruby-core:05177]
Fri Jun 10 22:54:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* missing.h: fd_set stuffs need sys/types.h. fixed: [ruby-core:05179]
@ -42,6 +59,32 @@ Thu Jun 9 18:24:16 2005 Tanaka Akira <akr@m17n.org>
* configure.in, eval.c, gc.c: use libunwind only on HP-UX.
[ruby-dev:26297]
Thu Jun 9 14:46:32 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (env_aset): do not treat nil as key-removing value.
[ruby-list:40865]
* parse.y (method_call): allow aref expression ([]) to take a
block.
* parse.y (block_dup_check): a function to check duplication of
a block argument and an actual block.
Thu Jun 9 11:55:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/delegate.rb (SimpleDelegator::__setobj__): need check for
recursive delegation. [ruby-core:04940]
Thu Jun 9 11:50:43 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/cgi.rb: add underscore aliases CGI::escape_html,
CGI::unescape_html, CGI::escape_element, CGI::unescape_element.
[ruby-core:05058]
Wed Jun 8 18:47:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* misc/ruby-mode.el (ruby-expr-beg): fix looking point drift.
Wed Jun 8 12:25:59 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_nitems): add the block feature to Array#nitems.

View file

@ -481,7 +481,7 @@ AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isnan finite isinf hypot acosh erf)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd\

39
eval.c
View file

@ -1392,6 +1392,14 @@ static int thread_reset_raised();
static VALUE exception_error;
static VALUE sysstack_error;
static int
sysexit_status(err)
VALUE err;
{
VALUE st = rb_iv_get(err, "status");
return NUM2INT(st);
}
static int
error_handle(ex)
int ex;
@ -1438,8 +1446,7 @@ error_handle(ex)
case TAG_RAISE:
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
VALUE st = rb_iv_get(ruby_errinfo, "status");
status = NUM2INT(st);
status = sysexit_status(ruby_errinfo);
}
else {
error_print();
@ -4386,6 +4393,9 @@ rb_f_exit(argc, argv)
break;
default:
istatus = NUM2INT(status);
#if EXIT_SUCCESS != 0
if (istatus == 0) istatus = EXIT_SUCCESS;
#endif
break;
}
}
@ -10383,8 +10393,7 @@ rb_thread_switch(n)
case RESTORE_EXIT:
ruby_errinfo = th_raise_exception;
ruby_current_node = th_raise_node;
error_print();
terminate_process(EXIT_FAILURE, 0, 0);
terminate_process(sysexit_status(ruby_errinfo), 0, 0);
break;
case RESTORE_NORMAL:
default:
@ -12464,6 +12473,28 @@ rb_thread_trap_eval(cmd, sig, safe)
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
}
void
rb_thread_signal_exit()
{
VALUE args[2];
rb_thread_critical = 0;
if (curr_thread == main_thread) {
rb_thread_ready(curr_thread);
rb_exit(EXIT_SUCCESS);
}
args[0] = INT2NUM(EXIT_SUCCESS);
args[1] = rb_str_new2("exit");
rb_thread_ready(main_thread);
if (!rb_thread_dead(curr_thread)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
}
rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit),
RESTORE_EXIT);
}
static VALUE
rb_thread_raise(argc, argv, th)
int argc;

View file

@ -801,8 +801,7 @@ Init_readline()
#if defined HAVE_RL_LIBRARY_VERSION
rb_define_const(mReadline, "VERSION", rb_str_new2(rl_library_version));
#else
rb_define_const(mReadline, "VERSION",
rb_str_new2("2.0 or before version"));
rb_define_const(mReadline, "VERSION", rb_str_new2("2.0 or prior version"));
#endif
rl_attempted_completion_function = readline_attempted_completion_function;

23
hash.c
View file

@ -1826,17 +1826,17 @@ ruby_setenv(name, value)
}
if (!value) {
if (environ != origenviron) {
char **envp = origenviron;
while (*envp && *envp != environ[i]) envp++;
if (!*envp)
free(environ[i]);
char **envp = origenviron;
while (*envp && *envp != environ[i]) envp++;
if (!*envp)
free(environ[i]);
}
while (environ[i]) {
environ[i] = environ[i+1];
i++;
while (environ[i]) {
environ[i] = environ[i+1];
i++;
}
return;
}
return;
}
if (!environ[i]) { /* does not exist yet */
REALLOC_N(environ, char*, i+2); /* just expand it a bit */
environ[i+1] = 0; /* make sure it's null terminated */
@ -1878,11 +1878,6 @@ env_aset(obj, nm, val)
rb_raise(rb_eSecurityError, "can't change environment variable");
}
if (NIL_P(val)) {
env_delete(obj, nm);
return Qnil;
}
StringValue(nm);
StringValue(val);
name = RSTRING(nm)->ptr;

View file

@ -252,6 +252,7 @@ VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
void rb_thread_interrupt _((void));
void rb_thread_trap_eval _((VALUE, int, int));
void rb_thread_signal_raise _((char*));
void rb_thread_signal_exit _((void));
int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
void rb_thread_wait_for _((struct timeval));
VALUE rb_thread_current _((void));

View file

@ -399,7 +399,12 @@ class CGI
end
end
end
def CGI::escape_html(str)
escapeHTML(str)
end
def CGI::unescape_html(str)
unescapeHTML(str)
end
# Escape only the tags of certain HTML elements in +string+.
#
@ -445,7 +450,12 @@ class CGI
string
end
end
def CGI::escape_element(str)
escapeElement(str)
end
def CGI::unescape_element(str)
unescapeElement(str)
end
# Format a +Time+ object as a String using the format specified by RFC 1123.
#

View file

@ -73,6 +73,7 @@ class SimpleDelegator<Delegator
end
def __setobj__(obj)
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
@_sd_obj = obj
end
@ -110,6 +111,7 @@ def DelegateClass(superclass)
@_dc_obj
end
def __setobj__(obj)
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
@_dc_obj = obj
end
def clone

View file

@ -61,13 +61,13 @@
(defconst ruby-delimiter
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
ruby-block-beg-re
"\\>\\|" ruby-block-end-re
"\\)\\|^=begin\\|" ruby-here-doc-beg-re)
"\\)\\>\\|" ruby-block-end-re
"\\|^=begin\\|" ruby-here-doc-beg-re)
)
(defconst ruby-negative
(concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|\\("
ruby-block-end-re "\\)\\|}\\|\\]\\)")
(concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|"
ruby-block-end-re "\\|}\\|\\]\\)")
)
(defconst ruby-operator-chars "-,.+*/%&|^~=<>:")
@ -302,8 +302,8 @@ The variable ruby-indent-level controls the amount of indentation.
(defun ruby-expr-beg (&optional option)
(save-excursion
(store-match-data nil)
(let ((start (point))
(space (skip-chars-backward " \t")))
(let ((space (skip-chars-backward " \t"))
(start (point)))
(cond
((bolp) t)
((progn
@ -327,7 +327,7 @@ The variable ruby-indent-level controls the amount of indentation.
"|" ruby-block-op-re
"|" ruby-block-mid-re "\\)\\>")))
(goto-char (match-end 0))
(not (looking-at "\\s_")))
(not (looking-at "\\s_")))
((eq option 'expr-qstr)
(looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"))
((eq option 'expr-re)

View file

@ -84,10 +84,6 @@ extern int memcmp _((char *, char *, int));
extern void *memmove _((void *, void *, int));
#endif
#ifndef HAVE_MKDIR
extern int mkdir _((char *, int));
#endif
/*
#ifndef HAVE_MODF
extern double modf _((double, double *));

View file

@ -1,104 +0,0 @@
/*
* Written by Robert Rother, Mariah Corporation, August 1985.
*
* If you want it, it's yours. All I ask in return is that if you
* figure out how to do this in a Bourne Shell script you send me
* a copy.
* sdcsvax!rmr or rmr@uscd
*
* Severely hacked over by John Gilmore to make a 4.2BSD compatible
* subroutine. 11Mar86; hoptoad!gnu
*
* Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir,
* subroutine didn't return EEXIST. It does now.
*/
#include <sys/stat.h>
#include <errno.h>
/*
* Make a directory.
*/
int
mkdir (dpath, dmode)
char *dpath;
int dmode;
{
int cpid, status;
struct stat statbuf;
if (stat (dpath, &statbuf) == 0)
{
errno = EEXIST; /* Stat worked, so it already exists */
return -1;
}
/* If stat fails for a reason other than non-existence, return error */
if (errno != ENOENT)
return -1;
switch (cpid = fork ())
{
case -1: /* Error in fork() */
return (-1); /* Errno is set already */
case 0: /* Child process */
/*
* Cheap hack to set mode of new directory. Since this
* child process is going away anyway, we zap its umask.
* FIXME, this won't suffice to set SUID, SGID, etc. on this
* directory. Does anybody care?
*/
status = umask (0); /* Get current umask */
status = umask (status | (0777 & ~dmode)); /* Set for mkdir */
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
_exit (-1); /* Can't exec /bin/mkdir */
default: /* Parent process */
while (cpid != wait (&status)); /* Wait for kid to finish */
}
if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/mkdir failed */
}
return 0;
}
int
rmdir (dpath)
char *dpath;
{
int cpid, status;
struct stat statbuf;
if (stat (dpath, &statbuf) != 0)
{
/* Stat just set errno. We don't have to */
return -1;
}
switch (cpid = fork ())
{
case -1: /* Error in fork() */
return (-1); /* Errno is set already */
case 0: /* Child process */
execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
_exit (-1); /* Can't exec /bin/mkdir */
default: /* Parent process */
while (cpid != wait (&status)); /* Wait for kid to finish */
}
if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
{
errno = EIO; /* We don't know why, but */
return -1; /* /bin/rmdir failed */
}
return 0;
}

60
parse.y
View file

@ -230,6 +230,7 @@ static NODE *remove_begin _((NODE*));
static void void_stmts_gen _((struct parser_params*,NODE*));
#define void_stmts(node) void_stmts_gen(parser, node)
static void reduce_nodes _((NODE**));
static void block_dup_check _((NODE*));
static NODE *block_append _((NODE*,NODE*));
static NODE *list_append _((NODE*,NODE*));
@ -1136,9 +1137,7 @@ command : operation command_args %prec tLOWEST
/*%%%*/
$$ = new_fcall($1, $2);
if ($3) {
if (nd_type($$) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
block_dup_check($$);
$3->nd_iter = $$;
$$ = $3;
}
@ -1162,9 +1161,7 @@ command : operation command_args %prec tLOWEST
/*%%%*/
$$ = new_call($1, $3, $4);
if ($5) {
if (nd_type($$) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
block_dup_check($$);
$5->nd_iter = $$;
$$ = $5;
}
@ -1188,9 +1185,7 @@ command : operation command_args %prec tLOWEST
/*%%%*/
$$ = new_call($1, $3, $4);
if ($5) {
if (nd_type($$) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
block_dup_check($$);
$5->nd_iter = $$;
$$ = $5;
}
@ -2513,18 +2508,6 @@ primary : literal
$$ = dispatch1(topconst_ref, $2);
%*/
}
| primary_value '[' aref_args ']'
{
/*%%%*/
if ($1 && nd_type($1) == NODE_SELF)
$$ = NEW_FCALL(tAREF, $3);
else
$$ = NEW_CALL($1, tAREF, $3);
fixpos($$, $1);
/*%
$$ = dispatch2(aref, $1, $3);
%*/
}
| tLBRACK aref_args ']'
{
/*%%%*/
@ -2626,9 +2609,7 @@ primary : literal
| method_call brace_block
{
/*%%%*/
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
block_dup_check($$);
$2->nd_iter = $1;
$$ = $2;
fixpos($$, $1);
@ -3233,9 +3214,7 @@ do_block : kDO_BLOCK
block_call : command do_block
{
/*%%%*/
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
block_dup_check($1);
$2->nd_iter = $1;
$$ = $2;
fixpos($$, $1);
@ -3328,6 +3307,18 @@ method_call : operation paren_args
$$ = method_optarg($$, $4);
%*/
}
| primary_value '[' aref_args ']'
{
/*%%%*/
if ($1 && nd_type($1) == NODE_SELF)
$$ = NEW_FCALL(tAREF, $3);
else
$$ = NEW_CALL($1, tAREF, $3);
fixpos($$, $1);
/*%
$$ = dispatch2(aref, $1, $3);
%*/
}
;
brace_block : '{'
@ -6309,11 +6300,13 @@ parser_yylex(parser)
return kEND;
}
pushback(c);
c = ';';
lex_state = EXPR_BEG;
command_start = Qtrue;
return ';';
case ',':
lex_state = EXPR_BEG;
return c;
return ',';
case '~':
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
@ -7218,6 +7211,15 @@ aryset_gen(parser, recv, idx)
return NEW_ATTRASGN(recv, tASET, idx);
}
static void
block_dup_check(node)
NODE *node;
{
if (node && nd_type(node) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
}
}
ID
rb_id_attrset(id)
ID id;

View file

@ -33,6 +33,7 @@ static struct signals {
char *signm;
int signo;
} siglist [] = {
{"EXIT", 0},
#ifdef SIGHUP
{"HUP", SIGHUP},
#endif
@ -592,7 +593,7 @@ sigexit(sig)
}
#endif
rb_exit(0);
rb_thread_signal_exit();
}
static VALUE