mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
join 1.1c6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1dev@310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5d71c8d89c
commit
75ff8fdb16
57 changed files with 1836 additions and 1036 deletions
96
ChangeLog
96
ChangeLog
|
|
@ -1,3 +1,88 @@
|
|||
Mon Oct 5 18:31:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* version 1.1c6 released.
|
||||
|
||||
Fri Oct 2 14:22:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* regex.c (re_search): `/\s*(--)$/ =~ "- --"' did not match,
|
||||
because of wrong optimize condition.
|
||||
|
||||
Thu Oct 1 01:55:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (rb_intern): should not raise exceptions.
|
||||
|
||||
* parse.y (yylex): symbol like `:foo?=' should not be allowed.
|
||||
|
||||
* ext/extmk.rb.in: makes *.a for static link modules.
|
||||
|
||||
Wed Sep 30 14:13:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* eval.c (rb_thread_start): supports making a subclass of the
|
||||
Thread class.
|
||||
|
||||
Tue Sep 29 17:46:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* eval.c (rb_thread_join): join is now an instance method.
|
||||
|
||||
Fri Sep 25 12:01:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (yylex): `@foo!' should be an error.
|
||||
|
||||
Thu Sep 24 14:55:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
|
||||
|
||||
* ext/etc/etc.c (Init_etc): wrong field definition.
|
||||
|
||||
Thu Sep 17 17:09:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (io_reopen): was creating FILE* for wrong fd.
|
||||
|
||||
Tue Sep 15 05:28:11 1998 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* regex.c (re_compile_pattern): forgot to fixup for the pattern
|
||||
like (?=(A)|(B)).
|
||||
|
||||
Tue Sep 15 01:06:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_io_gets_internal): do not set $_ by default, only
|
||||
gets/readline set the variable.
|
||||
|
||||
* eval.c (rb_f_load): load toplevel class is set to anonymous
|
||||
module if safe_level >= 5, to encapsulate modification.
|
||||
|
||||
* eval.c (rb_f_load): set frame properly.
|
||||
|
||||
* string.c (rb_str_each_line): do not set $_.
|
||||
|
||||
Mon Sep 14 14:42:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* regex.c (re_match): beginning and end of the string, do not
|
||||
automatically match `\b'.
|
||||
|
||||
* string.c (scan_once): comsume at leaset on character.
|
||||
|
||||
* regex.c (re_search): wrong behavior for negative range.
|
||||
|
||||
Sat Sep 12 21:21:26 1998 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* regex.c (re_search): range value should be maintained.
|
||||
|
||||
Thu Sep 10 10:55:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (backref_error): yyerror does not understand formats.
|
||||
|
||||
Tue Sep 8 18:05:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* version 1.1c5 released.
|
||||
|
||||
Tue Sep 8 10:03:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* string.c (str_each_line): wrong line splitting with newline at
|
||||
top of the string.
|
||||
|
||||
* string.c: non bang methods return copied string.
|
||||
|
||||
* eval.c (f_END): needed to initialize frame->argc;
|
||||
|
||||
Tue Sep 8 01:42:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* enum.c (Init_Enumerable): Enumerable#reverse removed.
|
||||
|
|
@ -6,15 +91,11 @@ Tue Sep 8 01:42:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
|||
|
||||
* eval.c (rb_call0): ditto.
|
||||
|
||||
Thu Sep 3 16:34:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* bignum.c (bigadd): proper sign combination.
|
||||
|
||||
* eval.c (dvar_asgn_push): modify calling block to create dvar,
|
||||
not insert it next to dummy dvar slot.
|
||||
|
||||
* eval.c (eval): save calling block in (thread local) global
|
||||
variable. no dummy dvar slot is generated by yield.
|
||||
* regex.c (re_search): wrong return value for \A.
|
||||
|
||||
Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
|
|
@ -22,6 +103,9 @@ Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
|||
|
||||
Tue Sep 1 10:47:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* regex.c (slow_search): do not compare llen and blen. llen may
|
||||
be longer than blen, if little contains 0xff.
|
||||
|
||||
* regex.c (mbctab_euc): set 0x8e as multibyte character.
|
||||
|
||||
* string.c (str_inspect): mask character for octal output.
|
||||
|
|
|
|||
3
MANIFEST
3
MANIFEST
|
|
@ -109,14 +109,15 @@ lib/mkmf.rb
|
|||
lib/monitor.rb
|
||||
lib/mutex_m.rb
|
||||
lib/observer.rb
|
||||
lib/open3.rb
|
||||
lib/ostruct.rb
|
||||
lib/parsearg.rb
|
||||
lib/parsedate.rb
|
||||
lib/ping.rb
|
||||
lib/profile.rb
|
||||
lib/pstore.rb
|
||||
lib/rational.rb
|
||||
lib/readbytes.rb
|
||||
lib/shell.rb
|
||||
lib/shellwords.rb
|
||||
lib/singleton.rb
|
||||
lib/sync.rb
|
||||
|
|
|
|||
2
array.c
2
array.c
|
|
@ -11,6 +11,7 @@
|
|||
************************************************/
|
||||
|
||||
#include "ruby.h"
|
||||
#include "util.h"
|
||||
|
||||
VALUE rb_cArray;
|
||||
|
||||
|
|
@ -44,7 +45,6 @@ static void
|
|||
rb_ary_modify(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
rb_secure(5);
|
||||
if (FL_TEST(ary, ARY_FREEZE|ARY_TMPLOCK)) {
|
||||
rb_raise(rb_eTypeError, "can't modify frozen array");
|
||||
}
|
||||
|
|
|
|||
8
class.c
8
class.c
|
|
@ -153,9 +153,9 @@ VALUE
|
|||
rb_define_module_id(id)
|
||||
ID id;
|
||||
{
|
||||
extern st_table *rb_class_tbl;
|
||||
VALUE mdl = rb_module_new();
|
||||
VALUE mdl;
|
||||
|
||||
mdl = rb_module_new();
|
||||
rb_name_class(mdl, id);
|
||||
|
||||
return mdl;
|
||||
|
|
@ -192,7 +192,7 @@ rb_define_module_under(outer, name)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
include_rb_class_new(module, super)
|
||||
include_class_new(module, super)
|
||||
VALUE module, super;
|
||||
{
|
||||
NEWOBJ(klass, struct RClass);
|
||||
|
|
@ -241,7 +241,7 @@ rb_include_module(klass, module)
|
|||
}
|
||||
}
|
||||
RCLASS(klass)->super =
|
||||
include_rb_class_new(module, RCLASS(klass)->super);
|
||||
include_class_new(module, RCLASS(klass)->super);
|
||||
klass = RCLASS(klass)->super;
|
||||
module = RCLASS(module)->super;
|
||||
}
|
||||
|
|
|
|||
24
configure.in
24
configure.in
|
|
@ -24,7 +24,7 @@ AC_ARG_ENABLE(thread, [--disable-thread never use user-level thread], [
|
|||
rb_thread=$enableval
|
||||
])
|
||||
if test $rb_thread = yes; then
|
||||
AC_DEFINE(THREAD)
|
||||
AC_DEFINE(USE_THREAD)
|
||||
fi
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
|
@ -72,6 +72,7 @@ AC_PROG_YACC
|
|||
AC_PROG_RANLIB
|
||||
AC_SUBST(AR)
|
||||
AC_CHECK_PROGS(AR, ar aal, ar)
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
# checks for UNIX variants that set C preprocessor variables
|
||||
|
|
@ -133,6 +134,7 @@ esac
|
|||
AC_CHECK_LIB(crypt, crypt)
|
||||
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
|
||||
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
|
||||
AC_CHECK_LIB(xpg4, setlocale) # FreeBSD needs this
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_DIRENT
|
||||
|
|
@ -273,18 +275,6 @@ else
|
|||
AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_getpwent" = yes; then
|
||||
AC_MSG_CHECKING(struct passwd)
|
||||
AC_EGREP_HEADER(pw_gecos, pwd.h, AC_DEFINE(PW_GECOS))
|
||||
AC_EGREP_HEADER(pw_change, pwd.h, AC_DEFINE(PW_CHANGE))
|
||||
AC_EGREP_HEADER(pw_quota, pwd.h, AC_DEFINE(PW_QUOTA))
|
||||
AC_EGREP_HEADER(pw_age, pwd.h, AC_DEFINE(PW_AGE))
|
||||
AC_EGREP_HEADER(pw_class, pwd.h, AC_DEFINE(PW_CLASS))
|
||||
AC_EGREP_HEADER(pw_comment, pwd.h, AC_DEFINE(PW_COMMENT))
|
||||
AC_EGREP_HEADER(pw_expire, pwd.h, AC_DEFINE(PW_EXPIRE))
|
||||
AC_MSG_RESULT(done)
|
||||
fi
|
||||
|
||||
dnl wheather use dln_a_out ot not
|
||||
AC_ARG_WITH(dln-a-out, [--with-dln-a-out use dln_a_out if possible], [
|
||||
case $withval in
|
||||
|
|
@ -343,6 +333,7 @@ if test "$with_dln_a_out" != yes; then
|
|||
openstep*) ;;
|
||||
rhapsody*) ;;
|
||||
human*) ;;
|
||||
cygwin32*) CCDLFLAGS=-DDLLIMPORT;;
|
||||
*) CCDLFLAGS=-fpic;;
|
||||
esac
|
||||
else
|
||||
|
|
@ -405,6 +396,7 @@ if test "$with_dln_a_out" != yes; then
|
|||
;;
|
||||
esac
|
||||
rb_cv_dlopen=yes ;;
|
||||
cygwin32*) LDSHARED='../../miniruby ../cygwin32_ld.rb' ;;
|
||||
*) LDSHARED='ld' ;;
|
||||
esac
|
||||
AC_MSG_RESULT($rb_cv_dlopen)
|
||||
|
|
@ -450,6 +442,8 @@ else
|
|||
AC_DEFINE(DLEXT, ".bundle");;
|
||||
rhapsody*) DLEXT=bundle
|
||||
AC_DEFINE(DLEXT, ".bundle");;
|
||||
cygwin32*) DLEXT=dll
|
||||
AC_DEFINE(DLEXT, ".dll");;
|
||||
*) DLEXT=so
|
||||
AC_DEFINE(DLEXT, ".so");;
|
||||
esac
|
||||
|
|
@ -532,6 +526,10 @@ rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no)])
|
|||
binsuffix=.x
|
||||
setup=Setup.x68
|
||||
;;
|
||||
cygwin32*)
|
||||
binsuffix=.exe
|
||||
setup=Setup
|
||||
;;
|
||||
*)
|
||||
binsuffix=
|
||||
setup=Setup
|
||||
|
|
|
|||
10
dln.c
10
dln.c
|
|
@ -72,7 +72,7 @@ char *getenv();
|
|||
|
||||
int eaccess();
|
||||
|
||||
#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT)
|
||||
#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(__CYGWIN32__) && !defined(_AIX)
|
||||
/* dynamic load with dlopen() */
|
||||
# define USE_DLN_DLOPEN
|
||||
#endif
|
||||
|
|
@ -1081,7 +1081,7 @@ dln_sym(name)
|
|||
#include "dl.h"
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
#if defined(_AIX)
|
||||
#include <ctype.h> /* for isdigit() */
|
||||
#include <errno.h> /* for global errno */
|
||||
#include <sys/ldr.h>
|
||||
|
|
@ -1143,7 +1143,7 @@ dln_strerror()
|
|||
}
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
#if defined(_AIX)
|
||||
static void
|
||||
aix_loaderror(char *pathname)
|
||||
{
|
||||
|
|
@ -1257,7 +1257,7 @@ dln_load(file)
|
|||
# endif
|
||||
|
||||
/* Load file */
|
||||
if ((handle = dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
|
||||
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
|
@ -1296,7 +1296,7 @@ dln_load(file)
|
|||
}
|
||||
#endif /* hpux */
|
||||
|
||||
#ifdef _AIX
|
||||
#if defined(_AIX)
|
||||
#define DLN_DEFINED
|
||||
{
|
||||
void (*init_fct)();
|
||||
|
|
|
|||
2
error.c
2
error.c
|
|
@ -239,7 +239,7 @@ VALUE
|
|||
rb_exc_new(etype, ptr, len)
|
||||
VALUE etype;
|
||||
char *ptr;
|
||||
unsigned len;
|
||||
int len;
|
||||
{
|
||||
VALUE exc = rb_obj_alloc(etype);
|
||||
|
||||
|
|
|
|||
245
eval.c
245
eval.c
|
|
@ -70,9 +70,9 @@ static int scope_vmode;
|
|||
#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
|
||||
#define SCOPE_TEST(f) (scope_vmode&(f))
|
||||
|
||||
#define CACHE_SIZE 0x200
|
||||
#define CACHE_MASK 0x1ff
|
||||
#define EXPR1(c,m) ((((int)(c)>>3)^(m))&CACHE_MASK)
|
||||
#define CACHE_SIZE 0x800
|
||||
#define CACHE_MASK 0x7ff
|
||||
#define EXPR1(c,m) ((((long)(c)>>4)^(m))&CACHE_MASK)
|
||||
|
||||
struct cache_entry { /* method hash table. */
|
||||
ID mid; /* method's id */
|
||||
|
|
@ -97,6 +97,22 @@ rb_clear_cache()
|
|||
}
|
||||
}
|
||||
|
||||
static int cache_conflict;
|
||||
|
||||
static int
|
||||
count_cent()
|
||||
{
|
||||
struct cache_entry *ent, *end;
|
||||
int n = 0;
|
||||
|
||||
ent = cache; end = ent + CACHE_SIZE;
|
||||
while (ent < end) {
|
||||
if (ent->mid != 0) n++;
|
||||
ent++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
rb_clear_cache_by_id(id)
|
||||
ID id;
|
||||
|
|
@ -122,6 +138,9 @@ rb_add_method(klass, mid, node, noex)
|
|||
NODE *body;
|
||||
|
||||
if (NIL_P(klass)) klass = rb_cObject;
|
||||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
body = NEW_METHOD(node, noex);
|
||||
st_insert(RCLASS(klass)->m_tbl, mid, body);
|
||||
}
|
||||
|
|
@ -191,6 +210,9 @@ rb_alias(klass, name, def)
|
|||
NODE *orig, *body;
|
||||
|
||||
if (name == def) return;
|
||||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
orig = search_method(klass, def, &origin);
|
||||
if (!orig || !orig->nd_body) {
|
||||
if (TYPE(klass) == T_MODULE) {
|
||||
|
|
@ -219,6 +241,9 @@ remove_method(klass, mid)
|
|||
{
|
||||
NODE *body;
|
||||
|
||||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) {
|
||||
rb_raise(rb_eNameError, "method `%s' not defined in %s",
|
||||
rb_id2name(mid), rb_class2name(klass));
|
||||
|
|
@ -283,6 +308,9 @@ rb_export_method(klass, name, noex)
|
|||
NODE *body;
|
||||
VALUE origin;
|
||||
|
||||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
body = search_method(klass, name, &origin);
|
||||
if (!body && TYPE(klass) == T_MODULE) {
|
||||
body = search_method(rb_cObject, name, &origin);
|
||||
|
|
@ -379,10 +407,11 @@ static struct SCOPE *top_scope;
|
|||
#define PUSH_FRAME() { \
|
||||
struct FRAME _frame; \
|
||||
_frame.prev = ruby_frame; \
|
||||
_frame.file = ruby_sourcefile; \
|
||||
_frame.line = ruby_sourceline; \
|
||||
_frame.file = ruby_sourcefile; \
|
||||
_frame.line = ruby_sourceline; \
|
||||
_frame.iter = ruby_iter->iter; \
|
||||
_frame.cbase = ruby_frame->cbase; \
|
||||
_frame.argc = 0; \
|
||||
ruby_frame = &_frame; \
|
||||
|
||||
#define POP_FRAME() ruby_frame = _frame.prev; }
|
||||
|
|
@ -398,7 +427,7 @@ struct BLOCK {
|
|||
int iter;
|
||||
int vmode;
|
||||
struct RVarmap *d_vars;
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
VALUE orig_thread;
|
||||
#endif
|
||||
struct BLOCK *prev;
|
||||
|
|
@ -623,7 +652,7 @@ VALUE ruby_class;
|
|||
ruby_scope->local_vars = 0;\
|
||||
ruby_scope->local_tbl = 0;\
|
||||
if (ruby_scope != top_scope)\
|
||||
rb_gc_force_recycle(ruby_scope);\
|
||||
rb_gc_force_recycle((VALUE)ruby_scope);\
|
||||
}\
|
||||
else {\
|
||||
ruby_scope->flag |= SCOPE_NOSTACK;\
|
||||
|
|
@ -647,10 +676,9 @@ static int safe_level = 0;
|
|||
/* safe-level:
|
||||
0 - strings from streams/environment/ARGV are tainted (default)
|
||||
1 - no dangerous operation by tainted string
|
||||
2 - some process operations prohibited
|
||||
2 - process/file operations prohibited
|
||||
3 - all genetated strings are tainted
|
||||
4 - no global variable value modification/no direct output
|
||||
5 - no instance variable value modification
|
||||
4 - no global variable modification/no direct output
|
||||
*/
|
||||
|
||||
int
|
||||
|
|
@ -713,7 +741,7 @@ rb_secure(level)
|
|||
{
|
||||
if (level <= safe_level) {
|
||||
rb_raise(rb_eSecurityError, "Insecure operation `%s' for level %d",
|
||||
rb_id2name(ruby_frame->last_func), level);
|
||||
rb_id2name(ruby_frame->last_func), safe_level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -918,7 +946,7 @@ eval_node(self)
|
|||
|
||||
int rb_in_eval;
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
static void rb_thread_cleanup _((void));
|
||||
static void rb_thread_wait_other_threads _((void));
|
||||
static VALUE rb_thread_current _((void));
|
||||
|
|
@ -952,12 +980,13 @@ ruby_run()
|
|||
PUSH_ITER(ITER_NOT);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
rb_trap_exit();
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_cleanup();
|
||||
rb_thread_wait_other_threads();
|
||||
#endif
|
||||
exec_end_proc();
|
||||
rb_gc_call_finalizer_at_exit();
|
||||
fprintf(stderr, "%d/%d(%d)\n", count_cent(), CACHE_SIZE, cache_conflict);
|
||||
}
|
||||
else {
|
||||
ex = state;
|
||||
|
|
@ -1253,7 +1282,7 @@ rb_mod_alias_method(mod, newname, oldname)
|
|||
return mod;
|
||||
}
|
||||
|
||||
#if defined(C_ALLOCA) && defined(THREAD)
|
||||
#if defined(C_ALLOCA) && defined(USE_THREAD)
|
||||
# define TMP_PROTECT NODE *__protect_tmp=0
|
||||
# define TMP_ALLOC(type,n) \
|
||||
(__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
|
||||
|
|
@ -1548,7 +1577,7 @@ call_trace_func(event, file, line, self, id, klass)
|
|||
|
||||
trace = trace_func;
|
||||
trace_func = 0;
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_critical++;
|
||||
#endif
|
||||
|
||||
|
|
@ -1578,7 +1607,7 @@ call_trace_func(event, file, line, self, id, klass)
|
|||
POP_TAG();
|
||||
POP_FRAME();
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_critical--;
|
||||
#endif
|
||||
if (!trace_func) trace_func = trace;
|
||||
|
|
@ -1649,7 +1678,7 @@ rb_eval(self, node)
|
|||
|
||||
/* nodes for speed-up(top-level loop for -n/-p) */
|
||||
case NODE_OPT_N:
|
||||
while (!NIL_P(rb_f_gets())) {
|
||||
while (!NIL_P(rb_gets())) {
|
||||
rb_eval(self, node->nd_body);
|
||||
}
|
||||
RETURN(Qnil);
|
||||
|
|
@ -2382,8 +2411,13 @@ rb_eval(self, node)
|
|||
}
|
||||
body = search_method(ruby_class, node->nd_mid, &origin);
|
||||
if (body) {
|
||||
if (origin == ruby_class && rb_verbose) {
|
||||
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
|
||||
if (origin == ruby_class) {
|
||||
if (safe_level >= 3) {
|
||||
rb_raise(rb_eSecurityError, "re-defining method prohibited");
|
||||
}
|
||||
if (rb_verbose) {
|
||||
rb_warning("discarding old %s", rb_id2name(node->nd_mid));
|
||||
}
|
||||
}
|
||||
rb_clear_cache_by_id(node->nd_mid);
|
||||
}
|
||||
|
|
@ -2441,9 +2475,13 @@ rb_eval(self, node)
|
|||
}
|
||||
|
||||
klass = rb_singleton_class(recv);
|
||||
if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)
|
||||
&& rb_verbose) {
|
||||
rb_warning("redefine %s", rb_id2name(node->nd_mid));
|
||||
if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
|
||||
if (safe_level >= 3) {
|
||||
rb_raise(rb_eSecurityError, "re-defining method prohibited");
|
||||
}
|
||||
if (rb_verbose) {
|
||||
rb_warning("redefine %s", rb_id2name(node->nd_mid));
|
||||
}
|
||||
}
|
||||
rb_clear_cache_by_id(node->nd_mid);
|
||||
rb_add_method(klass, node->nd_mid, node->nd_defn,
|
||||
|
|
@ -2462,6 +2500,9 @@ rb_eval(self, node)
|
|||
if (NIL_P(ruby_class)) {
|
||||
rb_raise(rb_eTypeError, "no class to undef method");
|
||||
}
|
||||
if (ruby_class == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
body = search_method(ruby_class, node->nd_mid, &origin);
|
||||
if (!body || !body->nd_body) {
|
||||
char *s0 = " class";
|
||||
|
|
@ -2757,10 +2798,9 @@ rb_f_exit(argc, argv, obj)
|
|||
/* not reached */
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_abort()
|
||||
static void
|
||||
rb_abort()
|
||||
{
|
||||
rb_secure(2);
|
||||
if (rb_errinfo) {
|
||||
error_print();
|
||||
}
|
||||
|
|
@ -2768,6 +2808,13 @@ rb_f_abort()
|
|||
/* not reached */
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_abort()
|
||||
{
|
||||
rb_secure(2);
|
||||
rb_abort();
|
||||
}
|
||||
|
||||
void
|
||||
rb_iter_break()
|
||||
{
|
||||
|
|
@ -2810,6 +2857,9 @@ rb_longjmp(tag, mesg)
|
|||
call_trace_func("raise", ruby_sourcefile, ruby_sourceline,
|
||||
ruby_frame->self, ruby_frame->last_func, 0);
|
||||
}
|
||||
if (!prot_tag) {
|
||||
error_print();
|
||||
}
|
||||
JUMP_TAG(tag);
|
||||
}
|
||||
|
||||
|
|
@ -3524,8 +3574,8 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
}
|
||||
b2 = body = body->nd_body;
|
||||
|
||||
PUSH_TAG(PROT_FUNC);
|
||||
PUSH_VARS();
|
||||
PUSH_TAG(PROT_FUNC);
|
||||
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
NODE *node = 0;
|
||||
|
|
@ -3598,8 +3648,8 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
|||
result = prot_tag->retval;
|
||||
state = 0;
|
||||
}
|
||||
POP_VARS();
|
||||
POP_TAG();
|
||||
POP_VARS();
|
||||
POP_SCOPE();
|
||||
if (trace_func) {
|
||||
char *file = ruby_frame->prev->file;
|
||||
|
|
@ -3659,13 +3709,14 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
|||
noex = ent->noex;
|
||||
body = ent->method;
|
||||
}
|
||||
else if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
|
||||
else { if (ent->mid) cache_conflict++;
|
||||
if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
|
||||
if (scope == 3) {
|
||||
rb_raise(rb_eNameError, "super: no superclass method `%s'",
|
||||
rb_id2name(mid));
|
||||
}
|
||||
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
||||
}
|
||||
}}
|
||||
|
||||
/* receiver specified form for private method */
|
||||
if ((noex & NOEX_PRIVATE) && scope == 0)
|
||||
|
|
@ -4053,6 +4104,7 @@ eval_under(under, self, src, file, line)
|
|||
{
|
||||
VALUE args[4];
|
||||
|
||||
Check_SafeStr(src);
|
||||
args[0] = self;
|
||||
args[1] = src;
|
||||
args[2] = (VALUE)file;
|
||||
|
|
@ -4071,6 +4123,7 @@ static VALUE
|
|||
yield_under(under, self)
|
||||
VALUE under, self;
|
||||
{
|
||||
rb_secure(3);
|
||||
return exec_under(yield_under_i, under, self);
|
||||
}
|
||||
|
||||
|
|
@ -4187,6 +4240,9 @@ find_file(file)
|
|||
vpath = rb_ary_join(rb_load_path, rb_str_new2(RUBY_LIB_SEP));
|
||||
Check_SafeStr(vpath);
|
||||
path = RSTRING(vpath)->ptr;
|
||||
if (safe_level >= 2) {
|
||||
rb_path_check(path);
|
||||
}
|
||||
}
|
||||
else {
|
||||
path = 0;
|
||||
|
|
@ -4195,9 +4251,9 @@ find_file(file)
|
|||
return dln_find_file(file, path);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_f_load(obj, fname)
|
||||
VALUE obj, fname;
|
||||
void
|
||||
rb_load(fname, priv)
|
||||
VALUE fname, priv;
|
||||
{
|
||||
int state;
|
||||
char *file;
|
||||
|
|
@ -4219,24 +4275,43 @@ rb_f_load(obj, fname)
|
|||
PUSH_VARS();
|
||||
PUSH_TAG(PROT_NONE);
|
||||
PUSH_CLASS();
|
||||
ruby_class = rb_cObject;
|
||||
if (priv == 0 || NIL_P(priv)) {
|
||||
rb_secure(4); /* should alter global state */
|
||||
ruby_class = rb_cObject;
|
||||
}
|
||||
else {
|
||||
switch (TYPE(priv)) {
|
||||
case T_MODULE:
|
||||
case T_CLASS:
|
||||
break;
|
||||
rb_secure(4); /* should alter global state */
|
||||
ruby_class = priv;
|
||||
default:
|
||||
/* load in anonymous module as toplevel */
|
||||
ruby_class = rb_module_new();
|
||||
break;
|
||||
}
|
||||
}
|
||||
PUSH_FRAME();
|
||||
ruby_frame->last_func = 0;
|
||||
ruby_frame->self = rb_top_self;
|
||||
ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,ruby_class,0,0);
|
||||
PUSH_SCOPE();
|
||||
if (top_scope->local_tbl) {
|
||||
if (ruby_class == rb_cObject && top_scope->local_tbl) {
|
||||
int len = top_scope->local_tbl[0]+1;
|
||||
ID *tbl = ALLOC_N(ID, len);
|
||||
VALUE *vars = TMP_ALLOC(VALUE, len);
|
||||
*vars++ = 0;
|
||||
MEMCPY(tbl, top_scope->local_tbl, ID, len);
|
||||
MEMCPY(vars, top_scope->local_vars, ID, len-1);
|
||||
ruby_scope->local_tbl = tbl;
|
||||
ruby_scope->local_vars = vars;
|
||||
ruby_scope->local_tbl = tbl; /* copy toplevel scope */
|
||||
ruby_scope->local_vars = vars; /* will not alter toplevel variables */
|
||||
}
|
||||
/* default visibility is private at loading toplevel */
|
||||
SCOPE_SET(SCOPE_PRIVATE);
|
||||
|
||||
state = EXEC_TAG();
|
||||
last_func = ruby_frame->last_func;
|
||||
ruby_frame->last_func = 0;
|
||||
if (state == 0) {
|
||||
rb_in_eval++;
|
||||
rb_load_file(file);
|
||||
|
|
@ -4246,10 +4321,12 @@ rb_f_load(obj, fname)
|
|||
}
|
||||
}
|
||||
ruby_frame->last_func = last_func;
|
||||
if (ruby_scope->flag == SCOPE_ALLOCA && ruby_scope->local_tbl) {
|
||||
free(ruby_scope->local_tbl);
|
||||
if (ruby_scope->flag == SCOPE_ALLOCA && ruby_class == rb_cObject) {
|
||||
if (ruby_scope->local_tbl) /* toplevel was empty */
|
||||
free(ruby_scope->local_tbl);
|
||||
}
|
||||
POP_SCOPE();
|
||||
POP_FRAME();
|
||||
POP_CLASS();
|
||||
POP_TAG();
|
||||
POP_VARS();
|
||||
|
|
@ -4257,7 +4334,17 @@ rb_f_load(obj, fname)
|
|||
rb_exc_raise(rb_errinfo);
|
||||
}
|
||||
if (state) JUMP_TAG(state);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_load(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE fname, priv;
|
||||
|
||||
rb_scan_args(argc, argv, "11", &fname, &priv);
|
||||
rb_load(fname, priv);
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
|
|
@ -4286,7 +4373,7 @@ rb_provided(feature)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
static int rb_thread_loading _((char*));
|
||||
static void rb_thread_loading_done _((void));
|
||||
#endif
|
||||
|
|
@ -4317,6 +4404,7 @@ rb_f_require(obj, fname)
|
|||
char *ext, *file, *feature, *buf; /* OK */
|
||||
VALUE load;
|
||||
|
||||
rb_secure(4);
|
||||
Check_SafeStr(fname);
|
||||
if (rb_provided(RSTRING(fname)->ptr))
|
||||
return Qfalse;
|
||||
|
|
@ -4365,7 +4453,8 @@ rb_f_require(obj, fname)
|
|||
RSTRING(fname)->ptr);
|
||||
|
||||
dyna_load:
|
||||
#ifdef THREAD
|
||||
rb_secure(2);
|
||||
#ifdef USE_THREAD
|
||||
if (rb_thread_loading(feature)) return Qfalse;
|
||||
else {
|
||||
int state;
|
||||
|
|
@ -4376,7 +4465,7 @@ rb_f_require(obj, fname)
|
|||
file = RSTRING(load)->ptr;
|
||||
dln_load(file);
|
||||
rb_provide(feature);
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
}
|
||||
POP_TAG();
|
||||
rb_thread_loading_done();
|
||||
|
|
@ -4386,16 +4475,16 @@ rb_f_require(obj, fname)
|
|||
return Qtrue;
|
||||
|
||||
rb_load:
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (rb_thread_loading(feature)) return Qfalse;
|
||||
else {
|
||||
int state;
|
||||
PUSH_TAG(PROT_NONE);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
#endif
|
||||
rb_f_load(obj, fname);
|
||||
rb_load(fname, 0);
|
||||
rb_provide(feature);
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
}
|
||||
POP_TAG();
|
||||
rb_thread_loading_done();
|
||||
|
|
@ -4845,7 +4934,7 @@ Init_load()
|
|||
rb_features = rb_ary_new();
|
||||
rb_define_readonly_variable("$\"", &rb_features);
|
||||
|
||||
rb_define_global_function("load", rb_f_load, 1);
|
||||
rb_define_global_function("load", rb_f_load, -1);
|
||||
rb_define_global_function("require", rb_f_require, 1);
|
||||
rb_define_global_function("autoload", rb_f_autoload, 2);
|
||||
}
|
||||
|
|
@ -4952,7 +5041,7 @@ rb_f_binding(self)
|
|||
bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
|
||||
*data = *ruby_block;
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
data->orig_thread = rb_thread_current();
|
||||
#endif
|
||||
data->iter = rb_f_iterator_p();
|
||||
|
|
@ -4995,7 +5084,7 @@ proc_s_new(klass)
|
|||
proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
|
||||
*data = *ruby_block;
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
data->orig_thread = rb_thread_current();
|
||||
#endif
|
||||
data->iter = data->prev?Qtrue:Qfalse;
|
||||
|
|
@ -5042,7 +5131,7 @@ blk_orphan(data)
|
|||
(data->scope->flag & SCOPE_NOSTACK)) {
|
||||
return 1;
|
||||
}
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (data->orig_thread != rb_thread_current()) {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -5363,7 +5452,7 @@ Init_Proc()
|
|||
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
|
||||
}
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
|
||||
static VALUE rb_eThreadError;
|
||||
|
||||
|
|
@ -5440,7 +5529,7 @@ struct thread {
|
|||
|
||||
int safe;
|
||||
|
||||
enum thread_status status;
|
||||
enum thread_status status;
|
||||
int wait_for;
|
||||
int fd;
|
||||
double delay;
|
||||
|
|
@ -5722,7 +5811,7 @@ rb_thread_deadlock()
|
|||
th_raise_argv[0] = rb_exc_new2(rb_eFatal, "Thread: deadlock");
|
||||
th_raise_file = ruby_sourcefile;
|
||||
th_raise_line = ruby_sourceline;
|
||||
rb_f_abort();
|
||||
rb_abort();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -6049,8 +6138,7 @@ rb_thread_select(max, read, write, except, timeout)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_thread_join(dmy, thread)
|
||||
VALUE dmy;
|
||||
rb_thread_join(thread)
|
||||
VALUE thread;
|
||||
{
|
||||
thread_t th = rb_thread_check(thread);
|
||||
|
|
@ -6067,6 +6155,15 @@ rb_thread_join(dmy, thread)
|
|||
return thread;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_thread_s_join(dmy, thread) /* will be removed in 1.2 */
|
||||
VALUE dmy;
|
||||
VALUE thread;
|
||||
{
|
||||
rb_warn("Thread.join is obsolete; use Thread#join instead");
|
||||
return rb_thread_join(thread);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_thread_current()
|
||||
{
|
||||
|
|
@ -6219,7 +6316,8 @@ rb_thread_abort_exc_set(thread, val)
|
|||
}
|
||||
|
||||
static thread_t
|
||||
rb_thread_alloc()
|
||||
rb_thread_alloc(klass)
|
||||
VALUE klass;
|
||||
{
|
||||
thread_t th;
|
||||
|
||||
|
|
@ -6251,7 +6349,7 @@ rb_thread_alloc()
|
|||
th->last_match = 0;
|
||||
th->abort = 0;
|
||||
|
||||
th->thread = Data_Wrap_Struct(rb_cThread, 0, rb_thread_free, th);
|
||||
th->thread = Data_Wrap_Struct(klass, 0, rb_thread_free, th);
|
||||
|
||||
if (curr_thread) {
|
||||
th->prev = curr_thread;
|
||||
|
|
@ -6290,12 +6388,14 @@ static VALUE rb_thread_raise _((int, VALUE*, VALUE));
|
|||
|
||||
#define SCOPE_SHARED FL_USER1
|
||||
|
||||
VALUE
|
||||
rb_thread_create(fn, arg)
|
||||
static VALUE
|
||||
rb_thread_create_0(fn, arg, klass)
|
||||
VALUE (*fn)();
|
||||
void *arg;
|
||||
VALUE klass;
|
||||
{
|
||||
thread_t th = rb_thread_alloc();
|
||||
thread_t th = rb_thread_alloc(klass);
|
||||
enum thread_status status;
|
||||
int state;
|
||||
|
||||
#if defined(HAVE_SETITIMER) && !defined(__BOW__)
|
||||
|
|
@ -6335,8 +6435,9 @@ rb_thread_create(fn, arg)
|
|||
}
|
||||
}
|
||||
POP_TAG();
|
||||
status = th->status;
|
||||
rb_thread_remove();
|
||||
if (state && th->status != THREAD_TO_KILL && !NIL_P(rb_errinfo)) {
|
||||
if (state && status != THREAD_TO_KILL && !NIL_P(rb_errinfo)) {
|
||||
if (state == TAG_FATAL) {
|
||||
/* fatal error within this thread, need to stop whole script */
|
||||
main_thread->rb_errinfo = rb_errinfo;
|
||||
|
|
@ -6360,6 +6461,14 @@ rb_thread_create(fn, arg)
|
|||
return 0; /* not reached */
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_thread_create(fn, arg)
|
||||
VALUE (*fn)();
|
||||
void *arg;
|
||||
{
|
||||
return rb_thread_create_0(fn, arg, rb_cThread);
|
||||
}
|
||||
|
||||
int
|
||||
rb_thread_scope_shared_p()
|
||||
{
|
||||
|
|
@ -6376,12 +6485,13 @@ rb_thread_yield(arg, th)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_thread_start()
|
||||
rb_thread_start(klass)
|
||||
VALUE klass;
|
||||
{
|
||||
if (!rb_iterator_p()) {
|
||||
rb_raise(rb_eThreadError, "must be called as iterator");
|
||||
}
|
||||
return rb_thread_create(rb_thread_yield, 0);
|
||||
return rb_thread_create_0(rb_thread_yield, 0, klass);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
@ -6390,7 +6500,7 @@ rb_thread_value(thread)
|
|||
{
|
||||
thread_t th = rb_thread_check(thread);
|
||||
|
||||
rb_thread_join(0, thread);
|
||||
rb_thread_join(thread);
|
||||
if (!NIL_P(th->rb_errinfo)) {
|
||||
VALUE oldbt = get_backtrace(th->rb_errinfo);
|
||||
VALUE errat = make_backtrace();
|
||||
|
|
@ -6582,7 +6692,7 @@ Init_Thread()
|
|||
rb_define_singleton_method(rb_cThread, "kill", rb_thread_s_kill, 1);
|
||||
rb_define_singleton_method(rb_cThread, "exit", rb_thread_exit, 0);
|
||||
rb_define_singleton_method(rb_cThread, "pass", rb_thread_pass, 0);
|
||||
rb_define_singleton_method(rb_cThread, "join", rb_thread_join, 1);
|
||||
rb_define_singleton_method(rb_cThread, "join", rb_thread_s_join, 1);
|
||||
rb_define_singleton_method(rb_cThread, "current", rb_thread_current, 0);
|
||||
rb_define_singleton_method(rb_cThread, "main", rb_thread_main, 0);
|
||||
|
||||
|
|
@ -6597,6 +6707,7 @@ Init_Thread()
|
|||
rb_define_method(rb_cThread, "exit", rb_thread_kill, 0);
|
||||
rb_define_method(rb_cThread, "value", rb_thread_value, 0);
|
||||
rb_define_method(rb_cThread, "status", rb_thread_status, 0);
|
||||
rb_define_method(rb_cThread, "join", rb_thread_join, 0);
|
||||
rb_define_method(rb_cThread, "alive?", rb_thread_status, 0);
|
||||
rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0);
|
||||
rb_define_method(rb_cThread, "raise", rb_thread_raise, -1);
|
||||
|
|
@ -6605,7 +6716,7 @@ Init_Thread()
|
|||
rb_define_method(rb_cThread, "abort_on_exception=", rb_thread_abort_exc_set, 1);
|
||||
|
||||
/* allocate main thread */
|
||||
main_thread = rb_thread_alloc();
|
||||
main_thread = rb_thread_alloc(rb_cThread);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -6665,7 +6776,7 @@ rb_f_throw(argc, argv)
|
|||
tt->dst = t;
|
||||
break;
|
||||
}
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (tt->tag == PROT_THREAD) {
|
||||
rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%x",
|
||||
rb_id2name(t),
|
||||
|
|
@ -6699,7 +6810,7 @@ rb_throw(tag, val)
|
|||
static void
|
||||
return_check()
|
||||
{
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
struct tag *tt = prot_tag;
|
||||
|
||||
while (tt) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def extract(nm, out)
|
|||
else
|
||||
next
|
||||
end
|
||||
}.sort!
|
||||
}.compact!.sort!
|
||||
uniq(data)
|
||||
exp = open(out, "w")
|
||||
for line in data
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
VALUE cDBM;
|
||||
|
||||
extern VALUE rb_mEnumerable;
|
||||
|
||||
struct dbmdata {
|
||||
int di_size;
|
||||
DBM *di_dbm;
|
||||
|
|
@ -48,10 +46,10 @@ free_dbm(dbmp)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
fdbm_s_open(argc, argv, class)
|
||||
fdbm_s_open(argc, argv, klass)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE class;
|
||||
VALUE klass;
|
||||
{
|
||||
VALUE file, vmode;
|
||||
DBM *dbm;
|
||||
|
|
@ -83,7 +81,7 @@ fdbm_s_open(argc, argv, class)
|
|||
rb_sys_fail(RSTRING(file)->ptr);
|
||||
}
|
||||
|
||||
obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp);
|
||||
obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp);
|
||||
dbmp->di_dbm = dbm;
|
||||
dbmp->di_size = -1;
|
||||
rb_obj_call_init(obj);
|
||||
|
|
@ -546,6 +544,7 @@ fdbm_to_a(obj)
|
|||
return ary;
|
||||
}
|
||||
|
||||
void
|
||||
Init_dbm()
|
||||
{
|
||||
cDBM = rb_define_class("DBM", rb_cObject);
|
||||
|
|
|
|||
|
|
@ -239,7 +239,10 @@ Init_etc()
|
|||
|
||||
sPasswd = rb_struct_define("Passwd",
|
||||
"name", "passwd", "uid", "gid",
|
||||
"gecos", "dir", "shell",
|
||||
#ifdef PW_GECOS
|
||||
"gecos",
|
||||
#endif
|
||||
"dir", "shell",
|
||||
#ifdef PW_CHANGE
|
||||
"change",
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,8 +1,31 @@
|
|||
require 'mkmf'
|
||||
|
||||
def etc_grep_header(field)
|
||||
f = open("conftest.c", "w")
|
||||
f.print <<EOF
|
||||
#include <pwd.h>
|
||||
EOF
|
||||
f.close
|
||||
begin
|
||||
if xsystem("#{CPP} | egrep #{field}")
|
||||
$defs.push(format("-D%s", field.upcase))
|
||||
end
|
||||
ensure
|
||||
system "rm -f conftest.c"
|
||||
end
|
||||
end
|
||||
|
||||
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
|
||||
a = have_func("getlogin")
|
||||
b = have_func("getpwent")
|
||||
c = have_func("getgrent")
|
||||
if a or b or c
|
||||
etc_grep_header("pw_gecos")
|
||||
etc_grep_header("pw_change")
|
||||
etc_grep_header("pw_quota")
|
||||
etc_grep_header("pw_age")
|
||||
etc_grep_header("pw_class")
|
||||
etc_grep_header("pw_comment")
|
||||
etc_grep_header("pw_expire")
|
||||
create_makefile("etc")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#! /usr/local/bin/ruby
|
||||
|
||||
$".push 'mkmf.rb' #"
|
||||
load '../lib/find.rb'
|
||||
|
||||
if ARGV[0] == 'static'
|
||||
$force_static = TRUE
|
||||
|
|
@ -93,6 +94,24 @@ def try_cpp
|
|||
xsystem(format(CPP, $CFLAGS))
|
||||
end
|
||||
|
||||
def install_rb(mfile)
|
||||
path = []
|
||||
dir = []
|
||||
Find.find("lib") do |f|
|
||||
next unless /\.rb$/ =~ f
|
||||
f = f[4..-1]
|
||||
path.push f
|
||||
dir |= File.dirname(f)
|
||||
end
|
||||
for f in dir
|
||||
next if f == "."
|
||||
mfile.printf "\t@test -d $(libdir)/%s || mkdir $(libdir)/%s\n", f, f
|
||||
end
|
||||
for f in path
|
||||
mfile.printf "\t$(INSTALL_DATA) lib/%s $(libdir)/%s\n", f, f
|
||||
end
|
||||
end
|
||||
|
||||
def have_library(lib, func)
|
||||
if $lib_cache[lib]
|
||||
if $lib_cache[lib] == "yes"
|
||||
|
|
@ -263,7 +282,8 @@ RUBY_INSTALL_NAME = `t='$(program_transform_name)'; echo ruby | sed $$t`
|
|||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
libdir = @libdir@/$(RUBY_INSTALL_NAME)/@arch@
|
||||
libdir = @libdir@/$(RUBY_INSTALL_NAME)
|
||||
archdir = $(libdir)/@arch@
|
||||
@SET_MAKE@
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
|
@ -299,24 +319,29 @@ clean:; @rm -f *.o *.so *.sl
|
|||
|
||||
realclean: clean
|
||||
", target,
|
||||
if $static then "o" else "@DLEXT@" end, $dots, $dots
|
||||
if $static then "a" else "@DLEXT@" end, $dots, $dots
|
||||
|
||||
mfile.printf "\
|
||||
|
||||
install:
|
||||
@test -d $(libdir) || mkdir $(libdir)
|
||||
@test -d $(archdir) || mkdir $(archdir)
|
||||
"
|
||||
if !$static
|
||||
mfile.printf "\
|
||||
@test -d $(libdir) || mkdir $(libdir)
|
||||
$(INSTALL) $(TARGET) $(libdir)/$(TARGET)
|
||||
$(INSTALL) $(TARGET) $(archdir)/$(TARGET)
|
||||
"
|
||||
end
|
||||
for rb in Dir["lib/*.rb"]
|
||||
mfile.printf "\t$(INSTALL_DATA) %s @libdir@/$(RUBY_INSTALL_NAME)\n", rb
|
||||
end
|
||||
install_rb(mfile)
|
||||
mfile.printf "\n"
|
||||
|
||||
if !$static && "@DLEXT@" != "o"
|
||||
if $static
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
@AR@ cru $(TARGET) $(OBJS)
|
||||
@-@RANLIB@ $(LIBRUBY) 2> /dev/null || true
|
||||
"
|
||||
elsif "@DLEXT@" != "o"
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
$(LDSHARED) $(DLDFLAGS) -o $(TARGET) $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
||||
|
|
@ -327,25 +352,10 @@ $(TARGET): $(OBJS)
|
|||
$(TARGET): $(OBJS)
|
||||
ar cru $(TARGET) $(OBJS)
|
||||
"
|
||||
elsif PLATFORM =~ "-nextstep"
|
||||
elsif PLATFORM =~ "-nextstep" || PLATFORM =~ "-openstep" || PLATFORM =~ "-rhapsody"
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
cc -r $(CFLAGS) -o $(TARGET) $(OBJS)
|
||||
"
|
||||
elsif PLATFORM =~ "-openstep"
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
cc -r $(CFLAGS) -o $(TARGET) $(OBJS)
|
||||
"
|
||||
elsif PLATFORM =~ "-rhapsody"
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
cc -r $(CFLAGS) -o $(TARGET) $(OBJS)
|
||||
"
|
||||
elsif $static
|
||||
mfile.printf "\
|
||||
$(TARGET): $(OBJS)
|
||||
ld -r -o $(TARGET) $(OBJS)
|
||||
"
|
||||
else
|
||||
mfile.printf "\
|
||||
|
|
@ -486,7 +496,7 @@ exit if $install or $clean
|
|||
$extinit = "" unless $extinit
|
||||
if $extlist.size > 0
|
||||
for s,t in $extlist
|
||||
f = format("%s/%s.o", s, t)
|
||||
f = format("%s/%s.a", s, t)
|
||||
if File.exist?(f)
|
||||
$extinit += format("\
|
||||
\tInit_%s();\n\
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
MANIFEST
|
||||
ENVIRONMENT
|
||||
extconf.rb
|
||||
gtk.c
|
||||
test.rb
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
require "mkmf"
|
||||
|
||||
# may need to be changed
|
||||
$LDFLAGS=`gtk-config --libs`.chomp!
|
||||
$CFLAGS=`gtk-config --cflags`.chomp!
|
||||
begin
|
||||
$LDFLAGS, *libs = `gtk-config --libs`.chomp!.split(/(-l.*)/)
|
||||
$libs = libs.join(' ') + ' ' + $libs
|
||||
$CFLAGS=`gtk-config --cflags`.chomp!
|
||||
rescue
|
||||
$LDFLAGS = '-L/usr/X11R6/lib -L/usr/local/lib'
|
||||
$CFLAGS = '-I/usr/X11R6/lib -I/usr/local/include'
|
||||
$libs = '-lm -lc'
|
||||
end
|
||||
|
||||
have_library("X11", "XOpenDisplay")
|
||||
have_library("Xext", "XShmQueryVersion")
|
||||
|
|
@ -10,5 +17,6 @@ have_library("Xi", "XOpenDevice")
|
|||
if have_library("glib", "g_print") and
|
||||
have_library("gdk", "gdk_init") and
|
||||
have_library("gtk", "gtk_init")
|
||||
$libs = $libs.split(/\s/).uniq.join(' ')
|
||||
create_makefile("gtk")
|
||||
end
|
||||
|
|
|
|||
636
ext/gtk/gtk.c
636
ext/gtk/gtk.c
File diff suppressed because it is too large
Load diff
|
|
@ -1891,10 +1891,15 @@ static VALUE
|
|||
kconv_guess(obj, src)
|
||||
VALUE obj, src;
|
||||
{
|
||||
unsigned char *p = RSTRING(src)->ptr;
|
||||
unsigned char *pend = p + RSTRING(src)->len;
|
||||
unsigned char *p;
|
||||
unsigned char *pend;
|
||||
int sequence_counter = 0;
|
||||
|
||||
Check_Type(src, T_STRING);
|
||||
|
||||
p = RSTRING(src)->ptr;
|
||||
pend = p + RSTRING(src)->len;
|
||||
|
||||
#define INCR do {\
|
||||
p++;\
|
||||
if (p==pend) return INT2FIX(_UNKNOWN);\
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extern int rb_thread_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); /*
|
|||
# include <GUSI.h>
|
||||
#endif
|
||||
|
||||
#if defined(THREAD) && defined(HAVE_FCNTL)
|
||||
#if defined(USE_THREAD) && defined(HAVE_FCNTL)
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
|
@ -72,9 +72,12 @@ static void
|
|||
sock_finalize(fptr)
|
||||
OpenFile *fptr;
|
||||
{
|
||||
SOCKET s = fileno(fptr->f);
|
||||
SOCKET s;
|
||||
|
||||
if (!fptr->f) return;
|
||||
s = fileno(fptr->f);
|
||||
free(fptr->f);
|
||||
free(fptr->f2);
|
||||
if (fptr->f2) free(fptr->f2);
|
||||
closesocket(s);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -129,6 +132,55 @@ bsock_shutdown(argc, argv, sock)
|
|||
return INT2FIX(0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bsock_close_read(sock)
|
||||
VALUE sock;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
|
||||
rb_secure(4);
|
||||
GetOpenFile(sock, fptr);
|
||||
if (fptr->f2 == 0) {
|
||||
return rb_io_close(sock);
|
||||
}
|
||||
if (shutdown(fileno(fptr->f), 0) == -1)
|
||||
rb_sys_fail(0);
|
||||
fptr->mode &= ~FMODE_READABLE;
|
||||
#ifdef NT
|
||||
free(fptr->f);
|
||||
#else
|
||||
fclose(fptr->f);
|
||||
#endif
|
||||
fptr->f = fptr->f2;
|
||||
fptr->f2 = 0;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bsock_close_write(sock)
|
||||
VALUE sock;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
|
||||
rb_secure(4);
|
||||
GetOpenFile(sock, fptr);
|
||||
if (fptr->f2 == 0) {
|
||||
return rb_io_close(sock);
|
||||
}
|
||||
if (shutdown(fileno(fptr->f), 1) == -1)
|
||||
rb_sys_fail(0);
|
||||
fptr->mode &= ~FMODE_WRITABLE;
|
||||
#ifdef NT
|
||||
free(fptr->f2);
|
||||
#else
|
||||
fclose(fptr->f2);
|
||||
#endif
|
||||
fptr->f2 = 0;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
bsock_setsockopt(sock, lev, optname, val)
|
||||
VALUE sock, lev, optname, val;
|
||||
|
|
@ -235,10 +287,10 @@ bsock_send(argc, argv, sock)
|
|||
rb_scan_args(argc, argv, "21", &msg, &flags, &to);
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
f = fptr->f2?fptr->f2:fptr->f;
|
||||
f = GetWriteFile(fptr);
|
||||
fd = fileno(f);
|
||||
retry:
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_fd_writable(fd);
|
||||
#endif
|
||||
m = rb_str2cstr(msg, &mlen);
|
||||
|
|
@ -257,7 +309,7 @@ bsock_send(argc, argv, sock)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -303,7 +355,7 @@ s_recv(sock, argc, argv, from)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fd = fileno(fptr->f);
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_wait_fd(fd);
|
||||
#endif
|
||||
TRAP_BEG;
|
||||
|
|
@ -319,7 +371,7 @@ s_recv(sock, argc, argv, from)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -449,7 +501,7 @@ setipaddr(name, addr)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(THREAD) && defined(HAVE_FCNTL)
|
||||
#if defined(USE_THREAD) && defined(HAVE_FCNTL)
|
||||
static int
|
||||
thread_connect(fd, sockaddr, len, type)
|
||||
int fd;
|
||||
|
|
@ -607,7 +659,7 @@ open_inet(class, h, serv, type)
|
|||
syscall = "bind(2)";
|
||||
}
|
||||
else {
|
||||
#if defined(THREAD) && defined(HAVE_FCNTL)
|
||||
#if defined(USE_THREAD) && defined(HAVE_FCNTL)
|
||||
status = thread_connect(fd, (struct sockaddr*)&sockaddr,
|
||||
sizeof(sockaddr), type);
|
||||
#else
|
||||
|
|
@ -726,7 +778,7 @@ s_accept(class, fd, sockaddr, len)
|
|||
int fd2;
|
||||
|
||||
retry:
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_wait_fd(fd);
|
||||
#endif
|
||||
TRAP_BEG;
|
||||
|
|
@ -739,7 +791,7 @@ s_accept(class, fd, sockaddr, len)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -927,7 +979,7 @@ udp_connect(sock, host, port)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -974,7 +1026,7 @@ udp_send(argc, argv, sock)
|
|||
|
||||
udp_addrsetup(host, port, &addr);
|
||||
GetOpenFile(sock, fptr);
|
||||
f = fptr->f2?fptr->f2:fptr->f;
|
||||
f = GetWriteFile(fptr);
|
||||
m = rb_str2cstr(mesg, &mlen);
|
||||
retry:
|
||||
n = sendto(fileno(f), m, mlen, NUM2INT(flags),
|
||||
|
|
@ -986,7 +1038,7 @@ udp_send(argc, argv, sock)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -1239,7 +1291,7 @@ sock_connect(sock, addr)
|
|||
#if EAGAIN != EWOULDBLOCK
|
||||
case EAGAIN:
|
||||
#endif
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
|
|
@ -1469,6 +1521,8 @@ Init_socket()
|
|||
rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
|
||||
rb_undef_method(CLASS_OF(rb_cBasicSocket), "new");
|
||||
rb_undef_method(CLASS_OF(rb_cBasicSocket), "open");
|
||||
rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
|
||||
rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
|
||||
rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1);
|
||||
rb_define_method(rb_cBasicSocket, "setsockopt", bsock_setsockopt, 3);
|
||||
rb_define_method(rb_cBasicSocket, "getsockopt", bsock_getsockopt, 2);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ $includes = []
|
|||
def search_header(include, *path)
|
||||
pwd = Dir.getwd
|
||||
begin
|
||||
for i in path.reverse!
|
||||
for i in path.sort!.reverse!
|
||||
dir = Dir[i]
|
||||
for path in dir
|
||||
next unless File.directory? path
|
||||
Dir.chdir path
|
||||
files = Dir[include]
|
||||
if files.size > 0
|
||||
|
|
@ -30,14 +31,14 @@ def search_header(include, *path)
|
|||
end
|
||||
|
||||
search_header("tcl.h",
|
||||
"/usr/include/tcl*",
|
||||
"/usr/include/tcl{,8*,7*}",
|
||||
"/usr/include",
|
||||
"/usr/local/include/tcl*",
|
||||
"/usr/local/include/tcl{,8*,7*}",
|
||||
"/usr/local/include")
|
||||
search_header("tk.h",
|
||||
"/usr/include/tk*",
|
||||
"/usr/include/tk{,8*,4*}",
|
||||
"/usr/include",
|
||||
"/usr/local/include/tk*",
|
||||
"/usr/local/include/tk{,8*,4*}",
|
||||
"/usr/local/include")
|
||||
search_header("X11/Xlib.h",
|
||||
"/usr/include/X11*",
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ void _timer_for_tcl (ClientData clientData)
|
|||
|
||||
timer->flag = 0;
|
||||
CHECK_INTS;
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (!rb_thread_critical) rb_thread_schedule();
|
||||
#endif
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ lib_mainloop(VALUE self)
|
|||
}
|
||||
DUMP1("stop Tk_Mainloop");
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (timer->flag) {
|
||||
Tk_DeleteTimerHandler(timer->token);
|
||||
}
|
||||
|
|
|
|||
10
file.c
10
file.c
|
|
@ -115,6 +115,7 @@ rb_file_reopen(argc, argv, file)
|
|||
char *mode;
|
||||
OpenFile *fptr;
|
||||
|
||||
rb_secure(2);
|
||||
if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
|
||||
if (TYPE(fname) == T_FILE) { /* fname must be IO */
|
||||
return rb_io_reopen(file, fname);
|
||||
|
|
@ -234,9 +235,10 @@ rb_stat(file, st)
|
|||
VALUE file;
|
||||
struct stat *st;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
|
||||
if (TYPE(file) == T_FILE) {
|
||||
OpenFile *fptr;
|
||||
|
||||
rb_secure(2);
|
||||
GetOpenFile(file, fptr);
|
||||
return fstat(fileno(fptr->f), st);
|
||||
}
|
||||
|
|
@ -296,6 +298,7 @@ rb_file_lstat(obj)
|
|||
OpenFile *fptr;
|
||||
struct stat st;
|
||||
|
||||
rb_secure(2);
|
||||
GetOpenFile(obj, fptr);
|
||||
if (lstat(fptr->path, &st) == -1) {
|
||||
rb_sys_fail(fptr->path);
|
||||
|
|
@ -1106,6 +1109,7 @@ rb_file_s_umask(argc, argv)
|
|||
#else
|
||||
int omask = 0;
|
||||
|
||||
rb_secure(2);
|
||||
if (argc == 0) {
|
||||
omask = umask(0);
|
||||
umask(omask);
|
||||
|
|
@ -1382,7 +1386,7 @@ rb_file_truncate(obj, len)
|
|||
# define LOCK_UN 8
|
||||
# endif
|
||||
|
||||
#if defined(THREAD) && defined(EWOULDBLOCK)
|
||||
#if defined(USE_THREAD) && defined(EWOULDBLOCK)
|
||||
static int
|
||||
rb_thread_flock(fd, op)
|
||||
int fd, op;
|
||||
|
|
|
|||
62
gc.c
62
gc.c
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
************************************************/
|
||||
|
||||
#define RUBY_NO_INLINE
|
||||
#include "ruby.h"
|
||||
#include "rubysig.h"
|
||||
#include "st.h"
|
||||
|
|
@ -302,8 +303,8 @@ looks_pointerp(ptr)
|
|||
|
||||
static void
|
||||
mark_locations_array(x, n)
|
||||
VALUE *x;
|
||||
long n;
|
||||
register VALUE *x;
|
||||
register long n;
|
||||
{
|
||||
while (n--) {
|
||||
if (looks_pointerp(*x)) {
|
||||
|
|
@ -399,6 +400,9 @@ rb_gc_mark(ptr)
|
|||
case NODE_FOR:
|
||||
case NODE_ITER:
|
||||
case NODE_CREF:
|
||||
case NODE_WHEN:
|
||||
case NODE_MASGN:
|
||||
case NODE_RESBODY:
|
||||
rb_gc_mark(obj->as.node.u2.node);
|
||||
/* fall through */
|
||||
case NODE_BLOCK: /* 1,3 */
|
||||
|
|
@ -409,7 +413,10 @@ rb_gc_mark(ptr)
|
|||
case NODE_DREGX:
|
||||
case NODE_DREGX_ONCE:
|
||||
case NODE_FBODY:
|
||||
case NODE_ENSURE:
|
||||
case NODE_CALL:
|
||||
case NODE_DEFS:
|
||||
case NODE_OP_ASGN1:
|
||||
#ifdef C_ALLOCA
|
||||
case NODE_ALLOCA:
|
||||
#endif
|
||||
|
|
@ -417,23 +424,41 @@ rb_gc_mark(ptr)
|
|||
/* fall through */
|
||||
case NODE_SUPER: /* 3 */
|
||||
case NODE_FCALL:
|
||||
case NODE_DEFN:
|
||||
case NODE_NEWLINE:
|
||||
obj = RANY(obj->as.node.u3.node);
|
||||
goto Top;
|
||||
|
||||
case NODE_WHILE: /* 1,2 */
|
||||
case NODE_UNTIL:
|
||||
case NODE_AND:
|
||||
case NODE_OR:
|
||||
case NODE_CASE:
|
||||
case NODE_RESCUE:
|
||||
case NODE_ARGS:
|
||||
case NODE_DOT2:
|
||||
case NODE_DOT3:
|
||||
case NODE_FLIP2:
|
||||
case NODE_FLIP3:
|
||||
case NODE_MATCH2:
|
||||
case NODE_MATCH3:
|
||||
case NODE_SCLASS:
|
||||
rb_gc_mark(obj->as.node.u1.node);
|
||||
/* fall through */
|
||||
case NODE_METHOD: /* 2 */
|
||||
case NODE_MODULE:
|
||||
case NODE_NOT:
|
||||
case NODE_GASGN:
|
||||
case NODE_LASGN:
|
||||
case NODE_DASGN:
|
||||
case NODE_DASGN_PUSH:
|
||||
case NODE_IASGN:
|
||||
case NODE_CASGN:
|
||||
case NODE_OP_ASGN_OR:
|
||||
case NODE_OP_ASGN_AND:
|
||||
case NODE_COLON3:
|
||||
case NODE_OPT_N:
|
||||
case NODE_BLOCK_PASS:
|
||||
obj = RANY(obj->as.node.u2.node);
|
||||
goto Top;
|
||||
|
||||
|
|
@ -443,15 +468,20 @@ rb_gc_mark(ptr)
|
|||
case NODE_XSTR:
|
||||
case NODE_DEFINED:
|
||||
case NODE_MATCH:
|
||||
case NODE_RETURN:
|
||||
case NODE_YIELD:
|
||||
case NODE_COLON2:
|
||||
obj = RANY(obj->as.node.u1.node);
|
||||
goto Top;
|
||||
|
||||
case NODE_SCOPE: /* 2,3 */
|
||||
case NODE_CLASS:
|
||||
rb_gc_mark(obj->as.node.u3.node);
|
||||
obj = RANY(obj->as.node.u2.node);
|
||||
goto Top;
|
||||
|
||||
case NODE_ZARRAY: /* - */
|
||||
case NODE_ZSUPER:
|
||||
case NODE_CFUNC:
|
||||
case NODE_VCALL:
|
||||
case NODE_GVAR:
|
||||
|
|
@ -463,9 +493,17 @@ rb_gc_mark(ptr)
|
|||
case NODE_BACK_REF:
|
||||
case NODE_ALIAS:
|
||||
case NODE_VALIAS:
|
||||
case NODE_BREAK:
|
||||
case NODE_NEXT:
|
||||
case NODE_REDO:
|
||||
case NODE_RETRY:
|
||||
case NODE_UNDEF:
|
||||
case NODE_SELF:
|
||||
case NODE_NIL:
|
||||
case NODE_TRUE:
|
||||
case NODE_FALSE:
|
||||
case NODE_ATTRSET:
|
||||
case NODE_BLOCK_ARG:
|
||||
case NODE_POSTEXE:
|
||||
break;
|
||||
|
||||
|
|
@ -487,11 +525,6 @@ rb_gc_mark(ptr)
|
|||
rb_gc_mark(obj->as.basic.klass);
|
||||
switch (obj->as.basic.flags & T_MASK) {
|
||||
case T_ICLASS:
|
||||
rb_gc_mark(obj->as.klass.super);
|
||||
mark_tbl(obj->as.klass.iv_tbl);
|
||||
mark_tbl(obj->as.klass.m_tbl);
|
||||
break;
|
||||
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
rb_gc_mark(obj->as.klass.super);
|
||||
|
|
@ -691,12 +724,9 @@ obj_free(obj)
|
|||
if ((long)RANY(obj)->as.data.dfree == -1) {
|
||||
free(DATA_PTR(obj));
|
||||
}
|
||||
if (RANY(obj)->as.data.dfree) {
|
||||
else if (RANY(obj)->as.data.dfree) {
|
||||
(*RANY(obj)->as.data.dfree)(DATA_PTR(obj));
|
||||
}
|
||||
else {
|
||||
free(DATA_PTR(obj));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case T_MATCH:
|
||||
|
|
@ -753,13 +783,7 @@ void
|
|||
rb_gc_mark_frame(frame)
|
||||
struct FRAME *frame;
|
||||
{
|
||||
int n = frame->argc;
|
||||
VALUE *tbl = frame->argv;
|
||||
|
||||
while (n--) {
|
||||
rb_gc_mark_maybe(*tbl);
|
||||
tbl++;
|
||||
}
|
||||
mark_locations_array(frame->argv, frame->argc);
|
||||
rb_gc_mark(frame->cbase);
|
||||
}
|
||||
|
||||
|
|
@ -835,7 +859,7 @@ rb_gc()
|
|||
(VALUE*)((char*)&stack_end + 2));
|
||||
#endif
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_gc_mark_threads();
|
||||
#endif
|
||||
|
||||
|
|
|
|||
9
hash.c
9
hash.c
|
|
@ -28,7 +28,6 @@ static void
|
|||
rb_hash_modify(hash)
|
||||
VALUE hash;
|
||||
{
|
||||
rb_secure(5);
|
||||
if (FL_TEST(hash, HASH_FREEZE)) {
|
||||
rb_raise(rb_eTypeError, "can't modify frozen hash");
|
||||
}
|
||||
|
|
@ -899,8 +898,8 @@ path_check_1(path)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
path_check(path)
|
||||
void
|
||||
rb_path_check(path)
|
||||
char *path;
|
||||
{
|
||||
char *p = path;
|
||||
|
|
@ -934,7 +933,7 @@ int
|
|||
rb_env_path_tainted()
|
||||
{
|
||||
if (path_tainted < 0) {
|
||||
path_check(getenv("PATH"));
|
||||
rb_path_check(getenv("PATH"));
|
||||
}
|
||||
return path_tainted;
|
||||
}
|
||||
|
|
@ -967,7 +966,7 @@ rb_f_setenv(obj, name, value)
|
|||
return Qtrue;
|
||||
}
|
||||
|
||||
path_check(RSTRING(name)->ptr);
|
||||
rb_path_check(RSTRING(name)->ptr);
|
||||
}
|
||||
return Qtrue;
|
||||
}
|
||||
|
|
|
|||
2
inits.c
2
inits.c
|
|
@ -54,7 +54,7 @@ rb_call_inits()
|
|||
Init_eval();
|
||||
Init_String();
|
||||
Init_Exception();
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
Init_Thread();
|
||||
#endif
|
||||
Init_Numeric();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ File.install "ruby#{binsuffix}",
|
|||
for dll in Dir['*.dll']
|
||||
File.install dll, "#{bindir}/#{dll}", 0755, TRUE
|
||||
end
|
||||
File.makedirs "#{prefix}/lib", TRUE
|
||||
for lib in ["libruby.so", "libruby.so.LIB"]
|
||||
if File.exist? lib
|
||||
File.install lib, "#{prefix}/lib", 0644, TRUE
|
||||
|
|
|
|||
16
intern.h
16
intern.h
|
|
@ -80,7 +80,7 @@ VALUE rb_singleton_class _((VALUE));
|
|||
VALUE rb_enum_length _((VALUE));
|
||||
/* error.c */
|
||||
extern int ruby_nerrs;
|
||||
VALUE rb_exc_new _((VALUE, char*, unsigned int));
|
||||
VALUE rb_exc_new _((VALUE, char*, int));
|
||||
VALUE rb_exc_new2 _((VALUE, char*));
|
||||
VALUE rb_exc_new3 _((VALUE, VALUE));
|
||||
void rb_loaderror __((char*, ...)) NORETURN;
|
||||
|
|
@ -108,7 +108,7 @@ VALUE rb_apply _((VALUE, ID, VALUE));
|
|||
VALUE rb_funcall2 _((VALUE, ID, int, VALUE*));
|
||||
void rb_backtrace _((void));
|
||||
ID rb_frame_last_func _((void));
|
||||
VALUE rb_f_load _((VALUE, VALUE));
|
||||
void rb_load _((VALUE, VALUE));
|
||||
void rb_provide _((char*));
|
||||
VALUE rb_f_require _((VALUE, VALUE));
|
||||
void rb_obj_call_init _((VALUE));
|
||||
|
|
@ -137,15 +137,16 @@ void rb_global_variable _((VALUE*));
|
|||
void rb_gc_mark_locations _((VALUE*, VALUE*));
|
||||
void rb_gc_mark_maybe();
|
||||
void rb_gc_mark();
|
||||
void rb_gc_force_recycle();
|
||||
void rb_gc_force_recycle _((VALUE));
|
||||
void rb_gc _((void));
|
||||
void rb_gc_call_finalizer_at_exit _((void));
|
||||
/* hash.c */
|
||||
VALUE rb_hash_freeze _((VALUE));
|
||||
VALUE rb_hash _((VALUE));
|
||||
VALUE rb_hash_new _((void));
|
||||
VALUE rb_hash_freeze _((VALUE));
|
||||
VALUE rb_hash_aref _((VALUE, VALUE));
|
||||
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
|
||||
void rb_path_check _((char *));
|
||||
int rb_env_path_tainted _((void));
|
||||
/* io.c */
|
||||
extern VALUE rb_fs;
|
||||
|
|
@ -154,7 +155,6 @@ extern VALUE rb_rs;
|
|||
extern VALUE rb_default_rs;
|
||||
extern VALUE rb_output_rs;
|
||||
VALUE rb_io_write _((VALUE, VALUE));
|
||||
VALUE rb_io_gets_method _((int, VALUE*, VALUE));
|
||||
VALUE rb_io_gets _((VALUE));
|
||||
VALUE rb_io_getc _((VALUE));
|
||||
VALUE rb_io_ungetc _((VALUE, VALUE));
|
||||
|
|
@ -162,7 +162,7 @@ VALUE rb_io_close _((VALUE));
|
|||
VALUE rb_io_binmode _((VALUE));
|
||||
int rb_io_mode_flags _((char*));
|
||||
VALUE rb_io_reopen _((VALUE, VALUE));
|
||||
VALUE rb_f_gets _((void));
|
||||
VALUE rb_gets _((void));
|
||||
void rb_str_setter _((VALUE, ID, VALUE*));
|
||||
/* numeric.c */
|
||||
void rb_num_zerodiv _((void));
|
||||
|
|
@ -239,7 +239,7 @@ void rb_trap_exec _((void));
|
|||
/* sprintf.c */
|
||||
VALUE rb_f_sprintf _((int, VALUE*));
|
||||
/* string.c */
|
||||
VALUE rb_str_new _((char*, unsigned int));
|
||||
VALUE rb_str_new _((char*, int));
|
||||
VALUE rb_str_new2 _((char*));
|
||||
VALUE rb_str_new3 _((VALUE));
|
||||
VALUE rb_str_new4 _((VALUE));
|
||||
|
|
@ -255,7 +255,7 @@ VALUE rb_str_dup_frozen _((VALUE));
|
|||
VALUE rb_str_taint _((VALUE));
|
||||
VALUE rb_str_tainted _((VALUE));
|
||||
VALUE rb_str_resize _((VALUE, int));
|
||||
VALUE rb_str_cat _((VALUE, char*, unsigned int));
|
||||
VALUE rb_str_cat _((VALUE, char*, int));
|
||||
VALUE rb_str_concat _((VALUE, VALUE));
|
||||
int rb_str_hash _((VALUE));
|
||||
int rb_str_cmp _((VALUE, VALUE));
|
||||
|
|
|
|||
177
io.c
177
io.c
|
|
@ -104,7 +104,7 @@ extern int ReadDataPending();
|
|||
# define READ_DATA_PENDING(fp) ReadDataPending(fp)
|
||||
#endif
|
||||
|
||||
#ifndef THREAD
|
||||
#ifndef USE_THREAD
|
||||
# define READ_CHECK(fp) 0
|
||||
#else
|
||||
# define READ_CHECK(fp) do {\
|
||||
|
|
@ -165,7 +165,6 @@ rb_io_write(io, str)
|
|||
rb_secure(4);
|
||||
GetOpenFile(io, fptr);
|
||||
rb_io_check_writable(fptr);
|
||||
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
#ifdef __human68k__
|
||||
|
|
@ -436,8 +435,8 @@ rb_io_read(argc, argv, io)
|
|||
return rb_str_taint(str);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_io_gets_method(argc, argv, io)
|
||||
static VALUE
|
||||
rb_io_gets_internal(argc, argv, io)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE io;
|
||||
|
|
@ -571,7 +570,6 @@ rb_io_gets_method(argc, argv, io)
|
|||
lineno = INT2FIX(fptr->lineno);
|
||||
rb_str_taint(str);
|
||||
}
|
||||
rb_lastline_set(str);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
@ -630,11 +628,24 @@ rb_io_gets(io)
|
|||
lineno = INT2FIX(fptr->lineno);
|
||||
rb_str_taint(str);
|
||||
}
|
||||
rb_lastline_set(str);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_gets_method(argc, argv, io)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE io;
|
||||
{
|
||||
VALUE str = rb_io_gets_internal(argc, argv, io);
|
||||
|
||||
if (!NIL_P(str)) {
|
||||
rb_lastline_set(str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_lineno(io)
|
||||
VALUE io;
|
||||
|
|
@ -690,7 +701,7 @@ rb_io_readlines(argc, argv, io)
|
|||
VALUE line, ary;
|
||||
|
||||
ary = rb_ary_new();
|
||||
while (!NIL_P(line = rb_io_gets_method(argc, argv, io))) {
|
||||
while (!NIL_P(line = rb_io_gets_internal(argc, argv, io))) {
|
||||
rb_ary_push(ary, line);
|
||||
}
|
||||
return ary;
|
||||
|
|
@ -704,7 +715,7 @@ rb_io_each_line(argc, argv, io)
|
|||
{
|
||||
VALUE str;
|
||||
|
||||
while (!NIL_P(str = rb_io_gets_method(argc, argv, io))) {
|
||||
while (!NIL_P(str = rb_io_gets_internal(argc, argv, io))) {
|
||||
rb_yield(str);
|
||||
}
|
||||
return Qnil;
|
||||
|
|
@ -845,13 +856,21 @@ rb_io_close(io)
|
|||
{
|
||||
OpenFile *fptr;
|
||||
|
||||
rb_secure(4);
|
||||
GetOpenFile(io, fptr);
|
||||
rb_io_fptr_close(fptr);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_close_method(io)
|
||||
VALUE io;
|
||||
{
|
||||
rb_secure(4);
|
||||
rb_io_close(io);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_closed(io)
|
||||
VALUE io;
|
||||
|
|
@ -862,6 +881,51 @@ rb_io_closed(io)
|
|||
return (fptr->f || fptr->f2)?Qfalse:Qtrue;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_io_close_read(io)
|
||||
VALUE io;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
FILE *save;
|
||||
|
||||
rb_secure(4);
|
||||
GetOpenFile(io, fptr);
|
||||
if (fptr->f2 == 0 && (fptr->mode & FMODE_WRITABLE)) {
|
||||
rb_raise(rb_eIOError, "closing non-duplex IO for reading");
|
||||
}
|
||||
if (fptr->f2 == 0) {
|
||||
return rb_io_close(io);
|
||||
}
|
||||
fclose(fptr->f);
|
||||
fptr->mode &= ~FMODE_READABLE;
|
||||
fptr->f = fptr->f2;
|
||||
fptr->f2 = 0;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_close_write(io)
|
||||
VALUE io;
|
||||
{
|
||||
OpenFile *fptr;
|
||||
FILE *save = 0;
|
||||
|
||||
rb_secure(4);
|
||||
GetOpenFile(io, fptr);
|
||||
if (fptr->f2 == 0 && (fptr->mode & FMODE_READABLE)) {
|
||||
rb_raise(rb_eIOError, "closing non-duplex IO for writing");
|
||||
}
|
||||
if (fptr->f2 == 0) {
|
||||
return rb_io_close(io);
|
||||
}
|
||||
fclose(fptr->f2);
|
||||
fptr->f2 = 0;
|
||||
fptr->mode &= ~FMODE_WRITABLE;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_syswrite(io, str)
|
||||
VALUE io, str;
|
||||
|
|
@ -878,7 +942,7 @@ rb_io_syswrite(io, str)
|
|||
rb_io_check_writable(fptr);
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_fd_writable(fileno(f));
|
||||
#endif
|
||||
n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
|
|
@ -902,7 +966,7 @@ rb_io_sysread(io, len)
|
|||
|
||||
str = rb_str_new(0, ilen);
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_wait_fd(fileno(fptr->f));
|
||||
#endif
|
||||
TRAP_BEG;
|
||||
|
|
@ -1086,10 +1150,10 @@ pipe_finalize(fptr)
|
|||
if (fptr->f2 != NULL) {
|
||||
pclose(fptr->f2);
|
||||
}
|
||||
fptr->f = fptr->f2 = NULL;
|
||||
#else
|
||||
fptr_finalize(fptr);
|
||||
#endif
|
||||
fptr->f = fptr->f2 = NULL;
|
||||
pipe_del_fptr(fptr);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1181,7 +1245,7 @@ pipe_open(pname, mode)
|
|||
|
||||
case -1: /* fork failed */
|
||||
if (errno == EAGAIN) {
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_sleep(1);
|
||||
#else
|
||||
sleep(1);
|
||||
|
|
@ -1346,12 +1410,15 @@ rb_io_reopen(io, nfile)
|
|||
|
||||
mode = rb_io_mode_string(fptr);
|
||||
fd = fileno(fptr->f);
|
||||
if (fileno(fptr->f) < 3) {
|
||||
if (fd < 3) {
|
||||
/* need to keep stdio */
|
||||
dup2(fileno(orig->f), fd);
|
||||
if (dup2(fileno(orig->f), fd) < 0)
|
||||
rb_sys_fail(orig->path);
|
||||
}
|
||||
else {
|
||||
fclose(fptr->f);
|
||||
if (dup2(fileno(orig->f), fd) < 0)
|
||||
rb_sys_fail(orig->path);
|
||||
fptr->f = rb_fdopen(fd, mode);
|
||||
}
|
||||
|
||||
|
|
@ -1359,7 +1426,8 @@ rb_io_reopen(io, nfile)
|
|||
fd = fileno(fptr->f2);
|
||||
fclose(fptr->f2);
|
||||
if (orig->f2) {
|
||||
dup2(fileno(orig->f2), fd);
|
||||
if (dup2(fileno(orig->f2), fd) < 0)
|
||||
rb_sys_fail(orig->path);
|
||||
fptr->f2 = rb_fdopen(fd, "w");
|
||||
}
|
||||
else {
|
||||
|
|
@ -1525,7 +1593,6 @@ rb_io_putc(io, ch)
|
|||
rb_secure(4);
|
||||
GetOpenFile(io, fptr);
|
||||
rb_io_check_writable(fptr);
|
||||
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
if (fputc(c, f) == EOF || ferror(f))
|
||||
|
|
@ -1800,7 +1867,7 @@ next_argv()
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_gets_method(argc, argv)
|
||||
rb_f_gets_internal(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
|
|
@ -1808,26 +1875,7 @@ rb_f_gets_method(argc, argv)
|
|||
|
||||
retry:
|
||||
if (!next_argv()) return Qnil;
|
||||
line = rb_io_gets_method(argc, argv, file);
|
||||
if (NIL_P(line) && next_p != -1) {
|
||||
rb_io_close(file);
|
||||
next_p = 1;
|
||||
goto retry;
|
||||
}
|
||||
gets_lineno++;
|
||||
lineno = INT2FIX(gets_lineno);
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_f_gets()
|
||||
{
|
||||
VALUE line;
|
||||
|
||||
retry:
|
||||
if (!next_argv()) return Qnil;
|
||||
line = rb_io_gets(file);
|
||||
line = rb_io_gets_internal(argc, argv, file);
|
||||
if (NIL_P(line) && next_p != -1) {
|
||||
rb_io_close(file);
|
||||
next_p = 1;
|
||||
|
|
@ -1839,12 +1887,45 @@ rb_f_gets()
|
|||
return line;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_gets(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE line = rb_f_gets_internal(argc, argv);
|
||||
|
||||
if (!NIL_P(line)) rb_lastline_set(line);
|
||||
return line;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_gets()
|
||||
{
|
||||
VALUE line;
|
||||
|
||||
retry:
|
||||
if (!next_argv()) return Qnil;
|
||||
line = rb_io_gets(file);
|
||||
if (NIL_P(line) && next_p != -1) {
|
||||
rb_io_close(file);
|
||||
next_p = 1;
|
||||
goto retry;
|
||||
}
|
||||
if (!NIL_P(line)) {
|
||||
rb_lastline_set(line);
|
||||
gets_lineno++;
|
||||
lineno = INT2FIX(gets_lineno);
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_readline(argc, argv)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE line = rb_f_gets_method(argc, argv);
|
||||
VALUE line = rb_f_gets(argc, argv);
|
||||
|
||||
if (NIL_P(line)) {
|
||||
rb_eof_error();
|
||||
|
|
@ -1935,7 +2016,7 @@ rb_f_readlines(argc, argv)
|
|||
VALUE line, ary;
|
||||
|
||||
ary = rb_ary_new();
|
||||
while (!NIL_P(line = rb_f_gets_method(argc, argv))) {
|
||||
while (!NIL_P(line = rb_f_gets_internal(argc, argv))) {
|
||||
rb_ary_push(ary, line);
|
||||
}
|
||||
|
||||
|
|
@ -2065,7 +2146,7 @@ rb_f_select(argc, argv, obj)
|
|||
|
||||
max++;
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
n = rb_thread_select(max, rp, wp, ep, tp);
|
||||
if (n < 0) {
|
||||
rb_sys_fail(0);
|
||||
|
|
@ -2372,7 +2453,7 @@ rb_io_foreach_line(arg)
|
|||
{
|
||||
VALUE str;
|
||||
|
||||
while (!NIL_P(str = rb_io_gets_method(arg->argc, &arg->sep, arg->io))) {
|
||||
while (!NIL_P(str = rb_io_gets_internal(arg->argc, &arg->sep, arg->io))) {
|
||||
rb_yield(str);
|
||||
}
|
||||
return Qnil;
|
||||
|
|
@ -2402,7 +2483,7 @@ rb_io_readline_line(arg)
|
|||
VALUE line, ary;
|
||||
|
||||
ary = rb_ary_new();
|
||||
while (!NIL_P(line = rb_io_gets_method(arg->argc, &arg->sep, arg->io))) {
|
||||
while (!NIL_P(line = rb_io_gets_internal(arg->argc, &arg->sep, arg->io))) {
|
||||
rb_ary_push(ary, line);
|
||||
}
|
||||
|
||||
|
|
@ -2507,7 +2588,7 @@ arg_each_line(argc, argv)
|
|||
{
|
||||
VALUE str;
|
||||
|
||||
while (RTEST(str = rb_f_gets_method(argc, argv))) {
|
||||
while (RTEST(str = rb_f_gets_internal(argc, argv))) {
|
||||
rb_yield(str);
|
||||
}
|
||||
return Qnil;
|
||||
|
|
@ -2596,7 +2677,7 @@ Init_IO()
|
|||
rb_define_global_function("print", rb_f_print, -1);
|
||||
rb_define_global_function("putc", rb_f_putc, 1);
|
||||
rb_define_global_function("puts", rb_f_puts, -1);
|
||||
rb_define_global_function("gets", rb_f_gets_method, -1);
|
||||
rb_define_global_function("gets", rb_f_gets, -1);
|
||||
rb_define_global_function("readline", rb_f_readline, -1);
|
||||
rb_define_global_function("tell", rb_f_tell, 0);
|
||||
rb_define_global_function("seek", rb_f_seek, 2);
|
||||
|
|
@ -2684,8 +2765,10 @@ Init_IO()
|
|||
rb_define_method(rb_cIO, "eof", rb_io_eof, 0);
|
||||
rb_define_method(rb_cIO, "eof?", rb_io_eof, 0);
|
||||
|
||||
rb_define_method(rb_cIO, "close", rb_io_close, 0);
|
||||
rb_define_method(rb_cIO, "close", rb_io_close_method, 0);
|
||||
rb_define_method(rb_cIO, "closed?", rb_io_closed, 0);
|
||||
rb_define_method(rb_cIO, "close_read", rb_io_close_read, 0);
|
||||
rb_define_method(rb_cIO, "close_write", rb_io_close_write, 0);
|
||||
|
||||
rb_define_method(rb_cIO, "isatty", rb_io_isatty, 0);
|
||||
rb_define_method(rb_cIO, "tty?", rb_io_isatty, 0);
|
||||
|
|
@ -2723,7 +2806,7 @@ Init_IO()
|
|||
rb_define_singleton_method(argf, "read", arg_read, -1);
|
||||
rb_define_singleton_method(argf, "readlines", rb_f_readlines, -1);
|
||||
rb_define_singleton_method(argf, "to_a", rb_f_readlines, -1);
|
||||
rb_define_singleton_method(argf, "gets", rb_f_gets_method, -1);
|
||||
rb_define_singleton_method(argf, "gets", rb_f_gets, -1);
|
||||
rb_define_singleton_method(argf, "readline", rb_f_readline, -1);
|
||||
rb_define_singleton_method(argf, "getc", arg_getc, 0);
|
||||
rb_define_singleton_method(argf, "readchar", arg_readchar, 0);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Usage:
|
||||
# require "find.rb"
|
||||
# require "find"
|
||||
#
|
||||
# Find.find('/foo','/bar') {|f| ...}
|
||||
# or
|
||||
|
|
|
|||
10
lib/jcode.rb
10
lib/jcode.rb
|
|
@ -104,7 +104,7 @@ class String
|
|||
end
|
||||
|
||||
def tr(from, to)
|
||||
self.dup.tr!(from, to)
|
||||
(str = self.dup).tr!(from, to) or str
|
||||
end
|
||||
|
||||
def delete!(del)
|
||||
|
|
@ -127,7 +127,7 @@ class String
|
|||
end
|
||||
|
||||
def delete(del)
|
||||
self.dup.delete!(del)
|
||||
(str = self.dup).delete!(del) or str
|
||||
end
|
||||
|
||||
def squeeze!(del=nil)
|
||||
|
|
@ -155,7 +155,7 @@ class String
|
|||
end
|
||||
|
||||
def squeeze(del=nil)
|
||||
self.dup.squeeze!(del)
|
||||
(str = self.dup).squeeze!(del) or str
|
||||
end
|
||||
|
||||
def tr_s!(from, to)
|
||||
|
|
@ -188,7 +188,7 @@ class String
|
|||
end
|
||||
|
||||
def tr_s(from, to)
|
||||
self.dup.tr_s!(from,to)
|
||||
(str = self.dup).tr_s!(from,to) or str
|
||||
end
|
||||
|
||||
alias original_chop! chop!
|
||||
|
|
@ -202,7 +202,7 @@ class String
|
|||
end
|
||||
|
||||
def chop
|
||||
self.dup.chop!
|
||||
(str = self.dup).chop! or str
|
||||
end
|
||||
end
|
||||
$VERBOSE = $vsave
|
||||
|
|
|
|||
23
lib/mkmf.rb
23
lib/mkmf.rb
|
|
@ -2,6 +2,7 @@
|
|||
# invoke like: ruby -r mkmf extconf.rb
|
||||
|
||||
require 'rbconfig'
|
||||
require 'find'
|
||||
|
||||
include Config
|
||||
|
||||
|
|
@ -83,6 +84,24 @@ def try_cpp
|
|||
xsystem(format(CPP, $CFLAGS))
|
||||
end
|
||||
|
||||
def install_rb(mfile)
|
||||
path = []
|
||||
dir = []
|
||||
Find.find("lib") do |f|
|
||||
next unless /\.rb$/ =~ f
|
||||
f = f[4..-1]
|
||||
path.push f
|
||||
dir |= File.dirname(f)
|
||||
end
|
||||
for f in dir
|
||||
next if f == "."
|
||||
mfile.printf "\t@test -d $(libdir)/%s || mkdir $(libdir)/%s\n", f, f
|
||||
end
|
||||
for f in path
|
||||
mfile.printf "\t$(INSTALL_DATA) lib/%s $(libdir)/%s\n", f, f
|
||||
end
|
||||
end
|
||||
|
||||
def have_library(lib, func)
|
||||
printf "checking for %s() in -l%s... ", func, lib
|
||||
STDOUT.flush
|
||||
|
|
@ -299,9 +318,7 @@ $(libdir)/$(TARGET): $(TARGET)
|
|||
@test -d $(libdir) || mkdir $(libdir)
|
||||
$(INSTALL) $(TARGET) $(libdir)/$(TARGET)
|
||||
EOMF
|
||||
for rb in Dir["lib/*.rb"]
|
||||
mfile.printf "\t$(INSTALL_DATA) %s %s\n", rb, $libdir
|
||||
end
|
||||
install_rb(mfile)
|
||||
mfile.printf "\n"
|
||||
|
||||
if CONFIG["DLEXT"] != "o"
|
||||
|
|
|
|||
55
lib/open3.rb
Normal file
55
lib/open3.rb
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# Usage:
|
||||
# require "open3"
|
||||
#
|
||||
# in, out, err = Open3.popen3('nroff -man')
|
||||
# or
|
||||
# include Open3
|
||||
# in, out, err = popen3('nroff -man')
|
||||
#
|
||||
|
||||
module Open3
|
||||
#[stdin, stdout, stderr] = popen3(command);
|
||||
def popen3(cmd)
|
||||
pw = pipe # pipe[0] for read, pipe[1] for write
|
||||
pr = pipe
|
||||
pe = pipe
|
||||
|
||||
pid = fork
|
||||
if pid == nil then # child
|
||||
pw[1].close
|
||||
STDIN.reopen(pw[0])
|
||||
pw[0].close
|
||||
|
||||
pr[0].close
|
||||
STDOUT.reopen(pr[1])
|
||||
pr[1].close
|
||||
|
||||
pe[0].close
|
||||
STDERR.reopen(pe[1])
|
||||
pe[1].close
|
||||
|
||||
exec(cmd)
|
||||
exit
|
||||
else
|
||||
pw[0].close
|
||||
pr[1].close
|
||||
pe[1].close
|
||||
pi = [ pw[1], pr[0], pe[0] ]
|
||||
end
|
||||
end
|
||||
module_function :popen3
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
a = Open3.popen3("nroff -man")
|
||||
Thread.start do
|
||||
while gets
|
||||
a[0].print $_
|
||||
end
|
||||
a[0].close
|
||||
end
|
||||
while a[1].gets
|
||||
print ":", $_
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -121,10 +121,13 @@ if __FILE__ == $0
|
|||
db.transaction do
|
||||
p db.roots
|
||||
ary = db["root"] = [1,2,3,4]
|
||||
ary[0] = [1,1.5]
|
||||
ary[1] = [1,1.5]
|
||||
end
|
||||
|
||||
db.transaction do
|
||||
p db["root"]
|
||||
1000.times do
|
||||
db.transaction do
|
||||
db["root"][0] += 1
|
||||
p db["root"][0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
21
lib/shell.rb
21
lib/shell.rb
|
|
@ -159,7 +159,7 @@ class Shell
|
|||
@dir_stack.push @cwd
|
||||
chdir pop
|
||||
else
|
||||
Shell.fail DirStackEmpty
|
||||
Shell.Fail DirStackEmpty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -169,7 +169,7 @@ class Shell
|
|||
if pop = @dir_stack.pop
|
||||
@cwd = pop
|
||||
else
|
||||
Shell.fail DirStackEmpty
|
||||
Shell.Fail DirStackEmpty
|
||||
end
|
||||
end
|
||||
alias popd popdir
|
||||
|
|
@ -350,10 +350,10 @@ class Shell
|
|||
if sh.exists?(path)
|
||||
return path
|
||||
else
|
||||
Shell.fail CommandNotFound, command
|
||||
Shell.Fail CommandNotFound, command
|
||||
end
|
||||
when FALSE
|
||||
Shell.fail CommandNotFound, command
|
||||
Shell.Fail CommandNotFound, command
|
||||
end
|
||||
|
||||
for p in @system_path
|
||||
|
|
@ -364,7 +364,8 @@ class Shell
|
|||
end
|
||||
end
|
||||
@system_commands[command] = FALSE
|
||||
Shell.fail CommandNotFound, command
|
||||
# Shell.fail CommandNotFound, command
|
||||
raise CommandNotFound, command
|
||||
end
|
||||
|
||||
#
|
||||
|
|
@ -380,7 +381,7 @@ class Shell
|
|||
eval d
|
||||
rescue
|
||||
print "Can't define self.#{command} path: #{path}\n" if debug? or verbose?
|
||||
Shell.fail CanNotDefine, comamnd, path
|
||||
Shell.Fail CanNotDefine, comamnd, path
|
||||
end
|
||||
if debug?
|
||||
print d
|
||||
|
|
@ -402,7 +403,7 @@ class Shell
|
|||
eval d
|
||||
rescue
|
||||
print "Can't define #{command} path: #{path}\n" if debug? or verbose?
|
||||
Shell.fail CanNotDefine, comamnd, path
|
||||
Shell.Fail CanNotDefine, comamnd, path
|
||||
end
|
||||
if debug?
|
||||
print d
|
||||
|
|
@ -474,7 +475,7 @@ class Shell
|
|||
@input = src
|
||||
self
|
||||
else
|
||||
Filter.fail CanNotMethodApply, "<", to.type
|
||||
Filter.Fail CanNotMethodApply, "<", to.type
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -490,7 +491,7 @@ class Shell
|
|||
when IO
|
||||
each(){|l| to << l}
|
||||
else
|
||||
Filter.fail CanNotMethodApply, ">", to.type
|
||||
Filter.Fail CanNotMethodApply, ">", to.type
|
||||
end
|
||||
self
|
||||
end
|
||||
|
|
@ -507,7 +508,7 @@ class Shell
|
|||
when IO
|
||||
each(){|l| to << l}
|
||||
else
|
||||
Filter.fail CanNotMethodApply, ">>", to.type
|
||||
Filter.Fail CanNotMethodApply, ">>", to.type
|
||||
end
|
||||
self
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
#
|
||||
# telnet.rb
|
||||
# ver0.14 1998/09/01
|
||||
# ver0.141 1998/09/22
|
||||
# Wakou Aoyama <wakou@fsinet.or.jp>
|
||||
#
|
||||
# ver0.141 1998/09/22
|
||||
# change default prompt
|
||||
# /[$%#>] $/ --> /[$%#>] \Z/
|
||||
#
|
||||
# ver0.14 1998/09/01
|
||||
# IAC WILL SGA send EOL --> CR+NULL
|
||||
# IAC WILL SGA IAC DO BIN send EOL --> CR
|
||||
|
|
@ -34,7 +38,7 @@
|
|||
# "Output_log" => "output_log", default: not output
|
||||
# "Dump_log" => "dump_log", default: not output
|
||||
# "Port" => 23, default: 23
|
||||
# "Prompt" => /[$%#>] $/, default: /[$%#>] $/
|
||||
# "Prompt" => /[$%#>] \Z/, default: /[$%#>] \Z/
|
||||
# "Telnetmode" => TRUE, default: TRUE
|
||||
# "Timeout" => 10, default: 10
|
||||
# "Waittime" => 0}) default: 0
|
||||
|
|
@ -60,13 +64,13 @@
|
|||
# == send string and wait prompt
|
||||
# line = host.cmd("string")
|
||||
# line = host.cmd({"String" => "string",
|
||||
# "Prompt" => /[$%#>] $//,
|
||||
# "Prompt" => /[$%#>] \Z/,
|
||||
# "Timeout" => 10})
|
||||
#
|
||||
# realtime output. of cource, set sync=TRUE or flush is necessary.
|
||||
# host.cmd("string"){|c| print c }
|
||||
# host.cmd({"String" => "string",
|
||||
# "Prompt" => /[$%#>] $//,
|
||||
# "Prompt" => /[$%#>] \Z/,
|
||||
# "Timeout" => 10}){|c| print c }
|
||||
#
|
||||
# == send string
|
||||
|
|
@ -76,14 +80,14 @@
|
|||
# host.login("username", "password")
|
||||
# host.login({"Name" => "username",
|
||||
# "Password" => "password",
|
||||
# "Prompt" => /[$%#>] $/,
|
||||
# "Prompt" => /[$%#>] \Z/,
|
||||
# "Timeout" => 10})
|
||||
#
|
||||
# realtime output. of cource, set sync=TRUE or flush is necessary.
|
||||
# host.login("username", "password"){|c| print c }
|
||||
# host.login({"Name" => "username",
|
||||
# "Password" => "password",
|
||||
# "Prompt" => /[$%#>] $/,
|
||||
# "Prompt" => /[$%#>] \Z/,
|
||||
# "Timeout" => 10}){|c| print c }
|
||||
#
|
||||
# and Telnet object has socket class methods
|
||||
|
|
@ -91,7 +95,7 @@
|
|||
# == sample
|
||||
# localhost = Telnet.new({"Host" => "localhost",
|
||||
# "Timeout" => 10,
|
||||
# "Prompt" => /[$%#>] $/})
|
||||
# "Prompt" => /[$%#>] \Z/})
|
||||
# localhost.login("username", "password"){|c| print c }
|
||||
# localhost.cmd("command"){|c| print c }
|
||||
# localhost.close
|
||||
|
|
@ -208,13 +212,13 @@ class Telnet < SimpleDelegator
|
|||
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@options["Binmode"] = TRUE if not @options.include?("Binmode")
|
||||
@options["Host"] = "localhost" if not @options.include?("Host")
|
||||
@options["Port"] = 23 if not @options.include?("Port")
|
||||
@options["Prompt"] = /[$%#>] $/ if not @options.include?("Prompt")
|
||||
@options["Telnetmode"] = TRUE if not @options.include?("Telnetmode")
|
||||
@options["Timeout"] = 10 if not @options.include?("Timeout")
|
||||
@options["Waittime"] = 0 if not @options.include?("Waittime")
|
||||
@options["Binmode"] = TRUE if not @options.include?("Binmode")
|
||||
@options["Host"] = "localhost" if not @options.include?("Host")
|
||||
@options["Port"] = 23 if not @options.include?("Port")
|
||||
@options["Prompt"] = /[$%#>] \Z/ if not @options.include?("Prompt")
|
||||
@options["Telnetmode"] = TRUE if not @options.include?("Telnetmode")
|
||||
@options["Timeout"] = 10 if not @options.include?("Timeout")
|
||||
@options["Waittime"] = 0 if not @options.include?("Waittime")
|
||||
|
||||
@telnet_option = { "SGA" => FALSE, "BINARY" => FALSE }
|
||||
|
||||
|
|
@ -378,14 +382,14 @@ class Telnet < SimpleDelegator
|
|||
end
|
||||
|
||||
if iterator?
|
||||
line = waitfor(/login[: ]*$/){|c| yield c }
|
||||
line = waitfor(/login[: ]*\Z/){|c| yield c }
|
||||
line.concat( cmd({"String" => username,
|
||||
"Match" => /Password[: ]*$/}){|c| yield c } )
|
||||
"Match" => /Password[: ]*\Z/}){|c| yield c } )
|
||||
line.concat( cmd(password){|c| yield c } )
|
||||
else
|
||||
line = waitfor(/login[: ]*$/)
|
||||
line = waitfor(/login[: ]*\Z/)
|
||||
line.concat( cmd({"String" => username,
|
||||
"Match" => /Password[: ]*$/}) )
|
||||
"Match" => /Password[: ]*\Z/}) )
|
||||
line.concat( cmd(password) )
|
||||
end
|
||||
line
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class ThreadsWait
|
|||
@threads.concat threads
|
||||
for th in threads
|
||||
Thread.start do
|
||||
th = Thread.join(th)
|
||||
th = th.join
|
||||
@wait_queue.push th
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module TkComm
|
|||
Tk_WINDOWS = {}
|
||||
|
||||
def error_at
|
||||
frames = caller(1)
|
||||
frames = caller()
|
||||
frames.delete_if do |c|
|
||||
c =~ %r!/tk(|core|thcore|canvas|text|entry|scrollbox)\.rb:\d+!
|
||||
end
|
||||
|
|
@ -1581,7 +1581,11 @@ class TkObject
|
|||
when 1
|
||||
configure name, args[0]
|
||||
when 0
|
||||
fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
|
||||
begin
|
||||
cget name
|
||||
rescue
|
||||
fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
|
||||
end
|
||||
else
|
||||
fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
|
||||
end
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ class TkAfter
|
|||
if !sleep == 'idle' && !sleep.kind_of?(Integer)
|
||||
fail format("%s need to be Integer", sleep.inspect)
|
||||
end
|
||||
@init_sleep = sleep
|
||||
@init_proc = init_proc
|
||||
@init_args = init_args
|
||||
self
|
||||
|
|
|
|||
|
|
@ -733,14 +733,11 @@ class TkImage<TkObject
|
|||
Tk_IMGTBL[@id] = nil if @id
|
||||
tk_call('image', 'delete', @path)
|
||||
end
|
||||
def height
|
||||
number(tk_call('image', 'height', @path))
|
||||
end
|
||||
def itemtype
|
||||
tk_call('image', 'type', @path)
|
||||
end
|
||||
def width
|
||||
number(tk_call('image', 'height', @path))
|
||||
number(tk_call('image', 'width', @path))
|
||||
end
|
||||
|
||||
def TkImage.names
|
||||
|
|
@ -823,7 +820,7 @@ class TkPhotoImage<TkImage
|
|||
term
|
||||
end
|
||||
}.flatten
|
||||
|
||||
|
||||
tk_send 'write', file, *args
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -391,6 +391,8 @@ dump_ensure(arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static st_table *cache[2];
|
||||
|
||||
static VALUE
|
||||
marshal_dump(argc, argv)
|
||||
int argc;
|
||||
|
|
|
|||
|
|
@ -184,8 +184,8 @@ NtInitialize(int *argc, char ***argv) {
|
|||
|
||||
tzset();
|
||||
|
||||
// Initialize Winsock
|
||||
StartSockets();
|
||||
// Initialize Winsock
|
||||
StartSockets();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
5
node.h
5
node.h
|
|
@ -66,8 +66,6 @@ enum node_type {
|
|||
NODE_CVAR,
|
||||
NODE_NTH_REF,
|
||||
NODE_BACK_REF,
|
||||
NODE_MATCH_REF,
|
||||
NODE_LASTLINE,
|
||||
NODE_MATCH,
|
||||
NODE_MATCH2,
|
||||
NODE_MATCH3,
|
||||
|
|
@ -104,7 +102,6 @@ enum node_type {
|
|||
NODE_TRUE,
|
||||
NODE_FALSE,
|
||||
NODE_DEFINED,
|
||||
NODE_TAG,
|
||||
NODE_NEWLINE,
|
||||
NODE_POSTEXE,
|
||||
#ifdef C_ALLOCA
|
||||
|
|
@ -242,7 +239,7 @@ typedef struct RNode {
|
|||
#define NEW_RESCUE(b,res) rb_node_newnode(NODE_RESCUE,b,res,0)
|
||||
#define NEW_RESBODY(a,ex,n) rb_node_newnode(NODE_RESBODY,n,ex,a)
|
||||
#define NEW_ENSURE(b,en) rb_node_newnode(NODE_ENSURE,b,0,en)
|
||||
#define NEW_RET(s) rb_node_newnode(NODE_RETURN,s,0,0)
|
||||
#define NEW_RETURN(s) rb_node_newnode(NODE_RETURN,s,0,0)
|
||||
#define NEW_YIELD(a) rb_node_newnode(NODE_YIELD,a,0,0)
|
||||
#define NEW_LIST(a) NEW_ARRAY(a)
|
||||
#define NEW_ARRAY(a) rb_node_newnode(NODE_ARRAY,a,1,0)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ rb_num_coerce_bin(x, y)
|
|||
return rb_funcall(x, rb_frame_last_func(), 1, y);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
num_clone(x)
|
||||
VALUE x;
|
||||
{
|
||||
/* Numerics are immutable values, which need not to copy */
|
||||
return x;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
num_uplus(num)
|
||||
VALUE num;
|
||||
|
|
@ -1354,6 +1362,7 @@ Init_Numeric()
|
|||
|
||||
rb_include_module(rb_cNumeric, rb_mComparable);
|
||||
rb_define_method(rb_cNumeric, "coerce", num_coerce, 1);
|
||||
rb_define_method(rb_cNumeric, "clone", num_clone, 0);
|
||||
|
||||
rb_define_method(rb_cNumeric, "+@", num_uplus, 0);
|
||||
rb_define_method(rb_cNumeric, "-@", num_uminus, 0);
|
||||
|
|
|
|||
121
parse.y
121
parse.y
|
|
@ -97,8 +97,8 @@ static struct RVarmap *dyna_push();
|
|||
static void dyna_pop();
|
||||
static int dyna_in_block();
|
||||
|
||||
#define crerb_f_push() NEW_CREF()
|
||||
static void crerb_f_pop();
|
||||
#define cref_push() NEW_CREF()
|
||||
static void cref_pop();
|
||||
static NODE *cur_cref;
|
||||
|
||||
static void top_local_init();
|
||||
|
|
@ -170,9 +170,9 @@ static void top_local_setup();
|
|||
%type <node> aref_args opt_block_arg block_arg
|
||||
%type <node> mrhs opt_list superclass iterator var_ref
|
||||
%type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
|
||||
%type <node> array assoc_list assocs assoc undef_list
|
||||
%type <node> array assoc_list assocs assoc undef_list backref
|
||||
%type <node> iter_var opt_iter_var iter_block iter_do_block
|
||||
%type <node> mlhs mlhs_head mlhs_tail mlhs_basic mlhs_item lhs backref
|
||||
%type <node> mlhs mlhs_head mlhs_tail mlhs_basic mlhs_entry mlhs_item lhs
|
||||
%type <id> variable symbol operation
|
||||
%type <id> cname fname op f_rest_arg
|
||||
%type <num> f_arg
|
||||
|
|
@ -372,7 +372,7 @@ expr : mlhs '=' mrhs
|
|||
value_expr($2);
|
||||
if (!cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RET($2);
|
||||
$$ = NEW_RETURN($2);
|
||||
}
|
||||
| kYIELD ret_args
|
||||
{
|
||||
|
|
@ -426,13 +426,13 @@ command_call : operation call_args
|
|||
}
|
||||
|
||||
mlhs : mlhs_basic
|
||||
| tLPAREN mlhs_item ')'
|
||||
| tLPAREN mlhs_entry ')'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
mlhs_item : mlhs_basic
|
||||
| tLPAREN mlhs_item ')'
|
||||
mlhs_entry : mlhs_basic
|
||||
| tLPAREN mlhs_entry ')'
|
||||
{
|
||||
$$ = NEW_MASGN(NEW_LIST($2), 0);
|
||||
}
|
||||
|
|
@ -458,21 +458,22 @@ mlhs_basic : mlhs_head
|
|||
$$ = NEW_MASGN(0, $2);
|
||||
}
|
||||
|
||||
mlhs_head : lhs ','
|
||||
| tLPAREN mlhs_item ')' ','
|
||||
mlhs_item : lhs
|
||||
| tLPAREN mlhs_entry ')'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
mlhs_tail : lhs
|
||||
mlhs_head : mlhs_item ','
|
||||
{
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
mlhs_tail : mlhs_item
|
||||
{
|
||||
$$ = NEW_LIST($1);
|
||||
}
|
||||
| tLPAREN mlhs_item ')'
|
||||
{
|
||||
$$ = NEW_LIST($2);
|
||||
}
|
||||
| mlhs_tail ',' lhs
|
||||
| mlhs_tail ',' mlhs_item
|
||||
{
|
||||
$$ = list_append($1, $3);
|
||||
}
|
||||
|
|
@ -956,19 +957,19 @@ primary : literal
|
|||
if (!cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
value_expr($3);
|
||||
$$ = NEW_RET($3);
|
||||
$$ = NEW_RETURN($3);
|
||||
}
|
||||
| kRETURN '(' ')'
|
||||
{
|
||||
if (!cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RET(0);
|
||||
$$ = NEW_RETURN(0);
|
||||
}
|
||||
| kRETURN
|
||||
{
|
||||
if (!cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RET(0);
|
||||
$$ = NEW_RETURN(0);
|
||||
}
|
||||
| kYIELD '(' ret_args ')'
|
||||
{
|
||||
|
|
@ -1082,7 +1083,7 @@ primary : literal
|
|||
yyerror("class definition in method body");
|
||||
|
||||
class_nest++;
|
||||
crerb_f_push();
|
||||
cref_push();
|
||||
local_push();
|
||||
}
|
||||
compstmt
|
||||
|
|
@ -1091,13 +1092,13 @@ primary : literal
|
|||
$$ = NEW_CLASS($2, $5, $3);
|
||||
fixpos($$, $3);
|
||||
local_pop();
|
||||
crerb_f_pop();
|
||||
cref_pop();
|
||||
class_nest--;
|
||||
}
|
||||
| kCLASS tLSHFT expr term
|
||||
{
|
||||
class_nest++;
|
||||
crerb_f_push();
|
||||
cref_push();
|
||||
local_push();
|
||||
}
|
||||
compstmt
|
||||
|
|
@ -1106,7 +1107,7 @@ primary : literal
|
|||
$$ = NEW_SCLASS($3, $6);
|
||||
fixpos($$, $3);
|
||||
local_pop();
|
||||
crerb_f_pop();
|
||||
cref_pop();
|
||||
class_nest--;
|
||||
}
|
||||
| kMODULE cname
|
||||
|
|
@ -1114,7 +1115,7 @@ primary : literal
|
|||
if (cur_mid || in_single)
|
||||
yyerror("module definition in method body");
|
||||
class_nest++;
|
||||
crerb_f_push();
|
||||
cref_push();
|
||||
local_push();
|
||||
}
|
||||
compstmt
|
||||
|
|
@ -1123,7 +1124,7 @@ primary : literal
|
|||
$$ = NEW_MODULE($2, $4);
|
||||
fixpos($$, $4);
|
||||
local_pop();
|
||||
crerb_f_pop();
|
||||
cref_pop();
|
||||
class_nest--;
|
||||
}
|
||||
| kDEF fname
|
||||
|
|
@ -3004,7 +3005,7 @@ retry:
|
|||
}
|
||||
c = nextc();
|
||||
}
|
||||
if (c == '!' || c == '?') {
|
||||
if ((c == '!' || c == '?') && is_identchar(tok()[0])) {
|
||||
tokadd(c);
|
||||
}
|
||||
else {
|
||||
|
|
@ -3038,23 +3039,6 @@ retry:
|
|||
}
|
||||
}
|
||||
|
||||
if (lex_state == EXPR_FNAME) {
|
||||
lex_state = EXPR_END;
|
||||
if ((c = nextc()) == '=') {
|
||||
tokadd(c);
|
||||
}
|
||||
else {
|
||||
pushback(c);
|
||||
}
|
||||
}
|
||||
else if (lex_state == EXPR_BEG ||
|
||||
lex_state == EXPR_DOT ||
|
||||
lex_state == EXPR_ARG){
|
||||
lex_state = EXPR_ARG;
|
||||
}
|
||||
else {
|
||||
lex_state = EXPR_END;
|
||||
}
|
||||
if (ISUPPER(tok()[0])) {
|
||||
result = tCONSTANT;
|
||||
}
|
||||
|
|
@ -3062,6 +3046,23 @@ retry:
|
|||
result = tFID;
|
||||
} else {
|
||||
result = tIDENTIFIER;
|
||||
if (lex_state == EXPR_FNAME) {
|
||||
lex_state = EXPR_END;
|
||||
if ((c = nextc()) == '=') {
|
||||
tokadd(c);
|
||||
}
|
||||
else {
|
||||
pushback(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lex_state == EXPR_BEG ||
|
||||
lex_state == EXPR_DOT ||
|
||||
lex_state == EXPR_ARG){
|
||||
lex_state = EXPR_ARG;
|
||||
}
|
||||
else {
|
||||
lex_state = EXPR_END;
|
||||
}
|
||||
}
|
||||
tokfix();
|
||||
|
|
@ -3544,10 +3545,7 @@ attrset(recv, id, val)
|
|||
value_expr(recv);
|
||||
value_expr(val);
|
||||
|
||||
id &= ~ID_SCOPE_MASK;
|
||||
id |= ID_ATTRSET;
|
||||
|
||||
return NEW_CALL(recv, id, NEW_LIST(val));
|
||||
return NEW_CALL(recv, rb_id_attrset(id), NEW_LIST(val));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3556,10 +3554,10 @@ rb_backref_error(node)
|
|||
{
|
||||
switch (nd_type(node)) {
|
||||
case NODE_NTH_REF:
|
||||
yyerror("Can't set variable $%d", node->nd_nth);
|
||||
rb_compile_error("Can't set variable $%d", node->nd_nth);
|
||||
break;
|
||||
case NODE_BACK_REF:
|
||||
yyerror("Can't set variable $%c", node->nd_nth);
|
||||
rb_compile_error("Can't set variable $%c", node->nd_nth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -3721,7 +3719,7 @@ logop(type, left, right)
|
|||
NODE *left, *right;
|
||||
{
|
||||
value_expr(left);
|
||||
return rb_node_newnode(type, cond(left), cond(right));
|
||||
return rb_node_newnode(type, cond(left), cond(right), 0);
|
||||
}
|
||||
|
||||
static NODE *
|
||||
|
|
@ -3925,7 +3923,7 @@ dyna_in_block()
|
|||
}
|
||||
|
||||
static void
|
||||
crerb_f_pop()
|
||||
cref_pop()
|
||||
{
|
||||
cur_cref = cur_cref->nd_next;
|
||||
}
|
||||
|
|
@ -4030,8 +4028,7 @@ rb_intern(name)
|
|||
if (st_lookup(sym_tbl, name, &id))
|
||||
return id;
|
||||
|
||||
id = ++last_id;
|
||||
id <<= ID_SCOPE_SHIFT;
|
||||
id = 0;
|
||||
switch (name[0]) {
|
||||
case '$':
|
||||
id |= ID_GLOBAL;
|
||||
|
|
@ -4044,18 +4041,13 @@ rb_intern(name)
|
|||
/* operator */
|
||||
int i;
|
||||
|
||||
id = 0;
|
||||
for (i=0; op_tbl[i].token; i++) {
|
||||
if (*op_tbl[i].name == *name &&
|
||||
strcmp(op_tbl[i].name, name) == 0) {
|
||||
id = op_tbl[i].token;
|
||||
break;
|
||||
goto id_regist;
|
||||
}
|
||||
}
|
||||
if (id == 0) {
|
||||
rb_raise(rb_eNameError, "Unknown operator `%s'", name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
last = strlen(name)-1;
|
||||
|
|
@ -4065,18 +4057,19 @@ rb_intern(name)
|
|||
|
||||
strncpy(buf, name, last);
|
||||
buf[last] = '\0';
|
||||
id = rb_intern(buf);
|
||||
id &= ~ID_SCOPE_MASK;
|
||||
id |= ID_ATTRSET;
|
||||
id = rb_id_attrset(rb_intern(buf));
|
||||
goto id_regist;
|
||||
}
|
||||
else if (ISUPPER(name[0])) {
|
||||
id |= ID_CONST;
|
||||
id = ID_CONST;
|
||||
}
|
||||
else {
|
||||
id |= ID_LOCAL;
|
||||
id = ID_LOCAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
id |= ++last_id << ID_SCOPE_SHIFT;
|
||||
id_regist:
|
||||
name = strdup(name);
|
||||
st_add_direct(sym_tbl, name, id);
|
||||
st_add_direct(sym_rev_tbl, id, name);
|
||||
|
|
|
|||
24
process.c
24
process.c
|
|
@ -79,7 +79,7 @@ rb_waitpid(pid, flags, st)
|
|||
{
|
||||
int result;
|
||||
#ifndef NO_WAITPID
|
||||
#if defined(THREAD)
|
||||
#if defined(USE_THREAD)
|
||||
int oflags = flags;
|
||||
if (!rb_thread_alone()) { /* there're other threads to run */
|
||||
flags |= WNOHANG;
|
||||
|
|
@ -94,14 +94,14 @@ rb_waitpid(pid, flags, st)
|
|||
#endif
|
||||
if (result < 0) {
|
||||
if (errno == EINTR) {
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
goto retry;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (result == 0) {
|
||||
if (oflags & WNOHANG) return 0;
|
||||
rb_thread_schedule();
|
||||
|
|
@ -124,7 +124,7 @@ rb_waitpid(pid, flags, st)
|
|||
result = wait(st);
|
||||
if (result < 0) {
|
||||
if (errno == EINTR) {
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
continue;
|
||||
|
|
@ -137,7 +137,7 @@ rb_waitpid(pid, flags, st)
|
|||
if (!pid_tbl)
|
||||
pid_tbl = st_init_numtable();
|
||||
st_insert(pid_tbl, pid, st);
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (!thread_alone()) rb_thread_schedule();
|
||||
#endif
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ rb_f_wait()
|
|||
|
||||
while ((pid = wait(&state)) < 0) {
|
||||
if (errno == EINTR) {
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_schedule();
|
||||
#endif
|
||||
continue;
|
||||
|
|
@ -212,7 +212,7 @@ rb_f_waitpid(obj, vpid, vflags)
|
|||
|
||||
char *strtok();
|
||||
|
||||
#if defined(THREAD) && defined(HAVE_SETITIMER)
|
||||
#if defined(USE_THREAD) && defined(HAVE_SETITIMER)
|
||||
static void
|
||||
before_exec()
|
||||
{
|
||||
|
|
@ -725,7 +725,7 @@ rb_f_system(argc, argv)
|
|||
|
||||
case -1:
|
||||
if (errno == EAGAIN) {
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
rb_thread_sleep(1);
|
||||
#else
|
||||
sleep(1);
|
||||
|
|
@ -754,7 +754,7 @@ rb_f_sleep(argc, argv)
|
|||
int beg, end;
|
||||
|
||||
beg = time(0);
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
if (argc == 0) {
|
||||
rb_thread_sleep_forever();
|
||||
}
|
||||
|
|
@ -917,11 +917,11 @@ proc_setuid(obj, id)
|
|||
int uid;
|
||||
|
||||
uid = NUM2INT(id);
|
||||
#ifdef HAVE_SETRUID
|
||||
setruid(uid);
|
||||
#else
|
||||
#ifdef HAVE_SETREUID
|
||||
setreuid(uid, -1);
|
||||
#else
|
||||
#ifdef HAVE_SETRUID
|
||||
setruid(uid);
|
||||
#else
|
||||
{
|
||||
if (geteuid() == uid)
|
||||
|
|
|
|||
121
regex.c
121
regex.c
|
|
@ -865,7 +865,7 @@ calculate_must_string(start, end)
|
|||
char *start;
|
||||
char *end;
|
||||
{
|
||||
int mcnt, mcnt2;
|
||||
int mcnt;
|
||||
int max = 0;
|
||||
char *p = start;
|
||||
char *pend = end;
|
||||
|
|
@ -925,8 +925,7 @@ calculate_must_string(start, end)
|
|||
p += mcnt;
|
||||
mcnt = EXTRACT_UNSIGNED_AND_INCR(p);
|
||||
while (mcnt--) {
|
||||
EXTRACT_MBC_AND_INCR(p);
|
||||
EXTRACT_MBC_AND_INCR(p);
|
||||
p += 4;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1069,6 +1068,7 @@ re_compile_pattern(pattern, size, bufp)
|
|||
bufp->fastmap_accurate = 0;
|
||||
bufp->must = 0;
|
||||
bufp->must_skip = 0;
|
||||
bufp->stclass = 0;
|
||||
|
||||
/* Initialize the syntax table. */
|
||||
init_syntax_once();
|
||||
|
|
@ -1585,23 +1585,22 @@ re_compile_pattern(pattern, size, bufp)
|
|||
if ((options ^ stackp[-1]) & RE_OPTION_IGNORECASE) {
|
||||
BUFPUSH((options&RE_OPTION_IGNORECASE)?casefold_off:casefold_on);
|
||||
}
|
||||
options = *--stackp;
|
||||
switch (c = *--stackp) {
|
||||
case '(':
|
||||
case ':':
|
||||
pending_exact = 0;
|
||||
if (fixup_alt_jump)
|
||||
{ /* Push a dummy failure point at the end of the
|
||||
alternative for a possible future
|
||||
`finalize_jump' to pop. See comments at
|
||||
`push_dummy_failure' in `re_match'. */
|
||||
BUFPUSH(push_dummy_failure);
|
||||
pending_exact = 0;
|
||||
if (fixup_alt_jump)
|
||||
{ /* Push a dummy failure point at the end of the
|
||||
alternative for a possible future
|
||||
`finalize_jump' to pop. See comments at
|
||||
`push_dummy_failure' in `re_match'. */
|
||||
BUFPUSH(push_dummy_failure);
|
||||
|
||||
/* We allocated space for this jump when we assigned
|
||||
to `fixup_alt_jump', in the `handle_alt' case below. */
|
||||
store_jump(fixup_alt_jump, jump, b);
|
||||
}
|
||||
if (c == '(') {
|
||||
/* We allocated space for this jump when we assigned
|
||||
to `fixup_alt_jump', in the `handle_alt' case below. */
|
||||
store_jump(fixup_alt_jump, jump, b);
|
||||
}
|
||||
options = *--stackp;
|
||||
switch (c = *--stackp) {
|
||||
case '(':
|
||||
{
|
||||
char *loc = bufp->buffer + *--stackp;
|
||||
*loc = regnum - stackp[-1];
|
||||
BUFPUSH(stop_memory);
|
||||
|
|
@ -2034,12 +2033,13 @@ re_compile_pattern(pattern, size, bufp)
|
|||
bufp->options |= RE_OPTIMIZE_ANCHOR;
|
||||
}
|
||||
else if (*laststart == charset || *laststart == charset_not) {
|
||||
mcnt = *++laststart;
|
||||
laststart += mcnt+1;
|
||||
mcnt = EXTRACT_UNSIGNED_AND_INCR(laststart);
|
||||
laststart += 4*mcnt;
|
||||
if (*laststart == maybe_finalize_jump) {
|
||||
bufp->options |= RE_OPTIMIZE_CCLASS;
|
||||
p0 = laststart;
|
||||
mcnt = *++p0 ;
|
||||
p0 += mcnt+1;
|
||||
mcnt = EXTRACT_UNSIGNED_AND_INCR(p0);
|
||||
p0 += 4*mcnt;
|
||||
if (*p0 == maybe_finalize_jump) {
|
||||
bufp->stclass = laststart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2239,7 +2239,6 @@ slow_match(little, lend, big, bend, translate)
|
|||
if (c == 0xff)
|
||||
c = *little++;
|
||||
if (!trans_eq(*big++, c, translate)) break;
|
||||
little++;
|
||||
}
|
||||
if (little == lend) return 1;
|
||||
return 0;
|
||||
|
|
@ -2330,11 +2329,9 @@ bm_search(little, llen, big, blen, skip, translate)
|
|||
unsigned char *big;
|
||||
int blen;
|
||||
int *skip;
|
||||
char *translate;
|
||||
unsigned char *translate;
|
||||
{
|
||||
int next[256];
|
||||
int i, j, k;
|
||||
unsigned char c;
|
||||
|
||||
i = llen-1;
|
||||
if (translate) {
|
||||
|
|
@ -2738,27 +2735,30 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
}
|
||||
|
||||
if (bufp->must) {
|
||||
int r = range;
|
||||
int len = ((unsigned char*)bufp->must)[0];
|
||||
int pos;
|
||||
int pos, pbeg, pend;
|
||||
|
||||
if (range >= 0) {
|
||||
r = 0;
|
||||
pbeg = startpos;
|
||||
pend = startpos + range;
|
||||
if (pbeg > pend) { /* swap pbeg,pend */
|
||||
pos = pend; pend = pbeg; pbeg = pos;
|
||||
}
|
||||
if (pend > size) pend = size;
|
||||
if (bufp->options & RE_OPTIMIZE_NO_BM) {
|
||||
pos = slow_search(bufp->must+1, len,
|
||||
string+startpos, size-startpos-r,
|
||||
string+pbeg, pend-pbeg,
|
||||
MAY_TRANSLATE()?translate:0);
|
||||
}
|
||||
else {
|
||||
pos = bm_search(bufp->must+1, len,
|
||||
string+startpos, size-startpos-r,
|
||||
string+pbeg, pend-pbeg,
|
||||
bufp->must_skip,
|
||||
MAY_TRANSLATE()?translate:0);
|
||||
}
|
||||
if (pos == -1) return -1;
|
||||
if (bufp->options & RE_OPTIMIZE_EXACTN) {
|
||||
if (range > 0 && (bufp->options & RE_OPTIMIZE_EXACTN)) {
|
||||
startpos += pos;
|
||||
range -= pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2827,29 +2827,33 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
#endif /* NO_ALLOCA */
|
||||
|
||||
if (range > 0) {
|
||||
if (anchor && startpos < size && string[startpos-1] != '\n') {
|
||||
if (anchor && startpos < size && startpos > 0 && string[startpos-1] != '\n') {
|
||||
while (range > 0 && string[startpos] != '\n') {
|
||||
range--;
|
||||
startpos++;
|
||||
}
|
||||
}
|
||||
else if (fastmap && (bufp->options & RE_OPTIMIZE_CCLASS)) {
|
||||
register unsigned char *p, c;
|
||||
else if (fastmap && (bufp->stclass)) {
|
||||
register unsigned char *p;
|
||||
register unsigned short c;
|
||||
int irange = range;
|
||||
|
||||
p = (unsigned char *)string+startpos;
|
||||
while (range > 0) {
|
||||
c = *p++;
|
||||
if (ismbchar(c)) {
|
||||
if (!fastmap[c]) break;
|
||||
c = *p++;
|
||||
range--;
|
||||
if (fastmap[c] != 2) break;
|
||||
if (ismbchar(c) && fastmap[c] != 2) {
|
||||
c = c << 8 | *p++;
|
||||
}
|
||||
else if (MAY_TRANSLATE())
|
||||
c = translate[c];
|
||||
if (*bufp->stclass == charset) {
|
||||
if (!is_in_list(c, bufp->stclass+1)) break;
|
||||
}
|
||||
else {
|
||||
if (is_in_list(c, bufp->stclass+1)) break;
|
||||
}
|
||||
else
|
||||
if (!fastmap[MAY_TRANSLATE() ? translate[c] : c])
|
||||
break;
|
||||
range--;
|
||||
if (c > 256) range--;
|
||||
}
|
||||
startpos += irange - range;
|
||||
}
|
||||
|
|
@ -3023,9 +3027,6 @@ typedef union
|
|||
#define AT_STRINGS_BEG(d) (d == string)
|
||||
#define AT_STRINGS_END(d) (d == dend)
|
||||
|
||||
#define AT_WORD_BOUNDARY(d) \
|
||||
(AT_STRINGS_BEG(d) || AT_STRINGS_END(d) || IS_A_LETTER(d - 1) != IS_A_LETTER(d))
|
||||
|
||||
/* We have two special cases to check for:
|
||||
1) if we're past the end of string1, we have to look at the first
|
||||
character in string2;
|
||||
|
|
@ -3752,12 +3753,28 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
continue;
|
||||
|
||||
case wordbound:
|
||||
if (AT_WORD_BOUNDARY(d))
|
||||
if (AT_STRINGS_BEG(d)) {
|
||||
if (IS_A_LETTER(d)) break;
|
||||
else goto fail;
|
||||
}
|
||||
if (AT_STRINGS_BEG(d)) {
|
||||
if (IS_A_LETTER(d-1)) break;
|
||||
else goto fail;
|
||||
}
|
||||
if (IS_A_LETTER(d - 1) != IS_A_LETTER(d))
|
||||
break;
|
||||
goto fail;
|
||||
|
||||
case notwordbound:
|
||||
if (AT_WORD_BOUNDARY(d))
|
||||
if (AT_STRINGS_BEG(d)) {
|
||||
if (IS_A_LETTER(d)) goto fail;
|
||||
else break;
|
||||
}
|
||||
if (AT_STRINGS_END(d)) {
|
||||
if (IS_A_LETTER(d-1)) goto fail;
|
||||
else break;
|
||||
}
|
||||
if (IS_A_LETTER(d - 1) != IS_A_LETTER(d))
|
||||
goto fail;
|
||||
break;
|
||||
|
||||
|
|
|
|||
6
regex.h
6
regex.h
|
|
@ -169,8 +169,7 @@ extern long re_syntax_options;
|
|||
#define RE_MAY_IGNORECASE (1L<<2)
|
||||
#define RE_OPTIMIZE_ANCHOR (1L<<4)
|
||||
#define RE_OPTIMIZE_EXACTN (1L<<5)
|
||||
#define RE_OPTIMIZE_CCLASS (1L<<6)
|
||||
#define RE_OPTIMIZE_NO_BM (1L<<7)
|
||||
#define RE_OPTIMIZE_NO_BM (1L<<6)
|
||||
|
||||
/* For multi-byte char support */
|
||||
#define MBCTYPE_ASCII 0
|
||||
|
|
@ -202,7 +201,8 @@ struct re_pattern_buffer
|
|||
to skip over totally implausible characters. */
|
||||
char *must; /* Pointer to exact pattern which strings should have
|
||||
to be matched. */
|
||||
int *must_skip; /* Pointer to exact pattern skip table for bm_search */
|
||||
int *must_skip; /* Pointer to exact pattern skip table for bm_search */
|
||||
char *stclass; /* Pointer to character class list at top */
|
||||
long options; /* Flags for options such as extended_pattern. */
|
||||
long re_nsub; /* Number of subexpressions found by the compiler. */
|
||||
char fastmap_accurate;
|
||||
|
|
|
|||
121
ruby.1
121
ruby.1
|
|
@ -1,45 +1,10 @@
|
|||
.\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
||||
.\"
|
||||
.\"This source is distributed under the conditions blow:
|
||||
.\"
|
||||
.\" 1. You may make and give away verbatim copies of the source form of
|
||||
.\" the software without restriction, provided that you do not modify
|
||||
.\" the original distribution files.
|
||||
.\"
|
||||
.\" If you want to distribute the modified version in any way, contact
|
||||
.\" the author.
|
||||
.\"
|
||||
.\" 2. You may distribute the software in object code or executable
|
||||
.\" form, provided that you distribute it with instructions on where
|
||||
.\" to get the software.
|
||||
.\"
|
||||
.\" 3. You may modify the software in any way, provided that you do not
|
||||
.\" distribute the modified version.
|
||||
.\"
|
||||
.\" 4. You may modify and include the part of the software into any other
|
||||
.\" software (possibly commercial). But some files in the distribution
|
||||
.\" are not written by the author, so that they are not under this terms.
|
||||
.\" They are gc.c(partly)$B!$(Butils.c(partly), regex.[ch]$B!$(Bfnmatch.[ch]$B!$(B
|
||||
.\" glob.c, st.[ch] and somme files under the ./missing directory. See
|
||||
.\" each files for the copying condition.
|
||||
.\"
|
||||
.\" 5. The scripts and library files supplied as input to or produced as
|
||||
.\" output from the software do not automatically fall under the
|
||||
.\" copyright of the software, but belong to whomever generated them,
|
||||
.\" and may be sold commercially, and may be aggregated with this
|
||||
.\" software.
|
||||
.\"
|
||||
.\" 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.na
|
||||
.TH RUBY 1 "ruby 1.1" "22/Jun/98" "Ruby Programmers Reference Guide"
|
||||
.SH NAME
|
||||
ruby - Interpreted scripting language
|
||||
ruby - interpreted object-oriented scripting language
|
||||
.SH SYNOPSIS
|
||||
.B ruby \c
|
||||
[ \c
|
||||
|
|
@ -101,22 +66,22 @@ straight-forward, and extensible.
|
|||
.PP
|
||||
If you want a language for easy object-oriented programming, or you
|
||||
don't like the PERL ugliness, or you do like the concept of lisp, but
|
||||
don't like too much parentheses, ruby may be the language of the
|
||||
don't like too much parentheses, Ruby may be the language of the
|
||||
choice.
|
||||
.SH DESCRIPTION
|
||||
Ruby's features are as follows:
|
||||
.TP
|
||||
.B "\(bu Interpretive"
|
||||
Ruby is the interpreted language, so you don't have to
|
||||
recompile to execute the program written in ruby.
|
||||
recompile to execute the program written in Ruby.
|
||||
.TP
|
||||
.B "\(bu Variables have no type (dynamic typing)"
|
||||
Variables in ruby can contain data of any type. You don't have
|
||||
Variables in Ruby can contain data of any type. You don't have
|
||||
to worry about variable typing. Consequently, it has weaker
|
||||
compile time check.
|
||||
.TP
|
||||
.B "\(bu No declaration needed"
|
||||
You can use variables in your ruby programs without any
|
||||
You can use variables in your Ruby programs without any
|
||||
declarations. Variable name itself denotes its scope (local,
|
||||
global, instance, etc.)
|
||||
.TP
|
||||
|
|
@ -133,7 +98,7 @@ Ruby is the pure object-oriented language from the beginning.
|
|||
Even basic data like integers are treated uniformly as objects.
|
||||
.TP
|
||||
.B "\(bu Class, inheritance, methods"
|
||||
Of course, as a O-O language, ruby has basic features like
|
||||
Of course, as a O-O language, Ruby has basic features like
|
||||
classes, inheritance, methods, etc.
|
||||
.TP
|
||||
.B "\(bu Singleton methods"
|
||||
|
|
@ -145,21 +110,21 @@ system using singleton methods (if you want to).
|
|||
.TP
|
||||
.B "\(bu Mix-in by modules"
|
||||
Ruby does not have the multiple inheritance intentionally. IMO,
|
||||
It is the source of confusion. Instead, ruby has modules to
|
||||
It is the source of confusion. Instead, Ruby has modules to
|
||||
share the implementation across the inheritance tree. It is
|
||||
often called "Mix-in."
|
||||
often called as "Mix-in."
|
||||
.TP
|
||||
.B "\(bu Iterators"
|
||||
Ruby has iterators for loop abstraction.
|
||||
.TP
|
||||
.B "\(bu Closures"
|
||||
In ruby, you can objectify the procedure.
|
||||
In Ruby, you can objectify the procedure.
|
||||
.TP
|
||||
.B "\(bu Text processing and regular expression"
|
||||
Ruby has bunch of text processing features like in perl.
|
||||
.TP
|
||||
.B "\(bu Bignums"
|
||||
With bu ilt-in bignums, you can calculate factorial(400), for
|
||||
With built-in bignums, you can calculate factorial(400), for
|
||||
example.
|
||||
.TP
|
||||
.B "\(bu Exception handling"
|
||||
|
|
@ -177,15 +142,15 @@ most of UNIXes.
|
|||
Ruby interpreter accepts following command-line options (switches).
|
||||
Basically they are quite similar to those of Perl.
|
||||
.TP
|
||||
.B -0digit
|
||||
specifies the input record separator ($/) as an octal number.
|
||||
.B -0\fIdigit
|
||||
specifies the input record separator (\fB$/\fR) as an octal number.
|
||||
If no digits given, the null character is the separator. Other
|
||||
switches may follow the digits. -00 turns ruby into paragraph
|
||||
mode. -0777 makes ruby read whole file at once as a single
|
||||
switches may follow the digits. \fB-00\fR turns ruby into paragraph
|
||||
mode. \fB-0777\fR makes ruby read whole file at once as a single
|
||||
string, since there is no legal character with that value.
|
||||
.TP
|
||||
.B -a
|
||||
turns on auto-split mode when used with -n or -p. In auto-split
|
||||
turns on auto-split mode when used with \fB-n\fR or \fB-p\fR. In auto-split
|
||||
mode, ruby executes
|
||||
.nf
|
||||
.ne 1
|
||||
|
|
@ -198,21 +163,21 @@ causes ruby to check the syntax of the script and exit without
|
|||
executing. If there is no syntax error, ruby will print "Syntax
|
||||
OK" to the standard output.
|
||||
.TP
|
||||
.B -Kc
|
||||
.B -K\fIc
|
||||
specifies KANJI (Japanese character) code-set.
|
||||
.TP
|
||||
.B
|
||||
-d --debug
|
||||
turns on debug mode. $DEBUG will set TRUE.
|
||||
turns on debug mode. \fB$DEBUG\fR will set TRUE.
|
||||
.TP
|
||||
.B -e script
|
||||
specifies script from command-line. if -e switch specified,
|
||||
.B -e \fIscript
|
||||
specifies script from command-line. if \fB-e\fR switch specified,
|
||||
ruby will not look for a script filename in the arguments.
|
||||
.TP
|
||||
.B -F regexp
|
||||
specifies input field separator ($;).
|
||||
.B -F \fIregexp
|
||||
specifies input field separator (\fB$;\fR).
|
||||
.TP
|
||||
.B -i extension
|
||||
.B -i \fIextension
|
||||
specifies in-place-edit mode. The extension, if specified, is
|
||||
added to old filename to make a backup copy.
|
||||
example:
|
||||
|
|
@ -228,19 +193,19 @@ example:
|
|||
\& matz
|
||||
.fi
|
||||
.TP
|
||||
.B -I directory
|
||||
.B -I \fIdirectory
|
||||
used to tell ruby where to load the library scripts. Directory
|
||||
path will be added to the load-path variable ($:').
|
||||
path will be added to the load-path variable (\fB$:\fR).
|
||||
.TP
|
||||
.B -l
|
||||
enables automatic line-ending processing, which means firstly
|
||||
set $\ to the value of $/, and secondly chops every line read
|
||||
using chop!.
|
||||
set \fB$\\\fR to the value of \fB$/\fR, and secondly chops every line read
|
||||
using \fBchop!\fR.
|
||||
.TP
|
||||
.B -n
|
||||
causes ruby to assume the following loop around your script,
|
||||
which makes it iterate over filename arguments somewhat like
|
||||
sed -n or awk.
|
||||
sed \fB-n\fR or awk.
|
||||
.nf
|
||||
.ne 3
|
||||
\& while gets
|
||||
|
|
@ -249,8 +214,8 @@ sed -n or awk.
|
|||
.fi
|
||||
.TP
|
||||
.B -p
|
||||
acts mostly same as -n switch, but print the value of variable
|
||||
$_ at the each end of the loop.
|
||||
acts mostly same as \fB-n\fR switch, but print the value of variable
|
||||
\fB$_\fR at the each end of the loop.
|
||||
example:
|
||||
.nf
|
||||
.ne 2
|
||||
|
|
@ -258,13 +223,13 @@ example:
|
|||
\& MATZ
|
||||
.fi
|
||||
.TP
|
||||
.B -r filename
|
||||
causes ruby to load the file using [4]require. It is useful
|
||||
with switches -n or -p.
|
||||
.B -r \fIfilename
|
||||
causes ruby to load the file using require. It is useful
|
||||
with switches -n or \fB-p\fR.
|
||||
.TP
|
||||
.B -s
|
||||
enables some switch parsing for switches after script name but
|
||||
before any filename arguments (or before a --). Any switches
|
||||
before any filename arguments (or before a \fB--\fR). Any switches
|
||||
found there is removed from ARGV and set the corresponding
|
||||
variable in the script.
|
||||
example:
|
||||
|
|
@ -278,7 +243,7 @@ example:
|
|||
.B -S
|
||||
makes ruby uses the PATH environment variable to search for
|
||||
script, unless if its name begins with a slash. This is used to
|
||||
emulate #! on machines that don't support it, in the following
|
||||
emulate \fB#!\fR on machines that don't support it, in the following
|
||||
manner:
|
||||
.nf
|
||||
.ne 2
|
||||
|
|
@ -287,17 +252,17 @@ manner:
|
|||
\& exec /usr/local/bin/ruby -S $0 $*
|
||||
.fi
|
||||
On some systems $0 does not always contain the full pathname,
|
||||
so you need -S switch to tell ruby to search for the script if
|
||||
so you need \fB-S\fR switch to tell ruby to search for the script if
|
||||
necessary.
|
||||
To handle embedded spaces or such, A better construct than $*
|
||||
would be ${1+"$@"}, but it does not work if the script is being
|
||||
To handle embedded spaces or such, A better construct than \fB$*\fR
|
||||
would be \fB${1+"$@"}\fR, but it does not work if the script is being
|
||||
interpreted by csh.
|
||||
.TP
|
||||
.B -v --verbose
|
||||
enables verbose mode. Ruby will prints its version at the
|
||||
beginning, and set the variable `$VERBOSE' to TRUE. Some
|
||||
beginning, and set the variable \fB$VERBOSE\fR to TRUE. Some
|
||||
methods prints extra messages if this variable is TRUE. If this
|
||||
switch is given, and no other switches present, ruby quits
|
||||
switch is given, and no other arguments present, ruby quits
|
||||
after printing its version.
|
||||
.TP
|
||||
.B --version
|
||||
|
|
@ -305,18 +270,18 @@ prints the version of ruby executable.
|
|||
.TP
|
||||
.B -w
|
||||
enables verbose mode without printing version message at the
|
||||
beginning. It set the variable `$VERBOSE' to TRUE.
|
||||
beginning. It set the variable \fB$VERBOSE\fR to TRUE.
|
||||
.TP
|
||||
.B -x[directory]
|
||||
.B -x\fR[\fIdirectory\fR]
|
||||
tells ruby that the script is embedded in a message. Leading
|
||||
garbage will be discarded until the first that starts with "#!"
|
||||
garbage will be discarded until the first that starts with "\fB#!\fR"
|
||||
and contains string "ruby". Any meaningful switches on that
|
||||
line will applied. The end of script must be specified with
|
||||
either EOF, ^D (control-D), ^Z (control-Z), or reserved word
|
||||
__END__.If the directory name is specified, ruby will switch to
|
||||
that directory before executing script.
|
||||
.TP
|
||||
.B -X directory
|
||||
.B -X \fIdirectory
|
||||
causes ruby to switch to the directory.
|
||||
.TP
|
||||
.B -y --yydebug
|
||||
|
|
|
|||
4
ruby.c
4
ruby.c
|
|
@ -48,7 +48,7 @@ static int version, copyright;
|
|||
|
||||
VALUE rb_debug = Qfalse;
|
||||
VALUE rb_verbose = Qfalse;
|
||||
int tainting = Qfalse;
|
||||
int rb_tainting = Qfalse;
|
||||
static int sflag = Qfalse;
|
||||
|
||||
char *ruby_inplace_mode = Qfalse;
|
||||
|
|
@ -309,7 +309,7 @@ proc_options(argcp, argvp)
|
|||
if (numlen == 0) v = 1;
|
||||
}
|
||||
rb_set_safe_level(v);
|
||||
tainting = Qtrue;
|
||||
rb_tainting = Qtrue;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
9
ruby.h
9
ruby.h
|
|
@ -380,9 +380,8 @@ void rb_define_const _((VALUE,char*,VALUE));
|
|||
void rb_define_global_const _((char*,VALUE));
|
||||
|
||||
void rb_define_method _((VALUE,char*,VALUE(*)(),int));
|
||||
void rb_define_function _((VALUE,char*,VALUE(*)(),int));
|
||||
void rb_define_module_function _((VALUE,char*,VALUE(*)(),int));
|
||||
void rb_define_global_function _((char *, VALUE (*)(), int));
|
||||
void rb_define_global_function _((char*,VALUE(*)(),int));
|
||||
|
||||
void rb_undef_method _((VALUE,char*));
|
||||
void rb_define_alias _((VALUE,char*,char*));
|
||||
|
|
@ -524,13 +523,7 @@ rb_special_const_p(VALUE obj)
|
|||
extern __inline__ int
|
||||
rb_test_false_or_nil(VALUE v)
|
||||
{
|
||||
#ifdef MACRUBY_PUBLIC_INTERFACE
|
||||
return (v != Qnil) && (v != RubyFALSE);
|
||||
return (v != Qnil) && (v != RubyFALSE);
|
||||
#else
|
||||
return (v != Qnil) && (v != Qfalse);
|
||||
return (v != Qnil) && (v != Qfalse);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
VALUE rb_class_of _((VALUE));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ extern int rb_prohibit_interrupt;
|
|||
extern int rb_trap_pending;
|
||||
void rb_trap_restore_mask _((void));
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
extern int rb_thread_critical;
|
||||
void rb_thread_schedule _((void));
|
||||
#if defined(HAVE_SETITIMER) && !defined(__BOW__)
|
||||
|
|
|
|||
4
signal.c
4
signal.c
|
|
@ -286,7 +286,7 @@ posix_signal(signum, handler)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef THREAD
|
||||
#ifdef USE_THREAD
|
||||
# define rb_interrupt rb_thread_interrupt
|
||||
# define rb_trap_eval rb_thread_trap_eval
|
||||
#endif
|
||||
|
|
@ -445,7 +445,7 @@ trap(arg)
|
|||
if (sig < 0 || sig > NSIG) {
|
||||
rb_raise(rb_eArgError, "Invalid signal no %d", sig);
|
||||
}
|
||||
#if defined(THREAD) && defined(HAVE_SETITIMER) && !defined(__BOW__)
|
||||
#if defined(USE_THREAD) && defined(HAVE_SETITIMER) && !defined(__BOW__)
|
||||
if (sig == SIGVTALRM) {
|
||||
rb_raise(rb_eArgError, "SIGVTALRM reserved for Thread; cannot set handler");
|
||||
}
|
||||
|
|
|
|||
106
string.c
106
string.c
|
|
@ -33,7 +33,7 @@ extern VALUE rb_rs;
|
|||
VALUE
|
||||
rb_str_new(ptr, len)
|
||||
char *ptr;
|
||||
unsigned len;
|
||||
int len;
|
||||
{
|
||||
NEWOBJ(str, struct RString);
|
||||
OBJSETUP(str, rb_cString, T_STRING);
|
||||
|
|
@ -346,9 +346,6 @@ rb_str_modify(str)
|
|||
{
|
||||
char *ptr;
|
||||
|
||||
if (rb_safe_level() >= 5) {
|
||||
rb_raise(rb_eSecurityError, "cannot change string status");
|
||||
}
|
||||
if (FL_TEST(str, STR_FREEZE))
|
||||
rb_raise(rb_eTypeError, "can't modify frozen string");
|
||||
if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return;
|
||||
|
|
@ -430,7 +427,7 @@ VALUE
|
|||
rb_str_cat(str, ptr, len)
|
||||
VALUE str;
|
||||
char *ptr;
|
||||
unsigned len;
|
||||
int len;
|
||||
{
|
||||
if (len > 0) {
|
||||
rb_str_modify(str);
|
||||
|
|
@ -1063,7 +1060,7 @@ rb_str_sub(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_sub_bang(argc, argv, rb_str_dup(str));
|
||||
VALUE val = rb_str_sub_bang(argc, argv, str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1167,7 +1164,7 @@ rb_str_gsub(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_gsub_bang(argc, argv, rb_str_dup(str));
|
||||
VALUE val = rb_str_gsub_bang(argc, argv, str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1214,13 +1211,11 @@ rb_f_sub(argc, argv)
|
|||
{
|
||||
VALUE line, v;
|
||||
|
||||
line = uscore_get();
|
||||
line = rb_str_dup(uscore_get());
|
||||
v = rb_str_sub_bang(argc, argv, line);
|
||||
if (!NIL_P(v)) {
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
}
|
||||
return line;
|
||||
if (NIL_P(v)) return line;
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
@ -1238,13 +1233,11 @@ rb_f_gsub(argc, argv)
|
|||
{
|
||||
VALUE line, v;
|
||||
|
||||
line = uscore_get();
|
||||
line = rb_str_dup(uscore_get());
|
||||
v = rb_str_gsub_bang(argc, argv, line);
|
||||
if (!NIL_P(v)) {
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
}
|
||||
return line;
|
||||
if (NIL_P(v)) return line;
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
@ -1366,15 +1359,10 @@ rb_str_inspect(str)
|
|||
CHECK(1);
|
||||
*b++ = c;
|
||||
}
|
||||
else if (c == '"') {
|
||||
else if (c == '"' || c == '\''|| c == '\\') {
|
||||
CHECK(2);
|
||||
*b++ = '\\';
|
||||
*b++ = '"';
|
||||
}
|
||||
else if (c == '\\') {
|
||||
CHECK(2);
|
||||
*b++ = '\\';
|
||||
*b++ = '\\';
|
||||
*b++ = c;
|
||||
}
|
||||
else if (ISPRINT(c)) {
|
||||
CHECK(1);
|
||||
|
|
@ -1440,7 +1428,7 @@ rb_str_dump(str)
|
|||
while (p < pend) {
|
||||
char c = *p++;
|
||||
switch (c) {
|
||||
case '"': case '\'':
|
||||
case '"': case '\'': case '\\':
|
||||
case '\n': case '\r':
|
||||
case '\t': case '\f':
|
||||
case '\013': case '\007': case '\033':
|
||||
|
|
@ -1466,7 +1454,7 @@ rb_str_dump(str)
|
|||
while (p < pend) {
|
||||
char c = *p++;
|
||||
|
||||
if (c == '"' || c == '\\') {
|
||||
if (c == '"' || c == '\'' || c == '\\') {
|
||||
*q++ = '\\';
|
||||
*q++ = c;
|
||||
}
|
||||
|
|
@ -1489,7 +1477,7 @@ rb_str_dump(str)
|
|||
*q++ = '\\';
|
||||
*q++ = 'f';
|
||||
}
|
||||
else if (c == '\13') {
|
||||
else if (c == '\013') {
|
||||
*q++ = '\\';
|
||||
*q++ = 'v';
|
||||
}
|
||||
|
|
@ -1497,7 +1485,7 @@ rb_str_dump(str)
|
|||
*q++ = '\\';
|
||||
*q++ = 'a';
|
||||
}
|
||||
else if (c == 033) {
|
||||
else if (c == '\033') {
|
||||
*q++ = '\\';
|
||||
*q++ = 'e';
|
||||
}
|
||||
|
|
@ -1540,7 +1528,7 @@ static VALUE
|
|||
rb_str_upcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_upcase_bang(rb_str_dup(str));
|
||||
VALUE val = rb_str_upcase_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1574,7 +1562,7 @@ static VALUE
|
|||
rb_str_downcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_downcase_bang(rb_str_dup(str));
|
||||
VALUE val = rb_str_downcase_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1610,7 +1598,7 @@ static VALUE
|
|||
rb_str_capitalize(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_capitalize_bang(rb_str_dup(str));
|
||||
VALUE val = rb_str_capitalize_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1648,7 +1636,7 @@ static VALUE
|
|||
rb_str_swapcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_swapcase_bang(rb_str_dup(str));
|
||||
VALUE val = rb_str_swapcase_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1803,7 +1791,7 @@ static VALUE
|
|||
rb_str_tr(str, src, repl)
|
||||
VALUE str, src, repl;
|
||||
{
|
||||
VALUE val = tr_trans(rb_str_dup(str), src, repl, 0);
|
||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 0);
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1866,7 +1854,7 @@ static VALUE
|
|||
rb_str_delete(str1, str2)
|
||||
VALUE str1, str2;
|
||||
{
|
||||
VALUE val = rb_str_delete_bang(rb_str_dup(str1), str2);
|
||||
VALUE val = rb_str_delete_bang(str1 = rb_str_dup(str1), str2);
|
||||
|
||||
if (NIL_P(val)) return str1;
|
||||
return val;
|
||||
|
|
@ -1930,7 +1918,7 @@ rb_str_squeeze(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_squeeze_bang(argc, argv, rb_str_dup(str));
|
||||
VALUE val = rb_str_squeeze_bang(argc, argv, str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -1947,7 +1935,7 @@ static VALUE
|
|||
rb_str_tr_s(str, src, repl)
|
||||
VALUE str, src, repl;
|
||||
{
|
||||
VALUE val = tr_trans(rb_str_dup(str), src, repl, 1);
|
||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 1);
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -2141,25 +2129,22 @@ rb_str_each_line(argc, argv, str)
|
|||
|
||||
for (s = p, p += rslen; p < pend; p++) {
|
||||
if (rslen == 0 && *p == '\n') {
|
||||
if (*(p+1) != '\n') continue;
|
||||
if (p[1] != '\n') continue;
|
||||
while (*p == '\n') p++;
|
||||
p--;
|
||||
}
|
||||
if (*p == newline &&
|
||||
if (p[-1] == newline &&
|
||||
(rslen <= 1 ||
|
||||
memcmp(RSTRING(rs)->ptr, p-rslen+1, rslen) == 0)) {
|
||||
line = rb_str_new(s, p - s + 1);
|
||||
rb_lastline_set(line);
|
||||
memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
|
||||
line = rb_str_new(s, p - s);
|
||||
rb_yield(line);
|
||||
if (RSTRING(str)->ptr != ptr || RSTRING(str)->len != len)
|
||||
rb_raise(rb_eArgError, "string modified");
|
||||
s = p + 1;
|
||||
s = p;
|
||||
}
|
||||
}
|
||||
|
||||
if (s != pend) {
|
||||
line = rb_str_new(s, p - s);
|
||||
rb_lastline_set(line);
|
||||
rb_yield(line);
|
||||
}
|
||||
|
||||
|
|
@ -2201,7 +2186,7 @@ static VALUE
|
|||
rb_str_chop(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_chop_bang(rb_str_dup(str));
|
||||
VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -2217,12 +2202,12 @@ rb_f_chop_bang(str)
|
|||
static VALUE
|
||||
rb_f_chop()
|
||||
{
|
||||
VALUE str = uscore_get();
|
||||
VALUE str = rb_str_dup(uscore_get());
|
||||
VALUE val = rb_str_chop_bang(str);
|
||||
|
||||
str = rb_str_chop_bang(rb_str_dup(str));
|
||||
if (NIL_P(str)) return uscore_get();
|
||||
rb_lastline_set(str);
|
||||
return str;
|
||||
if (NIL_P(str)) return str;
|
||||
rb_lastline_set(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
@ -2274,7 +2259,7 @@ rb_str_chomp(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(str));
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -2293,9 +2278,10 @@ rb_f_chomp(argc, argv)
|
|||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(uscore_get()));
|
||||
VALUE str = rb_str_dup(uscore_get());
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, str);
|
||||
|
||||
if (NIL_P(val)) return uscore_get();
|
||||
if (NIL_P(val)) return str;
|
||||
rb_lastline_set(val);
|
||||
return val;
|
||||
}
|
||||
|
|
@ -2340,7 +2326,8 @@ static VALUE
|
|||
rb_str_strip(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_strip_bang(rb_str_dup(str));
|
||||
|
||||
VALUE val = rb_str_strip_bang(str = rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
|
@ -2358,8 +2345,11 @@ scan_once(str, pat, start)
|
|||
if (rb_reg_search(pat, str, *start, 0) >= 0) {
|
||||
match = rb_backref_get();
|
||||
regs = RMATCH(match)->regs;
|
||||
if (END(0) == *start) {
|
||||
*start = END(0)+1;
|
||||
if (BEG(0) == END(0)) {
|
||||
/*
|
||||
* Always consume at least one character of the input string
|
||||
*/
|
||||
*start = END(0)+(ismbchar(RSTRING(str)->ptr[END(0)])?2:1);
|
||||
}
|
||||
else {
|
||||
*start = END(0);
|
||||
|
|
|
|||
26
util.c
26
util.c
|
|
@ -232,7 +232,9 @@ static char suffix2[] = ".~~~";
|
|||
#define strEQ(s1,s2) (strcmp(s1,s2) == 0)
|
||||
|
||||
void
|
||||
add_suffix(VALUE str, char *suffix)
|
||||
add_suffix(str, suffix)
|
||||
VALUE str;
|
||||
char *suffix;
|
||||
{
|
||||
int baselen;
|
||||
int extlen = strlen(suffix);
|
||||
|
|
@ -560,7 +562,7 @@ static int mmkind, mmsize, high, low;
|
|||
#define C ((int*)c)
|
||||
#define D ((int*)d)
|
||||
|
||||
static void mmprepare( void *base, int size )
|
||||
static void mmprepare(base, size) void *base; int size;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (sizeof(int) != 4) die("sizeof(int) != 4");
|
||||
|
|
@ -577,7 +579,7 @@ static void mmprepare( void *base, int size )
|
|||
low = (size & 0x0C );
|
||||
}
|
||||
|
||||
static void mmswap( register char *a, register char *b )
|
||||
static void mmswap(a, b) register char *a, *b;
|
||||
{
|
||||
register int s;
|
||||
if (a == b) return;
|
||||
|
|
@ -600,7 +602,7 @@ static void mmswap( register char *a, register char *b )
|
|||
}
|
||||
}
|
||||
|
||||
static void mmswapblock( register char *a, register char *b, int size )
|
||||
static void mmswapblock(a, b, size) register char *a, *b; int size;
|
||||
{
|
||||
register int s;
|
||||
if (mmkind >= 0) {
|
||||
|
|
@ -622,7 +624,7 @@ static void mmswapblock( register char *a, register char *b, int size )
|
|||
}
|
||||
}
|
||||
|
||||
static void mmrot3( register char *a, register char *b, register char *c )
|
||||
static void mmrot3(a, b, c) register char *a, *b, *c;
|
||||
{
|
||||
register int s;
|
||||
if (mmkind >= 0) {
|
||||
|
|
@ -661,14 +663,14 @@ typedef struct { char *LL, *RR; } stack_node; /* Stack structure for L,l,R,r */
|
|||
((*cmp)(b,c)<0 ? b : ((*cmp)(a,c)<0 ? c : a)) : \
|
||||
((*cmp)(b,c)>0 ? b : ((*cmp)(a,c)<0 ? a : c)) )
|
||||
|
||||
void qsort (base, nel, size, cmp) void* base; size_t nel; size_t size; int (*cmp)();
|
||||
void ruby_qsort (base, nel, size, cmp) void* base; int nel; int size; int (*cmp)();
|
||||
{
|
||||
register char *l, *r, *m; /*l,r:左右の集団の端 m:配列の中央の位置*/
|
||||
register int t, eq_l, eq_r; /*eq_l:左の集団が全てsに等しいことを示す*/
|
||||
char *L = base; /*現在分割している区間の左端の要素の先頭 */
|
||||
char *R = base + size * (nel - 1); /*現在分割している区間の右端の要素の先頭 */
|
||||
int chklim = 63; /*昇(降)順検査をする要素数の下限*/
|
||||
stack_node stack[32], *top = stack; /* 32 32ビットマシンでは32で十分*/
|
||||
register char *l, *r, *m; /* l,r:left,right group m:median point */
|
||||
register int t, eq_l, eq_r; /* eq_l: all items in left group are equal to S */
|
||||
char *L = base; /* left end of curren region */
|
||||
char *R = (char*)base + size*(nel-1); /* right end of current region */
|
||||
int chklim = 63; /* threshold of ordering element check */
|
||||
stack_node stack[32], *top = stack; /* 32 is enough for 32bit CPU */
|
||||
|
||||
if (nel <= 1) return; /* need not to sort */
|
||||
mmprepare( base, size );
|
||||
|
|
|
|||
17
util.h
17
util.h
|
|
@ -12,16 +12,27 @@
|
|||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#ifndef _
|
||||
# ifdef __STDC__
|
||||
# define _(args) args
|
||||
# else
|
||||
# define _(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define scan_oct ruby_scan_oct
|
||||
unsigned long scan_oct();
|
||||
unsigned long scan_oct _((char*, int, int*));
|
||||
#define scan_hex ruby_scan_hex
|
||||
unsigned long scan_hex();
|
||||
unsigned long scan_hex _((char*, int, int*));
|
||||
|
||||
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(NT)
|
||||
#define add_suffix ruby_add_suffix
|
||||
void add_suffix();
|
||||
#endif
|
||||
|
||||
char *ruby_mktemp();
|
||||
char *ruby_mktemp _((void));
|
||||
|
||||
void ruby_qsort _((void*, int, int, int (*)()));
|
||||
#define qsort(b,n,s,c) ruby_qsort(b,n,s,c)
|
||||
|
||||
#endif /* UTIL_H */
|
||||
|
|
|
|||
|
|
@ -722,9 +722,6 @@ rb_ivar_set(obj, id, val)
|
|||
ID id;
|
||||
VALUE val;
|
||||
{
|
||||
if (rb_safe_level() >= 5) {
|
||||
rb_raise(rb_eSecurityError, "cannot change object status");
|
||||
}
|
||||
switch (TYPE(obj)) {
|
||||
case T_OBJECT:
|
||||
case T_CLASS:
|
||||
|
|
@ -1037,6 +1034,10 @@ rb_define_const(klass, name, val)
|
|||
VALUE val;
|
||||
{
|
||||
ID id = rb_intern(name);
|
||||
|
||||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
if (!rb_is_const_id(id)) {
|
||||
rb_raise(rb_eNameError, "wrong constant name %s", name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define RUBY_VERSION "1.1c4"
|
||||
#define VERSION_DATE "98/09/03"
|
||||
#define RUBY_VERSION "1.1d0"
|
||||
#define VERSION_DATE "98/09/08"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue