mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
35247a52ef
commit
32e799db48
45 changed files with 3118 additions and 2650 deletions
54
ChangeLog
54
ChangeLog
|
@ -1,5 +1,59 @@
|
|||
Fri Apr 9 17:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* regex.c (re_match): should pop non-greedy stack items on
|
||||
failure, after best_regs are fixed.
|
||||
|
||||
Thu Apr 8 17:30:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* pack.c (PACK_LENGTH_ADJUST): need to adjust for `*' length.
|
||||
|
||||
Tue Apr 6 23:28:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (void_check): add void context checks.
|
||||
|
||||
Mon Apr 5 12:23:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* time.c (time_s_at): should copy gmt-mode.
|
||||
|
||||
* eval.c (eval_node): preserve ruby_eval_tree.
|
||||
|
||||
Fri Apr 2 14:00:34 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
|
||||
|
||||
* lib/debug.rb: wrong command interpreting.
|
||||
|
||||
Fri Apr 2 11:46:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* version 1.3.2
|
||||
|
||||
Fri Apr 2 10:40:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_io_s_pipe): forgot to define IO::pipe.
|
||||
|
||||
Thu Apr 1 14:40:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* eval.c (assign): modified for rhs change.
|
||||
|
||||
* parse.y (stmt): unparenthesisized method calls can be right hand
|
||||
side expression of the assignment.
|
||||
|
||||
Sat Mar 27 22:42:47 1999 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* ext/nkf/nkf.c (rb_nkf_kconv): check size output_ctr before
|
||||
decrement.
|
||||
|
||||
Thu Mar 25 09:11:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* time.c (time_s_at): preserve gmt-mode for result.
|
||||
|
||||
* parse.y (rb_compile_string): do not use cur_mid, use
|
||||
compile_for_eval instead.
|
||||
|
||||
* st.c (PTR_NOT_EQUAL): wrong logical condition.
|
||||
|
||||
Wed Mar 24 13:06:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* parse.y (yycompile): should clear cur_mid after compilation.
|
||||
|
||||
* io.c (next_argv): need to check type for ARGV.shift.
|
||||
|
||||
* eval.c (blk_copy_prev): need to preverse outer scope as well as
|
||||
|
|
1
MANIFEST
1
MANIFEST
|
@ -151,6 +151,7 @@ missing/isnan.c
|
|||
missing/memcmp.c
|
||||
missing/memmove.c
|
||||
missing/mkdir.c
|
||||
missing/os2.c
|
||||
missing/strcasecmp.c
|
||||
missing/strchr.c
|
||||
missing/strdup.c
|
||||
|
|
|
@ -208,6 +208,12 @@ nt.o: @srcdir@/missing/nt.c
|
|||
x68.o: @srcdir@/missing/x68.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/x68.c
|
||||
|
||||
os2.o: @srcdir@/missing/os2.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/os2.c
|
||||
|
||||
dl_os2.o: @srcdir@/missing/dl_os2.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/dl_os2.c
|
||||
|
||||
# Prevent GNU make v3 from overflowing arg limit on SysV.
|
||||
.NOEXPORT:
|
||||
###
|
||||
|
|
85
README.EXT
85
README.EXT
|
@ -487,12 +487,10 @@ struct dbmdata {
|
|||
obj = Data_Make_Struct(class,struct dbmdata,0,free_dbm,dbmp);
|
||||
--
|
||||
|
||||
ここではdbmstruct構造体へのポインタをDataにカプセル化してい
|
||||
ます.DBM*を直接カプセル化しないのはclose()した時の処理を考
|
||||
えてのことです.
|
||||
This code wraps dbmdata structure into Ruby object. We avoid wrapping
|
||||
DBM* directly, because we want to cache size information.
|
||||
|
||||
Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
|
||||
に以下のマクロを使っています.
|
||||
To retrieve dbmdata structure from Ruby object, we define the macro below:
|
||||
|
||||
--
|
||||
#define GetDBM(obj, dbmp) {\
|
||||
|
@ -501,14 +499,11 @@ Data
|
|||
}
|
||||
--
|
||||
|
||||
ちょっと複雑なマクロですが,要するにdbmdata構造体のポインタ
|
||||
の取り出しと,closeされているかどうかのチェックをまとめてい
|
||||
るだけです.
|
||||
This sort of complicated macro do the retrieving and close check for
|
||||
the DBM.
|
||||
|
||||
DBMクラスにはたくさんメソッドがありますが,分類すると3種類の
|
||||
引数の受け方があります.ひとつは引数の数が固定のもので,例と
|
||||
してはdeleteメソッドがあります.deleteメソッドを実装している
|
||||
fdbm_delete()はこのようになっています.
|
||||
There are three kind of way to receiving method arguments. First, the
|
||||
methods with fixed number of arguments receives arguments like this:
|
||||
|
||||
--
|
||||
static VALUE
|
||||
|
@ -519,13 +514,11 @@ fdbm_delete(obj, keystr)
|
|||
}
|
||||
--
|
||||
|
||||
引数の数が固定のタイプは第1引数がself,第2引数以降がメソッド
|
||||
の引数となります.
|
||||
The first argument of the C function is the self, the rest are the
|
||||
arguments to the method.
|
||||
|
||||
引数の数が不定のものはCの配列で受けるものとRubyの配列で受け
|
||||
るものとがあります.dbmモジュールの中で,Cの配列で受けるもの
|
||||
はDBMのクラスメソッドであるopen()です.これを実装している関
|
||||
数fdbm_s_open()はこうなっています.
|
||||
Second, the methods with arbtrary number of arguments receives
|
||||
arguments like this:
|
||||
|
||||
--
|
||||
static VALUE
|
||||
|
@ -542,22 +535,16 @@ fdbm_s_open(argc, argv, class)
|
|||
}
|
||||
--
|
||||
|
||||
このタイプの関数は第1引数が与えられた引数の数,第2引数が与え
|
||||
られた引数の入っている配列になります.selfは第3引数として与
|
||||
えられます.
|
||||
The first argument is the number of method arguments. the second
|
||||
argument is the C array of the method arguments. And the third
|
||||
argument is the receiver of the method.
|
||||
|
||||
この配列で与えられた引数を解析するための関数がopen()でも使わ
|
||||
れているrb_scan_args()です.第3引数に指定したフォーマットに
|
||||
従い,第4変数以降に指定した変数に値を代入してくれます.この
|
||||
フォーマットは,第1文字目が省略できない引数の数,第2文字目が
|
||||
省略できる引数の数,第3文字目が対応する相手が無いあまりの引
|
||||
数があるかどうかを示す"*"です.2文字目と3文字目は省略できま
|
||||
す.dbm.cの例では,フォーマットは"11"ですから,引数は最低1つ
|
||||
で,2つまで許されるという意味になります.省略されている時の
|
||||
変数の値はnil(C言語のレベルではQnil)になります.
|
||||
You can use the function rb_scan_args() to check and retrieve the
|
||||
arguments. For exapmle "11" means, the method requires at least one
|
||||
argument, and at most receives two arguments.
|
||||
|
||||
Rubyの配列で引数を受け取るものはindexesがあります.実装はこ
|
||||
うです.
|
||||
The methods with arbtrary number of arguments can receives arguments
|
||||
by Ruby's array, like this:
|
||||
|
||||
--
|
||||
static VALUE
|
||||
|
@ -709,16 +696,13 @@ class library
|
|||
|
||||
Appendix B. Ruby extension API reference
|
||||
|
||||
C言語からRubyの機能を利用するAPIは以下の通りである.
|
||||
|
||||
** 型
|
||||
** Types
|
||||
|
||||
VALUE
|
||||
|
||||
Rubyオブジェクトを表現する型.必要に応じてキャストして用いる.
|
||||
組み込み型を表現するCの型はruby.hに記述してあるRで始まる構造
|
||||
体である.VALUE型をこれらにキャストするためにRで始まる構造体
|
||||
名を全て大文字にした名前のマクロが用意されている.
|
||||
The type for Ruby object. Actual structures are defined in ruby.h,
|
||||
such as struct RString, etc. To refer the values in structures, use
|
||||
casting macros like RSTRING(obj).
|
||||
|
||||
** Variables and constants
|
||||
|
||||
|
@ -738,11 +722,10 @@ const: false object
|
|||
|
||||
Data_Wrap_Struct(VALUE class, void (*mark)(), void (*free)(), void *sval)
|
||||
|
||||
Cの任意のポインタをカプセル化したRubyオブジェクトを返す.こ
|
||||
のポインタがRubyからアクセスされなくなった時,freeで指定した
|
||||
関数が呼ばれる.また,このポインタの指すデータが他のRubyオブ
|
||||
ジェクトを指している場合,markに指定する関数でマークする必要
|
||||
がある.
|
||||
Wrap C pointer into Ruby object. If object has references to other
|
||||
Ruby object, they should be marked by using mark function during GC
|
||||
process. Otherwise, mark should be 0. When this object is no longer
|
||||
referred by anywhere, the pointer will be discarded by free function.
|
||||
|
||||
Data_Make_Struct(class, type, mark, free, sval)
|
||||
|
||||
|
@ -857,15 +840,13 @@ rb_define_method().
|
|||
|
||||
Defines a singleton method. Arguments are same as rb_define_method().
|
||||
|
||||
rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
|
||||
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
|
||||
|
||||
argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
|
||||
付加引数の数, 残りの引数があるかを指定する文字列で, "数字数
|
||||
字*"という形式である. 2 番目の数字と"*"はそれぞれ省略可能で
|
||||
ある.必須引数が一つもない場合は0を指定する.第3引数以降は変
|
||||
数へのポインタで, 該当する要素がその変数に格納される.付加引
|
||||
数に対応する引数が与えられていない場合は変数にQnilが代入され
|
||||
る.
|
||||
Retrieve argument from argc, argv. The fmt is the format string for
|
||||
the arguments, such as "12" for 1 non-optinal argument, 2 optinal
|
||||
aruguments. If `*' appears at the end of fmt, it means the rest of
|
||||
the arguments are assigned to corresponding variable, packed in
|
||||
array.
|
||||
|
||||
** Invoking Ruby method
|
||||
|
||||
|
|
|
@ -989,7 +989,7 @@ private
|
|||
|
||||
特異メソッドを定義する.引数はrb_define_method()と同じ.
|
||||
|
||||
rb_scan_args(int atgc, VALUE *argv, char *fmt, ...)
|
||||
rb_scan_args(int argc, VALUE *argv, char *fmt, ...)
|
||||
|
||||
argc,argv形式で与えられた引数を分解する.fmtは必須引数の数,
|
||||
付加引数の数, 残りの引数があるかを指定する文字列で, "数字数
|
||||
|
|
2
ToDo
2
ToDo
|
@ -6,7 +6,6 @@ Language Spec.
|
|||
* multiple return values, yield values. maybe imcompatible
|
||||
* cascading method invocation.
|
||||
* def Class#method .. end
|
||||
* exclusive range n...m (means n<=x<m).
|
||||
|
||||
Hacking Interpreter
|
||||
|
||||
|
@ -44,5 +43,4 @@ Tools
|
|||
|
||||
Misc
|
||||
|
||||
* translate README.EXT fully into English
|
||||
* publish Ruby books
|
||||
|
|
3
config.guess
vendored
3
config.guess
vendored
|
@ -62,6 +62,9 @@ trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
|||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:OS/2:*:*)
|
||||
echo "i386-pc-os2_emx"
|
||||
exit 0;;
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
|
|
2
config.sub
vendored
2
config.sub
vendored
|
@ -705,6 +705,8 @@ case $os in
|
|||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
;;
|
||||
-os2_emx)
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST END IN A *, to match a version number.
|
||||
|
|
19
configure.in
19
configure.in
|
@ -293,7 +293,13 @@ fi
|
|||
if test "$rb_cv_fcnt" = ""; then
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[FILE *f = stdin; f->readCount = 0;],
|
||||
rb_cv_fcnt="readCount", rb_cv_fcnt="not found")
|
||||
rb_cv_fcnt="readCount", )
|
||||
fi
|
||||
dnl for emx0.9c
|
||||
if test "$rb_cv_fcnt" = ""; then
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[FILE *f = stdin; f->_rcount = 0;],
|
||||
rb_cv_fcnt="_rcount", rb_cv_fcnt="not found")
|
||||
fi])
|
||||
if test "$rb_cv_fcnt" = "not found"; then
|
||||
AC_MSG_RESULT([not found(OK if using GNU libc)])
|
||||
|
@ -493,6 +499,8 @@ else
|
|||
AC_DEFINE(DLEXT, ".bundle");;
|
||||
cygwin*) DLEXT=dll
|
||||
AC_DEFINE(DLEXT, ".dll");;
|
||||
os2_emx) DLEXT=o
|
||||
AC_DEFINE(DLEXT, ".o");;
|
||||
*) DLEXT=so
|
||||
AC_DEFINE(DLEXT, ".so");;
|
||||
esac
|
||||
|
@ -573,6 +581,12 @@ rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no
|
|||
binsuffix=.x
|
||||
setup=Setup.x68
|
||||
;;
|
||||
dnl OS/2 environment w/ Autoconf 2.1x for EMX
|
||||
os2_emx)
|
||||
LIBOBJS="$LIBOBJS os2.o"
|
||||
binsuffix=.exe
|
||||
setup=Setup.emx
|
||||
;;
|
||||
cygwin*)
|
||||
binsuffix=.exe
|
||||
setup=Setup
|
||||
|
@ -622,6 +636,9 @@ fi
|
|||
|
||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
||||
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
|
||||
AC_ARG_ENABLE(enable-shared,
|
||||
[--enable-shared build a shared library for Ruby. ],
|
||||
[enable_shared=$enableval])
|
||||
if test "$enable_shared" = 'yes'; then
|
||||
LIBRUBY='$(LIBRUBY_SO)'
|
||||
LIBRUBYARG='-L./ -l$(RUBY_INSTALL_NAME)'
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define RUBY
|
||||
|
||||
/* define RUBY_USE_EUC/SJIS for default kanji-code */
|
||||
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__)
|
||||
#if defined(MSDOS) || defined(__CYGWIN32__) || defined(__human68k__) || defined(__MACOS__) || defined(__EMX__) || defined(OS2)
|
||||
#undef RUBY_USE_EUC
|
||||
#define RUBY_USE_SJIS
|
||||
#else
|
||||
|
|
2
dir.c
2
dir.c
|
@ -248,7 +248,7 @@ static VALUE
|
|||
dir_s_chroot(dir, path)
|
||||
VALUE dir, path;
|
||||
{
|
||||
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__)
|
||||
#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__)
|
||||
rb_secure(2);
|
||||
Check_SafeStr(path);
|
||||
|
||||
|
|
11
dln.c
11
dln.c
|
@ -1585,7 +1585,7 @@ dln_find_1(fname, path, exe_flag)
|
|||
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
|
||||
return fname;
|
||||
if (exe_flag && strchr(fname, '/')) return fname;
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
|
||||
if (fname[0] == '\\') return fname;
|
||||
if (strlen(fname) > 2 && fname[1] == ':') return fname;
|
||||
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
|
||||
|
@ -1617,7 +1617,7 @@ dln_find_1(fname, path, exe_flag)
|
|||
*/
|
||||
|
||||
if (*dp == '~' && (l == 1 ||
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
|
||||
dp[1] == '\\' ||
|
||||
#endif
|
||||
dp[1] == '/')) {
|
||||
|
@ -1671,7 +1671,7 @@ dln_find_1(fname, path, exe_flag)
|
|||
if (eaccess(mac_fullpath, X_OK) == 0) return mac_fullpath;
|
||||
}
|
||||
#endif
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__)
|
||||
#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
|
||||
if (exe_flag) {
|
||||
static const char *extension[] = {
|
||||
#if defined(MSDOS)
|
||||
|
@ -1680,7 +1680,10 @@ dln_find_1(fname, path, exe_flag)
|
|||
".btm", ".sh", ".ksh", ".pl", ".sed",
|
||||
#endif
|
||||
#else
|
||||
#if defined(__EMX__)
|
||||
".exe", ".com", ".cmd", ".bat",
|
||||
".r", ".R", ".x", ".X", ".bat", ".BAT",
|
||||
#endif /*__EMX__*/
|
||||
#endif
|
||||
(char *) NULL
|
||||
};
|
||||
|
@ -1703,7 +1706,7 @@ dln_find_1(fname, path, exe_flag)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* MSDOS or NT or __human68k__ */
|
||||
#endif /* MSDOS or NT or __human68k__ or __EMX__ */
|
||||
/* if not, and no other alternatives, life is bleak */
|
||||
if (*ep == '\0') {
|
||||
return NULL;
|
||||
|
|
27
eval.c
27
eval.c
|
@ -940,22 +940,19 @@ static VALUE
|
|||
eval_node(self)
|
||||
VALUE self;
|
||||
{
|
||||
VALUE result = Qnil;
|
||||
NODE *tree;
|
||||
NODE *beg_tree, *tree;
|
||||
|
||||
if (ruby_eval_tree_begin) {
|
||||
tree = ruby_eval_tree_begin;
|
||||
beg_tree = ruby_eval_tree_begin;
|
||||
tree = ruby_eval_tree;
|
||||
if (beg_tree) {
|
||||
ruby_eval_tree_begin = 0;
|
||||
rb_eval(self, tree);
|
||||
rb_eval(self, beg_tree);
|
||||
}
|
||||
|
||||
if (!ruby_eval_tree) return Qnil;
|
||||
|
||||
tree = ruby_eval_tree;
|
||||
if (!tree) return Qnil;
|
||||
ruby_eval_tree = 0;
|
||||
|
||||
result = rb_eval(self, tree);
|
||||
return result;
|
||||
return rb_eval(self, tree);
|
||||
}
|
||||
|
||||
int ruby_in_eval;
|
||||
|
@ -3258,7 +3255,7 @@ assign(self, lhs, val)
|
|||
{
|
||||
VALUE recv;
|
||||
recv = rb_eval(self, lhs->nd_recv);
|
||||
if (!lhs->nd_args->nd_head) {
|
||||
if (!lhs->nd_args) {
|
||||
/* attr set */
|
||||
rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, 0);
|
||||
}
|
||||
|
@ -3267,7 +3264,7 @@ assign(self, lhs, val)
|
|||
VALUE args;
|
||||
|
||||
args = rb_eval(self, lhs->nd_args);
|
||||
RARRAY(args)->ptr[RARRAY(args)->len-1] = val;
|
||||
rb_ary_push(args, val);
|
||||
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
|
||||
RARRAY(args)->len, RARRAY(args)->ptr, 0);
|
||||
}
|
||||
|
@ -4095,7 +4092,7 @@ compile(src)
|
|||
NODE *node;
|
||||
|
||||
Check_Type(src, T_STRING);
|
||||
node = rb_compile_string(ruby_sourcefile, src);
|
||||
node = rb_compile_string("(eval)", src);
|
||||
|
||||
if (ruby_nerrs == 0) return node;
|
||||
return 0;
|
||||
|
@ -4165,7 +4162,7 @@ eval(self, src, scope, file, line)
|
|||
PUSH_TAG(PROT_NONE);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
ruby_sourcefile = file;
|
||||
ruby_sourceline = line;
|
||||
ruby_sourceline = line - 1;
|
||||
compile(src);
|
||||
if (ruby_nerrs > 0) {
|
||||
compile_error(0);
|
||||
|
@ -4380,7 +4377,7 @@ is_absolute_path(path)
|
|||
const char *path;
|
||||
{
|
||||
if (path[0] == '/') return 1;
|
||||
# if defined(MSDOS) || defined(NT) || defined(__human68k__)
|
||||
# if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
|
||||
if (path[0] == '\\') return 1;
|
||||
if (strlen(path) > 2 && path[1] == ':') return 1;
|
||||
# endif
|
||||
|
|
|
@ -37,7 +37,13 @@ if $topdir !~ "^/"
|
|||
$topdir = Dir.pwd
|
||||
Dir.chdir save
|
||||
end
|
||||
$dots = if "@INSTALL@" =~ /^\// then "" else "#{$topdir}/ext/" end
|
||||
|
||||
## drive letter
|
||||
if PLATFORM == "i386-os2_emx" then
|
||||
$dots = ""
|
||||
else
|
||||
$dots = if "@INSTALL@" =~ /^\// then "" else "#{$topdir}/ext/" end
|
||||
end
|
||||
|
||||
if File.exist?("config.cache") then
|
||||
f = open("config.cache", "r")
|
||||
|
@ -75,7 +81,7 @@ end
|
|||
LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s @LDFLAGS@ %s conftest.c @LIBS@ %s"
|
||||
CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s conftest.c"
|
||||
|
||||
if /cygwin|mswin32|djgpp|mingw32|m68k-human/i =~ PLATFORM
|
||||
if /cygwin|mswin32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
|
||||
$null = open("nul", "w")
|
||||
else
|
||||
$null = open("/dev/null", "w")
|
||||
|
|
|
@ -78,7 +78,7 @@ rb_nkf_kconv(obj, opt, src)
|
|||
}
|
||||
|
||||
kanji_convert(NULL);
|
||||
output_ctr--;
|
||||
if (output_ctr > 0) output_ctr--;
|
||||
if (output[output_ctr] == '\0') {
|
||||
/*
|
||||
printf("([%c][%d])\n", output[output_ctr], output_ctr);
|
||||
|
|
|
@ -9,6 +9,9 @@ when /cygwin32/
|
|||
when /beos/
|
||||
test_func = "socket"
|
||||
have_library("net", "socket")
|
||||
when /i386-os2_emx/
|
||||
test_func = "socket"
|
||||
have_library("socket", "socket")
|
||||
else
|
||||
test_func = "socket"
|
||||
have_library("nsl", "t_open")
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include <netdb.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifdef __EMX__
|
||||
#undef HAVE_SYS_UN_H
|
||||
#endif
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
@ -1244,7 +1247,7 @@ static VALUE
|
|||
sock_s_socketpair(class, domain, type, protocol)
|
||||
VALUE class, domain, type, protocol;
|
||||
{
|
||||
#if !defined(NT) && !defined(__BEOS__)
|
||||
#if !defined(NT) && !defined(__BEOS__) && !defined(__EMX__)
|
||||
int d, t, sp[2];
|
||||
|
||||
setup_domain_and_type(domain, &d, type, &t);
|
||||
|
|
19
file.c
19
file.c
|
@ -64,6 +64,10 @@ char *strrchr _((const char*,const char));
|
|||
char* strdup(char*);
|
||||
#endif
|
||||
|
||||
#ifdef __EMX__
|
||||
#define lstat stat
|
||||
#endif
|
||||
|
||||
VALUE rb_cFile;
|
||||
VALUE rb_mFileTest;
|
||||
static VALUE sStat;
|
||||
|
@ -190,7 +194,7 @@ static VALUE
|
|||
rb_file_s_lstat(obj, fname)
|
||||
VALUE obj, fname;
|
||||
{
|
||||
#if !defined(MSDOS) && !defined(NT)
|
||||
#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
|
||||
struct stat st;
|
||||
|
||||
Check_SafeStr(fname);
|
||||
|
@ -208,7 +212,7 @@ static VALUE
|
|||
rb_file_lstat(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
#if !defined(MSDOS) && !defined(NT)
|
||||
#if !defined(MSDOS) && !defined(NT)
|
||||
OpenFile *fptr;
|
||||
struct stat st;
|
||||
|
||||
|
@ -779,7 +783,7 @@ rb_file_chmod(obj, vmode)
|
|||
mode = NUM2INT(vmode);
|
||||
|
||||
GetOpenFile(obj, fptr);
|
||||
#if defined(DJGPP) || defined(NT) || defined(USE_CWGUSI) || defined(__BEOS__)
|
||||
#if defined(DJGPP) || defined(NT) || defined(USE_CWGUSI) || defined(__BEOS__) || defined(__EMX__)
|
||||
if (chmod(fptr->path, mode) == -1)
|
||||
rb_sys_fail(fptr->path);
|
||||
#else
|
||||
|
@ -838,7 +842,7 @@ rb_file_chown(obj, owner, group)
|
|||
|
||||
rb_secure(4);
|
||||
GetOpenFile(obj, fptr);
|
||||
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(USE_CWGUSI)
|
||||
#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(USE_CWGUSI) || defined(__EMX__)
|
||||
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1)
|
||||
rb_sys_fail(fptr->path);
|
||||
#else
|
||||
|
@ -952,7 +956,7 @@ static VALUE
|
|||
rb_file_s_symlink(obj, from, to)
|
||||
VALUE obj, from, to;
|
||||
{
|
||||
#if !defined(MSDOS) && !defined(NT)
|
||||
#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
|
||||
Check_SafeStr(from);
|
||||
Check_SafeStr(to);
|
||||
|
||||
|
@ -969,7 +973,7 @@ static VALUE
|
|||
rb_file_s_readlink(obj, path)
|
||||
VALUE obj, path;
|
||||
{
|
||||
#if !defined(MSDOS) && !defined(NT)
|
||||
#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__)
|
||||
char buf[MAXPATHLEN];
|
||||
int cc;
|
||||
|
||||
|
@ -1585,9 +1589,12 @@ Init_File()
|
|||
|
||||
separator = rb_str_new2("/");
|
||||
rb_define_const(rb_cFile, "Separator", separator);
|
||||
rb_define_const(rb_cFile, "SEPARATOR", separator);
|
||||
rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1);
|
||||
rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
|
||||
|
||||
rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_str_new2(RUBY_PATH_SEP));
|
||||
|
||||
rb_define_method(rb_cIO, "stat", rb_io_stat, 0); /* this is IO's method */
|
||||
rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0);
|
||||
|
||||
|
|
6
hash.c
6
hash.c
|
@ -984,8 +984,8 @@ char *nam;
|
|||
|
||||
void
|
||||
ruby_setenv(name, value)
|
||||
char *name;
|
||||
char *value;
|
||||
const char *name;
|
||||
const char *value;
|
||||
{
|
||||
#if defined(WIN32) && !defined(__CYGWIN32__)
|
||||
#ifdef USE_WIN32_RTL_ENV
|
||||
|
@ -1092,7 +1092,7 @@ ruby_setenv(name, value)
|
|||
|
||||
void
|
||||
ruby_unsetenv(name)
|
||||
char *name;
|
||||
const char *name;
|
||||
{
|
||||
ruby_setenv(name, 0);
|
||||
}
|
||||
|
|
42
io.c
42
io.c
|
@ -40,7 +40,8 @@ struct timeval {
|
|||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
/* EMX has sys/parm.h, but.. */
|
||||
#if defined(HAVE_SYS_PARAM_H) && !defined(__EMX__)
|
||||
# include <sys/param.h>
|
||||
#else
|
||||
# define NOFILE 64
|
||||
|
@ -185,7 +186,7 @@ io_write(io, str)
|
|||
rb_sys_fail(fptr->path);
|
||||
#else
|
||||
n = fwrite(RSTRING(str)->ptr, 1, RSTRING(str)->len, f);
|
||||
if (n == 0 || ferror(f)) {
|
||||
if (ferror(f)) {
|
||||
rb_sys_fail(fptr->path);
|
||||
}
|
||||
#endif
|
||||
|
@ -236,7 +237,7 @@ rb_io_tell(io)
|
|||
|
||||
GetOpenFile(io, fptr);
|
||||
pos = ftell(fptr->f);
|
||||
if (ferror(fptr->f) != 0) rb_sys_fail(fptr->path);
|
||||
if (ferror(fptr->f)) rb_sys_fail(fptr->path);
|
||||
|
||||
return rb_int2inum(pos);
|
||||
}
|
||||
|
@ -700,6 +701,20 @@ lineno_setter(val, id, var)
|
|||
*var = INT2FIX(gets_lineno);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
arg_set_lineno(argf, val)
|
||||
VALUE argf, val;
|
||||
{
|
||||
gets_lineno = NUM2INT(val);
|
||||
lineno = INT2FIX(gets_lineno);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
arg_lineno()
|
||||
{
|
||||
return lineno;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_readline(argc, argv, io)
|
||||
int argc;
|
||||
|
@ -763,7 +778,7 @@ rb_io_each_byte(io)
|
|||
if (c == EOF) break;
|
||||
rb_yield(INT2FIX(c & 0xff));
|
||||
}
|
||||
if (ferror(f) != 0) rb_sys_fail(fptr->path);
|
||||
if (ferror(f)) rb_sys_fail(fptr->path);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
@ -785,7 +800,7 @@ rb_io_getc(io)
|
|||
TRAP_END;
|
||||
|
||||
if (c == EOF) {
|
||||
if (ferror(f) != 0) rb_sys_fail(fptr->path);
|
||||
if (ferror(f)) rb_sys_fail(fptr->path);
|
||||
return Qnil;
|
||||
}
|
||||
return INT2FIX(c & 0xff);
|
||||
|
@ -1012,7 +1027,8 @@ VALUE
|
|||
rb_io_binmode(io)
|
||||
VALUE io;
|
||||
{
|
||||
#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) || defined(USE_CWGUSI)
|
||||
#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__)\
|
||||
|| defined(__human68k__) || defined(USE_CWGUSI) || defined(__EMX__)
|
||||
OpenFile *fptr;
|
||||
|
||||
GetOpenFile(io, fptr);
|
||||
|
@ -1837,7 +1853,7 @@ rb_io_putc(io, ch)
|
|||
rb_io_check_writable(fptr);
|
||||
f = GetWriteFile(fptr);
|
||||
|
||||
if (fputc(c, f) == EOF || ferror(f))
|
||||
if (fputc(c, f) == EOF)
|
||||
rb_sys_fail(fptr->path);
|
||||
if (fptr->mode & FMODE_SYNC)
|
||||
fflush(f);
|
||||
|
@ -2079,7 +2095,7 @@ next_argv()
|
|||
rb_str_cat(str, ruby_inplace_mode,
|
||||
strlen(ruby_inplace_mode));
|
||||
#endif
|
||||
#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN32__) || defined(NT) || defined(__human68k__)
|
||||
#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN32__) || defined(NT) || defined(__human68k__) || defined(__EMX__)
|
||||
(void)fclose(fr);
|
||||
(void)unlink(RSTRING(str)->ptr);
|
||||
(void)rename(fn, RSTRING(str)->ptr);
|
||||
|
@ -2106,7 +2122,7 @@ next_argv()
|
|||
#endif
|
||||
}
|
||||
fw = rb_fopen(fn, "w");
|
||||
#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__)
|
||||
#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__)
|
||||
fstat(fileno(fw), &st2);
|
||||
fchmod(fileno(fw), st.st_mode);
|
||||
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
|
||||
|
@ -2947,6 +2963,7 @@ Init_IO()
|
|||
rb_define_singleton_method(rb_cIO, "foreach", rb_io_s_foreach, -1);
|
||||
rb_define_singleton_method(rb_cIO, "readlines", rb_io_s_readlines, -1);
|
||||
rb_define_singleton_method(rb_cIO, "select", rb_f_select, -1);
|
||||
rb_define_singleton_method(rb_cIO, "pipe", rb_io_s_pipe, 0);
|
||||
|
||||
rb_fs = rb_output_fs = Qnil;
|
||||
rb_define_hooked_variable("$;", &rb_fs, 0, rb_str_setter);
|
||||
|
@ -3070,10 +3087,13 @@ Init_IO()
|
|||
rb_define_singleton_method(argf, "close", arg_close, 0);
|
||||
rb_define_singleton_method(argf, "closed?", arg_closed, 0);
|
||||
|
||||
filename = rb_str_new2("-");
|
||||
rb_define_readonly_variable("$FILENAME", &filename);
|
||||
rb_define_singleton_method(argf, "lineno", arg_lineno, 0);
|
||||
rb_define_singleton_method(argf, "lineno=", arg_set_lineno, 1);
|
||||
|
||||
file = rb_stdin;
|
||||
rb_global_variable(&file);
|
||||
filename = rb_str_new2("-");
|
||||
rb_define_readonly_variable("$FILENAME", &filename);
|
||||
|
||||
rb_define_virtual_variable("$-i", opt_i_get, opt_i_set);
|
||||
|
||||
|
|
|
@ -92,16 +92,16 @@ class DEBUGGER__
|
|||
when /^c(ont)?$/
|
||||
return
|
||||
when /^s(tep)?\s*(\d+)?$/
|
||||
if $1
|
||||
lev = Integer($1)
|
||||
if $2
|
||||
lev = Integer($2)
|
||||
else
|
||||
lev = 1
|
||||
end
|
||||
@stop_next = lev
|
||||
return
|
||||
when /^n(ext)?\s*(\d+)?$/
|
||||
if $1
|
||||
lev = Integer($1)
|
||||
if $2
|
||||
lev = Integer($2)
|
||||
else
|
||||
lev = 1
|
||||
end
|
||||
|
|
|
@ -24,6 +24,9 @@ class << File
|
|||
fsize = 1024 if fsize < 512
|
||||
fsize = TOO_BIG if fsize > TOO_BIG
|
||||
|
||||
fmode = stat(from).mode
|
||||
tpath = to
|
||||
|
||||
from = open(from, "r")
|
||||
from.binmode
|
||||
to = open(to, "w")
|
||||
|
@ -47,6 +50,7 @@ class << File
|
|||
to.close
|
||||
from.close
|
||||
end
|
||||
chmod(fmode, tpath)
|
||||
ret
|
||||
end
|
||||
|
||||
|
@ -66,10 +70,17 @@ class << File
|
|||
if PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to
|
||||
unlink to
|
||||
end
|
||||
fstat = stat(from)
|
||||
begin
|
||||
rename from, to
|
||||
rescue
|
||||
from_stat = stat(from)
|
||||
syscopy from, to and unlink from
|
||||
utime(from_stat.atime, from_stat.mtime, to)
|
||||
begin
|
||||
chown(fstat.uid, fstat.gid, tpath)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -293,11 +293,7 @@ class FTP
|
|||
buf = file.gets
|
||||
break if buf == nil
|
||||
if buf[-2, 2] != CRLF
|
||||
if buf[-1] == ?\r or
|
||||
buf[-1] == ?\n
|
||||
buf = buf[0 .. -2]
|
||||
end
|
||||
buf = buf + CRLF
|
||||
buf = buf.chop + CRLF
|
||||
end
|
||||
conn.write(buf)
|
||||
callback.call(buf) if use_callback
|
||||
|
|
|
@ -43,6 +43,6 @@ class Mail
|
|||
end
|
||||
|
||||
def [](field)
|
||||
@header[field]
|
||||
@header[field.capitalize]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -221,7 +221,6 @@ class Matrix
|
|||
row[j] = values[j]
|
||||
row
|
||||
}
|
||||
self
|
||||
rows(rows, FALSE)
|
||||
end
|
||||
|
||||
|
@ -875,7 +874,7 @@ class Vector
|
|||
|
||||
# ARITHMETIC
|
||||
|
||||
def *(x) "is matrix or number"
|
||||
def *(x) # is matrix or number
|
||||
case x
|
||||
when Numeric
|
||||
els = @elements.collect{|e| e * x}
|
||||
|
|
|
@ -55,7 +55,7 @@ CFLAGS = CONFIG["CFLAGS"]
|
|||
if PLATFORM == "m68k-human"
|
||||
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
|
||||
end
|
||||
if /win32|djgpp|mingw32|m68k-human/i =~ PLATFORM
|
||||
if /win32|djgpp|mingw32|m68k-human|i386-os2_emx/i =~ PLATFORM
|
||||
$null = open("nul", "w")
|
||||
else
|
||||
$null = open("/dev/null", "w")
|
||||
|
|
|
@ -16,8 +16,8 @@ class WeakRef<Delegator
|
|||
class RefError<StandardError
|
||||
end
|
||||
|
||||
ID_MAP = {}
|
||||
ID_REV_MAP = {}
|
||||
ID_MAP = {} # obj -> [ref,...]
|
||||
ID_REV_MAP = {} # ref -> obj
|
||||
ObjectSpace.add_finalizer(lambda{|id|
|
||||
rids = ID_MAP[id]
|
||||
if rids
|
||||
|
@ -29,10 +29,11 @@ class WeakRef<Delegator
|
|||
rid = ID_REV_MAP[id]
|
||||
if rid
|
||||
ID_REV_MAP[id] = nil
|
||||
ID_MAP[rid] = nil
|
||||
ID_MAP[rid].delete(id)
|
||||
ID_MAP[rid] = nil if ID_MAP[rid].empty?
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
def initialize(orig)
|
||||
super
|
||||
@__id = orig.__id__
|
||||
|
|
13
missing/os2.c
Normal file
13
missing/os2.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
int
|
||||
chown(char *path, int owner, int group)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
link(char *from, char *to)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
12
pack.c
12
pack.c
|
@ -916,9 +916,11 @@ hex2num(c)
|
|||
|
||||
#define PACK_LENGTH_ADJUST(type) do { \
|
||||
tmp = 0; \
|
||||
if (len > (send - s)/sizeof(type)) { \
|
||||
tmp = len - (send - s) / sizeof(type); \
|
||||
len = (send - s) / sizeof(type); \
|
||||
if (len > (send-s)/sizeof(type)) { \
|
||||
if (!star) { \
|
||||
tmp = len - (send-s)/sizeof(type); \
|
||||
} \
|
||||
len = (send-s)/sizeof(type); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -933,7 +935,7 @@ pack_unpack(str, fmt)
|
|||
char *p, *pend;
|
||||
VALUE ary;
|
||||
char type;
|
||||
int len, tmp;
|
||||
int len, tmp, star;
|
||||
|
||||
s = rb_str2cstr(str, &len);
|
||||
send = s + len;
|
||||
|
@ -942,8 +944,10 @@ pack_unpack(str, fmt)
|
|||
|
||||
ary = rb_ary_new();
|
||||
while (p < pend) {
|
||||
star = 0;
|
||||
type = *p++;
|
||||
if (*p == '*') {
|
||||
star = 1;
|
||||
len = send - s;
|
||||
p++;
|
||||
}
|
||||
|
|
467
parse.y
467
parse.y
|
@ -62,19 +62,23 @@ static enum lex_state {
|
|||
|
||||
static int class_nest = 0;
|
||||
static int in_single = 0;
|
||||
static int compile_for_eval = 0;
|
||||
static ID cur_mid = 0;
|
||||
|
||||
static int value_expr();
|
||||
static NODE *cond();
|
||||
static NODE *logop();
|
||||
|
||||
static NODE *newline_node();
|
||||
static void fixpos();
|
||||
|
||||
static int value_expr();
|
||||
static void void_expr();
|
||||
static void void_stmts();
|
||||
|
||||
static NODE *block_append();
|
||||
static NODE *list_append();
|
||||
static NODE *list_concat();
|
||||
static NODE *arg_add();
|
||||
static NODE *arg_concat();
|
||||
static NODE *call_op();
|
||||
static int in_defined = 0;
|
||||
|
||||
|
@ -87,6 +91,7 @@ static NODE *assignable();
|
|||
static NODE *aryset();
|
||||
static NODE *attrset();
|
||||
static void rb_backref_error();
|
||||
static NODE *node_assign();
|
||||
|
||||
static NODE *match_gen();
|
||||
static void local_push();
|
||||
|
@ -170,12 +175,12 @@ static void top_local_setup();
|
|||
%type <node> compstmt stmts stmt expr arg primary command_call method_call
|
||||
%type <node> if_tail opt_else case_body cases rescue ensure
|
||||
%type <node> opt_call_args call_args ret_args args when_args
|
||||
%type <node> aref_args opt_block_arg block_arg
|
||||
%type <node> mrhs opt_list superclass iterator var_ref
|
||||
%type <node> aref_args opt_block_arg block_arg stmt_rhs
|
||||
%type <node> mrhs opt_list superclass generic_call block_call 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 backref
|
||||
%type <node> iter_var opt_iter_var iter_block iter_do_block
|
||||
%type <node> mlhs mlhs_head mlhs_tail mlhs_basic mlhs_entry mlhs_item lhs
|
||||
%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
|
||||
%type <id> cname fname op f_rest_arg
|
||||
%type <num> f_arg
|
||||
|
@ -240,6 +245,16 @@ program : {
|
|||
}
|
||||
compstmt
|
||||
{
|
||||
if ($2) { /* last expression is void */
|
||||
if (nd_type($2) != NODE_BLOCK) void_expr($2);
|
||||
else {
|
||||
NODE *node = $2;
|
||||
while (node->nd_next) {
|
||||
node = node->nd_next;
|
||||
}
|
||||
void_expr(node->nd_head);
|
||||
}
|
||||
}
|
||||
ruby_eval_tree = block_append(ruby_eval_tree, $2);
|
||||
top_local_setup();
|
||||
cur_cref = 0;
|
||||
|
@ -248,11 +263,12 @@ program : {
|
|||
}
|
||||
|
||||
compstmt : stmts opt_terms
|
||||
|
||||
stmts : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
void_stmts($1);
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
stmts : none
|
||||
| stmt
|
||||
{
|
||||
$$ = newline_node($1);
|
||||
|
@ -266,15 +282,7 @@ stmts : /* none */
|
|||
$$ = $2;
|
||||
}
|
||||
|
||||
stmt : iterator iter_do_block
|
||||
{
|
||||
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
|
||||
rb_compile_error("both block arg and actual block given");
|
||||
}
|
||||
$2->nd_iter = $1;
|
||||
$$ = $2;
|
||||
fixpos($$, $2);
|
||||
}
|
||||
stmt : block_call
|
||||
| kALIAS fname {lex_state = EXPR_FNAME;} fname
|
||||
{
|
||||
if (cur_mid || in_single)
|
||||
|
@ -344,24 +352,28 @@ stmt : iterator iter_do_block
|
|||
if (cur_mid || in_single) {
|
||||
yyerror("BEGIN in method");
|
||||
}
|
||||
|
||||
local_push();
|
||||
}
|
||||
'{' compstmt '}'
|
||||
{
|
||||
ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
|
||||
NEW_PREEXE($4));
|
||||
NEW_PREEXE($4));
|
||||
local_pop();
|
||||
$$ = 0;
|
||||
}
|
||||
| klEND '{' compstmt '}'
|
||||
{
|
||||
if (cur_mid || in_single) {
|
||||
if (compile_for_eval && (cur_mid || in_single)) {
|
||||
yyerror("END in method; use at_exit");
|
||||
}
|
||||
|
||||
$$ = NEW_ITER(0, NEW_POSTEXE(), $3);
|
||||
}
|
||||
| lhs '=' stmt_rhs
|
||||
{
|
||||
value_expr($3);
|
||||
$$ = node_assign($1, $3);
|
||||
}
|
||||
| expr
|
||||
|
||||
expr : mlhs '=' mrhs
|
||||
|
@ -373,7 +385,7 @@ expr : mlhs '=' mrhs
|
|||
| kRETURN ret_args
|
||||
{
|
||||
value_expr($2);
|
||||
if (!cur_mid && !in_single)
|
||||
if (!compile_for_eval && !cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RETURN($2);
|
||||
}
|
||||
|
@ -422,7 +434,7 @@ command_call : operation call_args
|
|||
}
|
||||
| kSUPER call_args
|
||||
{
|
||||
if (!cur_mid && !in_single && !in_defined)
|
||||
if (!compile_for_eval && !cur_mid && !in_single)
|
||||
yyerror("super called outside of method");
|
||||
$$ = NEW_SUPER($2);
|
||||
fixpos($$, $2);
|
||||
|
@ -456,12 +468,12 @@ mlhs_basic : mlhs_head
|
|||
{
|
||||
$$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),$5);
|
||||
}
|
||||
| tSTAR lhs
|
||||
| tSTAR mlhs_node
|
||||
{
|
||||
$$ = NEW_MASGN(0, $2);
|
||||
}
|
||||
|
||||
mlhs_item : lhs
|
||||
mlhs_item : mlhs_node
|
||||
| tLPAREN mlhs_entry ')'
|
||||
{
|
||||
$$ = $2;
|
||||
|
@ -481,17 +493,35 @@ mlhs_tail : mlhs_item
|
|||
$$ = list_append($1, $3);
|
||||
}
|
||||
|
||||
mlhs_node : variable
|
||||
{
|
||||
$$ = assignable($1, 0);
|
||||
}
|
||||
| primary '[' aref_args ']'
|
||||
{
|
||||
$$ = aryset($1, $3);
|
||||
}
|
||||
| primary '.' tIDENTIFIER
|
||||
{
|
||||
$$ = attrset($1, $3);
|
||||
}
|
||||
| backref
|
||||
{
|
||||
rb_backref_error($1);
|
||||
$$ = 0;
|
||||
}
|
||||
|
||||
lhs : variable
|
||||
{
|
||||
$$ = assignable($1, 0);
|
||||
}
|
||||
| primary '[' aref_args ']'
|
||||
{
|
||||
$$ = aryset($1, $3, 0);
|
||||
$$ = aryset($1, $3);
|
||||
}
|
||||
| primary '.' tIDENTIFIER
|
||||
{
|
||||
$$ = attrset($1, $3, 0);
|
||||
$$ = attrset($1, $3);
|
||||
}
|
||||
| backref
|
||||
{
|
||||
|
@ -564,34 +594,10 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
|
|||
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
|
||||
| kWHILE_MOD | kYIELD
|
||||
|
||||
arg : variable '=' {$$ = assignable($1, 0);} arg
|
||||
{
|
||||
$$ = $<node>3;
|
||||
if ($$) {
|
||||
$$->nd_value = $4;
|
||||
fixpos($$, $4);
|
||||
}
|
||||
}
|
||||
| primary '[' aref_args ']' '=' arg
|
||||
{
|
||||
$$ = aryset($1, $3, $6);
|
||||
fixpos($$, $1);
|
||||
}
|
||||
| primary '.' tIDENTIFIER '=' arg
|
||||
{
|
||||
$$ = attrset($1, $3, $5);
|
||||
fixpos($$, $5);
|
||||
}
|
||||
| primary '.' tCONSTANT '=' arg
|
||||
{
|
||||
$$ = attrset($1, $3, $5);
|
||||
fixpos($$, $5);
|
||||
}
|
||||
| backref '=' arg
|
||||
arg : lhs '=' arg
|
||||
{
|
||||
value_expr($3);
|
||||
rb_backref_error($1);
|
||||
$$ = 0;
|
||||
$$ = node_assign($1, $3);
|
||||
}
|
||||
| variable tOP_ASGN {$$ = assignable($1, 0);} arg
|
||||
{
|
||||
|
@ -792,10 +798,7 @@ aref_args : opt_call_args
|
|||
$$ = $1;
|
||||
}
|
||||
|
||||
opt_call_args : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
opt_call_args : none
|
||||
| call_args opt_nl
|
||||
|
||||
call_args : command_call
|
||||
|
@ -813,7 +816,7 @@ call_args : command_call
|
|||
}
|
||||
| args ',' tSTAR arg opt_block_arg
|
||||
{
|
||||
$$ = arg_add($1, $4);
|
||||
$$ = arg_concat($1, $4);
|
||||
$$ = arg_blk_pass($$, $5);
|
||||
}
|
||||
| assocs ','
|
||||
|
@ -827,7 +830,7 @@ call_args : command_call
|
|||
}
|
||||
| assocs ',' tSTAR arg opt_block_arg
|
||||
{
|
||||
$$ = arg_add(NEW_LIST(NEW_HASH($1)), $4);
|
||||
$$ = arg_concat(NEW_LIST(NEW_HASH($1)), $4);
|
||||
$$ = arg_blk_pass($$, $5);
|
||||
}
|
||||
| args ',' assocs opt_block_arg
|
||||
|
@ -841,7 +844,7 @@ call_args : command_call
|
|||
}
|
||||
| args ',' assocs ',' tSTAR arg opt_block_arg
|
||||
{
|
||||
$$ = arg_add(list_append($1, NEW_HASH($3)), $6);
|
||||
$$ = arg_concat(list_append($1, NEW_HASH($3)), $6);
|
||||
$$ = arg_blk_pass($$, $7);
|
||||
}
|
||||
| tSTAR arg opt_block_arg
|
||||
|
@ -861,16 +864,10 @@ opt_block_arg : ',' block_arg
|
|||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| none
|
||||
|
||||
opt_list : args
|
||||
| /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| none
|
||||
|
||||
args : arg
|
||||
{
|
||||
|
@ -898,7 +895,7 @@ mrhs : args
|
|||
| args ',' tSTAR arg
|
||||
{
|
||||
value_expr($4);
|
||||
$$ = arg_add($1, $4);
|
||||
$$ = arg_concat($1, $4);
|
||||
}
|
||||
| tSTAR arg
|
||||
{
|
||||
|
@ -920,10 +917,7 @@ ret_args : call_args
|
|||
}
|
||||
}
|
||||
|
||||
array : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
array : none
|
||||
| args trailer
|
||||
|
||||
primary : literal
|
||||
|
@ -971,20 +965,20 @@ primary : literal
|
|||
}
|
||||
| kRETURN '(' ret_args ')'
|
||||
{
|
||||
if (!cur_mid && !in_single)
|
||||
if (!compile_for_eval && !cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
value_expr($3);
|
||||
$$ = NEW_RETURN($3);
|
||||
}
|
||||
| kRETURN '(' ')'
|
||||
{
|
||||
if (!cur_mid && !in_single)
|
||||
if (!compile_for_eval && !cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RETURN(0);
|
||||
}
|
||||
| kRETURN
|
||||
{
|
||||
if (!cur_mid && !in_single)
|
||||
if (!compile_for_eval && !cur_mid && !in_single)
|
||||
yyerror("return appeared outside of method");
|
||||
$$ = NEW_RETURN(0);
|
||||
}
|
||||
|
@ -1010,13 +1004,13 @@ primary : literal
|
|||
{
|
||||
$$ = NEW_VCALL($1);
|
||||
}
|
||||
| operation iter_block
|
||||
| operation brace_block
|
||||
{
|
||||
$2->nd_iter = NEW_FCALL($1, 0);
|
||||
$$ = $2;
|
||||
}
|
||||
| method_call
|
||||
| method_call iter_block
|
||||
| method_call brace_block
|
||||
{
|
||||
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
|
||||
rb_compile_error("both block arg and actual block given");
|
||||
|
@ -1067,7 +1061,7 @@ primary : literal
|
|||
$$ = NEW_CASE($2, $3);
|
||||
fixpos($$, $2);
|
||||
}
|
||||
| kFOR iter_var kIN expr do
|
||||
| kFOR block_var kIN expr do
|
||||
compstmt
|
||||
kEND
|
||||
{
|
||||
|
@ -1216,22 +1210,16 @@ if_tail : opt_else
|
|||
fixpos($$, $2);
|
||||
}
|
||||
|
||||
opt_else : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
opt_else : none
|
||||
| kELSE compstmt
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
iter_var : lhs
|
||||
block_var : lhs
|
||||
| mlhs
|
||||
|
||||
opt_iter_var : /* node */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
opt_block_var : none
|
||||
| '|' /* none */ '|'
|
||||
{
|
||||
$$ = 0;
|
||||
|
@ -1240,16 +1228,16 @@ opt_iter_var : /* node */
|
|||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| '|' iter_var '|'
|
||||
| '|' block_var '|'
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
iter_do_block : kDO
|
||||
do_block : kDO
|
||||
{
|
||||
$<vars>$ = dyna_push();
|
||||
}
|
||||
opt_iter_var
|
||||
opt_block_var
|
||||
compstmt
|
||||
kEND
|
||||
{
|
||||
|
@ -1258,11 +1246,11 @@ iter_do_block : kDO
|
|||
dyna_pop($<vars>2);
|
||||
}
|
||||
|
||||
iter_block : '{'
|
||||
brace_block : '{'
|
||||
{
|
||||
$<vars>$ = dyna_push();
|
||||
}
|
||||
opt_iter_var
|
||||
opt_block_var
|
||||
compstmt '}'
|
||||
{
|
||||
$$ = NEW_ITER($3, 0, $4);
|
||||
|
@ -1270,7 +1258,7 @@ iter_block : '{'
|
|||
dyna_pop($<vars>2);
|
||||
}
|
||||
|
||||
iterator : tIDENTIFIER
|
||||
generic_call : tIDENTIFIER
|
||||
{
|
||||
$$ = NEW_VCALL($1);
|
||||
}
|
||||
|
@ -1285,6 +1273,16 @@ iterator : tIDENTIFIER
|
|||
| method_call
|
||||
| command_call
|
||||
|
||||
block_call : generic_call do_block
|
||||
{
|
||||
if ($1 && nd_type($1) == NODE_BLOCK_PASS) {
|
||||
rb_compile_error("both block arg and actual block given");
|
||||
}
|
||||
$2->nd_iter = $1;
|
||||
$$ = $2;
|
||||
fixpos($$, $2);
|
||||
}
|
||||
|
||||
method_call : operation '(' opt_call_args ')'
|
||||
{
|
||||
$$ = new_fcall($1, $3);
|
||||
|
@ -1315,18 +1313,23 @@ method_call : operation '(' opt_call_args ')'
|
|||
}
|
||||
| kSUPER '(' opt_call_args ')'
|
||||
{
|
||||
if (!cur_mid && !in_single && !in_defined)
|
||||
if (!compile_for_eval && !cur_mid &&
|
||||
!in_single && !in_defined)
|
||||
yyerror("super called outside of method");
|
||||
$$ = NEW_SUPER($3);
|
||||
}
|
||||
| kSUPER
|
||||
{
|
||||
if (!cur_mid && !in_single && !in_defined)
|
||||
if (!compile_for_eval && !cur_mid &&
|
||||
!in_single && !in_defined)
|
||||
yyerror("super called outside of method");
|
||||
$$ = NEW_ZSUPER();
|
||||
}
|
||||
|
||||
|
||||
stmt_rhs : block_call
|
||||
| command_call
|
||||
|
||||
case_body : kWHEN when_args then
|
||||
compstmt
|
||||
cases
|
||||
|
@ -1356,15 +1359,9 @@ rescue : kRESCUE opt_list do
|
|||
$$ = NEW_RESBODY($2, $4, $5);
|
||||
fixpos($$, $2?$2:$4);
|
||||
}
|
||||
| /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| none
|
||||
|
||||
ensure : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
ensure : none
|
||||
| kENSURE compstmt
|
||||
{
|
||||
$$ = $2;
|
||||
|
@ -1512,10 +1509,7 @@ opt_f_block_arg : ',' f_block_arg
|
|||
{
|
||||
$$ = $2;
|
||||
}
|
||||
| /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| none
|
||||
|
||||
singleton : var_ref
|
||||
{
|
||||
|
@ -1548,10 +1542,7 @@ singleton : var_ref
|
|||
$$ = $2;
|
||||
}
|
||||
|
||||
assoc_list : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
assoc_list : none
|
||||
| assocs trailer
|
||||
{
|
||||
$$ = $1;
|
||||
|
@ -1600,6 +1591,11 @@ term : ';' {yyerrok;}
|
|||
|
||||
terms : term
|
||||
| terms ';' {yyerrok;}
|
||||
|
||||
none : /* none */
|
||||
{
|
||||
$$ = 0;
|
||||
}
|
||||
%%
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -1686,6 +1682,7 @@ yycompile(f)
|
|||
ruby_sourcefile = f;
|
||||
ruby_in_compile = 1;
|
||||
n = yyparse();
|
||||
compile_for_eval = 0;
|
||||
ruby_in_compile = 0;
|
||||
if (n == 0) return ruby_eval_tree;
|
||||
|
||||
|
@ -1725,8 +1722,8 @@ rb_compile_string(f, s)
|
|||
lex_pbeg = lex_p = lex_pend = 0;
|
||||
if (!ruby_sourcefile || strcmp(f, ruby_sourcefile)) /* not in eval() */
|
||||
ruby_sourceline = 0;
|
||||
else if (ruby_frame) /* in eval() */
|
||||
cur_mid = ruby_frame->last_func;
|
||||
else /* in eval() */
|
||||
compile_for_eval = 1;
|
||||
|
||||
return yycompile(f);
|
||||
}
|
||||
|
@ -1754,23 +1751,6 @@ rb_compile_file(f, file, start)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
normalize_newline(line)
|
||||
VALUE line;
|
||||
{
|
||||
if (RSTRING(line)->len >= 2 &&
|
||||
RSTRING(line)->ptr[RSTRING(line)->len-1] == '\n' &&
|
||||
RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
|
||||
{
|
||||
RSTRING(line)->ptr[RSTRING(line)->len-2] = '\n';
|
||||
RSTRING(line)->len--;
|
||||
}
|
||||
#ifdef __MACOS__
|
||||
else if (RSTRING(line)->ptr[RSTRING(line)->len-1] == '\r')
|
||||
RSTRING(line)->ptr[RSTRING(line)->len-1] = '\n';
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
nextc()
|
||||
{
|
||||
|
@ -1785,7 +1765,6 @@ nextc()
|
|||
ruby_sourceline = heredoc_end;
|
||||
heredoc_end = 0;
|
||||
}
|
||||
normalize_newline(v);
|
||||
ruby_sourceline++;
|
||||
lex_pbeg = lex_p = RSTRING(v)->ptr;
|
||||
lex_pend = lex_p + RSTRING(v)->len;
|
||||
|
@ -2300,7 +2279,7 @@ here_document(term, indent)
|
|||
c = term;
|
||||
term = '"';
|
||||
if (!is_identchar(c)) {
|
||||
rb_warn("Use of bare << to mean <<\"\" is deprecated");
|
||||
rb_warn("use of bare << to mean <<\"\" is deprecated");
|
||||
break;
|
||||
}
|
||||
while (is_identchar(c)) {
|
||||
|
@ -2326,7 +2305,6 @@ here_document(term, indent)
|
|||
free(eos);
|
||||
return 0;
|
||||
}
|
||||
normalize_newline(line);
|
||||
ruby_sourceline++;
|
||||
p = RSTRING(line)->ptr;
|
||||
if (indent) {
|
||||
|
@ -2472,7 +2450,6 @@ yylex()
|
|||
}
|
||||
pushback(c);
|
||||
if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){
|
||||
arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
return tSTAR;
|
||||
}
|
||||
|
@ -2600,7 +2577,6 @@ yylex()
|
|||
c = nextc();
|
||||
if (lex_state == EXPR_ARG && ISSPACE(c)){
|
||||
pushback(c);
|
||||
arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
return '?';
|
||||
}
|
||||
|
@ -2629,7 +2605,6 @@ yylex()
|
|||
}
|
||||
pushback(c);
|
||||
if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)){
|
||||
arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
return tAMPER;
|
||||
}
|
||||
|
@ -2676,7 +2651,6 @@ yylex()
|
|||
if (ISDIGIT(c)) {
|
||||
goto start_num;
|
||||
}
|
||||
if (lex_state == EXPR_ARG) arg_ambiguous();
|
||||
pushback(c);
|
||||
lex_state = EXPR_BEG;
|
||||
return tUPLUS;
|
||||
|
@ -2706,7 +2680,6 @@ yylex()
|
|||
c = '-';
|
||||
goto start_num;
|
||||
}
|
||||
if (lex_state == EXPR_ARG) arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
pushback(c);
|
||||
return tUMINUS;
|
||||
|
@ -2882,7 +2855,6 @@ yylex()
|
|||
return tCOLON3;
|
||||
}
|
||||
if (lex_state == EXPR_ARG && space_seen) {
|
||||
arg_ambiguous();
|
||||
lex_state = EXPR_BEG;
|
||||
return tCOLON3;
|
||||
}
|
||||
|
@ -2966,7 +2938,6 @@ yylex()
|
|||
c = tLBRACK;
|
||||
}
|
||||
else if (lex_state == EXPR_ARG && space_seen) {
|
||||
arg_ambiguous();
|
||||
c = tLBRACK;
|
||||
}
|
||||
lex_state = EXPR_BEG;
|
||||
|
@ -2980,6 +2951,10 @@ yylex()
|
|||
|
||||
case '\\':
|
||||
c = nextc();
|
||||
if (c == '\r') {
|
||||
c = nextc();
|
||||
if (c != '\n') pushback(c);
|
||||
}
|
||||
if (c == '\n') {
|
||||
space_seen = 1;
|
||||
goto retry; /* skip \\n */
|
||||
|
@ -3036,11 +3011,8 @@ yylex()
|
|||
yylval.id = '%';
|
||||
return tOP_ASGN;
|
||||
}
|
||||
if (lex_state == EXPR_ARG) {
|
||||
if (space_seen && !ISSPACE(c)) {
|
||||
arg_ambiguous();
|
||||
goto quotation;
|
||||
}
|
||||
if (lex_state == EXPR_ARG && space_seen && !ISSPACE(c)) {
|
||||
goto quotation;
|
||||
}
|
||||
lex_state = EXPR_BEG;
|
||||
pushback(c);
|
||||
|
@ -3659,30 +3631,11 @@ assignable(id, val)
|
|||
}
|
||||
|
||||
static NODE *
|
||||
arg_add(node1, node2)
|
||||
NODE *node1;
|
||||
NODE *node2;
|
||||
{
|
||||
return NEW_ARGSCAT(node1, node2);
|
||||
}
|
||||
|
||||
static NODE *
|
||||
aryset(recv, idx, val)
|
||||
NODE *recv, *idx, *val;
|
||||
aryset(recv, idx)
|
||||
NODE *recv, *idx;
|
||||
{
|
||||
value_expr(recv);
|
||||
value_expr(val);
|
||||
if (idx) {
|
||||
if (nd_type(idx) == NODE_ARRAY) {
|
||||
idx = list_append(idx, val);
|
||||
}
|
||||
else {
|
||||
idx = arg_add(idx, val);
|
||||
}
|
||||
}
|
||||
else {
|
||||
idx = val;
|
||||
}
|
||||
|
||||
return NEW_CALL(recv, tASET, idx);
|
||||
}
|
||||
|
||||
|
@ -3696,14 +3649,13 @@ rb_id_attrset(id)
|
|||
}
|
||||
|
||||
static NODE *
|
||||
attrset(recv, id, val)
|
||||
NODE *recv, *val;
|
||||
attrset(recv, id)
|
||||
NODE *recv;
|
||||
ID id;
|
||||
{
|
||||
value_expr(recv);
|
||||
value_expr(val);
|
||||
|
||||
return NEW_CALL(recv, rb_id_attrset(id), NEW_LIST(val));
|
||||
return NEW_CALL(recv, rb_id_attrset(id), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3720,6 +3672,59 @@ rb_backref_error(node)
|
|||
}
|
||||
}
|
||||
|
||||
static NODE *
|
||||
arg_concat(node1, node2)
|
||||
NODE *node1;
|
||||
NODE *node2;
|
||||
{
|
||||
return NEW_ARGSCAT(node1, node2);
|
||||
}
|
||||
|
||||
static NODE *
|
||||
arg_add(node1, node2)
|
||||
NODE *node1;
|
||||
NODE *node2;
|
||||
{
|
||||
if (!node1) return NEW_LIST(node2);
|
||||
if (nd_type(node1) == NODE_ARRAY) {
|
||||
return list_append(node1, node2);
|
||||
}
|
||||
else {
|
||||
return NEW_ARGSCAT(node1, node2);
|
||||
}
|
||||
}
|
||||
|
||||
static NODE*
|
||||
node_assign(lhs, rhs)
|
||||
NODE *lhs, *rhs;
|
||||
{
|
||||
if (!lhs) return 0;
|
||||
|
||||
value_expr(rhs);
|
||||
switch (nd_type(lhs)) {
|
||||
case NODE_GASGN:
|
||||
case NODE_IASGN:
|
||||
case NODE_LASGN:
|
||||
case NODE_DASGN:
|
||||
case NODE_DASGN_PUSH:
|
||||
case NODE_CASGN:
|
||||
case NODE_MASGN:
|
||||
lhs->nd_value = rhs;
|
||||
break;
|
||||
|
||||
case NODE_CALL:
|
||||
lhs->nd_args = arg_add(lhs->nd_args, rhs);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* should not happen */
|
||||
break;
|
||||
}
|
||||
|
||||
if (rhs) fixpos(lhs, rhs);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
static int
|
||||
value_expr(node)
|
||||
NODE *node;
|
||||
|
@ -3759,6 +3764,123 @@ value_expr(node)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void_expr(node)
|
||||
NODE *node;
|
||||
{
|
||||
char *useless = 0;
|
||||
|
||||
if (!ruby_verbose) return;
|
||||
if (!node) return;
|
||||
|
||||
again:
|
||||
switch (nd_type(node)) {
|
||||
case NODE_NEWLINE:
|
||||
node = node->nd_next;
|
||||
goto again;
|
||||
|
||||
case NODE_CALL:
|
||||
switch (node->nd_mid) {
|
||||
case '+':
|
||||
case '-':
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
case tPOW:
|
||||
case tUPLUS:
|
||||
case tUMINUS:
|
||||
case '|':
|
||||
case '^':
|
||||
case '&':
|
||||
case tCMP:
|
||||
case '>':
|
||||
case tGEQ:
|
||||
case '<':
|
||||
case tLEQ:
|
||||
case tEQ:
|
||||
case tEQQ:
|
||||
case tNEQ:
|
||||
case tMATCH:
|
||||
case tNMATCH:
|
||||
case tAREF:
|
||||
case tRSHFT:
|
||||
case tCOLON2:
|
||||
case tCOLON3:
|
||||
useless = rb_id2name(node->nd_mid);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case NODE_LVAR:
|
||||
case NODE_DVAR:
|
||||
case NODE_GVAR:
|
||||
case NODE_IVAR:
|
||||
case NODE_NTH_REF:
|
||||
case NODE_BACK_REF:
|
||||
useless = "a variable";
|
||||
break;
|
||||
case NODE_CVAR:
|
||||
case NODE_CREF:
|
||||
useless = "a constant";
|
||||
break;
|
||||
case NODE_LIT:
|
||||
case NODE_STR:
|
||||
case NODE_DSTR:
|
||||
case NODE_DREGX:
|
||||
case NODE_DREGX_ONCE:
|
||||
useless = "a literal";
|
||||
break;
|
||||
case NODE_COLON2:
|
||||
case NODE_COLON3:
|
||||
useless = "::";
|
||||
break;
|
||||
case NODE_DOT2:
|
||||
useless = "..";
|
||||
break;
|
||||
case NODE_DOT3:
|
||||
useless = "...";
|
||||
break;
|
||||
case NODE_SELF:
|
||||
useless = "self";
|
||||
break;
|
||||
case NODE_NIL:
|
||||
useless = "nil";
|
||||
break;
|
||||
case NODE_TRUE:
|
||||
useless = "true";
|
||||
break;
|
||||
case NODE_FALSE:
|
||||
useless = "false";
|
||||
break;
|
||||
case NODE_DEFINED:
|
||||
useless = "defined?";
|
||||
break;
|
||||
}
|
||||
|
||||
if (useless) {
|
||||
int line = ruby_sourceline;
|
||||
|
||||
ruby_sourceline = nd_line(node);
|
||||
rb_warn("useless use of %s in void context", useless);
|
||||
ruby_sourceline = line;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void_stmts(node)
|
||||
NODE *node;
|
||||
{
|
||||
if (!ruby_verbose) return;
|
||||
if (!node) return;
|
||||
if (nd_type(node) != NODE_BLOCK) return;
|
||||
|
||||
for (;;) {
|
||||
if (!node->nd_next) return;
|
||||
void_expr(node->nd_head);
|
||||
node = node->nd_next;
|
||||
}
|
||||
}
|
||||
|
||||
static NODE *cond2();
|
||||
|
||||
static int
|
||||
|
@ -4126,6 +4248,7 @@ static struct {
|
|||
char *name;
|
||||
} op_tbl[] = {
|
||||
tDOT2, "..",
|
||||
tDOT3, "...",
|
||||
'+', "+",
|
||||
'-', "-",
|
||||
'+', "+(binary)",
|
||||
|
|
16
process.c
16
process.c
|
@ -240,11 +240,15 @@ proc_exec_v(argv, prog)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
#if (defined(MSDOS) && !defined(DJGPP)) || defined(__human68k__)
|
||||
#if (defined(MSDOS) && !defined(DJGPP)) || defined(__human68k__) || defined(__EMX__) || defined(OS2)
|
||||
{
|
||||
#if defined(__human68k__)
|
||||
#define COMMAND "command.x"
|
||||
#else
|
||||
#endif
|
||||
#if defined(__EMX__) || defined(OS2) /* OS/2 emx */
|
||||
#define COMMAND "cmd.exe"
|
||||
#endif
|
||||
#if (defined(MSDOS) && !defined(DJGPP))
|
||||
#define COMMAND "command.com"
|
||||
#endif
|
||||
char *extension;
|
||||
|
@ -272,7 +276,7 @@ proc_exec_v(argv, prog)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* MSDOS or __human68k__ */
|
||||
#endif /* MSDOS or __human68k__ or __EMX__ */
|
||||
before_exec();
|
||||
execv(prog, argv);
|
||||
after_exec();
|
||||
|
@ -326,7 +330,7 @@ rb_proc_exec(str)
|
|||
if (state != -1)
|
||||
exit(state);
|
||||
#else
|
||||
#if defined(__human68k__) || defined(__CYGWIN32__)
|
||||
#if defined(__human68k__) || defined(__CYGWIN32__) || defined(__EMX__)
|
||||
char *shell = dln_find_exe("sh", 0);
|
||||
int state = -1;
|
||||
before_exec();
|
||||
|
@ -510,7 +514,7 @@ static VALUE
|
|||
rb_f_fork(obj)
|
||||
VALUE obj;
|
||||
{
|
||||
#if !defined(__human68k__) && !defined(__MACOS__)
|
||||
#if !defined(__human68k__) && !defined(NT) && !defined(__MACOS__) && !defined(__EMX__)
|
||||
int pid;
|
||||
|
||||
rb_secure(2);
|
||||
|
@ -1005,9 +1009,7 @@ Init_process()
|
|||
#ifndef USE_CWGUSI
|
||||
rb_define_global_function("exec", rb_f_exec, -1);
|
||||
#endif
|
||||
#if !defined(NT)
|
||||
rb_define_global_function("fork", rb_f_fork, 0);
|
||||
#endif
|
||||
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);
|
||||
|
|
6
range.c
6
range.c
|
@ -191,7 +191,11 @@ rb_range_beg_len(range, begp, lenp, len, err)
|
|||
beg += len;
|
||||
if (beg < 0) goto out_of_range;
|
||||
}
|
||||
if (err == 2 && beg > len) goto out_of_range;
|
||||
if (err == 2) {
|
||||
if (beg > len) goto out_of_range;
|
||||
if (end > len || (!EXCL(range) && end == len))
|
||||
goto out_of_range;
|
||||
}
|
||||
if (end < 0) {
|
||||
end += len;
|
||||
if (end < 0) {
|
||||
|
|
4
regex.c
4
regex.c
|
@ -3396,7 +3396,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
#ifdef SWITCH_ENUM_BUG
|
||||
switch ((int)((enum regexpcode)*p++))
|
||||
#else
|
||||
switch ((enum regexpcode)*p++)
|
||||
switch ((enum regexpcode)*p++)
|
||||
#endif
|
||||
{
|
||||
|
||||
|
@ -4019,7 +4019,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
|
||||
/* If this failure point is from a dummy_failure_point, just
|
||||
skip it. */
|
||||
if (stackp[-3] == 0) {
|
||||
if (stackp[-3] == 0 || (best_regs_set && stackp[-1] == 1)) {
|
||||
POP_FAILURE_POINT();
|
||||
goto fail;
|
||||
}
|
||||
|
|
6
ruby.c
6
ruby.c
|
@ -548,6 +548,12 @@ load_file(fname, script)
|
|||
xflag = Qfalse;
|
||||
while (!NIL_P(line = rb_io_gets(f))) {
|
||||
line_start++;
|
||||
#if defined(__EMX__) || defined(OS2)
|
||||
/*
|
||||
if (p = strstr(RSTRING(line)->ptr, "extproc"))
|
||||
line = io_gets(f);
|
||||
*/
|
||||
#endif /* __EMX__ */
|
||||
if (RSTRING(line)->len > 2
|
||||
&& RSTRING(line)->ptr[0] == '#'
|
||||
&& RSTRING(line)->ptr[1] == '!') {
|
||||
|
|
|
@ -64,7 +64,7 @@ class Point
|
|||
end
|
||||
end
|
||||
|
||||
# global variables are start with `$'.
|
||||
# global variable name starts with `$'.
|
||||
$list1 = MyList.new
|
||||
$list1.add_to_list(10)
|
||||
$list1.add_to_list(20)
|
||||
|
|
|
@ -417,7 +417,7 @@ ok(i == 5)
|
|||
done = true
|
||||
loop{
|
||||
break
|
||||
done = false
|
||||
done = false # should not reach here
|
||||
}
|
||||
ok(done)
|
||||
|
||||
|
@ -427,7 +427,7 @@ loop {
|
|||
break if done
|
||||
done = true
|
||||
next
|
||||
$bad = true
|
||||
$bad = true # should not reach here
|
||||
}
|
||||
ok(!$bad)
|
||||
|
||||
|
@ -437,7 +437,7 @@ loop {
|
|||
break if done
|
||||
done = true
|
||||
redo
|
||||
$bad = true
|
||||
$bad = true # should not reach here
|
||||
}
|
||||
ok(!$bad)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#! /usr/local/bin/ruby
|
||||
path = ENV['PATH'].split(/:/)
|
||||
|
||||
path = ENV['PATH'].split(File::PATH_SEPARATOR)
|
||||
|
||||
for dir in path
|
||||
if File.directory?(dir)
|
||||
|
|
6
signal.c
6
signal.c
|
@ -310,8 +310,10 @@ signal_exec(sig)
|
|||
case SIGINT:
|
||||
rb_thread_interrupt();
|
||||
break;
|
||||
#ifndef NT
|
||||
case SIGHUP:
|
||||
case SIGTERM:
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
case SIGPIPE:
|
||||
#endif
|
||||
|
@ -493,8 +495,10 @@ trap(arg)
|
|||
if (func == SIG_DFL) {
|
||||
switch (sig) {
|
||||
case SIGINT:
|
||||
#ifndef NT
|
||||
case SIGHUP:
|
||||
case SIGTERM:
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
|
@ -609,8 +613,10 @@ Init_signal()
|
|||
#ifndef MACOS_UNUSE_SIGNAL
|
||||
rb_define_global_function("trap", rb_f_trap, -1);
|
||||
ruby_signal(SIGINT, sighandle);
|
||||
#ifndef NT
|
||||
ruby_signal(SIGHUP, sighandle);
|
||||
ruby_signal(SIGTERM, sighandle);
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
ruby_signal(SIGPIPE, sighandle);
|
||||
#endif
|
||||
|
|
2
st.c
2
st.c
|
@ -186,7 +186,7 @@ st_free_table(table)
|
|||
}
|
||||
|
||||
#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
|
||||
((ptr) != 0 && ptr->hash != (hash_val) && !EQUAL((table), (key), (ptr)->key))
|
||||
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
|
||||
|
||||
#define FIND_ENTRY(table, ptr, hash_val, bin_pos) \
|
||||
bin_pos = hash_val%(table)->num_bins;\
|
||||
|
|
11
time.c
11
time.c
|
@ -147,9 +147,18 @@ time_s_at(klass, time)
|
|||
VALUE klass, time;
|
||||
{
|
||||
struct timeval tv;
|
||||
VALUE t;
|
||||
|
||||
tv = rb_time_timeval(time);
|
||||
return time_new_internal(klass, tv.tv_sec, tv.tv_usec);
|
||||
t = time_new_internal(klass, tv.tv_sec, tv.tv_usec);
|
||||
if (TYPE(time) == T_DATA) {
|
||||
struct time_object *tobj, *tobj2;
|
||||
|
||||
GetTimeval(time, tobj);
|
||||
GetTimeval(t, tobj2);
|
||||
tobj2->gmt = tobj->gmt;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static char *months [12] = {
|
||||
|
|
19
util.h
19
util.h
|
@ -13,11 +13,16 @@
|
|||
#define UTIL_H
|
||||
|
||||
#ifndef _
|
||||
# ifdef __STDC__
|
||||
# define _(args) args
|
||||
# else
|
||||
# define _(args) ()
|
||||
# endif
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
# define _(args) args
|
||||
#else
|
||||
# define _(args) ()
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_PROTOTYPES
|
||||
# define __(args) args
|
||||
#else
|
||||
# define __(args) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define scan_oct ruby_scan_oct
|
||||
|
@ -35,8 +40,8 @@ char *ruby_mktemp _((void));
|
|||
void ruby_qsort _((void*, int, int, int (*)()));
|
||||
#define qsort(b,n,s,c) ruby_qsort(b,n,s,c)
|
||||
|
||||
void ruby_setenv _((char*, char*));
|
||||
void ruby_unsetenv _((char*));
|
||||
void ruby_setenv _((const char*, const char*));
|
||||
void ruby_unsetenv _((const char*));
|
||||
#undef setenv
|
||||
#undef unsetenv
|
||||
#define setenv(name,val) ruby_setenv((name),(val))
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define RUBY_VERSION "1.3.1"
|
||||
#define RUBY_RELEASE_DATE "1999-03-24"
|
||||
#define RUBY_VERSION "1.3.2"
|
||||
#define RUBY_RELEASE_DATE "1999-04-08"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define HAVE_PROTOTYPES 1
|
||||
#define HAVE_STDARG_PROTOTYPES 1
|
||||
/* #define HAVE_ATTR_NORETURN 1 */
|
||||
|
|
Loading…
Add table
Reference in a new issue