mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
990715
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e12510c502
commit
86307f52ee
39 changed files with 1095 additions and 629 deletions
138
ChangeLog
138
ChangeLog
|
@ -1,6 +1,136 @@
|
|||
Fri Jun 25 13:07:20 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
|
||||
Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* missing/isinf.c: include "config.h" added.
|
||||
* version 1.3.5 - version 1.4 alpha
|
||||
|
||||
Wed Jul 14 23:45:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||
|
||||
* eval.c (ruby_init): initialize for the first time only.
|
||||
|
||||
Tue Jul 13 00:15:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* hash.c (rb_hash_index): re-defined; method to retrieve a key
|
||||
from the value.
|
||||
|
||||
* hash.c (Init_Hash): member? should be re-defined for Hash.
|
||||
|
||||
Tue Jul 12 13:54:51 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
|
||||
|
||||
* io.c (rb_file_sysopen): wrong number of argument.
|
||||
|
||||
Mon Jul 12 11:52:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* eval.c (rb_f_missing): class name included in message.
|
||||
|
||||
* eval.c (print_undef): better error message.
|
||||
|
||||
Sun Jul 11 05:36:17 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
|
||||
|
||||
* lib/debug.rb: patch to show proper position.
|
||||
|
||||
Fri Jul 9 23:56:14 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||
|
||||
* dln.c (dln_find_1): path conv. moved to conv_to_posix_path.
|
||||
|
||||
* dln.c (conv_to_posix_path): path conv. should be done.
|
||||
|
||||
Fri Jul 9 10:26:47 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
|
||||
|
||||
* random.c (RANDOM_NUMBER): should place parentheses.
|
||||
|
||||
Fri Jul 8 11:00:51 1999 Shugo Maeda <shugo@netlab.co.jp>
|
||||
|
||||
* numeric.c (fix_div): division may be out of fixnum range.
|
||||
|
||||
* bignum.c (bigdivmod): proper sign calculation to result.
|
||||
|
||||
Wed Jul 7 18:27:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* st.c (st_delete_safe): was modifying wrong slot.
|
||||
|
||||
Mon Jul 5 13:17:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* gc.c (rb_gc_call_finalizer_at_exit): close all files at exit.
|
||||
|
||||
Fri Jul 2 18:00:21 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
|
||||
|
||||
* lib/Mail/README: Mail-0.3.0 added to the distribution.
|
||||
|
||||
Fri Jul 2 01:45:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* regex.c (re_compile_fastmap): avoid allocation of register
|
||||
variables for each invocation of re_match(). Suggested by
|
||||
Zasukhin Ruslan <ruslan@paradigmasoft.com>. Thanks.
|
||||
|
||||
Tue Jun 29 20:39:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* ext/tk/lib/tk.rb (TkVariable): bug fix; should value type check
|
||||
be added?
|
||||
|
||||
* string.c (rb_str_each_line): a bug in paragraph mode.
|
||||
|
||||
* ruby.c (load_file): shifted too much to skip #!.
|
||||
|
||||
Tue Jun 29 06:50:21 1999 Wakou Aoyama <wakou@fsinet.or.jp>
|
||||
|
||||
* lib/CGI.rb: 0.30 - cleanup release, incompatible.
|
||||
|
||||
* lib/telnet.rb: 0.22 - timeout added.
|
||||
|
||||
Tue Jun 29 10:49:25 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
|
||||
|
||||
* configure.in: better Rhapsody support.
|
||||
|
||||
* lib/mkmf.rb: Rhapsody/NEXTSTEP support.
|
||||
|
||||
Tue Jun 29 01:42:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* ext/pty/pty.c (chld_changed): should use POSIX.1 style wait.
|
||||
|
||||
Mon Jun 28 21:07:36 1999 KIMURA Koichi <kbk@kt.rim.or.jp>
|
||||
|
||||
* ext/extmk.rb.nt: wrong result for have_library().
|
||||
|
||||
Mon Jun 28 15:24:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* missing/isinf.c: OSF/1 raises SIGFPE on one()/zero().
|
||||
|
||||
* regex.c (re_search): should search til EOS, for patterns may
|
||||
match beyond the end of range.
|
||||
|
||||
Mon Jun 28 12:49:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_f_select): should not accept Time objects as an
|
||||
argument for it is time interval.
|
||||
|
||||
* process.c (rb_f_sleep): ditto.
|
||||
|
||||
* file.c (test_s): should return nil for false condition.
|
||||
|
||||
Mon Jun 28 12:23:52 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||
|
||||
* bignum.c (rb_dbl2big): typo.
|
||||
|
||||
* file.c (rb_f_test): ditto.
|
||||
|
||||
* string.c (rb_str_crypt): wrong message.
|
||||
|
||||
Sun Jun 27 19:50:11 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
|
||||
|
||||
* eval.c (rb_f_exit): should have treat signed integer status, not
|
||||
VALUE.
|
||||
|
||||
* process.c (rb_f_exit_bang): should work like exit().
|
||||
|
||||
Sun Jun 27 16:21:32 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||
|
||||
* string.c (rb_str_rindex): wrong position to search.
|
||||
|
||||
Sat Jun 26 04:05:30 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
|
||||
|
||||
* configure.in (configure_args): --with-search-path to specify
|
||||
additional ruby search path.
|
||||
|
||||
* ruby.c (ruby_prog_init): additional search path.
|
||||
|
||||
Fri Jun 25 13:09:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
|
@ -9,6 +139,10 @@ Fri Jun 25 13:09:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
|||
* regex.c (re_compile_pattern): add start_paren to avoid too much
|
||||
finalization on maybe_finalize_jump.
|
||||
|
||||
Fri Jun 25 13:07:20 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
|
||||
|
||||
* missing/isinf.c: include "config.h" added.
|
||||
|
||||
Fri Jun 25 07:25:05 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||
|
||||
* lib/mkmf.rb: initialize $(topdir).
|
||||
|
|
15
MANIFEST
15
MANIFEST
|
@ -89,6 +89,21 @@ ext/extmk.rb.nt
|
|||
lib/CGI.rb
|
||||
lib/English.rb
|
||||
lib/Env.rb
|
||||
lib/Mail/README
|
||||
lib/Mail/README.jp
|
||||
lib/Mail/doc.jp/changes.html
|
||||
lib/Mail/doc.jp/index.html
|
||||
lib/Mail/doc.jp/pop.html
|
||||
lib/Mail/doc.jp/session.html
|
||||
lib/Mail/doc.jp/smtp.html
|
||||
lib/Mail/doc/changes.html
|
||||
lib/Mail/doc/index.html
|
||||
lib/Mail/doc/pop.html
|
||||
lib/Mail/doc/session.html
|
||||
lib/Mail/doc/smtp.html
|
||||
lib/Mail/pop.rb
|
||||
lib/Mail/session.rb
|
||||
lib/Mail/smtp.rb
|
||||
lib/README
|
||||
lib/base64.rb
|
||||
lib/cgi-lib.rb
|
||||
|
|
18
ToDo
18
ToDo
|
@ -1,11 +1,13 @@
|
|||
Language Spec.
|
||||
|
||||
* %w(a\ b\ c abc) => ["a b c", "abc"]
|
||||
* package or access control for global variables
|
||||
* named arguments like foo(nation:="german" or nation: "german").
|
||||
* named arguments like foo(nation:="german") or foo(nation: "german").
|
||||
* method to retrieve argument information (need new C API)
|
||||
* multiple return values, yield values. maybe imcompatible
|
||||
* cascading method invocation.
|
||||
* def Class#method .. end
|
||||
* multiple return values, yield values. maybe incompatible
|
||||
* cascading method invocation ???
|
||||
* def Class#method .. end ??
|
||||
* class Foo::Bar<Baz .. end, module Boo::Bar .. end
|
||||
|
||||
Hacking Interpreter
|
||||
|
||||
|
@ -15,14 +17,17 @@ Hacking Interpreter
|
|||
* remove rb_eval() recursions
|
||||
* syntax tree -> bytecode ???
|
||||
* scrambled script, or script filter
|
||||
* setuid ruby
|
||||
|
||||
Standard Libraries
|
||||
|
||||
* IO/File to call initialize
|
||||
* String#scanf(?)
|
||||
* Object#fmt(?)
|
||||
* Integer[num], Float[num] (String[str]?, Array[obj]??)
|
||||
* Stream or Port, abstract superclass of IO.
|
||||
* method to detect non-number trailer for to_i/to_f.
|
||||
* Stream or Port, abstract superclass of IO ?
|
||||
* String#{pred,prev}, String#downto
|
||||
* optional stepsize argument for succ()
|
||||
|
||||
Extension Libraries
|
||||
|
||||
|
@ -31,6 +36,7 @@ Extension Libraries
|
|||
|
||||
Ruby Libraries
|
||||
|
||||
* maillib {pop3,smtp}
|
||||
* httplib.rb, urllib.rb, nttplib.rb, etc.
|
||||
* format like perl's
|
||||
|
||||
|
|
3
bignum.c
3
bignum.c
|
@ -404,7 +404,7 @@ rb_dbl2big(d)
|
|||
double u = (d < 0)?-d:d;
|
||||
|
||||
if (isinf(d)) {
|
||||
rb_raise(rb_eFloatDomainError, d < 0 ? "-Inifinity" : "Inifinity");
|
||||
rb_raise(rb_eFloatDomainError, d < 0 ? "-Infinity" : "Infinity");
|
||||
}
|
||||
if (isnan(d)) {
|
||||
rb_raise(rb_eFloatDomainError, "NaN");
|
||||
|
@ -725,6 +725,7 @@ bigdivmod(x, y, div, mod, modulo)
|
|||
zds[i] = (USHORT)(t2 / dd);
|
||||
t2 %= dd;
|
||||
}
|
||||
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
|
||||
if (div) *div = bignorm(z);
|
||||
if (mod) {
|
||||
if (!RBIGNUM(y)->sign) t2 = -(long)t2;
|
||||
|
|
27
configure.in
27
configure.in
|
@ -39,19 +39,11 @@ AC_ARG_ENABLE(fat-binary,
|
|||
case "$host_os" in
|
||||
rhapsody*)
|
||||
echo -n "MacOS X Server: "
|
||||
if test "$TARGET_ARCHS" = "" ; then
|
||||
TARGET_ARCHS="ppc i386"
|
||||
fi
|
||||
if test "$TARGET_ARCHS" = "" ; then
|
||||
TARGET_ARCHS="ppc i386"
|
||||
fi
|
||||
;;
|
||||
nextstep*|openstep*)
|
||||
echo -n "NeXTSTEP/OPENSTEP: "
|
||||
|
||||
if test "$host_os" = "rhapsody" ; then
|
||||
echo -n "Rhapsody: "
|
||||
if test "$TARGET_ARCHS" = "" ; then
|
||||
TARGET_ARCHS="ppc i486"
|
||||
fi
|
||||
else
|
||||
echo -n "NeXTSTEP/OPENSTEP: "
|
||||
if test "$TARGET_ARCHS" = "" ; then
|
||||
if test `/usr/bin/arch` = "m68k" ; then
|
||||
|
@ -60,7 +52,6 @@ AC_ARG_ENABLE(fat-binary,
|
|||
TARGET_ARCHS="m68k `/usr/bin/arch`"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
|
||||
|
@ -162,9 +153,10 @@ AC_CHECK_LIB(xpg4, setlocale) # FreeBSD needs this
|
|||
dnl Checks for header files.
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/file.h sys/ioctl.h pwd.h \
|
||||
sys/select.h sys/time.h sys/times.h sys/param.h sys/wait.h\
|
||||
syscall.h a.out.h string.h utime.h memory.h direct.h fnmatch.h)
|
||||
sys/select.h sys/time.h sys/times.h sys/param.h syscall.h\
|
||||
a.out.h string.h utime.h memory.h direct.h fnmatch.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_TYPE_UID_T
|
||||
|
@ -315,7 +307,7 @@ fi
|
|||
dnl default value for $KANJI
|
||||
AC_SUBST(DEFAULT_KCODE)
|
||||
AC_ARG_WITH(default-kcode,
|
||||
[--with-default-kcode=CODE speficy default value for \$KCODE (utf8|euc|sjis|none)],
|
||||
[--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
|
||||
[case $withval in
|
||||
utf8) AC_DEFINE(DEFAULT_KCODE, KCODE_UTF8);;
|
||||
euc) AC_DEFINE(DEFAULT_KCODE, KCODE_EUC);;
|
||||
|
@ -786,6 +778,11 @@ fi
|
|||
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
|
||||
AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH}/${arch}")
|
||||
|
||||
AC_ARG_WITH(search-path,
|
||||
[--with-search-path specify the additional search path],
|
||||
[search_path=$withval])
|
||||
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
|
||||
|
||||
echo "creating config.h"
|
||||
cat confdefs.h > config.h
|
||||
|
||||
|
|
9
dln.c
9
dln.c
|
@ -1565,7 +1565,7 @@ conv_to_posix_path(win32, posix, len)
|
|||
if (len < strlen(first))
|
||||
fprintf(stderr, "PATH length too long: %s\n", first);
|
||||
else
|
||||
strcpy(posix, first);
|
||||
cygwin32_conv_to_posix_path(first, posix);
|
||||
return dst;
|
||||
}
|
||||
#endif
|
||||
|
@ -1587,13 +1587,6 @@ dln_find_1(fname, path, exe_flag)
|
|||
const char* mac_fullpath;
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN32__)
|
||||
int pathlen = 2 * strlen(path);
|
||||
int rubypathlen = pathlen > MAXPATHLEN ? pathlen : MAXPATHLEN;
|
||||
char *rubypath = alloca(rubypathlen);
|
||||
conv_to_posix_path(path, rubypath, rubypathlen);
|
||||
path = rubypath;
|
||||
#endif
|
||||
if (fname[0] == '/') return fname;
|
||||
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
|
||||
return fname;
|
||||
|
|
95
eval.c
95
eval.c
|
@ -68,6 +68,19 @@ static int scope_vmode;
|
|||
#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
|
||||
#define SCOPE_TEST(f) (scope_vmode&(f))
|
||||
|
||||
static void print_undef _((VALUE, ID)) NORETURN;
|
||||
static void
|
||||
print_undef(klass, id)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
{
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for %s `%s'",
|
||||
rb_id2name(id),
|
||||
(TYPE(klass) == T_MODULE)?"module":"class",
|
||||
rb_class2name(klass));
|
||||
}
|
||||
|
||||
|
||||
#define CACHE_SIZE 0x800
|
||||
#define CACHE_MASK 0x7ff
|
||||
#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
|
||||
|
@ -202,8 +215,7 @@ rb_alias(klass, name, def)
|
|||
}
|
||||
}
|
||||
if (!orig || !orig->nd_body) {
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
|
||||
rb_id2name(def), rb_class2name(klass));
|
||||
print_undef(klass, def);
|
||||
}
|
||||
body = orig->nd_body;
|
||||
if (nd_type(body) == NODE_FBODY) { /* was alias */
|
||||
|
@ -252,8 +264,7 @@ rb_disable_super(klass, name)
|
|||
|
||||
body = search_method(klass, mid, &origin);
|
||||
if (!body || !body->nd_body) {
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
|
||||
rb_id2name(mid), rb_class2name(klass));
|
||||
print_undef(klass, mid);
|
||||
}
|
||||
if (origin == klass) {
|
||||
body->nd_noex |= NOEX_UNDEF;
|
||||
|
@ -275,8 +286,7 @@ rb_enable_super(klass, name)
|
|||
|
||||
body = search_method(klass, mid, &origin);
|
||||
if (!body || !body->nd_body || origin != klass) {
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
|
||||
rb_id2name(mid), rb_class2name(klass));
|
||||
print_undef(klass, mid);
|
||||
}
|
||||
body->nd_noex &= ~NOEX_UNDEF;
|
||||
}
|
||||
|
@ -298,8 +308,7 @@ rb_export_method(klass, name, noex)
|
|||
body = search_method(rb_cObject, name, &origin);
|
||||
}
|
||||
if (!body) {
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for `%s'",
|
||||
rb_id2name(name), rb_class2name(klass));
|
||||
print_undef(klass, name);
|
||||
}
|
||||
if (body->nd_noex != noex) {
|
||||
if (klass == origin) {
|
||||
|
@ -370,7 +379,7 @@ rb_attr(klass, id, read, write, ex)
|
|||
}
|
||||
}
|
||||
|
||||
static ID init, eqq, each, aref, aset, match;
|
||||
static ID init, eqq, each, aref, aset, match, missing;
|
||||
VALUE ruby_errinfo = Qnil;
|
||||
extern NODE *ruby_eval_tree_begin;
|
||||
extern NODE *ruby_eval_tree;
|
||||
|
@ -886,10 +895,15 @@ void Init_ext _((void));
|
|||
void
|
||||
ruby_init()
|
||||
{
|
||||
static int initialized = 0;
|
||||
static struct FRAME frame;
|
||||
static struct iter iter;
|
||||
int state;
|
||||
|
||||
if (initialized)
|
||||
return;
|
||||
initialized = 1;
|
||||
|
||||
ruby_frame = top_frame = &frame;
|
||||
ruby_iter = &iter;
|
||||
|
||||
|
@ -2648,6 +2662,9 @@ rb_eval(self, node)
|
|||
s0 = "";
|
||||
}
|
||||
}
|
||||
else if (TYPE(klass) == T_MODULE) {
|
||||
s0 = " module";
|
||||
}
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
|
||||
rb_id2name(node->nd_mid),s0,rb_class2name(klass));
|
||||
}
|
||||
|
@ -2935,15 +2952,16 @@ rb_f_exit(argc, argv, obj)
|
|||
VALUE obj;
|
||||
{
|
||||
VALUE status;
|
||||
int istatus;
|
||||
|
||||
rb_secure(4);
|
||||
if (rb_scan_args(argc, argv, "01", &status) == 1) {
|
||||
status = NUM2INT(status);
|
||||
istatus = NUM2INT(status);
|
||||
}
|
||||
else {
|
||||
status = 0;
|
||||
istatus = 0;
|
||||
}
|
||||
rb_exit(status);
|
||||
rb_exit(istatus);
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
|
@ -3526,23 +3544,20 @@ rb_f_missing(argc, argv, obj)
|
|||
}
|
||||
if (d) {
|
||||
if (last_call_status & CSTAT_PRIV) {
|
||||
format = "private method `%s' called for %s";
|
||||
format = "private method `%s' called for %s%s%s";
|
||||
}
|
||||
if (last_call_status & CSTAT_PROT) {
|
||||
format = "protected method `%s' called for %s";
|
||||
}
|
||||
else if (rb_iterator_p()) {
|
||||
format = "undefined iterator `%s' for %s";
|
||||
format = "protected method `%s' called for %s%s%s";
|
||||
}
|
||||
else if (last_call_status & CSTAT_VCALL) {
|
||||
const char *mname = rb_id2name(id);
|
||||
|
||||
if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
|
||||
format = "undefined local variable or method `%s' for %s";
|
||||
format = "undefined local variable or method `%s' for %s%s%s";
|
||||
}
|
||||
}
|
||||
if (!format) {
|
||||
format = "undefined method `%s' for %s";
|
||||
format = "undefined method `%s' for %s%s%s";
|
||||
}
|
||||
if (RSTRING(d)->len > 65) {
|
||||
d = rb_any_to_s(obj);
|
||||
|
@ -3555,7 +3570,9 @@ rb_f_missing(argc, argv, obj)
|
|||
PUSH_FRAME(); /* fake frame */
|
||||
*ruby_frame = *_frame.prev->prev;
|
||||
|
||||
rb_raise(rb_eNameError, format, rb_id2name(id), desc);
|
||||
rb_raise(rb_eNameError, format, rb_id2name(id),
|
||||
desc, desc[0]=='#'?"":":",
|
||||
desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
|
||||
POP_FRAME();
|
||||
|
||||
return Qnil; /* not reached */
|
||||
|
@ -3577,7 +3594,7 @@ rb_undefined(obj, id, argc, argv, call_status)
|
|||
|
||||
last_call_status = call_status;
|
||||
|
||||
return rb_funcall2(obj, rb_intern("method_missing"), argc+1, nargv);
|
||||
return rb_funcall2(obj, missing, argc+1, nargv);
|
||||
}
|
||||
|
||||
#ifdef DJGPP
|
||||
|
@ -3941,17 +3958,19 @@ rb_call(klass, recv, mid, argc, argv, scope)
|
|||
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
|
||||
}
|
||||
|
||||
/* receiver specified form for private method */
|
||||
if ((noex & NOEX_PRIVATE) && scope == 0)
|
||||
return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
|
||||
if (mid != missing) {
|
||||
/* receiver specified form for private method */
|
||||
if ((noex & NOEX_PRIVATE) && scope == 0)
|
||||
return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
|
||||
|
||||
/* self must be kind of a specified form for private method */
|
||||
if ((noex & NOEX_PROTECTED)) {
|
||||
VALUE defined_class = klass;
|
||||
while (TYPE(defined_class) == T_ICLASS)
|
||||
defined_class = RBASIC(defined_class)->klass;
|
||||
if (!rb_obj_is_kind_of(ruby_frame->self, defined_class))
|
||||
return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
|
||||
/* self must be kind of a specified form for private method */
|
||||
if ((noex & NOEX_PROTECTED)) {
|
||||
VALUE defined_class = klass;
|
||||
while (TYPE(defined_class) == T_ICLASS)
|
||||
defined_class = RBASIC(defined_class)->klass;
|
||||
if (!rb_obj_is_kind_of(ruby_frame->self, defined_class))
|
||||
return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
|
||||
}
|
||||
}
|
||||
|
||||
return rb_call0(klass, recv, id, argc, argv, body, noex & NOEX_UNDEF);
|
||||
|
@ -4859,8 +4878,7 @@ rb_mod_modfunc(argc, argv, module)
|
|||
id = rb_to_id(argv[i]);
|
||||
body = search_method(module, id, 0);
|
||||
if (body == 0 || body->nd_body == 0) {
|
||||
rb_raise(rb_eNameError, "undefined method `%s' for module `%s'",
|
||||
rb_id2name(id), rb_class2name(module));
|
||||
rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
|
||||
}
|
||||
rb_clear_cache_by_id(id);
|
||||
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
|
||||
|
@ -5109,6 +5127,7 @@ Init_eval()
|
|||
aref = rb_intern("[]");
|
||||
aset = rb_intern("[]=");
|
||||
match = rb_intern("=~");
|
||||
missing = rb_intern("method_missing");
|
||||
|
||||
rb_global_variable((VALUE*)&top_scope);
|
||||
rb_global_variable((VALUE*)&ruby_eval_tree_begin);
|
||||
|
@ -5873,10 +5892,10 @@ struct thread {
|
|||
VALUE thread;
|
||||
};
|
||||
|
||||
static thread_t curr_thread;
|
||||
static int num_waiting_on_fd;
|
||||
static int num_waiting_on_timer;
|
||||
static int num_waiting_on_join;
|
||||
static thread_t curr_thread = 0;
|
||||
static int num_waiting_on_fd = 0;
|
||||
static int num_waiting_on_timer = 0;
|
||||
static int num_waiting_on_join = 0;
|
||||
|
||||
#define FOREACH_THREAD_FROM(f,x) x = f; do { x = x->next;
|
||||
#define END_FOREACH_FROM(f,x) } while (x != f)
|
||||
|
@ -7281,7 +7300,7 @@ Init_Thread()
|
|||
rb_cContinuation = rb_define_class("Continuation", rb_cObject);
|
||||
rb_undef_method(CLASS_OF(rb_cContinuation), "new");
|
||||
rb_define_method(rb_cContinuation, "call", rb_continuation_call, -1);
|
||||
rb_define_method(rb_mKernel, "callcc", rb_callcc, 0);
|
||||
rb_define_global_function("callcc", rb_callcc, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -438,11 +438,6 @@ $(DLLIB): $(OBJS)
|
|||
mfile.printf "\
|
||||
$(DLLIB): $(OBJS)
|
||||
ar cru $(DLLIB) $(OBJS)
|
||||
"
|
||||
elsif PLATFORM =~ "-nextstep" || PLATFORM =~ "-openstep" || PLATFORM =~ "-rhapsody"
|
||||
mfile.printf "\
|
||||
$(DLLIB): $(OBJS)
|
||||
cc -r $(CFLAGS) -o $(DLLIB) $(OBJS)
|
||||
"
|
||||
else
|
||||
mfile.printf "\
|
||||
|
|
|
@ -61,8 +61,8 @@ end
|
|||
|
||||
CFLAGS = ""
|
||||
#LINK = "cl -o conftest.exe -I../.. -Zi -O -I. %s conftest.c %s > nul"
|
||||
LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s > nul"
|
||||
CPP = "cl -E -I../.. -I../../missing -I../../win32 -I. -Zi -O %s conftest.c > nul"
|
||||
LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s %s > nul"
|
||||
CPP = "cl -E -I#{$ruby_inc} -I#{$ruby_inc}/missing -I#{$ruby_inc}/win32 -I. -Zi -O %s conftest.c > nul"
|
||||
$null = open("nul", "w")
|
||||
|
||||
$orgerr = $stderr.dup
|
||||
|
@ -322,7 +322,7 @@ VPATH = .
|
|||
|
||||
CC = cl
|
||||
|
||||
CFLAGS = %s -I../.. -I../../missing -I../../win32 -I. -O -DNT %s #{CFLAGS} #{$CFLAGS} %s
|
||||
CFLAGS = %s -I#{$ruby_inc} -I#{$ruby_inc}/missing -I#{$ruby_inc}/win32 -I. -O -DNT %s #{CFLAGS} #{$CFLAGS} %s
|
||||
|
||||
RUBYLIB = ../../ruby.lib
|
||||
DLDFLAGS = /DLL
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
#if !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#else
|
||||
#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#include <ruby.h>
|
||||
|
@ -160,7 +164,7 @@ chld_changed()
|
|||
#ifdef HAVE_WAITPID
|
||||
cpid = waitpid(-1, &statusp, WUNTRACED|WNOHANG);
|
||||
#else
|
||||
cpid = wait3((int *) &statusp, WUNTRACED|WNOHANG, 0);
|
||||
cpid = wait3(&statusp, WUNTRACED|WNOHANG, 0);
|
||||
#endif
|
||||
if (cpid == 0 || cpid == -1)
|
||||
return;
|
||||
|
|
|
@ -753,10 +753,9 @@ class TkVariable
|
|||
if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
|
||||
raise
|
||||
else
|
||||
INTERP._eval(format('global %s; unset %s'), @id, @id)
|
||||
if val == []
|
||||
INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
|
||||
@id, @id, @id))
|
||||
INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)',
|
||||
@id, @id, @id, @id))
|
||||
elsif val.kind_of?(Array)
|
||||
a = []
|
||||
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
|
||||
|
@ -857,7 +856,7 @@ class TkVariable
|
|||
Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
else
|
||||
newopts = @trace_opts.dup
|
||||
opts.each_byte{|c| newopts += c.chr unless @newopts.index(c)}
|
||||
opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
if newopts != @trace_opts
|
||||
Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
|
@ -877,7 +876,7 @@ class TkVariable
|
|||
Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
|
||||
else
|
||||
newopts = @trace_opts.dup
|
||||
opts.each_byte{|c| newopts += c.chr unless @newopts.index(c)}
|
||||
opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
|
||||
if newopts != @trace_opts
|
||||
Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
|
||||
@trace_opts.replace(newopts)
|
||||
|
@ -2191,12 +2190,12 @@ class TkListbox<TkTextWin
|
|||
def selection_set(first, last=None)
|
||||
tk_send 'selection', 'set', first, last
|
||||
end
|
||||
def xview(cmd, index, *more)
|
||||
v = tk_send('xview', cmd, index, *more)
|
||||
def xview(cmd, *more)
|
||||
v = tk_send('xview', cmd, *more)
|
||||
v.to_i if more.size == 0
|
||||
end
|
||||
def yview(cmd, index, *more)
|
||||
v = tk_send('yview', cmd, index, *more)
|
||||
def yview(cmd, *more)
|
||||
v = tk_send('yview', cmd, *more)
|
||||
v.to_i if more.size == 0
|
||||
end
|
||||
end
|
||||
|
|
8
file.c
8
file.c
|
@ -521,8 +521,8 @@ test_s(obj, fname)
|
|||
{
|
||||
struct stat st;
|
||||
|
||||
if (rb_stat(fname, &st) < 0) return Qfalse;
|
||||
if (st.st_size == 0) return Qfalse;
|
||||
if (rb_stat(fname, &st) < 0) return Qnil;
|
||||
if (st.st_size == 0) return Qnil;
|
||||
return rb_int2inum(st.st_size);
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ test_sticky(obj, fname)
|
|||
#ifdef S_ISVTX
|
||||
return check3rdbyte(STR2CSTR(fname), S_ISVTX);
|
||||
#else
|
||||
return Qfalse;
|
||||
return Qnil;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1511,7 +1511,7 @@ rb_f_test(argc, argv)
|
|||
}
|
||||
}
|
||||
/* unknown command */
|
||||
rb_raise(rb_eArgError, "unknow command ?%c", cmd);
|
||||
rb_raise(rb_eArgError, "unknown command ?%c", cmd);
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
|
|
11
gc.c
11
gc.c
|
@ -1133,13 +1133,12 @@ rb_gc_call_finalizer_at_exit()
|
|||
p = heaps[i]; pend = p + HEAP_SLOTS;
|
||||
while (p < pend) {
|
||||
if (BUILTIN_TYPE(p) == T_DATA &&
|
||||
DATA_PTR(p) &&
|
||||
RANY(p)->as.data.dfree)
|
||||
DATA_PTR(p) && RANY(p)->as.data.dfree) {
|
||||
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
|
||||
#if 0
|
||||
else if (BUILTIN_TYPE(p))
|
||||
obj_free((VALUE)p);
|
||||
#endif
|
||||
}
|
||||
else if (BUILTIN_TYPE(p) == T_FILE) {
|
||||
rb_io_fptr_finalize(RANY(p)->as.file.fptr);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
|
62
hash.c
62
hash.c
|
@ -148,14 +148,6 @@ rb_hash_foreach_call(arg)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static int
|
||||
rb_hash_delete_nil(key, value)
|
||||
VALUE key, value;
|
||||
{
|
||||
if (value == Qnil) return ST_DELETE;
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_hash_foreach_ensure(hash)
|
||||
VALUE hash;
|
||||
|
@ -164,7 +156,7 @@ rb_hash_foreach_ensure(hash)
|
|||
|
||||
if (RHASH(hash)->iter_lev == 0) {
|
||||
if (FL_TEST(hash, HASH_DELETED)) {
|
||||
st_foreach(RHASH(hash)->tbl, rb_hash_delete_nil, 0);
|
||||
st_cleanup_safe(RHASH(hash)->tbl, Qnil);
|
||||
FL_UNSET(hash, HASH_DELETED);
|
||||
}
|
||||
}
|
||||
|
@ -381,6 +373,32 @@ rb_hash_set_default(hash, ifnone)
|
|||
return hash;
|
||||
}
|
||||
|
||||
static int
|
||||
index_i(key, value, args)
|
||||
VALUE key, value;
|
||||
VALUE *args;
|
||||
{
|
||||
if (rb_equal(value, args[0])) {
|
||||
args[1] = key;
|
||||
return ST_STOP;
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_hash_index(hash, value)
|
||||
VALUE hash, value;
|
||||
{
|
||||
VALUE args[2];
|
||||
|
||||
args[0] = value;
|
||||
args[1] = Qnil;
|
||||
|
||||
st_foreach(RHASH(hash)->tbl, index_i, args);
|
||||
|
||||
return args[1];
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_hash_indexes(argc, argv, hash)
|
||||
int argc;
|
||||
|
@ -1314,10 +1332,8 @@ env_has_value(dmy, value)
|
|||
VALUE dmy, value;
|
||||
{
|
||||
char **env;
|
||||
volatile VALUE ary;
|
||||
|
||||
if (TYPE(value) != T_STRING) return Qfalse;
|
||||
ary = rb_ary_new();
|
||||
env = environ;
|
||||
while (*env) {
|
||||
char *s = strchr(*env, '=')+1;
|
||||
|
@ -1330,6 +1346,26 @@ env_has_value(dmy, value)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_index(dmy, value)
|
||||
VALUE dmy, value;
|
||||
{
|
||||
char **env;
|
||||
|
||||
if (TYPE(value) != T_STRING) return Qnil;
|
||||
env = environ;
|
||||
while (*env) {
|
||||
char *s = strchr(*env, '=')+1;
|
||||
if (s) {
|
||||
if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
|
||||
return rb_tainted_str_new(*env, s-*env);
|
||||
}
|
||||
}
|
||||
env++;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
env_indexes(argc, argv)
|
||||
int argc;
|
||||
|
@ -1405,6 +1441,7 @@ Init_Hash()
|
|||
rb_define_method(rb_cHash,"store", rb_hash_aset, 2);
|
||||
rb_define_method(rb_cHash,"default", rb_hash_default, 0);
|
||||
rb_define_method(rb_cHash,"default=", rb_hash_set_default, 1);
|
||||
rb_define_method(rb_cHash,"index", rb_hash_index, 1);
|
||||
rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
|
||||
rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
|
||||
rb_define_method(rb_cHash,"length", rb_hash_length, 0);
|
||||
|
@ -1430,6 +1467,7 @@ Init_Hash()
|
|||
rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
|
||||
|
||||
rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1);
|
||||
rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1);
|
||||
rb_define_method(rb_cHash,"has_key?", rb_hash_has_key, 1);
|
||||
rb_define_method(rb_cHash,"has_value?", rb_hash_has_value, 1);
|
||||
rb_define_method(rb_cHash,"key?", rb_hash_has_key, 1);
|
||||
|
@ -1452,6 +1490,7 @@ Init_Hash()
|
|||
rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
|
||||
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
|
||||
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
|
||||
rb_define_singleton_method(envtbl,"index", env_index, 1);
|
||||
rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
|
||||
rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
|
||||
rb_define_singleton_method(envtbl,"length", env_size, 0);
|
||||
|
@ -1459,6 +1498,7 @@ Init_Hash()
|
|||
rb_define_singleton_method(envtbl,"keys", env_keys, 0);
|
||||
rb_define_singleton_method(envtbl,"values", env_values, 0);
|
||||
rb_define_singleton_method(envtbl,"include?", env_has_key, 1);
|
||||
rb_define_singleton_method(envtbl,"member?", env_has_key, 1);
|
||||
rb_define_singleton_method(envtbl,"has_key?", env_has_key, 1);
|
||||
rb_define_singleton_method(envtbl,"has_value?", env_has_value, 1);
|
||||
rb_define_singleton_method(envtbl,"key?", env_has_key, 1);
|
||||
|
|
8
io.c
8
io.c
|
@ -90,7 +90,7 @@ static ID id_write;
|
|||
|
||||
extern char *ruby_inplace_mode;
|
||||
|
||||
struct timeval rb_time_timeval _((VALUE));
|
||||
struct timeval rb_time_interval _((VALUE));
|
||||
|
||||
static VALUE filename, file;
|
||||
static int gets_lineno;
|
||||
|
@ -1296,10 +1296,10 @@ rb_file_sysopen_internal(klass, fname, flags, mode)
|
|||
|
||||
VALUE
|
||||
rb_file_sysopen(fname, flags, mode)
|
||||
char *fname;
|
||||
const char *fname;
|
||||
int flags, mode;
|
||||
{
|
||||
return rb_file_sysopen_internal(rb_cFile, flags, mode);
|
||||
return rb_file_sysopen_internal(rb_cFile, fname, flags, mode);
|
||||
}
|
||||
|
||||
#if defined (NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__)
|
||||
|
@ -2438,7 +2438,7 @@ rb_f_select(argc, argv, obj)
|
|||
tp = NULL;
|
||||
}
|
||||
else {
|
||||
timerec = rb_time_timeval(timeout);
|
||||
timerec = rb_time_interval(timeout);
|
||||
tp = &timerec;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ class CGI < SimpleDelegator
|
|||
when "GET"
|
||||
ENV['QUERY_STRING'] or ""
|
||||
when "POST"
|
||||
input.read Integer(ENV['CONTENT_LENGTH'])
|
||||
input.read(Integer(ENV['CONTENT_LENGTH'])) or ""
|
||||
else
|
||||
read_from_cmdline
|
||||
end.split(/&/).each do |x|
|
||||
|
|
178
lib/debug.rb
178
lib/debug.rb
|
@ -1,12 +1,21 @@
|
|||
|
||||
class DEBUGGER__
|
||||
|
||||
def max(a,b)
|
||||
if (a<b); b; else a; end
|
||||
end
|
||||
|
||||
def min(a,b)
|
||||
if (a<=b); a; else b; end
|
||||
end
|
||||
|
||||
trap("INT") { DEBUGGER__::CONTEXT.interrupt }
|
||||
$DEBUG = TRUE
|
||||
def initialize
|
||||
@break_points = []
|
||||
@stop_next = 1
|
||||
@frames = [nil]
|
||||
@frame_pos = nil
|
||||
@frame_pos = nil # nil means not '0' but `unknown'.
|
||||
@last_file = nil
|
||||
@scripts = {}
|
||||
end
|
||||
|
@ -23,19 +32,23 @@ class DEBUGGER__
|
|||
val
|
||||
rescue
|
||||
at = caller(0)
|
||||
printf "%s:%s\n", at.shift, $!
|
||||
STDOUT.printf "%s:%s\n", at.shift, $!
|
||||
for i in at
|
||||
break if i =~ /`debug_(eval|command)'$/ #`
|
||||
printf "\tfrom %s\n", i
|
||||
STDOUT.printf "\tfrom %s\n", i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def debug_command(file, line, id, binding)
|
||||
binding_file = file
|
||||
binding_line = line
|
||||
debug_line = {}
|
||||
if (ENV['EMACS'] == 't')
|
||||
printf "\032\032%s:%d:\n", file, line
|
||||
STDOUT.printf "\032\032%s:%d:\n", binding_file, binding_line
|
||||
else
|
||||
printf "%s:%d:%s", file, line, line_at(file, line)
|
||||
STDOUT.printf "%s:%d:%s", binding_file, binding_line,
|
||||
line_at(binding_file, binding_line)
|
||||
end
|
||||
@frames[-1] = binding
|
||||
STDOUT.print "(rdb:-) "
|
||||
|
@ -48,6 +61,7 @@ class DEBUGGER__
|
|||
DEBUG_LAST_CMD[0] = input
|
||||
end
|
||||
case input
|
||||
|
||||
when /^b(reak)?\s+(([^:\n]+:)?.+)/
|
||||
pos = $2
|
||||
if pos.index ":"
|
||||
|
@ -60,14 +74,17 @@ class DEBUGGER__
|
|||
else
|
||||
pname = pos = pos.intern.id2name
|
||||
end
|
||||
printf "Set breakpoint %d at %s:%s\n", @break_points.size, file, pname
|
||||
STDOUT.printf "Set breakpoint %d at %s:%s\n", @break_points.size, file,
|
||||
pname
|
||||
@break_points.push [file, pos]
|
||||
when /^b(reak)?$/, /^info b(reak)?$/
|
||||
|
||||
when /^b(reak)?$/
|
||||
n = 0
|
||||
for f, p in @break_points
|
||||
printf "%d %s:%s\n", n, f, p
|
||||
STDOUT.printf "%d %s:%s\n", n, f, p
|
||||
n += 1
|
||||
end
|
||||
|
||||
when /^del(ete)?(\s+(\d+))?$/
|
||||
pos = $3
|
||||
unless pos
|
||||
|
@ -83,14 +100,16 @@ class DEBUGGER__
|
|||
pos = Integer(pos)
|
||||
if @break_points[pos]
|
||||
bp = @break_points[pos]
|
||||
printf "Clear breakpoint %d at %s:%s\n", pos, bp[0], bp[1]
|
||||
STDOUT.printf "Clear breakpoint %d at %s:%s\n", pos, bp[0], bp[1]
|
||||
@break_points[pos] = nil
|
||||
else
|
||||
printf "Breakpoint %d is not defined\n", pos
|
||||
STDOUT.printf "Breakpoint %d is not defined\n", pos
|
||||
end
|
||||
end
|
||||
|
||||
when /^c(ont)?$/
|
||||
return
|
||||
|
||||
when /^s(tep)?\s*(\d+)?$/
|
||||
if $2
|
||||
lev = Integer($2)
|
||||
|
@ -99,6 +118,7 @@ class DEBUGGER__
|
|||
end
|
||||
@stop_next = lev
|
||||
return
|
||||
|
||||
when /^n(ext)?\s*(\d+)?$/
|
||||
if $2
|
||||
lev = Integer($2)
|
||||
|
@ -108,78 +128,86 @@ class DEBUGGER__
|
|||
@stop_next = lev
|
||||
@no_step = @frames.size
|
||||
return
|
||||
when /^up\s*(\d+)?$/
|
||||
if $1
|
||||
lev = Integer($1)
|
||||
|
||||
when /^i(?:nfo)?/, /^w(?:here)?/
|
||||
fs = @frames.size
|
||||
tb = caller(0)[-fs..-1].reverse
|
||||
unless @frame_pos; @frame_pos = fs - 1; end
|
||||
|
||||
(fs-1).downto(0){ |i|
|
||||
if (@frame_pos == i)
|
||||
STDOUT.printf "--> frame %d:%s\n", i, tb[i]
|
||||
else
|
||||
STDOUT.printf " frame %d:%s\n", i, tb[i]
|
||||
end
|
||||
}
|
||||
|
||||
when /^l(ist)?$/
|
||||
fs = @frames.size
|
||||
tb = caller(0)[-fs..-1].reverse
|
||||
unless @frame_pos; @frame_pos = fs - 1; end
|
||||
|
||||
file, line, func = tb[@frame_pos].split(":")
|
||||
line = line.to_i
|
||||
b = line - 1
|
||||
e = line + 9
|
||||
line_at(file, line)
|
||||
if lines = @scripts[file] and lines != TRUE
|
||||
lines = [0] + lines # Simple offset adjust
|
||||
b = max(0, b); e = min(lines.size-1, e)
|
||||
for l in b..e
|
||||
if (l == line)
|
||||
STDOUT.printf "--> %5d %s", l, lines[l]
|
||||
else
|
||||
STDOUT.printf " %5d %s", l, lines[l]
|
||||
end
|
||||
end
|
||||
else
|
||||
lev = 1
|
||||
end
|
||||
unless @frame_pos
|
||||
@frame_pos = @frames.size - 1
|
||||
STDOUT.printf "no sourcefile available for %s\n", file
|
||||
end
|
||||
|
||||
when /^d(?:own)?\s*(\d+)??$/
|
||||
if $1; lev = Integer($1); else lev = 1; end
|
||||
unless @frame_pos; @frame_pos = 0; end
|
||||
@frame_pos -= lev
|
||||
if @frame_pos < 0
|
||||
STDOUT.print "at toplevel\n"
|
||||
STDOUT.print "at stack bottom\n"
|
||||
@frame_pos = 0
|
||||
else
|
||||
binding = @frames[@frame_pos]
|
||||
STDOUT.printf "at level %d\n", @frame_pos
|
||||
end
|
||||
when /^down\s*(\d+)??$/
|
||||
if $1
|
||||
lev = Integer($1)
|
||||
else
|
||||
lev = 1
|
||||
end
|
||||
unless @frame_pos
|
||||
@frame_pos = @frames.size - 1
|
||||
end
|
||||
if lev >= @frames.size or @frame_pos and @frame_pos+lev >= @frames.size
|
||||
STDOUT.print "at stack bottom\n"
|
||||
binding = @frames[@frame_pos]
|
||||
|
||||
when /^u(?:p)?\s*(\d+)?$/
|
||||
if $1; lev = Integer($1); else lev = 1; end
|
||||
unless @frame_pos; @frame_pos = @frames.size - 1; end
|
||||
@frame_pos += lev
|
||||
p @frame_pos
|
||||
if @frame_pos >= @frames.size
|
||||
STDOUT.print "at toplevel\n"
|
||||
@frame_pos = nil
|
||||
else
|
||||
@frame_pos += lev
|
||||
binding = @frames[@frame_pos]
|
||||
frame_info = caller(4)[-(@frame_pos+1)]
|
||||
STDOUT.print "at #{frame_info}\n"
|
||||
frame_info.sub( /:in `.*'$/, '' ) =~ /^(.*):(\d+)$/ #`
|
||||
binding_file, binding_line = $1, $2.to_i
|
||||
binding = @frames[@frame_pos]
|
||||
end
|
||||
when /^fin(ish)?$/
|
||||
|
||||
when /^f(inish)?/
|
||||
@finish_pos = @frames.size
|
||||
return
|
||||
|
||||
when /^q(uit)?$/
|
||||
STDOUT.print "really quit? (y/n) "
|
||||
STDOUT.flush
|
||||
input = STDIN.gets.chop!
|
||||
exit if input == "y"
|
||||
when /^where$/
|
||||
at = caller(4)
|
||||
for i in at
|
||||
printf " %s\n", i
|
||||
end
|
||||
when /^l(ist)?(\s+(.*))?$/
|
||||
if $3
|
||||
b, e = $3.split(/[-,]/)
|
||||
b = Integer(b)-1
|
||||
if e
|
||||
e = Integer(e)-1
|
||||
else
|
||||
e = b + 10
|
||||
end
|
||||
end
|
||||
unless b
|
||||
b = line - 1
|
||||
e = line + 9
|
||||
end
|
||||
p [b,e]
|
||||
line_at(file, line)
|
||||
if lines = @scripts[file] and lines != TRUE
|
||||
n = b+1
|
||||
for l in lines[b..e]
|
||||
printf "%4d %s", n, l
|
||||
n += 1
|
||||
end
|
||||
else
|
||||
printf "no sourcefile available for %s\n", file
|
||||
end
|
||||
|
||||
when /^p\s+/
|
||||
p debug_eval($', binding) #'
|
||||
p debug_eval($', binding)
|
||||
|
||||
else
|
||||
v = debug_eval(input, binding)
|
||||
p v unless v == nil
|
||||
|
@ -224,13 +252,26 @@ class DEBUGGER__
|
|||
file = File.basename(file)
|
||||
if @break_points.include? [file, pos]
|
||||
index = @break_points.index([file, pos])
|
||||
printf "Breakpoint %d, %s at %s:%s\n",
|
||||
STDOUT.printf "Breakpoint %d, %s at %s:%s\n",
|
||||
index, debug_funcname(id), file, pos
|
||||
return TRUE
|
||||
end
|
||||
return FALSE
|
||||
end
|
||||
|
||||
def excn_handle(file, line, id, binding)
|
||||
fs = @frames.size
|
||||
tb = caller(0)[-fs..-1]
|
||||
unless @frame_pos; @frame_pos = fs - 1; end
|
||||
|
||||
STDOUT.printf "%s\n", $!
|
||||
for i in tb
|
||||
STDOUT.printf "\tfrom %s\n", i
|
||||
end
|
||||
debug_command(file, line, id, binding)
|
||||
end
|
||||
|
||||
|
||||
def trace_func(event, file, line, id, binding)
|
||||
if event == 'line'
|
||||
if @no_step == nil or @no_step >= @frames.size
|
||||
|
@ -249,21 +290,30 @@ class DEBUGGER__
|
|||
debug_command(file, line, id, binding)
|
||||
end
|
||||
end
|
||||
|
||||
if event == 'call'
|
||||
@frames.push binding
|
||||
if check_break_points(file, id.id2name, binding, id)
|
||||
debug_command(file, line, id, binding)
|
||||
end
|
||||
end
|
||||
|
||||
if event == 'class'
|
||||
@frames.push binding
|
||||
end
|
||||
|
||||
if event == 'return' or event == 'end'
|
||||
if @finish_pos == @frames.size
|
||||
@stop_next = 1
|
||||
end
|
||||
@frames.pop
|
||||
end
|
||||
|
||||
if event == 'raise'
|
||||
# @frames.push binding
|
||||
excn_handle(file, line, id, binding)
|
||||
end
|
||||
|
||||
@last_file = file
|
||||
end
|
||||
|
||||
|
|
13
lib/mkmf.rb
13
lib/mkmf.rb
|
@ -54,6 +54,8 @@ end
|
|||
CFLAGS = CONFIG["CFLAGS"]
|
||||
if PLATFORM == "m68k-human"
|
||||
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
|
||||
elsif PLATFORM =~ /-nextstep|-rhapsody/
|
||||
CFLAGS.gsub!( /-arch\s\w*/, '' );
|
||||
end
|
||||
if /win32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
|
||||
$null = open("nul", "w")
|
||||
|
@ -98,6 +100,7 @@ def try_cpp(src, opt="")
|
|||
cfile.print src
|
||||
cfile.close
|
||||
begin
|
||||
|
||||
xsystem(format(CPP, $CFLAGS, opt))
|
||||
ensure
|
||||
system "rm -f conftest*"
|
||||
|
@ -335,9 +338,9 @@ def create_makefile(target)
|
|||
end
|
||||
|
||||
unless $objs then
|
||||
$objs = Dir["*.{c,cc}"]
|
||||
$objs = Dir["*.{c,cc,m}"]
|
||||
for f in $objs
|
||||
f.sub!(/\.(c|cc)$/, ".o")
|
||||
f.sub!(/\.(c|cc|m)$/, ".o")
|
||||
end
|
||||
end
|
||||
$objs = $objs.join(" ")
|
||||
|
@ -402,13 +405,11 @@ EOMF
|
|||
$(DLLIB): $(OBJS)
|
||||
$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
|
||||
EOMF
|
||||
elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") or
|
||||
elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
|
||||
mfile.print "$(DLLIB): $(OBJS)\n"
|
||||
case PLATFORM
|
||||
when "m68k-human"
|
||||
mfile.printf "ar cru $(DLLIB) $(OBJS)\n"
|
||||
when /-nextstep/
|
||||
mfile.printf "cc -r $(CFLAGS) -o $(DLLIB) $(OBJS)\n"
|
||||
else
|
||||
mfile.printf "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n"
|
||||
end
|
||||
|
@ -459,7 +460,7 @@ EOMF
|
|||
end
|
||||
end
|
||||
|
||||
$libs = PLATFORM =~ /cygwin32|beos/ ? nil : "-lc"
|
||||
$libs = PLATFORM =~ /cygwin32|beos|rhapsody|nextstep/ ? nil : "-lc"
|
||||
$objs = nil
|
||||
$LOCAL_LIBS = ""
|
||||
$CFLAGS = ""
|
||||
|
|
245
lib/telnet.rb
245
lib/telnet.rb
|
@ -1,11 +1,11 @@
|
|||
=begin
|
||||
$Date: 1999/06/04 06:24:58 $
|
||||
$Date: 1999/06/29 09:08:51 $
|
||||
|
||||
== SIMPLE TELNET CLIANT LIBRARY
|
||||
|
||||
telnet.rb
|
||||
|
||||
Version 0.20
|
||||
Version 0.22
|
||||
|
||||
Wakou Aoyama <wakou@fsinet.or.jp>
|
||||
|
||||
|
@ -20,6 +20,7 @@ Wakou Aoyama <wakou@fsinet.or.jp>
|
|||
"Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
|
||||
"Telnetmode" => TRUE, # default: TRUE
|
||||
"Timeout" => 10, # default: 10
|
||||
# if ignore timeout then set "Timeout" to FALSE.
|
||||
"Waittime" => 0, # default: 0
|
||||
"Proxy" => proxy}) # default: nil
|
||||
# proxy is Telnet or TCPsocket object
|
||||
|
@ -49,6 +50,7 @@ example
|
|||
line = host.waitfor({"Match" => /match/,
|
||||
"String" => "string",
|
||||
"Timeout" => secs})
|
||||
# if ignore timeout then set "Timeout" to FALSE.
|
||||
|
||||
if set "String" option. Match = Regexp.new(quote(string))
|
||||
|
||||
|
@ -145,76 +147,128 @@ of cource, set sync=TRUE or flush is necessary.
|
|||
|
||||
== HISTORY
|
||||
|
||||
=== Version 0.22
|
||||
|
||||
1999/06/29 09:08:51
|
||||
|
||||
- new, waitfor, cmd: {"Timeout" => FALSE} # ignore timeout
|
||||
|
||||
=== Version 0.21
|
||||
|
||||
1999/06/28 18:18:55
|
||||
|
||||
- waitfor: not rescue (EOFError)
|
||||
|
||||
=== Version 0.20
|
||||
waitfor: support for divided telnet command
|
||||
|
||||
=== Version 0.181 1999/05/22
|
||||
bug fix: print method
|
||||
1999/06/04 06:24:58
|
||||
|
||||
=== Version 0.18 1999/05/14
|
||||
respond to "IAC WON'T SGA" with "IAC DON'T SGA"
|
||||
- waitfor: support for divided telnet command
|
||||
|
||||
DON'T SGA : end of line --> CR + LF
|
||||
=== Version 0.181
|
||||
|
||||
bug fix: preprocess method
|
||||
1999/05/22
|
||||
|
||||
=== Version 0.17 1999/04/30
|
||||
bug fix: $! + "\n" --> $!.to_s + "\n"
|
||||
- bug fix: print method
|
||||
|
||||
=== Version 0.163 1999/04/11
|
||||
STDOUT.write(message) --> yield(message) if iterator?
|
||||
=== Version 0.18
|
||||
|
||||
=== Version 0.162 1999/03/17
|
||||
add "Proxy" option
|
||||
1999/05/14
|
||||
|
||||
required timeout.rb
|
||||
- respond to "IAC WON'T SGA" with "IAC DON'T SGA"
|
||||
- DON'T SGA : end of line --> CR + LF
|
||||
- bug fix: preprocess method
|
||||
|
||||
=== Version 0.161 1999/02/03
|
||||
select --> IO::select
|
||||
=== Version 0.17
|
||||
|
||||
=== Version 0.16 1998/10/09
|
||||
preprocess method change for the better
|
||||
1999/04/30
|
||||
|
||||
add binmode method.
|
||||
- bug fix: $! + "\n" --> $!.to_s + "\n"
|
||||
|
||||
change default Binmode
|
||||
TRUE --> FALSE
|
||||
=== Version 0.163
|
||||
|
||||
=== Version 0.15 1998/10/04
|
||||
add telnetmode method.
|
||||
1999/04/11
|
||||
|
||||
=== Version 0.141 1998/09/22
|
||||
change default prompt
|
||||
/[$%#>] $/ --> /[$%#>] \Z/
|
||||
- STDOUT.write(message) --> yield(message) if iterator?
|
||||
|
||||
=== Version 0.14 1998/09/01
|
||||
IAC WILL SGA send EOL --> CR+NULL
|
||||
=== Version 0.162
|
||||
|
||||
IAC WILL SGA IAC DO BIN send EOL --> CR
|
||||
1999/03/17
|
||||
|
||||
NONE send EOL --> LF
|
||||
- add "Proxy" option
|
||||
- required timeout.rb
|
||||
|
||||
add Dump_log option.
|
||||
=== Version 0.161
|
||||
|
||||
=== Version 0.13 1998/08/25
|
||||
add print method.
|
||||
1999/02/03
|
||||
|
||||
=== Version 0.122 1998/08/05
|
||||
support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
|
||||
- select --> IO::select
|
||||
|
||||
socket.<< --> socket.write
|
||||
=== Version 0.16
|
||||
|
||||
=== Version 0.121 1998/07/15
|
||||
string.+= --> string.concat
|
||||
1998/10/09
|
||||
|
||||
=== Version 0.12 1998/06/01
|
||||
add timeout, waittime.
|
||||
- preprocess method change for the better
|
||||
- add binmode method.
|
||||
- change default Binmode. TRUE --> FALSE
|
||||
|
||||
=== Version 0.11 1998/04/21
|
||||
add realtime output.
|
||||
=== Version 0.15
|
||||
|
||||
=== Version 0.10 1998/04/13
|
||||
first release.
|
||||
1998/10/04
|
||||
|
||||
- add telnetmode method.
|
||||
|
||||
=== Version 0.141
|
||||
|
||||
1998/09/22
|
||||
|
||||
- change default prompt. /[$%#>] $/ --> /[$%#>] \Z/
|
||||
|
||||
=== Version 0.14
|
||||
|
||||
1998/09/01
|
||||
|
||||
- IAC WILL SGA send EOL --> CR+NULL
|
||||
- IAC WILL SGA IAC DO BIN send EOL --> CR
|
||||
- NONE send EOL --> LF
|
||||
- add Dump_log option.
|
||||
|
||||
=== Version 0.13
|
||||
|
||||
1998/08/25
|
||||
|
||||
- add print method.
|
||||
|
||||
=== Version 0.122
|
||||
|
||||
1998/08/05
|
||||
|
||||
- support for HP-UX 10.20 thanks to WATANABE Tetsuya <tetsu@jpn.hp.com>
|
||||
- socket.<< --> socket.write
|
||||
|
||||
=== Version 0.121
|
||||
|
||||
1998/07/15
|
||||
|
||||
- string.+= --> string.concat
|
||||
|
||||
=== Version 0.12
|
||||
|
||||
1998/06/01
|
||||
|
||||
- add timeout, waittime.
|
||||
|
||||
=== Version 0.11
|
||||
|
||||
1998/04/21
|
||||
|
||||
- add realtime output.
|
||||
|
||||
=== Version 0.10
|
||||
|
||||
1998/04/13
|
||||
|
||||
- first release.
|
||||
|
||||
=end
|
||||
|
||||
|
@ -296,35 +350,35 @@ class Telnet < SimpleDelegator
|
|||
EOL = CR + LF
|
||||
v = $-v
|
||||
$-v = false
|
||||
VERSION = "0.20"
|
||||
RELEASE_DATE = "$Date: 1999/06/04 06:24:58 $"
|
||||
VERSION = "0.22"
|
||||
RELEASE_DATE = "$Date: 1999/06/29 09:08:51 $"
|
||||
$-v = v
|
||||
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@options["Binmode"] = FALSE if not @options.include?("Binmode")
|
||||
@options["Host"] = "localhost" if not @options.include?("Host")
|
||||
@options["Port"] = 23 if not @options.include?("Port")
|
||||
@options["Prompt"] = /[$%#>] \z/n 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"] = FALSE unless @options.key?("Binmode")
|
||||
@options["Host"] = "localhost" unless @options.key?("Host")
|
||||
@options["Port"] = 23 unless @options.key?("Port")
|
||||
@options["Prompt"] = /[$%#>] \z/n unless @options.key?("Prompt")
|
||||
@options["Telnetmode"] = TRUE unless @options.key?("Telnetmode")
|
||||
@options["Timeout"] = 10 unless @options.key?("Timeout")
|
||||
@options["Waittime"] = 0 unless @options.key?("Waittime")
|
||||
|
||||
@telnet_option = { "SGA" => FALSE, "BINARY" => FALSE }
|
||||
|
||||
if @options.include?("Output_log")
|
||||
if @options.key?("Output_log")
|
||||
@log = File.open(@options["Output_log"], 'a+')
|
||||
@log.sync = TRUE
|
||||
@log.binmode
|
||||
end
|
||||
|
||||
if @options.include?("Dump_log")
|
||||
if @options.key?("Dump_log")
|
||||
@dumplog = File.open(@options["Dump_log"], 'a+')
|
||||
@dumplog.sync = TRUE
|
||||
@dumplog.binmode
|
||||
end
|
||||
|
||||
if @options.include?("Proxy")
|
||||
if @options.key?("Proxy")
|
||||
if @options["Proxy"].kind_of?(Telnet)
|
||||
@sock = @options["Proxy"].sock
|
||||
elsif @options["Proxy"].kind_of?(TCPsocket)
|
||||
|
@ -335,18 +389,22 @@ $-v = v
|
|||
else
|
||||
message = "Trying " + @options["Host"] + "...\n"
|
||||
yield(message) if iterator?
|
||||
@log.write(message) if @options.include?("Output_log")
|
||||
@dumplog.write(message) if @options.include?("Dump_log")
|
||||
@log.write(message) if @options.key?("Output_log")
|
||||
@dumplog.write(message) if @options.key?("Dump_log")
|
||||
|
||||
begin
|
||||
timeout(@options["Timeout"]){
|
||||
if @options["Timeout"] == FALSE
|
||||
@sock = TCPsocket.open(@options["Host"], @options["Port"])
|
||||
}
|
||||
else
|
||||
timeout(@options["Timeout"]){
|
||||
@sock = TCPsocket.open(@options["Host"], @options["Port"])
|
||||
}
|
||||
end
|
||||
rescue TimeoutError
|
||||
raise TimeOut, "timed-out; opening of the host"
|
||||
rescue
|
||||
@log.write($!.to_s + "\n") if @options.include?("Output_log")
|
||||
@dumplog.write($!.to_s + "\n") if @options.include?("Dump_log")
|
||||
@log.write($!.to_s + "\n") if @options.key?("Output_log")
|
||||
@dumplog.write($!.to_s + "\n") if @options.key?("Dump_log")
|
||||
raise
|
||||
end
|
||||
@sock.sync = TRUE
|
||||
|
@ -354,8 +412,8 @@ $-v = v
|
|||
|
||||
message = "Connected to " + @options["Host"] + ".\n"
|
||||
yield(message) if iterator?
|
||||
@log.write(message) if @options.include?("Output_log")
|
||||
@dumplog.write(message) if @options.include?("Dump_log")
|
||||
@log.write(message) if @options.key?("Output_log")
|
||||
@dumplog.write(message) if @options.key?("Dump_log")
|
||||
end
|
||||
|
||||
super(@sock)
|
||||
|
@ -386,7 +444,7 @@ $-v = v
|
|||
str.gsub!(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
|
||||
|
||||
# combine EOL into "\n"
|
||||
str.gsub!(/#{EOL}/no, "\n") if not @options["Binmode"]
|
||||
str.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
|
||||
|
||||
# respond to "IAC DO x"
|
||||
str.gsub!(/([^#{IAC}]?)#{IAC}#{DO}([#{OPT_BINARY}-#{OPT_NEW_ENVIRON}#{OPT_EXOPL}])/no){
|
||||
|
@ -443,41 +501,42 @@ $-v = v
|
|||
waittime = @options["Waittime"]
|
||||
|
||||
if options.kind_of?(Hash)
|
||||
prompt = if options.include?("Match")
|
||||
prompt = if options.key?("Match")
|
||||
options["Match"]
|
||||
elsif options.include?("Prompt")
|
||||
elsif options.key?("Prompt")
|
||||
options["Prompt"]
|
||||
elsif options.include?("String")
|
||||
elsif options.key?("String")
|
||||
Regexp.new( Regexp.quote(options["String"]) )
|
||||
end
|
||||
time_out = options["Timeout"] if options.include?("Timeout")
|
||||
waittime = options["Waittime"] if options.include?("Waittime")
|
||||
time_out = options["Timeout"] if options.key?("Timeout")
|
||||
waittime = options["Waittime"] if options.key?("Waittime")
|
||||
else
|
||||
prompt = options
|
||||
end
|
||||
|
||||
if time_out == FALSE
|
||||
time_out = nil
|
||||
end
|
||||
|
||||
line = ''
|
||||
buf = ''
|
||||
until(not IO::select([@sock], nil, nil, waittime) and prompt === line)
|
||||
raise TimeOut, "timed-out; wait for the next data" if
|
||||
not IO::select([@sock], nil, nil, time_out)
|
||||
begin
|
||||
c = @sock.sysread(1024 * 1024)
|
||||
@dumplog.print(c) if @options.include?("Dump_log")
|
||||
buf.concat c
|
||||
if @options["Telnetmode"]
|
||||
buf = preprocess(buf)
|
||||
if /#{IAC}.?\z/no === buf
|
||||
next
|
||||
end
|
||||
end
|
||||
@log.print(buf) if @options.include?("Output_log")
|
||||
yield buf if iterator?
|
||||
line.concat(buf)
|
||||
buf = ''
|
||||
rescue EOFError # End of file reached
|
||||
break
|
||||
unless IO::select([@sock], nil, nil, time_out)
|
||||
raise TimeOut, "timed-out; wait for the next data"
|
||||
end
|
||||
c = @sock.sysread(1024 * 1024)
|
||||
@dumplog.print(c) if @options.key?("Dump_log")
|
||||
buf.concat c
|
||||
if @options["Telnetmode"]
|
||||
buf = preprocess(buf)
|
||||
if /#{IAC}.?\z/no === buf
|
||||
next
|
||||
end
|
||||
end
|
||||
@log.print(buf) if @options.key?("Output_log")
|
||||
yield buf if iterator?
|
||||
line.concat(buf)
|
||||
buf = ''
|
||||
end
|
||||
line
|
||||
end
|
||||
|
@ -487,7 +546,7 @@ $-v = v
|
|||
|
||||
str.gsub!(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"]
|
||||
|
||||
if not @options["Binmode"]
|
||||
unless @options["Binmode"]
|
||||
if @telnet_option["BINARY"] and @telnet_option["SGA"]
|
||||
# IAC WILL SGA IAC DO BIN send EOL --> CR
|
||||
str.gsub!(/\n/n, CR)
|
||||
|
@ -509,8 +568,8 @@ $-v = v
|
|||
|
||||
if options.kind_of?(Hash)
|
||||
string = options["String"]
|
||||
match = options["Match"] if options.include?("Match")
|
||||
time_out = options["Timeout"] if options.include?("Timeout")
|
||||
match = options["Match"] if options.key?("Match")
|
||||
time_out = options["Timeout"] if options.key?("Timeout")
|
||||
else
|
||||
string = options
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(J;;;(B (J-*-Emacs-Lisp-*-(B
|
||||
;;; -*-Emacs-Lisp-*-
|
||||
;;;
|
||||
;;; $Id$
|
||||
;;; $Author$
|
||||
|
@ -35,9 +35,12 @@
|
|||
;;; HISTORY
|
||||
;;; senda - 8 Apr 1998: Created.
|
||||
;;; $Log$
|
||||
;;; Revision 1.1.1.1.2.1 1999/07/15 07:59:59 matz
|
||||
;;; 990715
|
||||
;;;
|
||||
;;; Revision 1.1.1.1 1999/01/20 04:59:36 matz
|
||||
;;; ruby 1.3 cycle
|
||||
;;;
|
||||
;;;
|
||||
;;; Revision 1.1.2.1 1998/12/16 07:30:36 matz
|
||||
;;; first public release of 1.1d (pre1.2) series
|
||||
;;;
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
;;; History of argument lists passed to rubydb.
|
||||
(defvar gud-rubydb-history nil)
|
||||
|
||||
(defun gud-rubydb-massage-args (file args)
|
||||
(cons "-r" (cons "debug" (cons file args))))
|
||||
(if (fboundp 'gud-overload-functions)
|
||||
(defun gud-rubydb-massage-args (file args)
|
||||
(cons "-r" (cons "debug" (cons file args))))
|
||||
(defun gud-rubydb-massage-args (file args)
|
||||
(cons "-r" (cons "debug" args))))
|
||||
|
||||
;; There's no guarantee that Emacs will hand the filter the entire
|
||||
;; marker at once; it could be broken up across several strings. We
|
||||
|
@ -17,6 +20,7 @@
|
|||
;; beginning of a marker, we save it here between calls to the
|
||||
;; filter.
|
||||
(defvar gud-rubydb-marker-acc "")
|
||||
(make-variable-buffer-local 'gud-rubydb-marker-acc)
|
||||
|
||||
(defun gud-rubydb-marker-filter (string)
|
||||
(setq gud-rubydb-marker-acc (concat gud-rubydb-marker-acc string))
|
||||
|
@ -85,10 +89,13 @@ and source-file directory for your debugger."
|
|||
nil nil
|
||||
'(gud-rubydb-history . 1))))
|
||||
|
||||
(gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
|
||||
(gud-marker-filter . gud-rubydb-marker-filter)
|
||||
(gud-find-file . gud-rubydb-find-file)))
|
||||
(gud-common-init command-line rubydb-command-name)
|
||||
(if (not (fboundp 'gud-overload-functions))
|
||||
(gud-common-init command-line 'gud-rubydb-massage-args
|
||||
'gud-rubydb-marker-filter 'gud-rubydb-find-file)
|
||||
(gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
|
||||
(gud-marker-filter . gud-rubydb-marker-filter)
|
||||
(gud-find-file . gud-rubydb-find-file)))
|
||||
(gud-common-init command-line rubydb-command-name))
|
||||
|
||||
(gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
|
||||
; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
#ifdef __osf__
|
||||
|
||||
#define _IEEE 1
|
||||
#include <nan.h>
|
||||
|
||||
int
|
||||
isinf(n)
|
||||
double n;
|
||||
{
|
||||
if (IsNANorINF(n) && IsINF(n)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
|
@ -23,3 +41,4 @@ isinf(n)
|
|||
return memcmp(&n, &pinf, sizeof n) == 0
|
||||
|| memcmp(&n, &ninf, sizeof n) == 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,5 +14,3 @@ double_ne(n1, n2)
|
|||
{
|
||||
return n1 != n2;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -950,7 +950,7 @@ fix_div(x, y)
|
|||
i = FIX2LONG(y);
|
||||
if (i == 0) rb_num_zerodiv();
|
||||
i = FIX2LONG(x)/i;
|
||||
return INT2FIX(i);
|
||||
return INT2NUM(i); /* FIXNUM_MIN / -1 > FIXNUM_MAX */
|
||||
}
|
||||
return rb_num_coerce_bin(x, y);
|
||||
}
|
||||
|
|
28
parse.y
28
parse.y
|
@ -178,7 +178,7 @@ static void top_local_setup();
|
|||
%type <node> array assoc_list assocs assoc undef_list backref
|
||||
%type <node> block_var opt_block_var brace_block do_block lhs none
|
||||
%type <node> mlhs mlhs_head mlhs_tail mlhs_basic mlhs_entry mlhs_item mlhs_node
|
||||
%type <id> variable symbol operation operation2 operation3
|
||||
%type <id> fitem variable sym symbol operation operation2 operation3
|
||||
%type <id> cname fname op f_rest_arg
|
||||
%type <num> f_norm_arg f_arg
|
||||
%token tUPLUS /* unary+ */
|
||||
|
@ -283,7 +283,7 @@ stmts : none
|
|||
}
|
||||
|
||||
stmt : block_call
|
||||
| kALIAS fname {lex_state = EXPR_FNAME;} fname
|
||||
| kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||
{
|
||||
if (cur_mid || in_single)
|
||||
yyerror("alias within method");
|
||||
|
@ -561,11 +561,14 @@ fname : tIDENTIFIER
|
|||
$$ = $<id>1;
|
||||
}
|
||||
|
||||
undef_list : fname
|
||||
fitem : fname
|
||||
| symbol
|
||||
|
||||
undef_list : fitem
|
||||
{
|
||||
$$ = NEW_UNDEF($1);
|
||||
}
|
||||
| undef_list ',' {lex_state = EXPR_FNAME;} fname
|
||||
| undef_list ',' {lex_state = EXPR_FNAME;} fitem
|
||||
{
|
||||
$$ = block_append($1, NEW_UNDEF($4));
|
||||
}
|
||||
|
@ -1411,17 +1414,23 @@ ensure : none
|
|||
}
|
||||
|
||||
literal : numeric
|
||||
| tSYMBEG symbol
|
||||
| symbol
|
||||
{
|
||||
lex_state = EXPR_END;
|
||||
$$ = INT2FIX($2);
|
||||
$$ = INT2FIX($1);
|
||||
}
|
||||
| tREGEXP
|
||||
|
||||
symbol : fname
|
||||
symbol : tSYMBEG sym
|
||||
{
|
||||
lex_state = EXPR_END;
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
sym : fname
|
||||
| tIVAR
|
||||
| tGVAR
|
||||
|
||||
|
||||
numeric : tINTEGER
|
||||
| tFLOAT
|
||||
|
||||
|
@ -1811,6 +1820,9 @@ rb_compile_file(f, file, start)
|
|||
return yycompile(strdup(f));
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 2
|
||||
__inline__
|
||||
#endif
|
||||
static int
|
||||
nextc()
|
||||
{
|
||||
|
|
32
process.c
32
process.c
|
@ -30,7 +30,7 @@ struct timeval {
|
|||
#endif /* NT */
|
||||
#include <ctype.h>
|
||||
|
||||
struct timeval rb_time_timeval _((VALUE));
|
||||
struct timeval rb_time_interval _((VALUE));
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
|
@ -539,23 +539,27 @@ rb_f_fork(obj)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_f_exit_bang(obj, status)
|
||||
VALUE obj, status;
|
||||
rb_f_exit_bang(argc, argv, obj)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE obj;
|
||||
{
|
||||
int code = -1;
|
||||
VALUE status;
|
||||
int istatus;
|
||||
|
||||
rb_secure(4);
|
||||
if (FIXNUM_P(status)) {
|
||||
code = INT2FIX(status);
|
||||
if (rb_scan_args(argc, argv, "01", &status) == 1) {
|
||||
istatus = NUM2INT(status);
|
||||
}
|
||||
else {
|
||||
istatus = -1;
|
||||
}
|
||||
|
||||
#ifdef USE_CWGUSI
|
||||
exit(code);
|
||||
exit(istatus);
|
||||
#else
|
||||
_exit(code);
|
||||
_exit(istatus);
|
||||
#endif
|
||||
|
||||
/* not reached */
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -732,7 +736,7 @@ rb_f_sleep(argc, argv)
|
|||
rb_thread_sleep_forever();
|
||||
}
|
||||
else if (argc == 1) {
|
||||
rb_thread_wait_for(rb_time_timeval(argv[0]));
|
||||
rb_thread_wait_for(rb_time_interval(argv[0]));
|
||||
}
|
||||
else {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
|
@ -1007,7 +1011,7 @@ Init_process()
|
|||
rb_define_global_function("exec", rb_f_exec, -1);
|
||||
#endif
|
||||
rb_define_global_function("fork", rb_f_fork, 0);
|
||||
rb_define_global_function("exit!", rb_f_exit_bang, 1);
|
||||
rb_define_global_function("exit!", rb_f_exit_bang, -1);
|
||||
rb_define_global_function("system", rb_f_system, -1);
|
||||
rb_define_global_function("sleep", rb_f_sleep, -1);
|
||||
|
||||
|
@ -1029,7 +1033,7 @@ Init_process()
|
|||
#if !defined(NT)
|
||||
rb_define_singleton_method(rb_mProcess, "fork", rb_f_fork, 0);
|
||||
#endif
|
||||
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, 1);
|
||||
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, -1);
|
||||
#ifndef USE_CWGUSI
|
||||
rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1);
|
||||
#endif
|
||||
|
|
2
random.c
2
random.c
|
@ -69,7 +69,7 @@ void srand48 _((long));
|
|||
#endif /* HAVE_RANDOM */
|
||||
|
||||
/* 0 <= RANDOM_NUMBER <= 1 */
|
||||
#define RANDOM_NUMBER (((double)RANDOM())/(double)RANDOM_MAX+1)
|
||||
#define RANDOM_NUMBER (((double)RANDOM())/((double)RANDOM_MAX+1))
|
||||
|
||||
#endif /* not HAVE_DRAND48 */
|
||||
|
||||
|
|
71
regex.c
71
regex.c
|
@ -108,7 +108,7 @@ char *alloca();
|
|||
|
||||
#define FREE_AND_RETURN_VOID(stackb) return
|
||||
#define FREE_AND_RETURN(stackb,val) return(val)
|
||||
#define DOUBLE_STACK(stackx,stackb,len,type) \
|
||||
#define DOUBLE_STACK(stackx,stackb,len,type) \
|
||||
(stackx = (type*)alloca(2 * len * sizeof(type)), \
|
||||
/* Only copy what is in use. */ \
|
||||
(type*)memcpy(stackx, stackb, len * sizeof (type)))
|
||||
|
@ -117,16 +117,7 @@ char *alloca();
|
|||
#define RE_ALLOCATE xmalloc
|
||||
|
||||
#define FREE_VAR(var) if (var) free(var); var = NULL
|
||||
#define FREE_VARIABLES() \
|
||||
do { \
|
||||
FREE_VAR(regstart); \
|
||||
FREE_VAR(regend); \
|
||||
FREE_VAR(old_regstart) \
|
||||
FREE_VAR(old_regend); \
|
||||
FREE_VAR(best_regstart); \
|
||||
FREE_VAR(best_regend); \
|
||||
FREE_VAR(reg_info); \
|
||||
} while (0)
|
||||
#define FREE_VARIABLES()
|
||||
|
||||
#define FREE_AND_RETURN_VOID(stackb) free(stackb);return
|
||||
#define FREE_AND_RETURN(stackb,val) free(stackb);return(val)
|
||||
|
@ -2278,6 +2269,13 @@ re_compile_pattern(pattern, size, bufp)
|
|||
}
|
||||
}
|
||||
|
||||
bufp->regstart = TMALLOC(regnum, unsigned char*);
|
||||
bufp->regend = TMALLOC(regnum, unsigned char*);
|
||||
bufp->old_regstart = TMALLOC(regnum, unsigned char*);
|
||||
bufp->old_regend = TMALLOC(regnum, unsigned char*);
|
||||
bufp->reg_info = TMALLOC(regnum, register_info_type);
|
||||
bufp->best_regstart = TMALLOC(regnum, unsigned char*);
|
||||
bufp->best_regend = TMALLOC(regnum, unsigned char*);
|
||||
FREE_AND_RETURN(stackb, 0);
|
||||
|
||||
invalid_pattern:
|
||||
|
@ -2303,6 +2301,14 @@ re_free_pattern(bufp)
|
|||
free(bufp->buffer);
|
||||
free(bufp->fastmap);
|
||||
if (bufp->must_skip) free(bufp->must_skip);
|
||||
|
||||
free(bufp->regstart);
|
||||
free(bufp->regend);
|
||||
free(bufp->old_regstart);
|
||||
free(bufp->old_regend);
|
||||
free(bufp->best_regstart);
|
||||
free(bufp->best_regend);
|
||||
free(bufp->reg_info);
|
||||
free(bufp);
|
||||
}
|
||||
|
||||
|
@ -2584,7 +2590,7 @@ re_compile_fastmap(bufp)
|
|||
register int j, k;
|
||||
unsigned is_a_succeed_n;
|
||||
|
||||
unsigned char **stackb = RE_TALLOC(NFAILURES, unsigned char*);
|
||||
unsigned char **stackb = TMALLOC(NFAILURES, unsigned char*);
|
||||
unsigned char **stackp = stackb;
|
||||
unsigned char **stacke = stackb + NFAILURES;
|
||||
int options = bufp->options;
|
||||
|
@ -2932,9 +2938,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
if (range > 0) {
|
||||
if (startpos > 0)
|
||||
return -1;
|
||||
else if (re_match(bufp, string, size, 0, regs) >= 0)
|
||||
return 0;
|
||||
return -1;
|
||||
return re_match(bufp, string, size, 0, regs);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2962,7 +2966,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
if (pbeg > pend) { /* swap pbeg,pend */
|
||||
pos = pend; pend = pbeg; pbeg = pos;
|
||||
}
|
||||
if (pend > size) pend = size;
|
||||
pend = size;
|
||||
if (bufp->options & RE_OPTIMIZE_NO_BM) {
|
||||
pos = slow_search(bufp->must+1, len,
|
||||
string+pbeg, pend-pbeg,
|
||||
|
@ -3118,18 +3122,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
|||
|
||||
/* The following are used for re_match, defined below: */
|
||||
|
||||
/* Routine used by re_match. */
|
||||
|
||||
/* Structure and accessing macros used in re_match: */
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned char *word;
|
||||
struct {
|
||||
unsigned is_active : 1;
|
||||
unsigned matched_something : 1;
|
||||
} bits;
|
||||
} register_info_type;
|
||||
/* Accessing macros used in re_match: */
|
||||
|
||||
#define IS_ACTIVE(R) ((R).bits.is_active)
|
||||
#define MATCHED_SOMETHING(R) ((R).bits.matched_something)
|
||||
|
@ -3161,7 +3154,7 @@ typedef union
|
|||
\
|
||||
/* Find out how many registers are active or have been matched. \
|
||||
(Aside from register zero, which is only set at the end.) */ \
|
||||
for (last_used_reg = num_regs - 1; last_used_reg > 0; last_used_reg--)\
|
||||
for (last_used_reg = num_regs-1; last_used_reg > 0; last_used_reg--)\
|
||||
if (!REG_UNSET(regstart[last_used_reg])) \
|
||||
break; \
|
||||
\
|
||||
|
@ -3323,16 +3316,16 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
stopped matching the regnum-th subexpression. (The zeroth register
|
||||
keeps track of what the whole pattern matches.) */
|
||||
|
||||
unsigned char **regstart = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **regend = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **regstart = bufp->regstart;
|
||||
unsigned char **regend = bufp->regend;
|
||||
|
||||
/* If a group that's operated upon by a repetition operator fails to
|
||||
match anything, then the register for its start will need to be
|
||||
restored because it will have been set to wherever in the string we
|
||||
are when we last see its open-group operator. Similarly for a
|
||||
register's end. */
|
||||
unsigned char **old_regstart = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **old_regend = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **old_regstart = bufp->old_regstart;
|
||||
unsigned char **old_regend = bufp->old_regend;
|
||||
|
||||
/* The is_active field of reg_info helps us keep track of which (possibly
|
||||
nested) subexpressions we are currently in. The matched_something
|
||||
|
@ -3341,7 +3334,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
subexpression. These two fields get reset each time through any
|
||||
loop their register is in. */
|
||||
|
||||
register_info_type *reg_info = RE_TALLOC(num_regs, register_info_type);
|
||||
register_info_type *reg_info = bufp->reg_info;
|
||||
|
||||
/* The following record the register info as found in the above
|
||||
variables when we find a match better than any we've seen before.
|
||||
|
@ -3349,8 +3342,8 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
turn happens only if we have not yet matched the entire string. */
|
||||
|
||||
unsigned best_regs_set = 0;
|
||||
unsigned char **best_regstart = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **best_regend = RE_TALLOC(num_regs, unsigned char*);
|
||||
unsigned char **best_regstart = bufp->best_regstart;
|
||||
unsigned char **best_regend = bufp->best_regend;
|
||||
|
||||
if (regs) {
|
||||
init_regs(regs, num_regs);
|
||||
|
@ -3540,8 +3533,13 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
|
||||
case start_nowidth:
|
||||
PUSH_FAILURE_POINT(0, d);
|
||||
if (stackp - stackb > RE_DUP_MAX) {
|
||||
FREE_VARIABLES();
|
||||
FREE_AND_RETURN(stackb,(-2));
|
||||
}
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
STORE_NUMBER(p+mcnt, stackp - stackb);
|
||||
printf("%d\n", stackp - stackb);
|
||||
continue;
|
||||
|
||||
case stop_nowidth:
|
||||
|
@ -4106,6 +4104,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
if (best_regs_set)
|
||||
goto restore_best_regs;
|
||||
|
||||
FREE_VARIABLES();
|
||||
FREE_AND_RETURN(stackb,(-1)); /* Failure to match. */
|
||||
}
|
||||
|
||||
|
|
21
regex.h
21
regex.h
|
@ -33,6 +33,7 @@
|
|||
# define re_mbcinit ruby_re_mbcinit
|
||||
# define re_search ruby_re_search
|
||||
# define re_set_casetable ruby_re_set_casetable
|
||||
# define register_info_type ruby_register_info_type
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
@ -90,6 +91,17 @@ void re_mbcinit ();
|
|||
#define ismbchar(c) re_mbctab[(unsigned char)(c)]
|
||||
#define mbclen(c) (re_mbctab[(unsigned char)(c)]+1)
|
||||
|
||||
/* Structure used in re_match() */
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned char *word;
|
||||
struct {
|
||||
unsigned is_active : 1;
|
||||
unsigned matched_something : 1;
|
||||
} bits;
|
||||
} register_info_type;
|
||||
|
||||
/* This data structure is used to represent a compiled pattern. */
|
||||
|
||||
struct re_pattern_buffer
|
||||
|
@ -116,6 +128,15 @@ struct re_pattern_buffer
|
|||
2 as value means can match null string
|
||||
but at end of range or before a character
|
||||
listed in the fastmap. */
|
||||
|
||||
/* stack & working area for re_match() */
|
||||
unsigned char **regstart;
|
||||
unsigned char **regend;
|
||||
unsigned char **old_regstart;
|
||||
unsigned char **old_regend;
|
||||
register_info_type *reg_info;
|
||||
unsigned char **best_regstart;
|
||||
unsigned char **best_regend;
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
|
6
ruby.c
6
ruby.c
|
@ -634,7 +634,7 @@ load_file(fname, script)
|
|||
char *path;
|
||||
char *pend = RSTRING(line)->ptr + RSTRING(line)->len;
|
||||
|
||||
p = RSTRING(line)->ptr + 2; /* skip `#!' */
|
||||
p = RSTRING(line)->ptr + 1; /* skip `#!' */
|
||||
if (pend[-1] == '\n') pend--; /* chomp line */
|
||||
if (pend[-1] == '\r') pend--;
|
||||
*pend = '\0';
|
||||
|
@ -884,6 +884,10 @@ ruby_prog_init()
|
|||
addpath(RUBY_SITE_THIN_ARCHLIB);
|
||||
#endif
|
||||
|
||||
#ifdef RUBY_SEARCH_PATH
|
||||
addpath(RUBY_SEARCH_PATH);
|
||||
#endif
|
||||
|
||||
if (rb_safe_level() == 0) {
|
||||
addpath(getenv("RUBYLIB"));
|
||||
}
|
||||
|
|
2
ruby.h
2
ruby.h
|
@ -87,7 +87,7 @@ extern "C" {
|
|||
|
||||
#if SIZEOF_LONG != SIZEOF_VOIDP
|
||||
---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
|
||||
# endif
|
||||
#endif
|
||||
typedef unsigned long VALUE;
|
||||
typedef unsigned int ID;
|
||||
|
||||
|
|
23
rubytest.rb
23
rubytest.rb
|
@ -1,12 +1,27 @@
|
|||
#! ./miniruby -I.
|
||||
|
||||
x = ENV["LD_LIBRARY_PATH"]
|
||||
x = x ? x+":." : "."
|
||||
ENV["LD_LIBRARY_PATH"] = x
|
||||
|
||||
require 'rbconfig'
|
||||
include Config
|
||||
|
||||
if File.exist? CONFIG['LIBRUBY_SO']
|
||||
case RUBY_PLATFORM
|
||||
when /-hpux/
|
||||
dldpath = "SHLIB_PATH"
|
||||
when /-aix/
|
||||
dldpath = "LIBPATH"
|
||||
else
|
||||
dldpath = "LD_LIBRARY_PATH"
|
||||
end
|
||||
x = ENV[dldpath]
|
||||
x = x ? ".:"+x : "."
|
||||
ENV[dldpath] = x
|
||||
end
|
||||
|
||||
if File.exist? CONFIG['LIBRUBY_SO']
|
||||
ENV["LD_PRELOAD"] ||= ""
|
||||
ENV["LD_PRELOAD"] += " ./#{CONFIG['LIBRUBY_SO']}"
|
||||
end
|
||||
|
||||
$stderr.reopen($stdout)
|
||||
error = ''
|
||||
`./#{CONFIG["ruby_install_name"]} #{CONFIG["srcdir"]}/sample/test.rb`.each do |line|
|
||||
|
|
31
st.c
31
st.c
|
@ -403,16 +403,8 @@ st_delete_safe(table, key, value, never)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (EQUAL(table, *key, ptr->key)) {
|
||||
table->num_entries--;
|
||||
*key = ptr->key;
|
||||
if (value != 0) *value = ptr->record;
|
||||
ptr->key = ptr->record = never;
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(; ptr->next != 0; ptr = ptr->next) {
|
||||
if (EQUAL(table, ptr->next->key, *key)) {
|
||||
for(; ptr != 0; ptr = ptr->next) {
|
||||
if (EQUAL(table, ptr->key, *key)) {
|
||||
table->num_entries--;
|
||||
*key = ptr->key;
|
||||
if (value != 0) *value = ptr->record;
|
||||
|
@ -424,6 +416,25 @@ st_delete_safe(table, key, value, never)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
delete_never(key, value, never)
|
||||
char *key, *value, *never;
|
||||
{
|
||||
if (value == never) return ST_DELETE;
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
st_cleanup_safe(table, never)
|
||||
st_table *table;
|
||||
char *never;
|
||||
{
|
||||
int num_entries = table->num_entries;
|
||||
|
||||
st_foreach(table, delete_never, never);
|
||||
table->num_entries = num_entries;
|
||||
}
|
||||
|
||||
void
|
||||
st_foreach(table, func, arg)
|
||||
st_table *table;
|
||||
|
|
2
st.h
2
st.h
|
@ -32,7 +32,7 @@ st_table *st_init_strtable();
|
|||
st_table *st_init_strtable_with_size();
|
||||
int st_delete(), st_delete_safe();
|
||||
int st_insert(), st_lookup();
|
||||
void st_foreach(), st_add_direct(), st_free_table();
|
||||
void st_foreach(), st_add_direct(), st_free_table(), st_cleanup_safe();
|
||||
st_table *st_copy();
|
||||
|
||||
#define ST_NUMCMP ((int (*)()) 0)
|
||||
|
|
39
string.c
39
string.c
|
@ -631,29 +631,39 @@ rb_str_rindex(argc, argv, str)
|
|||
|
||||
switch (TYPE(sub)) {
|
||||
case T_REGEXP:
|
||||
pos = rb_reg_search(sub, str, pos, 1);
|
||||
if (pos >= 0) return INT2NUM(pos);
|
||||
if (RREGEXP(sub)->len) {
|
||||
pos = rb_reg_search(sub, str, pos, 1);
|
||||
}
|
||||
if (pos >= 0) return INT2NUM(pos);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
/* substring longer than string */
|
||||
if (pos < RSTRING(sub)->len) return Qnil;
|
||||
sbeg = RSTRING(str)->ptr;
|
||||
s = RSTRING(str)->ptr + pos - RSTRING(sub)->len;
|
||||
t = RSTRING(sub)->ptr;
|
||||
len = RSTRING(sub)->len;
|
||||
while (sbeg <= s) {
|
||||
if (*s == *t && memcmp(s, t, len) == 0) {
|
||||
return INT2NUM(s - RSTRING(str)->ptr);
|
||||
/* substring longer than string */
|
||||
if (RSTRING(str)->len < len) return Qnil;
|
||||
if (RSTRING(str)->len - pos < len) {
|
||||
pos = RSTRING(str)->len - len;
|
||||
}
|
||||
sbeg = RSTRING(str)->ptr;
|
||||
s = RSTRING(str)->ptr + pos;
|
||||
t = RSTRING(sub)->ptr;
|
||||
if (len) {
|
||||
while (sbeg <= s) {
|
||||
if (*s == *t && memcmp(s, t, len) == 0) {
|
||||
return INT2NUM(s - RSTRING(str)->ptr);
|
||||
}
|
||||
s--;
|
||||
}
|
||||
s--;
|
||||
}
|
||||
else {
|
||||
return INT2NUM(pos);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_FIXNUM:
|
||||
{
|
||||
int c = FIX2INT(sub);
|
||||
char *p = RSTRING(str)->ptr + pos - 1;
|
||||
char *p = RSTRING(str)->ptr + pos;
|
||||
char *pbeg = RSTRING(str)->ptr;
|
||||
|
||||
while (pbeg <= p) {
|
||||
|
@ -1945,7 +1955,6 @@ rb_str_count(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE a1, a2;
|
||||
char table[256];
|
||||
char *s, *send;
|
||||
int init = 1;
|
||||
|
@ -2165,7 +2174,7 @@ 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 != '\n') continue;
|
||||
while (*p == '\n') p++;
|
||||
}
|
||||
if (p[-1] == newline &&
|
||||
|
@ -2462,7 +2471,7 @@ rb_str_crypt(str, salt)
|
|||
|
||||
if (TYPE(salt) != T_STRING) salt = rb_str_to_str(salt);
|
||||
if (RSTRING(salt)->len < 2)
|
||||
rb_raise(rb_eArgError, "salt too short(need >2 bytes)");
|
||||
rb_raise(rb_eArgError, "salt too short(need >=2 bytes)");
|
||||
return rb_str_new2(crypt(RSTRING(str)->ptr, RSTRING(salt)->ptr));
|
||||
}
|
||||
|
||||
|
|
25
time.c
25
time.c
|
@ -101,7 +101,7 @@ rb_time_new(sec, usec)
|
|||
}
|
||||
|
||||
struct timeval
|
||||
rb_time_timeval(time)
|
||||
rb_time_interval(time)
|
||||
VALUE time;
|
||||
{
|
||||
struct time_object *tobj;
|
||||
|
@ -130,17 +130,28 @@ rb_time_timeval(time)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (!rb_obj_is_kind_of(time, rb_cTime)) {
|
||||
rb_raise(rb_eTypeError, "can't convert %s into Time",
|
||||
rb_class2name(CLASS_OF(time)));
|
||||
}
|
||||
GetTimeval(time, tobj);
|
||||
t = tobj->tv;
|
||||
rb_raise(rb_eTypeError, "can't convert %s into Time interval",
|
||||
rb_class2name(CLASS_OF(time)));
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
struct timeval
|
||||
rb_time_timeval(time)
|
||||
VALUE time;
|
||||
{
|
||||
struct time_object *tobj;
|
||||
struct timeval t;
|
||||
|
||||
if (rb_obj_is_kind_of(time, rb_cTime)) {
|
||||
GetTimeval(time, tobj);
|
||||
t = tobj->tv;
|
||||
return t;
|
||||
}
|
||||
return rb_time_interval(time);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
time_s_at(klass, time)
|
||||
VALUE klass, time;
|
||||
|
|
|
@ -35,12 +35,7 @@ Init_version()
|
|||
void
|
||||
ruby_show_version()
|
||||
{
|
||||
#if RUBY_VERSION_CODE < 140
|
||||
printf("ruby %s-%d [%s]\n", RUBY_VERSION, RUBY_RELEASE_CODE % 1000000,
|
||||
RUBY_PLATFORM);
|
||||
#else
|
||||
printf("ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define RUBY_VERSION "1.3.4"
|
||||
#define RUBY_RELEASE_DATE "1999-06-25"
|
||||
#define RUBY_VERSION_CODE 134
|
||||
#define RUBY_RELEASE_CODE 19990625
|
||||
#define RUBY_VERSION "1.3.5"
|
||||
#define RUBY_RELEASE_DATE "1999-07-15"
|
||||
#define RUBY_VERSION_CODE 135
|
||||
#define RUBY_RELEASE_CODE 19990715
|
||||
|
|
Loading…
Add table
Reference in a new issue