mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
2000-05-24
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
24b9bdca25
commit
8b1de0b1ad
49 changed files with 610 additions and 613 deletions
93
ChangeLog
93
ChangeLog
|
@ -1,3 +1,40 @@
|
||||||
|
Wed May 24 13:12:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-parse-region): support `while .. do' etc.
|
||||||
|
|
||||||
|
Tue May 23 23:50:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* re.c (rb_reg_initialize_m): wrong kcode value.
|
||||||
|
|
||||||
|
* re.c (rb_reg_s_new): forgot to initialize re->ptr.
|
||||||
|
|
||||||
|
Tue May 23 08:36:24 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* regex.c (re_compile_pattern): forgot to restore old option
|
||||||
|
status by (?ix-ix).
|
||||||
|
|
||||||
|
* regex.c (re_compile_fastmap): anychar may match newline if
|
||||||
|
RE_OPTION_MULTILINE or RE_OPTION_POSIXLINE is set.
|
||||||
|
|
||||||
|
Mon May 22 21:56:43 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||||
|
|
||||||
|
* struct.c (rb_struct_getmember): should use ID2SYM, not INT2NUM.
|
||||||
|
|
||||||
|
Mon May 22 15:07:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* file.c (rb_find_file): should check if the file really exists.
|
||||||
|
|
||||||
|
Mon May 22 09:08:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* io.c (rb_io_popen): _exit(0) after processing block under the
|
||||||
|
child process.
|
||||||
|
|
||||||
|
* io.c (rb_io_popen): flush stdout/stderr before subprocess
|
||||||
|
termination.
|
||||||
|
|
||||||
|
* eval.c (rb_check_safe_str): insert rb_secure(4); operation
|
||||||
|
requires untainted string should be prohibited in level 4.
|
||||||
|
|
||||||
Sun May 21 21:17:00 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
Sun May 21 21:17:00 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||||
|
|
||||||
* configure.in: add Setup.dj for djgpp cross-compiling.
|
* configure.in: add Setup.dj for djgpp cross-compiling.
|
||||||
|
@ -6,6 +43,10 @@ Sun May 21 21:17:00 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||||
|
|
||||||
* instruby.rb: copy win32/win32.h to archlibdir on mingw32.
|
* instruby.rb: copy win32/win32.h to archlibdir on mingw32.
|
||||||
|
|
||||||
|
Sun May 21 20:58:08 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||||
|
|
||||||
|
* pack.c: fix OFF16 and OFF32 definitions for Alpha and IRIX64.
|
||||||
|
|
||||||
Sun May 21 17:31:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
Sun May 21 17:31:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||||
|
|
||||||
* instruby.rb: support "make install" for cross-compiling.
|
* instruby.rb: support "make install" for cross-compiling.
|
||||||
|
@ -18,6 +59,53 @@ Sun May 21 14:22:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
|
||||||
|
|
||||||
* configure.in: ditto.
|
* configure.in: ditto.
|
||||||
|
|
||||||
|
Sat May 20 23:29:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* dir.c (dir_s_new): does not take block; "open" does.
|
||||||
|
|
||||||
|
* io.c (rb_io_s_new): ditto.
|
||||||
|
|
||||||
|
Fri May 19 07:44:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* dir.c (dir_s_open): Dir#open does not returns closed Dir if a
|
||||||
|
block is given to the method.
|
||||||
|
|
||||||
|
* re.c (rb_reg_initialize_m): Regexp::new calls initialize now.
|
||||||
|
|
||||||
|
* string.c (Init_String): String#delete_at removed.
|
||||||
|
|
||||||
|
* string.c (rb_str_aset_m): should have checked argc != 2.
|
||||||
|
|
||||||
|
* eval.c (rb_thread_schedule): select(2) was called too many.
|
||||||
|
|
||||||
|
* regex.c (re_compile_pattern): a bug in (?m) support. Pointed
|
||||||
|
out by Dave Thomas <Dave@thomases.com>.
|
||||||
|
|
||||||
|
Thu May 18 23:55:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||||
|
|
||||||
|
* dln.c (search_undef): st_lookup()'s 3rd parameter should be
|
||||||
|
a pointer of the variable which has the same size and alignment
|
||||||
|
as `char *'.
|
||||||
|
|
||||||
|
* marshal.c (w_symbol, w_object): ditto.
|
||||||
|
|
||||||
|
* parse.y (rb_intern): ditto.
|
||||||
|
|
||||||
|
Thu May 18 13:34:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (ruby_connect): should not have replaced
|
||||||
|
thread_write_select() by rb_thread_fd_writable().
|
||||||
|
|
||||||
|
Wed May 18 09:01:25 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
|
||||||
|
|
||||||
|
* configure.in, ext/extmk.rb.in, lib/mkmf.rb: remove BeOS R3 support.
|
||||||
|
Make a shared library (libruby.so) only if the --enable-shared
|
||||||
|
option is specified.
|
||||||
|
|
||||||
|
* instruby.rb: no longer use libruby.so.LIB and import.h.
|
||||||
|
|
||||||
|
* io.c: fix READ_DATA_PENDING definition for BeOS (PowerPC).
|
||||||
|
|
||||||
Wed May 17 14:14:23 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Wed May 17 14:14:23 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* re.c (rb_reg_new_1): use /m instead of /p.
|
* re.c (rb_reg_new_1): use /m instead of /p.
|
||||||
|
@ -71,6 +159,11 @@ Mon May 15 15:38:09 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* dir.c (glob): trailing path may be null, e.g. glob("**").
|
* dir.c (glob): trailing path may be null, e.g. glob("**").
|
||||||
|
|
||||||
|
Mon May 15 14:48:41 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||||
|
|
||||||
|
* io.c (rb_io_pid): new method; returns nil if no process attached
|
||||||
|
to the IO.
|
||||||
|
|
||||||
Mon May 15 01:18:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
Mon May 15 01:18:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||||
|
|
||||||
* io.c (rb_io_s_popen): _exit after Proc execution.
|
* io.c (rb_io_s_popen): _exit after Proc execution.
|
||||||
|
|
4
ToDo
4
ToDo
|
@ -63,7 +63,7 @@ Standard Libraries
|
||||||
- Struct::new([name,]member,...)
|
- Struct::new([name,]member,...)
|
||||||
- IO#reopen accepts path as well
|
- IO#reopen accepts path as well
|
||||||
- Kernel#scan
|
- Kernel#scan
|
||||||
- call initialize for builtin classes too (not yet: Regexp, Class, Module)
|
- call initialize for builtin classes too (not yet: Class, Module)
|
||||||
- performance tune for String's non-bang methods.
|
- performance tune for String's non-bang methods.
|
||||||
- 'w' template for pack/unpack
|
- 'w' template for pack/unpack
|
||||||
* String#scanf(?)
|
* String#scanf(?)
|
||||||
|
@ -107,6 +107,6 @@ Things To Do Before 1.6
|
||||||
|
|
||||||
* alternative for $! (exception? in? into? =>?)
|
* alternative for $! (exception? in? into? =>?)
|
||||||
* alternative for interator?
|
* alternative for interator?
|
||||||
* regex - /p, /m
|
- regex - /p, /m
|
||||||
* odd? even?
|
* odd? even?
|
||||||
* mkmf.rb - create_makefile("net/socket")
|
* mkmf.rb - create_makefile("net/socket")
|
||||||
|
|
40
array.c
40
array.c
|
@ -584,30 +584,32 @@ rb_ary_aset(argc, argv, ary)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
VALUE arg1, arg2, arg3;
|
|
||||||
long offset, beg, len;
|
long offset, beg, len;
|
||||||
|
|
||||||
if (rb_scan_args(argc, argv, "21", &arg1, &arg2, &arg3) == 3) {
|
if (argc == 3) {
|
||||||
rb_ary_replace(ary, NUM2LONG(arg1), NUM2LONG(arg2), arg3);
|
rb_ary_replace(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
|
||||||
return arg3;
|
return argv[2];
|
||||||
}
|
}
|
||||||
else if (FIXNUM_P(arg1)) {
|
if (argc != 2) {
|
||||||
offset = FIX2LONG(arg1);
|
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||||
|
}
|
||||||
|
if (FIXNUM_P(argv[0])) {
|
||||||
|
offset = FIX2LONG(argv[0]);
|
||||||
goto fixnum;
|
goto fixnum;
|
||||||
}
|
}
|
||||||
else if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
|
else if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
|
||||||
/* check if idx is Range */
|
/* check if idx is Range */
|
||||||
rb_ary_replace(ary, beg, len, arg2);
|
rb_ary_replace(ary, beg, len, argv[1]);
|
||||||
return arg2;
|
return argv[1];
|
||||||
}
|
}
|
||||||
if (TYPE(arg1) == T_BIGNUM) {
|
if (TYPE(argv[0]) == T_BIGNUM) {
|
||||||
rb_raise(rb_eIndexError, "index too big");
|
rb_raise(rb_eIndexError, "index too big");
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = NUM2LONG(arg1);
|
offset = NUM2LONG(argv[0]);
|
||||||
fixnum:
|
fixnum:
|
||||||
rb_ary_store(ary, offset, arg2);
|
rb_ary_store(ary, offset, argv[1]);
|
||||||
return arg2;
|
return argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -957,7 +959,7 @@ sort_internal(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
|
qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
|
||||||
rb_iterator_p()?sort_1:sort_2);
|
rb_block_given_p()?sort_1:sort_2);
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,7 +999,7 @@ rb_ary_collect(ary)
|
||||||
long len, i;
|
long len, i;
|
||||||
VALUE collect;
|
VALUE collect;
|
||||||
|
|
||||||
if (!rb_iterator_p()) {
|
if (!rb_block_given_p()) {
|
||||||
return rb_ary_dup(ary);
|
return rb_ary_dup(ary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1048,7 @@ rb_ary_delete(ary, item)
|
||||||
i2++;
|
i2++;
|
||||||
}
|
}
|
||||||
if (RARRAY(ary)->len == i2) {
|
if (RARRAY(ary)->len == i2) {
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
return rb_yield(item);
|
return rb_yield(item);
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -1081,7 +1083,7 @@ rb_ary_delete_at(ary, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_ary_delete_at_m(argc, argv, ary)
|
rb_ary_slice_bang(argc, argv, ary)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
|
@ -1627,7 +1629,7 @@ Init_Array()
|
||||||
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
|
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
|
||||||
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
|
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
|
||||||
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
|
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
|
||||||
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, -1);
|
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at, -1);
|
||||||
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
|
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
|
||||||
rb_define_method(rb_cArray, "reject!", rb_ary_delete_if, 0);
|
rb_define_method(rb_cArray, "reject!", rb_ary_delete_if, 0);
|
||||||
rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);
|
rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);
|
||||||
|
@ -1637,7 +1639,7 @@ Init_Array()
|
||||||
rb_define_method(rb_cArray, "<=>", rb_ary_cmp, 1);
|
rb_define_method(rb_cArray, "<=>", rb_ary_cmp, 1);
|
||||||
|
|
||||||
rb_define_method(rb_cArray, "slice", rb_ary_aref, -1);
|
rb_define_method(rb_cArray, "slice", rb_ary_aref, -1);
|
||||||
rb_define_method(rb_cArray, "slice!", rb_ary_delete_at_m, -1);
|
rb_define_method(rb_cArray, "slice!", rb_ary_slice_bang, -1);
|
||||||
|
|
||||||
rb_define_method(rb_cArray, "assoc", rb_ary_assoc, 1);
|
rb_define_method(rb_cArray, "assoc", rb_ary_assoc, 1);
|
||||||
rb_define_method(rb_cArray, "rassoc", rb_ary_rassoc, 1);
|
rb_define_method(rb_cArray, "rassoc", rb_ary_rassoc, 1);
|
||||||
|
|
2
class.c
2
class.c
|
@ -662,7 +662,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
|
||||||
|
|
||||||
if (*p == '&') {
|
if (*p == '&') {
|
||||||
var = va_arg(vargs, VALUE*);
|
var = va_arg(vargs, VALUE*);
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
*var = rb_f_lambda();
|
*var = rb_f_lambda();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
4
config.guess
vendored
4
config.guess
vendored
|
@ -969,10 +969,6 @@ EOF
|
||||||
*:Rhapsody:*:*)
|
*:Rhapsody:*:*)
|
||||||
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
|
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
*:"Mac OS":*:*)
|
|
||||||
echo `uname -p`-apple-macos${UNAME_RELEASE}
|
|
||||||
exit 0 ;;
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||||
|
|
2
config.sub
vendored
2
config.sub
vendored
|
@ -910,7 +910,7 @@ case $os in
|
||||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||||
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
|
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||||
| -interix* | -uwin* | -rhapsody* | -openstep* | -macos | -oskit*)
|
| -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
|
||||||
# Remember, each alternative MUST END IN *, to match a version number.
|
# Remember, each alternative MUST END IN *, to match a version number.
|
||||||
;;
|
;;
|
||||||
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
|
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
|
||||||
|
|
56
configure.in
56
configure.in
|
@ -44,12 +44,6 @@ AC_ARG_ENABLE(fat-binary,
|
||||||
TARGET_ARCHS="ppc i386"
|
TARGET_ARCHS="ppc i386"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
macos*)
|
|
||||||
echo -n "MacOS X : "
|
|
||||||
if test "$TARGET_ARCHS" = "" ; then
|
|
||||||
TARGET_ARCHS="ppc i386"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
nextstep*|openstep*)
|
nextstep*|openstep*)
|
||||||
echo -n "NeXTSTEP/OPENSTEP: "
|
echo -n "NeXTSTEP/OPENSTEP: "
|
||||||
if test "$TARGET_ARCHS" = "" ; then
|
if test "$TARGET_ARCHS" = "" ; then
|
||||||
|
@ -161,7 +155,6 @@ case "$target_os" in
|
||||||
nextstep*) ;;
|
nextstep*) ;;
|
||||||
openstep*) ;;
|
openstep*) ;;
|
||||||
rhapsody*) ;;
|
rhapsody*) ;;
|
||||||
macos*) ;;
|
|
||||||
human*) ac_cv_func_getpgrp_void=yes;;
|
human*) ac_cv_func_getpgrp_void=yes;;
|
||||||
beos*) ;;
|
beos*) ;;
|
||||||
cygwin*) ;;
|
cygwin*) ;;
|
||||||
|
@ -424,9 +417,9 @@ if test "$with_dln_a_out" != yes; then
|
||||||
nextstep*) ;;
|
nextstep*) ;;
|
||||||
openstep*) ;;
|
openstep*) ;;
|
||||||
rhapsody*) ;;
|
rhapsody*) ;;
|
||||||
macos*) ;;
|
|
||||||
human*) ;;
|
human*) ;;
|
||||||
bsdi*) ;;
|
bsdi*) ;;
|
||||||
|
beos*) ;;
|
||||||
cygwin*) ;;
|
cygwin*) ;;
|
||||||
mingw*) ;;
|
mingw*) ;;
|
||||||
netbsd*) CCDLFLAGS=-fpic
|
netbsd*) CCDLFLAGS=-fpic
|
||||||
|
@ -504,10 +497,6 @@ if test "$with_dln_a_out" != yes; then
|
||||||
LDFLAGS=""
|
LDFLAGS=""
|
||||||
DLDFLAGS="$ARCH_FLAG"
|
DLDFLAGS="$ARCH_FLAG"
|
||||||
rb_cv_dlopen=yes ;;
|
rb_cv_dlopen=yes ;;
|
||||||
macos*) LDSHARED='cc -dynamic -bundle -undefined suppress'
|
|
||||||
LDFLAGS=""
|
|
||||||
DLDFLAGS="$ARCH_FLAG"
|
|
||||||
rb_cv_dlopen=yes ;;
|
|
||||||
aix*) LDSHARED='/usr/ccs/bin/ld'
|
aix*) LDSHARED='/usr/ccs/bin/ld'
|
||||||
XLDFLAGS='-Wl,-bE:ruby.imp'
|
XLDFLAGS='-Wl,-bE:ruby.imp'
|
||||||
DLDFLAGS='-eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
|
DLDFLAGS='-eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
|
||||||
|
@ -521,14 +510,12 @@ if test "$with_dln_a_out" != yes; then
|
||||||
beos*) case "$target_cpu" in
|
beos*) case "$target_cpu" in
|
||||||
powerpc*)
|
powerpc*)
|
||||||
LDSHARED="ld -xms"
|
LDSHARED="ld -xms"
|
||||||
DLDFLAGS="-f ruby.exp -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
|
DLDFLAGS='-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
|
||||||
;;
|
;;
|
||||||
i586*)
|
i586*)
|
||||||
LDSHARED="ld -shared"
|
LDSHARED="ld -shared"
|
||||||
DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
|
DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
DLDFLAGS="ruby.def -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o"
|
|
||||||
esac
|
esac
|
||||||
rb_cv_dlopen=yes ;;
|
rb_cv_dlopen=yes ;;
|
||||||
cygwin*|mingw*) : ${LDSHARED="${DLLWRAP} --target=${target_os} --as=${AS} --dlltool-name=${DLLTOOL} --driver-name=${CC} --export-all -s"}
|
cygwin*|mingw*) : ${LDSHARED="${DLLWRAP} --target=${target_os} --as=${AS} --dlltool-name=${DLLTOOL} --driver-name=${CC} --export-all -s"}
|
||||||
|
@ -576,8 +563,6 @@ else
|
||||||
AC_DEFINE(DLEXT, ".bundle");;
|
AC_DEFINE(DLEXT, ".bundle");;
|
||||||
rhapsody*) DLEXT=bundle
|
rhapsody*) DLEXT=bundle
|
||||||
AC_DEFINE(DLEXT, ".bundle");;
|
AC_DEFINE(DLEXT, ".bundle");;
|
||||||
macos*) DLEXT=bundle
|
|
||||||
AC_DEFINE(DLEXT, ".bundle");;
|
|
||||||
os2_emx*) DLEXT=dll
|
os2_emx*) DLEXT=dll
|
||||||
AC_DEFINE(DLEXT, ".dll");;
|
AC_DEFINE(DLEXT, ".dll");;
|
||||||
cygwin*|mingw*) DLEXT=so
|
cygwin*|mingw*) DLEXT=so
|
||||||
|
@ -605,8 +590,6 @@ case "$target_os" in
|
||||||
STRIP='strip -A -n';;
|
STRIP='strip -A -n';;
|
||||||
rhapsody*)
|
rhapsody*)
|
||||||
STRIP='strip -A -n';;
|
STRIP='strip -A -n';;
|
||||||
macos*)
|
|
||||||
STRIP='strip -A -n';;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
EXTSTATIC=
|
EXTSTATIC=
|
||||||
|
@ -705,28 +688,9 @@ LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
|
||||||
LIBRUBY='$(LIBRUBY_A)'
|
LIBRUBY='$(LIBRUBY_A)'
|
||||||
LIBRUBYARG='$(LIBRUBY_A)'
|
LIBRUBYARG='$(LIBRUBY_A)'
|
||||||
SOLIBS=
|
SOLIBS=
|
||||||
if test "$target_os" = "beos"; then
|
|
||||||
LIBRUBY='$(LIBRUBY_SO)'
|
|
||||||
LIBRUBYARG='-l$(RUBY_INSTALL_NAME)'
|
|
||||||
SOLIBS='-lnet'
|
|
||||||
echo creating ruby.def
|
|
||||||
case "$target_cpu" in
|
|
||||||
powerpc*)
|
|
||||||
cp beos/ruby.def.in ruby.exp
|
|
||||||
CFLAGS="$CFLAGS -relax_pointers"
|
|
||||||
;;
|
|
||||||
i586*)
|
|
||||||
LDFLAGS="$LDFLAGS -L."
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo EXPORTS > ruby.def
|
|
||||||
cat beos/ruby.def.in >> ruby.def
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$target_os" in
|
case "$target_os" in
|
||||||
cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|macos*|os2_emx*)
|
cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|os2_emx*)
|
||||||
DLDLIBS=""
|
DLDLIBS=""
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -787,6 +751,13 @@ if test "$enable_shared" = 'yes'; then
|
||||||
LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
|
LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
|
||||||
SOLIBS='-lm -lc'
|
SOLIBS='-lm -lc'
|
||||||
;;
|
;;
|
||||||
|
beos*)
|
||||||
|
case "$target_cpu" in
|
||||||
|
powerpc*)
|
||||||
|
LIBRUBY_DLDFLAGS='-f ruby.exp -lnet -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
cygwin*|mingw*)
|
cygwin*|mingw*)
|
||||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).a'
|
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).a'
|
||||||
LIBRUBY_ALIASES=''
|
LIBRUBY_ALIASES=''
|
||||||
|
@ -834,6 +805,13 @@ case "$target_os" in
|
||||||
CFLAGS="$CFLAGS -std"
|
CFLAGS="$CFLAGS -std"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
beos*)
|
||||||
|
case "$target_cpu" in
|
||||||
|
powerpc*)
|
||||||
|
CFLAGS="$CFLAGS -relax_pointers"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
cygwin*)
|
cygwin*)
|
||||||
LIBOBJS="$LIBOBJS strftime.o"
|
LIBOBJS="$LIBOBJS strftime.o"
|
||||||
;;
|
;;
|
||||||
|
|
15
dir.c
15
dir.c
|
@ -241,10 +241,6 @@ dir_s_new(argc, argv, klass)
|
||||||
|
|
||||||
rb_obj_call_init(obj, argc, argv);
|
rb_obj_call_init(obj, argc, argv);
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
|
||||||
rb_ensure(rb_yield, obj, dir_close, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +264,7 @@ dir_initialize(dir, dirname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DATA_PTR(dir) = dirp;
|
DATA_PTR(dir) = dirp;
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +272,13 @@ static VALUE
|
||||||
dir_s_open(klass, dirname)
|
dir_s_open(klass, dirname)
|
||||||
VALUE klass, dirname;
|
VALUE klass, dirname;
|
||||||
{
|
{
|
||||||
return dir_s_new(1, &dirname, klass);
|
VALUE dir = dir_s_new(1, &dirname, klass);
|
||||||
|
if (rb_block_given_p()) {
|
||||||
|
rb_ensure(rb_yield, dir, dir_close, dir);
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -760,7 +763,7 @@ dir_s_glob(dir, str)
|
||||||
}
|
}
|
||||||
if (buf != buffer)
|
if (buf != buffer)
|
||||||
free(buf);
|
free(buf);
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
long len = RARRAY(ary)->len;
|
long len = RARRAY(ary)->len;
|
||||||
VALUE *ptr = RARRAY(ary)->ptr;
|
VALUE *ptr = RARRAY(ary)->ptr;
|
||||||
|
|
||||||
|
|
2
dln.c
2
dln.c
|
@ -881,7 +881,7 @@ search_undef(key, value, lib_tbl)
|
||||||
int value;
|
int value;
|
||||||
st_table *lib_tbl;
|
st_table *lib_tbl;
|
||||||
{
|
{
|
||||||
int offset;
|
long offset;
|
||||||
|
|
||||||
if (st_lookup(lib_tbl, key, &offset) == 0) return ST_CONTINUE;
|
if (st_lookup(lib_tbl, key, &offset) == 0) return ST_CONTINUE;
|
||||||
target_offset = offset;
|
target_offset = offset;
|
||||||
|
|
8
enum.c
8
enum.c
|
@ -50,7 +50,7 @@ enum_grep(obj, pat)
|
||||||
VALUE tmp, arg[2];
|
VALUE tmp, arg[2];
|
||||||
|
|
||||||
arg[0] = pat; arg[1] = tmp = rb_ary_new();
|
arg[0] = pat; arg[1] = tmp = rb_ary_new();
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
rb_iterate(rb_each, obj, grep_iter_i, (VALUE)arg);
|
rb_iterate(rb_each, obj, grep_iter_i, (VALUE)arg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -173,7 +173,7 @@ enum_collect(obj)
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
|
|
||||||
tmp = rb_ary_new();
|
tmp = rb_ary_new();
|
||||||
rb_iterate(rb_each, obj, rb_iterator_p() ? collect_i : enum_all, tmp);
|
rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : enum_all, tmp);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ enum_min(obj)
|
||||||
{
|
{
|
||||||
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
||||||
|
|
||||||
rb_iterate(rb_each, obj, rb_iterator_p()?min_ii:min_i, (VALUE)memo);
|
rb_iterate(rb_each, obj, rb_block_given_p()?min_ii:min_i, (VALUE)memo);
|
||||||
rb_gc_force_recycle((VALUE)memo);
|
rb_gc_force_recycle((VALUE)memo);
|
||||||
return memo->u1.value;
|
return memo->u1.value;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ enum_max(obj)
|
||||||
{
|
{
|
||||||
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
|
||||||
|
|
||||||
rb_iterate(rb_each, obj, rb_iterator_p()?max_ii:max_i, (VALUE)memo);
|
rb_iterate(rb_each, obj, rb_block_given_p()?max_ii:max_i, (VALUE)memo);
|
||||||
rb_gc_force_recycle((VALUE)memo);
|
rb_gc_force_recycle((VALUE)memo);
|
||||||
return memo->u1.value;
|
return memo->u1.value;
|
||||||
}
|
}
|
||||||
|
|
96
eval.c
96
eval.c
|
@ -74,7 +74,7 @@ static VALUE rb_cBinding;
|
||||||
static VALUE proc_call _((VALUE,VALUE));
|
static VALUE proc_call _((VALUE,VALUE));
|
||||||
static VALUE rb_f_binding _((VALUE));
|
static VALUE rb_f_binding _((VALUE));
|
||||||
static void rb_f_END _((void));
|
static void rb_f_END _((void));
|
||||||
static VALUE rb_f_iterator_p _((void));
|
static VALUE rb_f_block_given_p _((void));
|
||||||
static VALUE block_pass _((VALUE,NODE*));
|
static VALUE block_pass _((VALUE,NODE*));
|
||||||
static VALUE rb_cMethod;
|
static VALUE rb_cMethod;
|
||||||
static VALUE method_proc _((VALUE));
|
static VALUE method_proc _((VALUE));
|
||||||
|
@ -125,20 +125,6 @@ safe_setter(val)
|
||||||
ruby_safe_level = level;
|
ruby_safe_level = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
rb_check_safe_str(x)
|
|
||||||
VALUE x;
|
|
||||||
{
|
|
||||||
if (ruby_safe_level > 0 && OBJ_TAINTED(x)){
|
|
||||||
rb_raise(rb_eSecurityError, "Insecure operation - %s",
|
|
||||||
rb_id2name(ruby_frame->last_func));
|
|
||||||
}
|
|
||||||
if (TYPE(x)!= T_STRING) {
|
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
|
|
||||||
rb_class2name(CLASS_OF(x)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_secure(level)
|
rb_secure(level)
|
||||||
int level;
|
int level;
|
||||||
|
@ -149,6 +135,26 @@ rb_secure(level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_check_safe_str(x)
|
||||||
|
VALUE x;
|
||||||
|
{
|
||||||
|
if (ruby_safe_level > 0 && OBJ_TAINTED(x)){
|
||||||
|
if (ruby_frame->last_func) {
|
||||||
|
rb_raise(rb_eSecurityError, "Insecure operation - %s",
|
||||||
|
rb_id2name(ruby_frame->last_func));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rb_raise(rb_eSecurityError, "Insecure operation: -r");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rb_secure(4);
|
||||||
|
if (TYPE(x)!= T_STRING) {
|
||||||
|
rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
|
||||||
|
rb_class2name(CLASS_OF(x)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void print_undef _((VALUE, ID)) NORETURN;
|
static void print_undef _((VALUE, ID)) NORETURN;
|
||||||
static void
|
static void
|
||||||
print_undef(klass, id)
|
print_undef(klass, id)
|
||||||
|
@ -1642,7 +1648,7 @@ is_defined(self, node, buf)
|
||||||
return "method";
|
return "method";
|
||||||
|
|
||||||
case NODE_YIELD:
|
case NODE_YIELD:
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
return "yield";
|
return "yield";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2562,7 +2568,7 @@ rb_eval(self, n)
|
||||||
case NODE_BLOCK_ARG:
|
case NODE_BLOCK_ARG:
|
||||||
if (ruby_scope->local_vars == 0)
|
if (ruby_scope->local_vars == 0)
|
||||||
rb_bug("unexpected block argument");
|
rb_bug("unexpected block argument");
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
result = rb_f_lambda();
|
result = rb_f_lambda();
|
||||||
ruby_scope->local_vars[node->nd_cnt] = result;
|
ruby_scope->local_vars[node->nd_cnt] = result;
|
||||||
}
|
}
|
||||||
|
@ -3291,14 +3297,20 @@ rb_jump_tag(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_iterator_p()
|
rb_block_given_p()
|
||||||
{
|
{
|
||||||
if (ruby_frame->iter) return Qtrue;
|
if (ruby_frame->iter) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_iterator_p()
|
||||||
|
{
|
||||||
|
return rb_block_given_p();
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_iterator_p()
|
rb_f_block_given_p()
|
||||||
{
|
{
|
||||||
if (ruby_frame->prev && ruby_frame->prev->iter) return Qtrue;
|
if (ruby_frame->prev && ruby_frame->prev->iter) return Qtrue;
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
|
@ -4158,7 +4170,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
|
||||||
rb_raise(rb_eLocalJumpError, "unexpected redo");
|
rb_raise(rb_eLocalJumpError, "unexpected redo");
|
||||||
break;
|
break;
|
||||||
case TAG_RETRY:
|
case TAG_RETRY:
|
||||||
if (!rb_iterator_p()) {
|
if (!rb_block_given_p()) {
|
||||||
rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
|
rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -4247,7 +4259,7 @@ rb_f_send(argc, argv, recv)
|
||||||
if (argc == 0) rb_raise(rb_eArgError, "no method name given");
|
if (argc == 0) rb_raise(rb_eArgError, "no method name given");
|
||||||
|
|
||||||
vid = *argv++; argc--;
|
vid = *argv++; argc--;
|
||||||
PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT);
|
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
|
||||||
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
|
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
|
||||||
POP_ITER();
|
POP_ITER();
|
||||||
|
|
||||||
|
@ -4708,7 +4720,7 @@ specific_eval(argc, argv, klass, self)
|
||||||
{
|
{
|
||||||
char *file = "(eval)";
|
char *file = "(eval)";
|
||||||
int line = 1;
|
int line = 1;
|
||||||
int iter = rb_iterator_p();
|
int iter = rb_block_given_p();
|
||||||
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
if (ruby_safe_level >= 4) {
|
if (ruby_safe_level >= 4) {
|
||||||
|
@ -5207,7 +5219,7 @@ rb_obj_call_init(obj, argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT);
|
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
|
||||||
rb_funcall2(obj, init, argc, argv);
|
rb_funcall2(obj, init, argc, argv);
|
||||||
POP_ITER();
|
POP_ITER();
|
||||||
}
|
}
|
||||||
|
@ -5447,7 +5459,8 @@ Init_eval()
|
||||||
rb_define_hooked_variable("$!", &ruby_errinfo, 0, errinfo_setter);
|
rb_define_hooked_variable("$!", &ruby_errinfo, 0, errinfo_setter);
|
||||||
|
|
||||||
rb_define_global_function("eval", rb_f_eval, -1);
|
rb_define_global_function("eval", rb_f_eval, -1);
|
||||||
rb_define_global_function("iterator?", rb_f_iterator_p, 0);
|
rb_define_global_function("iterator?", rb_f_block_given_p, 0);
|
||||||
|
rb_define_global_function("block_given?", rb_f_block_given_p, 0);
|
||||||
rb_define_global_function("method_missing", rb_f_missing, -1);
|
rb_define_global_function("method_missing", rb_f_missing, -1);
|
||||||
rb_define_global_function("loop", rb_f_loop, 0);
|
rb_define_global_function("loop", rb_f_loop, 0);
|
||||||
|
|
||||||
|
@ -5678,7 +5691,7 @@ rb_f_binding(self)
|
||||||
*data = *ruby_block;
|
*data = *ruby_block;
|
||||||
|
|
||||||
data->orig_thread = rb_thread_current();
|
data->orig_thread = rb_thread_current();
|
||||||
data->iter = rb_f_iterator_p();
|
data->iter = rb_f_block_given_p();
|
||||||
frame_dup(&data->frame);
|
frame_dup(&data->frame);
|
||||||
if (ruby_frame->prev) {
|
if (ruby_frame->prev) {
|
||||||
data->frame.last_func = ruby_frame->prev->last_func;
|
data->frame.last_func = ruby_frame->prev->last_func;
|
||||||
|
@ -5754,7 +5767,7 @@ proc_new(klass)
|
||||||
struct BLOCK *data;
|
struct BLOCK *data;
|
||||||
struct RVarmap *vars;
|
struct RVarmap *vars;
|
||||||
|
|
||||||
if (!rb_iterator_p() && !rb_f_iterator_p()) {
|
if (!rb_block_given_p() && !rb_f_block_given_p()) {
|
||||||
rb_raise(rb_eArgError, "tried to create Procedure-Object out of iterator");
|
rb_raise(rb_eArgError, "tried to create Procedure-Object out of iterator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5856,7 +5869,7 @@ proc_call(proc, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orphan) {/* orphan procedure */
|
if (orphan) {/* orphan procedure */
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
ruby_block->frame.iter = ITER_CUR;
|
ruby_block->frame.iter = ITER_CUR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -6086,7 +6099,7 @@ method_call(argc, argv, method)
|
||||||
volatile int safe = ruby_safe_level;
|
volatile int safe = ruby_safe_level;
|
||||||
|
|
||||||
Data_Get_Struct(method, struct METHOD, data);
|
Data_Get_Struct(method, struct METHOD, data);
|
||||||
PUSH_ITER(rb_iterator_p()?ITER_PRE:ITER_NOT);
|
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if (OBJ_TAINTED(data->recv) || OBJ_TAINTED(method)) {
|
if (OBJ_TAINTED(data->recv) || OBJ_TAINTED(method)) {
|
||||||
OBJ_TAINT(method);
|
OBJ_TAINT(method);
|
||||||
|
@ -6612,23 +6625,12 @@ rb_thread_fd_close(fd)
|
||||||
static void
|
static void
|
||||||
rb_thread_deadlock()
|
rb_thread_deadlock()
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
curr_thread = main_thread;
|
curr_thread = main_thread;
|
||||||
th_raise_argc = 1;
|
th_raise_argc = 1;
|
||||||
th_raise_argv[0] = rb_exc_new2(rb_eFatal, "Thread: deadlock");
|
th_raise_argv[0] = rb_exc_new2(rb_eFatal, "Thread: deadlock");
|
||||||
th_raise_file = ruby_sourcefile;
|
th_raise_file = ruby_sourcefile;
|
||||||
th_raise_line = ruby_sourceline;
|
th_raise_line = ruby_sourceline;
|
||||||
rb_thread_restore_context(main_thread, RESTORE_RAISE);
|
rb_thread_restore_context(main_thread, RESTORE_RAISE);
|
||||||
#else
|
|
||||||
static int invoked = 0;
|
|
||||||
|
|
||||||
if (invoked) return;
|
|
||||||
invoked = 1;
|
|
||||||
rb_prohibit_interrupt = 1;
|
|
||||||
ruby_errinfo = rb_exc_new2(rb_eFatal, "Thread: deadlock");
|
|
||||||
set_backtrace(ruby_errinfo, make_backtrace());
|
|
||||||
rb_abort();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -6741,7 +6743,7 @@ rb_thread_schedule()
|
||||||
if (!next && (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL)) {
|
if (!next && (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
if ((th->wait_for&WAIT_JOIN) && rb_thread_dead(th->join)) {
|
if ((th->wait_for & WAIT_JOIN) && rb_thread_dead(th->join)) {
|
||||||
th->join = 0;
|
th->join = 0;
|
||||||
th->wait_for = 0;
|
th->wait_for = 0;
|
||||||
th->status = THREAD_RUNNABLE;
|
th->status = THREAD_RUNNABLE;
|
||||||
|
@ -6775,7 +6777,7 @@ rb_thread_schedule()
|
||||||
END_FOREACH_FROM(curr, th);
|
END_FOREACH_FROM(curr, th);
|
||||||
|
|
||||||
/* Do the select if needed */
|
/* Do the select if needed */
|
||||||
if (need_select || !found) {
|
if (need_select) {
|
||||||
do {
|
do {
|
||||||
/* Convert delay to a timeval */
|
/* Convert delay to a timeval */
|
||||||
/* If a thread is runnable, just poll */
|
/* If a thread is runnable, just poll */
|
||||||
|
@ -6855,6 +6857,7 @@ rb_thread_schedule()
|
||||||
END_FOREACH_FROM(curr, th);
|
END_FOREACH_FROM(curr, th);
|
||||||
|
|
||||||
if (!next) {
|
if (!next) {
|
||||||
|
/* raise fatal error to main thread */
|
||||||
curr_thread->file = ruby_sourcefile;
|
curr_thread->file = ruby_sourcefile;
|
||||||
curr_thread->line = ruby_sourceline;
|
curr_thread->line = ruby_sourceline;
|
||||||
FOREACH_THREAD_FROM(curr, th) {
|
FOREACH_THREAD_FROM(curr, th) {
|
||||||
|
@ -6864,7 +6867,6 @@ rb_thread_schedule()
|
||||||
th->file, th->line);
|
th->file, th->line);
|
||||||
}
|
}
|
||||||
END_FOREACH_FROM(curr, th);
|
END_FOREACH_FROM(curr, th);
|
||||||
/* raise fatal error to main thread */
|
|
||||||
rb_thread_deadlock();
|
rb_thread_deadlock();
|
||||||
next = main_thread;
|
next = main_thread;
|
||||||
rb_thread_ready(next);
|
rb_thread_ready(next);
|
||||||
|
@ -7178,7 +7180,7 @@ rb_thread_stop()
|
||||||
{
|
{
|
||||||
rb_thread_critical = 0;
|
rb_thread_critical = 0;
|
||||||
if (curr_thread == curr_thread->next) {
|
if (curr_thread == curr_thread->next) {
|
||||||
rb_raise(rb_eThreadError, "stopping only thread");
|
rb_raise(rb_eThreadError, "stopping only thread\n\tnote: use sleep to stop forever");
|
||||||
}
|
}
|
||||||
curr_thread->status = THREAD_STOPPED;
|
curr_thread->status = THREAD_STOPPED;
|
||||||
rb_thread_schedule();
|
rb_thread_schedule();
|
||||||
|
@ -7523,8 +7525,8 @@ static VALUE
|
||||||
rb_thread_initialize(thread, args)
|
rb_thread_initialize(thread, args)
|
||||||
VALUE thread, args;
|
VALUE thread, args;
|
||||||
{
|
{
|
||||||
if (!rb_iterator_p()) {
|
if (!rb_block_given_p()) {
|
||||||
rb_raise(rb_eThreadError, "must be called as iterator");
|
rb_raise(rb_eThreadError, "must be called with a block");
|
||||||
}
|
}
|
||||||
return rb_thread_start_0(rb_thread_yield, args, rb_thread_check(thread));
|
return rb_thread_start_0(rb_thread_yield, args, rb_thread_check(thread));
|
||||||
}
|
}
|
||||||
|
@ -7533,8 +7535,8 @@ static VALUE
|
||||||
rb_thread_start(klass, args)
|
rb_thread_start(klass, args)
|
||||||
VALUE klass, args;
|
VALUE klass, args;
|
||||||
{
|
{
|
||||||
if (!rb_iterator_p()) {
|
if (!rb_block_given_p()) {
|
||||||
rb_raise(rb_eThreadError, "must be called as iterator");
|
rb_raise(rb_eThreadError, "must be called with a block");
|
||||||
}
|
}
|
||||||
return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(klass));
|
return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(klass));
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ fdbm_delete(obj, keystr)
|
||||||
|
|
||||||
value = dbm_fetch(dbm, key);
|
value = dbm_fetch(dbm, key);
|
||||||
if (value.dptr == 0) {
|
if (value.dptr == 0) {
|
||||||
if (rb_iterator_p()) rb_yield(keystr);
|
if (rb_block_given_p()) rb_yield(keystr);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ etc_passwd(obj)
|
||||||
#ifdef HAVE_GETPWENT
|
#ifdef HAVE_GETPWENT
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
setpwent();
|
setpwent();
|
||||||
while (pw = getpwent()) {
|
while (pw = getpwent()) {
|
||||||
rb_yield(setup_passwd(pw));
|
rb_yield(setup_passwd(pw));
|
||||||
|
@ -210,7 +210,7 @@ etc_group(obj)
|
||||||
#ifdef HAVE_GETGRENT
|
#ifdef HAVE_GETGRENT
|
||||||
struct group *grp;
|
struct group *grp;
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
setgrent();
|
setgrent();
|
||||||
while (grp = getgrent()) {
|
while (grp = getgrent()) {
|
||||||
rb_yield(setup_group(grp));
|
rb_yield(setup_group(grp));
|
||||||
|
|
|
@ -334,11 +334,6 @@ def create_makefile(target)
|
||||||
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
|
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /beos/ and not $static
|
|
||||||
$libs = $libs + " @LIBRUBYARG@"
|
|
||||||
$DLDFLAGS = $DLDFLAGS + " -L" + $topdir
|
|
||||||
end
|
|
||||||
|
|
||||||
defflag = ''
|
defflag = ''
|
||||||
if RUBY_PLATFORM =~ /cygwin|mingw/ and not $static
|
if RUBY_PLATFORM =~ /cygwin|mingw/ and not $static
|
||||||
if File.exist? target + ".def"
|
if File.exist? target + ".def"
|
||||||
|
@ -477,19 +472,6 @@ $(DLLIB): $(OBJS)
|
||||||
dfile.close
|
dfile.close
|
||||||
end
|
end
|
||||||
mfile.close
|
mfile.close
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /beos/
|
|
||||||
if RUBY_PLATFORM =~ /^powerpc/ then
|
|
||||||
deffilename = "ruby.exp"
|
|
||||||
else
|
|
||||||
deffilename = "ruby.def"
|
|
||||||
end
|
|
||||||
print "creating #{deffilename}\n"
|
|
||||||
open(deffilename, "w") do |file|
|
|
||||||
file.print("EXPORTS\n") if RUBY_PLATFORM =~ /^i/
|
|
||||||
file.print("Init_#{target}\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extmake(target)
|
def extmake(target)
|
||||||
|
|
|
@ -159,7 +159,7 @@ fgdbm_delete(obj, keystr)
|
||||||
|
|
||||||
value = gdbm_fetch(dbm, key);
|
value = gdbm_fetch(dbm, key);
|
||||||
if (value.dptr == 0) {
|
if (value.dptr == 0) {
|
||||||
if (rb_iterator_p()) rb_yield(keystr);
|
if (rb_block_given_p()) rb_yield(keystr);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
MANIFEST
|
MANIFEST
|
||||||
depend
|
depend
|
||||||
|
extconf.rb
|
||||||
md5.txt
|
md5.txt
|
||||||
md5.txt.jp
|
md5.txt.jp
|
||||||
md5.h
|
md5.h
|
||||||
|
|
|
@ -457,7 +457,7 @@ pty_getpty(self, shell)
|
||||||
rb_ary_store(res,1,(VALUE)wport);
|
rb_ary_store(res,1,(VALUE)wport);
|
||||||
rb_ary_store(res,2,INT2FIX(info.child_pid));
|
rb_ary_store(res,2,INT2FIX(info.child_pid));
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
rb_yield((VALUE)res);
|
rb_yield((VALUE)res);
|
||||||
reset_signal_action();
|
reset_signal_action();
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
|
@ -156,7 +156,7 @@ fsdbm_delete(obj, keystr)
|
||||||
|
|
||||||
value = sdbm_fetch(dbm, key);
|
value = sdbm_fetch(dbm, key);
|
||||||
if (value.dptr == 0) {
|
if (value.dptr == 0) {
|
||||||
if (rb_iterator_p()) rb_yield(keystr);
|
if (rb_block_given_p()) rb_yield(keystr);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ def find_tcl(tcllib)
|
||||||
find_library(tcllib, func, *paths)
|
find_library(tcllib, func, *paths)
|
||||||
else
|
else
|
||||||
find_library("tcl", func, *paths) or
|
find_library("tcl", func, *paths) or
|
||||||
|
find_library("tcl8.3", func, *paths) or
|
||||||
find_library("tcl8.2", func, *paths) or
|
find_library("tcl8.2", func, *paths) or
|
||||||
find_library("tcl8.0", func, *paths) or
|
find_library("tcl8.0", func, *paths) or
|
||||||
find_library("tcl7.6", func, *paths)
|
find_library("tcl7.6", func, *paths)
|
||||||
|
@ -36,6 +37,7 @@ def find_tk(tklib)
|
||||||
find_library(tklib, func, *paths)
|
find_library(tklib, func, *paths)
|
||||||
else
|
else
|
||||||
find_library("tk", func, *paths) or
|
find_library("tk", func, *paths) or
|
||||||
|
find_library("tk8.3", func, *paths) or
|
||||||
find_library("tk8.2", func, *paths) or
|
find_library("tk8.2", func, *paths) or
|
||||||
find_library("tk8.0", func, *paths) or
|
find_library("tk8.0", func, *paths) or
|
||||||
find_library("tk4.2", func, *paths)
|
find_library("tk4.2", func, *paths)
|
||||||
|
|
|
@ -470,7 +470,7 @@ module TkCore
|
||||||
end
|
end
|
||||||
|
|
||||||
def rb_appsend(interp, async, *args)
|
def rb_appsend(interp, async, *args)
|
||||||
args = args.filter{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
|
args = args.collect!{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
|
||||||
args.push(').to_s"')
|
args.push(').to_s"')
|
||||||
appsend(interp, async, 'ruby "(', *args)
|
appsend(interp, async, 'ruby "(', *args)
|
||||||
end
|
end
|
||||||
|
@ -485,7 +485,7 @@ module TkCore
|
||||||
end
|
end
|
||||||
|
|
||||||
def rb_appsend_displayof(interp, win, async, *args)
|
def rb_appsend_displayof(interp, win, async, *args)
|
||||||
args = args.filter{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
|
args = args.collect!{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
|
||||||
args.push(').to_s"')
|
args.push(').to_s"')
|
||||||
appsend_displayof(interp, win, async, 'ruby "(', *args)
|
appsend_displayof(interp, win, async, 'ruby "(', *args)
|
||||||
end
|
end
|
||||||
|
@ -526,7 +526,7 @@ module TkCore
|
||||||
|
|
||||||
def tk_call(*args)
|
def tk_call(*args)
|
||||||
print args.join(" "), "\n" if $DEBUG
|
print args.join(" "), "\n" if $DEBUG
|
||||||
args.filter {|x|_get_eval_string(x)}
|
args.collect! {|x|_get_eval_string(x)}
|
||||||
args.compact!
|
args.compact!
|
||||||
args.flatten!
|
args.flatten!
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -26,7 +26,7 @@ class TkAfter
|
||||||
end
|
end
|
||||||
|
|
||||||
def TkAfter.info
|
def TkAfter.info
|
||||||
tk_call('after', 'info').split(' ').filter{|id|
|
tk_call('after', 'info').split(' ').collect!{|id|
|
||||||
ret = Tk_CBTBL.find{|key,val| val.after_id == id}
|
ret = Tk_CBTBL.find{|key,val| val.after_id == id}
|
||||||
(ret == nil)? id: ret[1]
|
(ret == nil)? id: ret[1]
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ class TkCanvas<TkWindow
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(mode, *args)
|
def find(mode, *args)
|
||||||
list(tk_send 'find', mode, *args).filter{|id|
|
list(tk_send 'find', mode, *args).collect!{|id|
|
||||||
TkcItem.id2obj(id)
|
TkcItem.id2obj(id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -368,13 +368,6 @@ class TkCanvas<TkWindow
|
||||||
def itemtype(tag)
|
def itemtype(tag)
|
||||||
TkcItem.type2class(tk_send 'type', tagid(tag))
|
TkcItem.type2class(tk_send 'type', tagid(tag))
|
||||||
end
|
end
|
||||||
|
|
||||||
def xview(*index)
|
|
||||||
tk_send 'xview', *index
|
|
||||||
end
|
|
||||||
def yview(*index)
|
|
||||||
tk_send 'yview', *index
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module TkcTagAccess
|
module TkcTagAccess
|
||||||
|
@ -725,7 +718,7 @@ class TkImage<TkObject
|
||||||
end
|
end
|
||||||
|
|
||||||
def TkImage.names
|
def TkImage.names
|
||||||
Tk.tk_call('image', 'names').split.filter{|id|
|
Tk.tk_call('image', 'names').split.collect!{|id|
|
||||||
(Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
|
(Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -245,16 +245,10 @@ class TkText<TkTextWin
|
||||||
(inf == "")? [0,0,0,0,0]: inf
|
(inf == "")? [0,0,0,0,0]: inf
|
||||||
end
|
end
|
||||||
|
|
||||||
def yview(*what)
|
|
||||||
tk_send 'yview', *what
|
|
||||||
end
|
|
||||||
def yview_pickplace(*what)
|
def yview_pickplace(*what)
|
||||||
tk_send 'yview', '-pickplace', *what
|
tk_send 'yview', '-pickplace', *what
|
||||||
end
|
end
|
||||||
|
|
||||||
def xview(*what)
|
|
||||||
tk_send 'xview', *what
|
|
||||||
end
|
|
||||||
def xview_pickplace(*what)
|
def xview_pickplace(*what)
|
||||||
tk_send 'xview', '-pickplace', *what
|
tk_send 'xview', '-pickplace', *what
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TkVirtualEvent<TkObject
|
||||||
end
|
end
|
||||||
|
|
||||||
def TkVirtualEvent.info
|
def TkVirtualEvent.info
|
||||||
tk_call('event', 'info').split(/\s+/).filter{|seq|
|
tk_call('event', 'info').split(/\s+/).collect!{|seq|
|
||||||
TkVirtualEvent.getobj(seq[1..-2])
|
TkVirtualEvent.getobj(seq[1..-2])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -49,8 +49,8 @@ class TkVirtualEvent<TkObject
|
||||||
end
|
end
|
||||||
|
|
||||||
def info
|
def info
|
||||||
tk_call('event', 'info', "<#{@id}>").split(/\s+/).filter{|seq|
|
tk_call('event', 'info', "<#{@id}>").split(/\s+/).collect!{|seq|
|
||||||
l = seq.scan(/<*[^<>]+>*/).filter{|subseq|
|
l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
|
||||||
case (subseq)
|
case (subseq)
|
||||||
when /^<<[^<>]+>>$/
|
when /^<<[^<>]+>>$/
|
||||||
TkVirtualEvent.getobj(subseq[1..-2])
|
TkVirtualEvent.getobj(subseq[1..-2])
|
||||||
|
|
|
@ -29,7 +29,7 @@ tk_s_new(argc, argv, klass)
|
||||||
{
|
{
|
||||||
VALUE obj = rb_class_new_instance(argc, argv, klass);
|
VALUE obj = rb_class_new_instance(argc, argv, klass);
|
||||||
|
|
||||||
if (rb_iterator_p()) rb_obj_instance_eval(0, 0, obj);
|
if (rb_block_given_p()) rb_obj_instance_eval(0, 0, obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
file.c
7
file.c
|
@ -2033,6 +2033,7 @@ rb_find_file(file)
|
||||||
volatile VALUE vpath;
|
volatile VALUE vpath;
|
||||||
VALUE fname;
|
VALUE fname;
|
||||||
char *path;
|
char *path;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
#if defined(__MACOS__) || defined(riscos)
|
#if defined(__MACOS__) || defined(riscos)
|
||||||
if (is_macos_native_path(file)) {
|
if (is_macos_native_path(file)) {
|
||||||
|
@ -2091,7 +2092,11 @@ rb_find_file(file)
|
||||||
path = 0;
|
path = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dln_find_file(file, path);
|
path = dln_find_file(file, path);
|
||||||
|
if (stat(path, &st) == 0) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
8
hash.c
8
hash.c
|
@ -334,7 +334,7 @@ rb_hash_fetch(argc, argv, hash)
|
||||||
rb_scan_args(argc, argv, "11", &key, &if_none);
|
rb_scan_args(argc, argv, "11", &key, &if_none);
|
||||||
|
|
||||||
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
|
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ rb_hash_delete(hash, key)
|
||||||
}
|
}
|
||||||
else if (st_delete(RHASH(hash)->tbl, &key, &val))
|
else if (st_delete(RHASH(hash)->tbl, &key, &val))
|
||||||
return val;
|
return val;
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
return rb_yield(key);
|
return rb_yield(key);
|
||||||
}
|
}
|
||||||
return RHASH(hash)->ifnone;
|
return RHASH(hash)->ifnone;
|
||||||
|
@ -894,7 +894,7 @@ env_delete_m(obj, name)
|
||||||
VALUE obj, name;
|
VALUE obj, name;
|
||||||
{
|
{
|
||||||
VALUE val = env_delete(obj, name);
|
VALUE val = env_delete(obj, name);
|
||||||
if (rb_iterator_p()) rb_yield(name);
|
if (rb_block_given_p()) rb_yield(name);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ env_fetch(argc, argv)
|
||||||
}
|
}
|
||||||
env = getenv(nam);
|
env = getenv(nam);
|
||||||
if (!env) {
|
if (!env) {
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
rb_raise(rb_eArgError, "wrong # of arguments", argc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ for dll in Dir['*.dll']
|
||||||
File.install dll, "#{bindir}/#{dll}", 0755, true
|
File.install dll, "#{bindir}/#{dll}", 0755, true
|
||||||
end
|
end
|
||||||
File.makedirs libdir, true
|
File.makedirs libdir, true
|
||||||
for lib in ["libruby.so.LIB", CONFIG["LIBRUBY_SO"]]
|
for lib in [CONFIG["LIBRUBY_SO"]]
|
||||||
if File.exist? lib
|
if File.exist? lib
|
||||||
File.install lib, libdir, 0555, true
|
File.install lib, libdir, 0555, true
|
||||||
end
|
end
|
||||||
|
@ -57,10 +57,6 @@ File.makedirs archlibdir, true
|
||||||
File.makedirs sitelibdir, true
|
File.makedirs sitelibdir, true
|
||||||
File.makedirs sitearchlibdir, true
|
File.makedirs sitearchlibdir, true
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /cygwin/ and File.exist? "import.h"
|
|
||||||
File.install "import.h", archlibdir, 0644, true
|
|
||||||
end
|
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /-aix/
|
if RUBY_PLATFORM =~ /-aix/
|
||||||
File.install "ruby.imp", archlibdir, 0644, true
|
File.install "ruby.imp", archlibdir, 0644, true
|
||||||
end
|
end
|
||||||
|
|
162
io.c
162
io.c
|
@ -105,7 +105,7 @@ static VALUE lineno;
|
||||||
#elif defined(FILE_COUNT)
|
#elif defined(FILE_COUNT)
|
||||||
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
|
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
|
||||||
#elif defined(__BEOS__)
|
#elif defined(__BEOS__)
|
||||||
# define ReadDataPending(fp) (fp->_state._eof == 0)
|
# define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
|
||||||
#else
|
#else
|
||||||
/* requires systems own version of the ReadDataPending() */
|
/* requires systems own version of the ReadDataPending() */
|
||||||
extern int ReadDataPending();
|
extern int ReadDataPending();
|
||||||
|
@ -392,6 +392,18 @@ rb_io_fileno(io)
|
||||||
return INT2FIX(fd);
|
return INT2FIX(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_io_pid(io)
|
||||||
|
VALUE io;
|
||||||
|
{
|
||||||
|
OpenFile *fptr;
|
||||||
|
|
||||||
|
GetOpenFile(io, fptr);
|
||||||
|
if (!fptr->pid)
|
||||||
|
return Qnil;
|
||||||
|
return INT2FIX(fptr->pid);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_io_to_io(io)
|
rb_io_to_io(io)
|
||||||
VALUE io;
|
VALUE io;
|
||||||
|
@ -1572,10 +1584,11 @@ pipe_open(pname, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_io_s_popen(argc, argv, self)
|
rb_io_popen(str, argc, argv, klass)
|
||||||
|
char *str;
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE self;
|
VALUE klass;
|
||||||
{
|
{
|
||||||
char *mode;
|
char *mode;
|
||||||
VALUE pname, pmode, port, proc;
|
VALUE pname, pmode, port, proc;
|
||||||
|
@ -1584,66 +1597,42 @@ rb_io_s_popen(argc, argv, self)
|
||||||
mode = "r";
|
mode = "r";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int len;
|
|
||||||
|
|
||||||
mode = STR2CSTR(pmode);
|
mode = STR2CSTR(pmode);
|
||||||
len = strlen(mode);
|
|
||||||
if (len == 0 || len > 3)
|
|
||||||
rb_raise(rb_eArgError, "illegal access mode");
|
|
||||||
}
|
}
|
||||||
Check_SafeStr(pname);
|
Check_SafeStr(pname);
|
||||||
port = pipe_open(RSTRING(pname)->ptr, mode);
|
port = pipe_open(str, mode);
|
||||||
if (NIL_P(port)) {
|
if (NIL_P(port)) {
|
||||||
/* child */
|
/* child */
|
||||||
if (!NIL_P(proc)) {
|
if (!NIL_P(proc)) {
|
||||||
rb_eval_cmd(proc, rb_ary_new2(0));
|
rb_eval_cmd(proc, rb_ary_new2(0));
|
||||||
_exit(0);
|
|
||||||
}
|
}
|
||||||
else if (rb_iterator_p()) {
|
else if (rb_block_given_p()) {
|
||||||
rb_yield(Qnil);
|
rb_yield(Qnil);
|
||||||
}
|
}
|
||||||
return Qnil;
|
fflush(stdout);
|
||||||
|
fflush(stderr);
|
||||||
|
_exit(0);
|
||||||
}
|
}
|
||||||
else if (rb_iterator_p()) {
|
RBASIC(port)->klass = klass;
|
||||||
return rb_ensure(rb_yield, port, rb_io_close, port);
|
if (rb_block_given_p()) {
|
||||||
|
rb_ensure(rb_yield, port, rb_io_close, port);
|
||||||
|
return Qnil;
|
||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_file_initialize(argc, argv, io)
|
rb_io_s_popen(argc, argv, klass)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE io;
|
VALUE klass;
|
||||||
{
|
{
|
||||||
VALUE fname, vmode, file, perm;
|
char *str = 0;
|
||||||
char *path, *mode;
|
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
if (argc >= 1) {
|
||||||
Check_SafeStr(fname);
|
str = STR2CSTR(argv[0]);
|
||||||
path = RSTRING(fname)->ptr;
|
|
||||||
|
|
||||||
if (FIXNUM_P(vmode)) {
|
|
||||||
int flags = NUM2INT(vmode);
|
|
||||||
int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
|
|
||||||
|
|
||||||
file = rb_file_sysopen_internal(io, path, flags, fmode);
|
|
||||||
}
|
}
|
||||||
else {
|
return rb_io_popen(str, argc, argv, klass);
|
||||||
if (!NIL_P(vmode)) {
|
|
||||||
mode = STR2CSTR(vmode);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mode = "r";
|
|
||||||
}
|
|
||||||
file = rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
|
||||||
return rb_ensure(rb_yield, file, rb_io_close, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1668,17 +1657,18 @@ rb_file_s_open(argc, argv, klass)
|
||||||
file = rb_file_sysopen_internal((VALUE)io, path, flags, fmode);
|
file = rb_file_sysopen_internal((VALUE)io, path, flags, fmode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!NIL_P(vmode)) {
|
if (NIL_P(vmode)) {
|
||||||
mode = STR2CSTR(vmode);
|
mode = "r";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mode = "r";
|
mode = STR2CSTR(vmode);
|
||||||
}
|
}
|
||||||
file = rb_file_open_internal((VALUE)io, RSTRING(fname)->ptr, mode);
|
file = rb_file_open_internal((VALUE)io, RSTRING(fname)->ptr, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
return rb_ensure(rb_yield, file, rb_io_close, file);
|
rb_ensure(rb_yield, file, rb_io_close, file);
|
||||||
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
@ -1689,41 +1679,14 @@ rb_f_open(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
{
|
{
|
||||||
char *mode;
|
if (argc >= 1) {
|
||||||
VALUE pname, pmode, perm;
|
char *str = STR2CSTR(argv[0]);
|
||||||
VALUE port;
|
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "12", &pname, &pmode, &perm);
|
if (str[0] == '|') {
|
||||||
Check_SafeStr(pname);
|
return rb_io_popen(str+1, argc, argv, rb_cIO);
|
||||||
if (RSTRING(pname)->ptr[0] != '|') /* open file */
|
}
|
||||||
return rb_file_s_open(argc, argv, rb_cFile);
|
|
||||||
|
|
||||||
/* open pipe */
|
|
||||||
if (NIL_P(pmode)) {
|
|
||||||
mode = "r";
|
|
||||||
}
|
}
|
||||||
else if (FIXNUM_P(pmode)) {
|
return rb_file_s_open(argc, argv, rb_cFile);
|
||||||
mode = rb_io_flags_mode(NUM2INT(pmode));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int len;
|
|
||||||
|
|
||||||
mode = STR2CSTR(pmode);
|
|
||||||
len = strlen(mode);
|
|
||||||
if (len == 0 || len > 3)
|
|
||||||
rb_raise(rb_eArgError, "illegal access mode %s", mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
port = pipe_open(RSTRING(pname)->ptr+1, mode);
|
|
||||||
if (!rb_iterator_p()) return port;
|
|
||||||
if (NIL_P(port)) {
|
|
||||||
rb_yield(port);
|
|
||||||
}
|
|
||||||
else if (rb_iterator_p()) {
|
|
||||||
return rb_ensure(rb_yield, port, rb_io_close, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
return port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -2280,12 +2243,44 @@ rb_io_initialize(argc, argv, io)
|
||||||
fp->f = rb_fdopen(NUM2INT(fnum), m);
|
fp->f = rb_fdopen(NUM2INT(fnum), m);
|
||||||
fp->mode = rb_io_mode_flags(m);
|
fp->mode = rb_io_mode_flags(m);
|
||||||
|
|
||||||
if (rb_iterator_p()) {
|
|
||||||
return rb_ensure(rb_yield, io, rb_io_close, io);
|
|
||||||
}
|
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_file_initialize(argc, argv, io)
|
||||||
|
int argc;
|
||||||
|
VALUE *argv;
|
||||||
|
VALUE io;
|
||||||
|
{
|
||||||
|
VALUE fname, vmode, file, perm;
|
||||||
|
char *path, *mode;
|
||||||
|
|
||||||
|
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
|
||||||
|
Check_SafeStr(fname);
|
||||||
|
path = RSTRING(fname)->ptr;
|
||||||
|
|
||||||
|
if (FIXNUM_P(vmode)) {
|
||||||
|
int flags = NUM2INT(vmode);
|
||||||
|
int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
|
||||||
|
|
||||||
|
file = rb_file_sysopen_internal(io, path, flags, fmode);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (NIL_P(vmode)) {
|
||||||
|
mode = "r";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mode = STR2CSTR(vmode);
|
||||||
|
}
|
||||||
|
file = rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
|
||||||
|
}
|
||||||
|
if (rb_block_given_p()) {
|
||||||
|
rb_warn("File::new() does not take block; use File::open() instead");
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
static int binmode = 0;
|
static int binmode = 0;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -3339,6 +3334,7 @@ Init_IO()
|
||||||
|
|
||||||
rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
|
rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
|
||||||
rb_define_method(rb_cIO, "fcntl", rb_io_fcntl, -1);
|
rb_define_method(rb_cIO, "fcntl", rb_io_fcntl, -1);
|
||||||
|
rb_define_method(rb_cIO, "pid", rb_io_pid, 0);
|
||||||
|
|
||||||
rb_stdin = orig_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
|
rb_stdin = orig_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
|
||||||
rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_stdin);
|
rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_stdin);
|
||||||
|
|
93
lib/date2.rb
93
lib/date2.rb
|
@ -1,5 +1,5 @@
|
||||||
# date2.rb: Written by Tadayoshi Funaba 1998-2000
|
# date2.rb: Written by Tadayoshi Funaba 1998-2000
|
||||||
# $Id: date2.rb,v 1.18 2000/03/20 16:23:32 tadf Exp $
|
# $Id: date2.rb,v 1.21 2000/05/14 15:47:09 tadf Exp $
|
||||||
|
|
||||||
class Date
|
class Date
|
||||||
|
|
||||||
|
@ -115,6 +115,8 @@ class Date
|
||||||
def ld_to_jd(ld) ld + 2299160 end
|
def ld_to_jd(ld) ld + 2299160 end
|
||||||
def jd_to_ld(jd) jd - 2299160 end
|
def jd_to_ld(jd) jd - 2299160 end
|
||||||
|
|
||||||
|
def jd_to_wday(jd) (jd + 1) % 7 end
|
||||||
|
|
||||||
def julian_leap? (y) y % 4 == 0 end
|
def julian_leap? (y) y % 4 == 0 end
|
||||||
def gregorian_leap? (y) y % 4 == 0 and y % 100 != 0 or y % 400 == 0 end
|
def gregorian_leap? (y) y % 4 == 0 and y % 100 != 0 or y % 400 == 0 end
|
||||||
|
|
||||||
|
@ -127,8 +129,8 @@ class Date
|
||||||
m += 13
|
m += 13
|
||||||
end
|
end
|
||||||
if d < 0
|
if d < 0
|
||||||
ny, nm = Date.clfloor(y * 12 + m, 12)
|
ny, nm = clfloor(y * 12 + m, 12)
|
||||||
nm, = Date.clfloor(m + 1, 1)
|
nm, = clfloor(m + 1, 1)
|
||||||
la = nil
|
la = nil
|
||||||
31.downto 1 do |z|
|
31.downto 1 do |z|
|
||||||
break if la = exist3?(y, m, z, sg)
|
break if la = exist3?(y, m, z, sg)
|
||||||
|
@ -199,10 +201,9 @@ class Date
|
||||||
def once(*ids)
|
def once(*ids)
|
||||||
for id in ids
|
for id in ids
|
||||||
module_eval <<-"end;"
|
module_eval <<-"end;"
|
||||||
alias_method :__#{id.to_i}__, #{id.inspect}
|
alias_method :__#{id.to_i}__, :#{id.id2name}
|
||||||
def #{id.id2name}(*args, &block)
|
def #{id.id2name}(*args, &block)
|
||||||
def self.#{id.id2name}(*args, &block); @__#{id.to_i}__ end
|
(@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
|
||||||
@__#{id.to_i}__ = __#{id.to_i}__(*args, &block)
|
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
@ -215,79 +216,76 @@ class Date
|
||||||
def initialize(rjd=0, sg=ITALY) @rjd, @sg = rjd, sg end
|
def initialize(rjd=0, sg=ITALY) @rjd, @sg = rjd, sg end
|
||||||
|
|
||||||
def rjd() @rjd end
|
def rjd() @rjd end
|
||||||
def rmjd() Date.jd_to_mjd(@rjd) end
|
def rmjd() type.jd_to_mjd(@rjd) end
|
||||||
def rtjd() Date.jd_to_tjd(@rjd) end
|
def rtjd() type.jd_to_tjd(@rjd) end
|
||||||
def rtjd2() Date.jd_to_tjd2(@rjd) end
|
def rtjd2() type.jd_to_tjd2(@rjd) end
|
||||||
|
|
||||||
once :rmjd, :rtjd, :rtjd2
|
once :rmjd, :rtjd, :rtjd2
|
||||||
|
|
||||||
def jd() Date.rjd_to_jd(@rjd)[0] end
|
def jd() type.rjd_to_jd(@rjd)[0] end
|
||||||
def fr1() Date.rjd_to_jd(@rjd)[1] end
|
def fr1() type.rjd_to_jd(@rjd)[1] end
|
||||||
def mjd() Date.jd_to_mjd(jd) end
|
def mjd() type.jd_to_mjd(jd) end
|
||||||
def tjd() Date.jd_to_tjd(jd) end
|
def tjd() type.jd_to_tjd(jd) end
|
||||||
def tjd2() Date.jd_to_tjd2(jd) end
|
def tjd2() type.jd_to_tjd2(jd) end
|
||||||
def ld() Date.jd_to_ld(jd) end
|
def ld() type.jd_to_ld(jd) end
|
||||||
|
|
||||||
once :jd, :fr1, :mjd, :tjd, :tjd2, :ld
|
once :jd, :fr1, :mjd, :tjd, :tjd2, :ld
|
||||||
|
|
||||||
def civil() Date.jd_to_civil(jd, @sg) end
|
def civil() type.jd_to_civil(jd, @sg) end
|
||||||
def ordinal() Date.jd_to_ordinal(jd, @sg) end
|
def ordinal() type.jd_to_ordinal(jd, @sg) end
|
||||||
def commercial() Date.jd_to_commercial(jd, @sg) end
|
def commercial() type.jd_to_commercial(jd, @sg) end
|
||||||
|
|
||||||
once :civil, :ordinal, :commercial
|
once :civil, :ordinal, :commercial
|
||||||
|
private :civil, :ordinal, :commercial
|
||||||
|
|
||||||
def year() civil[0] end
|
def year() civil[0] end
|
||||||
def yday() ordinal[1] end
|
def yday() ordinal[1] end
|
||||||
def mon() civil[1] end
|
def mon() civil[1] end
|
||||||
|
|
||||||
alias_method :month, :mon
|
alias_method :month, :mon
|
||||||
once :year, :yday, :mon, :month
|
|
||||||
|
|
||||||
def mday() civil[2] end
|
def mday() civil[2] end
|
||||||
|
|
||||||
alias_method :day, :mday
|
alias_method :day, :mday
|
||||||
once :mday, :day
|
|
||||||
|
|
||||||
def cwyear() commercial[0] end
|
def cwyear() commercial[0] end
|
||||||
def cweek() commercial[1] end
|
def cweek() commercial[1] end
|
||||||
def cwday() commercial[2] end
|
def cwday() commercial[2] end
|
||||||
|
|
||||||
once :cwyear, :cweek, :cwday
|
def wday() type.jd_to_wday(jd) end
|
||||||
|
|
||||||
def wday() (jd + 1) % 7 end
|
|
||||||
|
|
||||||
once :wday
|
once :wday
|
||||||
|
|
||||||
def os? () Date.os?(jd, @sg) end
|
def os? () type.os?(jd, @sg) end
|
||||||
def ns? () Date.ns?(jd, @sg) end
|
def ns? () type.ns?(jd, @sg) end
|
||||||
|
|
||||||
once :os?, :ns?
|
once :os?, :ns?
|
||||||
|
|
||||||
def leap?
|
def leap?
|
||||||
Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1,
|
type.jd_to_civil(type.civil_to_jd(year, 3, 1, ns?) - 1,
|
||||||
ns?)[-1] == 29
|
ns?)[-1] == 29
|
||||||
end
|
end
|
||||||
|
|
||||||
once :leap?
|
once :leap?
|
||||||
|
|
||||||
def sg() @sg end
|
def sg() @sg end
|
||||||
def newsg(sg=Date::ITALY) Date.new(@rjd, sg) end
|
def newsg(sg=type::ITALY) type.new(@rjd, sg) end
|
||||||
|
|
||||||
def italy() newsg(Date::ITALY) end
|
def italy() newsg(type::ITALY) end
|
||||||
def england() newsg(Date::ENGLAND) end
|
def england() newsg(type::ENGLAND) end
|
||||||
def julian() newsg(Date::JULIAN) end
|
def julian() newsg(type::JULIAN) end
|
||||||
def gregorian() newsg(Date::GREGORIAN) end
|
def gregorian() newsg(type::GREGORIAN) end
|
||||||
|
|
||||||
def + (n)
|
def + (n)
|
||||||
case n
|
case n
|
||||||
when Numeric; return Date.new(@rjd + n, @sg)
|
when Numeric; return type.new(@rjd + n, @sg)
|
||||||
end
|
end
|
||||||
fail TypeError, 'expected numeric'
|
fail TypeError, 'expected numeric'
|
||||||
end
|
end
|
||||||
|
|
||||||
def - (x)
|
def - (x)
|
||||||
case x
|
case x
|
||||||
when Numeric; return Date.new(@rjd - x, @sg)
|
when Numeric; return type.new(@rjd - x, @sg)
|
||||||
when Date; return @rjd - x.rjd
|
when Date; return @rjd - x.rjd
|
||||||
end
|
end
|
||||||
fail TypeError, 'expected numeric or date'
|
fail TypeError, 'expected numeric or date'
|
||||||
|
@ -310,27 +308,21 @@ class Date
|
||||||
end
|
end
|
||||||
|
|
||||||
def >> (n)
|
def >> (n)
|
||||||
y, m = Date.clfloor(year * 12 + (mon - 1) + n, 12)
|
y, m = type.clfloor(year * 12 + (mon - 1) + n, 12)
|
||||||
m, = Date.clfloor(m + 1, 1)
|
m, = type.clfloor(m + 1, 1)
|
||||||
d = mday
|
d = mday
|
||||||
d -= 1 until jd2 = Date.exist3?(y, m, d, ns?)
|
d -= 1 until jd2 = type.exist3?(y, m, d, ns?)
|
||||||
self + (jd2 - jd)
|
self + (jd2 - jd)
|
||||||
end
|
end
|
||||||
|
|
||||||
def << (n) self >> -n end
|
def << (n) self >> -n end
|
||||||
|
|
||||||
def step(limit, step)
|
def step(limit, step)
|
||||||
rjd = @rjd
|
da = self
|
||||||
if (step > 0)
|
op = [:-,:<=,:>=][step<=>0]
|
||||||
while rjd <= limit.rjd
|
while da.__send__(op, limit)
|
||||||
yield Date.new(rjd, @sg)
|
yield da
|
||||||
rjd += step
|
da += step
|
||||||
end
|
|
||||||
else
|
|
||||||
while rjd >= limit.rjd
|
|
||||||
yield Date.new(rjd, @sg)
|
|
||||||
rjd += step
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -343,11 +335,12 @@ class Date
|
||||||
alias_method :next, :succ
|
alias_method :next, :succ
|
||||||
|
|
||||||
def eql? (other) Date === other and self == other end
|
def eql? (other) Date === other and self == other end
|
||||||
def hash() Date.clfloor(@rjd)[0] end
|
def hash() type.clfloor(@rjd)[0] end
|
||||||
def inspect() format('#<Date: %s,%s>', @rjd, @sg) end
|
|
||||||
|
def inspect() format('#<%s: %s,%s>', type, @rjd, @sg) end
|
||||||
def to_s() format('%.4d-%02d-%02d', year, mon, mday) end
|
def to_s() format('%.4d-%02d-%02d', year, mon, mday) end
|
||||||
|
|
||||||
def _dump(limit) Marshal.dump([@rjd, @sg], -1) end
|
def _dump(limit) Marshal.dump([@rjd, @sg], -1) end
|
||||||
def Date._load(str) Date.new(*Marshal.load(str)) end
|
def self._load(str) new(*Marshal.load(str)) end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
18
lib/mkmf.rb
18
lib/mkmf.rb
|
@ -333,11 +333,6 @@ def create_makefile(target)
|
||||||
$DLDFLAGS = $DLDFLAGS + " -L$(topdir)"
|
$DLDFLAGS = $DLDFLAGS + " -L$(topdir)"
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /beos/
|
|
||||||
$libs = $libs + " " + CONFIG["LIBRUBYARG"]
|
|
||||||
$DLDFLAGS = $DLDFLAGS + " -L" + CONFIG["prefix"] + "/lib"
|
|
||||||
end
|
|
||||||
|
|
||||||
defflag = ''
|
defflag = ''
|
||||||
if RUBY_PLATFORM =~ /cygwin|mingw/
|
if RUBY_PLATFORM =~ /cygwin|mingw/
|
||||||
if File.exist? target + ".def"
|
if File.exist? target + ".def"
|
||||||
|
@ -447,19 +442,6 @@ EOMF
|
||||||
dfile.close
|
dfile.close
|
||||||
end
|
end
|
||||||
mfile.close
|
mfile.close
|
||||||
|
|
||||||
if RUBY_PLATFORM =~ /beos/
|
|
||||||
if RUBY_PLATFORM =~ /^powerpc/ then
|
|
||||||
deffilename = "ruby.exp"
|
|
||||||
else
|
|
||||||
deffilename = "ruby.def"
|
|
||||||
end
|
|
||||||
print "creating #{deffilename}\n"
|
|
||||||
open(deffilename, "w") do |file|
|
|
||||||
file.print("EXPORTS\n") if RUBY_PLATFORM =~ /^i/
|
|
||||||
file.print("Init_#{target}\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
$OBJEXT = CONFIG["OBJEXT"]
|
$OBJEXT = CONFIG["OBJEXT"]
|
||||||
|
|
|
@ -148,7 +148,7 @@ w_symbol(id, arg)
|
||||||
struct dump_arg *arg;
|
struct dump_arg *arg;
|
||||||
{
|
{
|
||||||
char *sym = rb_id2name(id);
|
char *sym = rb_id2name(id);
|
||||||
int num;
|
long num;
|
||||||
|
|
||||||
if (st_lookup(arg->symbol, id, &num)) {
|
if (st_lookup(arg->symbol, id, &num)) {
|
||||||
w_byte(TYPE_SYMLINK, arg);
|
w_byte(TYPE_SYMLINK, arg);
|
||||||
|
@ -258,7 +258,7 @@ w_object(obj, arg, limit)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int num;
|
long num;
|
||||||
|
|
||||||
limit--;
|
limit--;
|
||||||
c_arg.limit = limit;
|
c_arg.limit = limit;
|
||||||
|
@ -381,7 +381,7 @@ w_object(obj, arg, limit)
|
||||||
w_long(len, arg);
|
w_long(len, arg);
|
||||||
mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__"));
|
mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__"));
|
||||||
if (mem == Qnil) {
|
if (mem == Qnil) {
|
||||||
rb_raise(rb_eTypeError, "non-initialized struct");
|
rb_raise(rb_eTypeError, "uninitialized struct");
|
||||||
}
|
}
|
||||||
for (i=0; i<len; i++) {
|
for (i=0; i<len; i++) {
|
||||||
w_symbol(FIX2LONG(RARRAY(mem)->ptr[i]), arg);
|
w_symbol(FIX2LONG(RARRAY(mem)->ptr[i]), arg);
|
||||||
|
@ -813,7 +813,7 @@ r_object(arg)
|
||||||
klass = rb_path2class(r_unique(arg));
|
klass = rb_path2class(r_unique(arg));
|
||||||
mem = rb_ivar_get(klass, rb_intern("__member__"));
|
mem = rb_ivar_get(klass, rb_intern("__member__"));
|
||||||
if (mem == Qnil) {
|
if (mem == Qnil) {
|
||||||
rb_raise(rb_eTypeError, "non-initialized struct");
|
rb_raise(rb_eTypeError, "uninitialized struct");
|
||||||
}
|
}
|
||||||
len = r_long(arg);
|
len = r_long(arg);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
(substring ruby-mode-revision (match-beginning 0) (match-end 0))))
|
(substring ruby-mode-revision (match-beginning 0) (match-end 0))))
|
||||||
|
|
||||||
(defconst ruby-block-beg-re
|
(defconst ruby-block-beg-re
|
||||||
"class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do"
|
"class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin"
|
||||||
|
)
|
||||||
|
|
||||||
|
(defconst ruby-non-block-do-re
|
||||||
|
"while\\|until\\|for\\|rescue"
|
||||||
)
|
)
|
||||||
|
|
||||||
(defconst ruby-indent-beg-re
|
(defconst ruby-indent-beg-re
|
||||||
|
@ -372,6 +376,39 @@ The variable ruby-indent-level controls the amount of indentation.
|
||||||
(goto-char (match-end 0)))
|
(goto-char (match-end 0)))
|
||||||
((looking-at ruby-block-beg-re)
|
((looking-at ruby-block-beg-re)
|
||||||
(and
|
(and
|
||||||
|
(or (not (looking-at "do\\>[^_]"))
|
||||||
|
(save-excursion
|
||||||
|
(back-to-indentation)
|
||||||
|
(not (looking-at ruby-non-block-do-re))))
|
||||||
|
(or (bolp)
|
||||||
|
(progn
|
||||||
|
(forward-char -1)
|
||||||
|
(setq w (char-after (point)))
|
||||||
|
(not (or (eq ?_ w)
|
||||||
|
(eq ?. w)))))
|
||||||
|
(goto-char pnt)
|
||||||
|
(setq w (char-after (point)))
|
||||||
|
(not (eq ?_ w))
|
||||||
|
(not (eq ?! w))
|
||||||
|
(not (eq ?? w))
|
||||||
|
(skip-chars-forward " \t")
|
||||||
|
(if (not (eolp))
|
||||||
|
(progn
|
||||||
|
(goto-char (match-beginning 0))
|
||||||
|
(if (looking-at ruby-modifier-re)
|
||||||
|
(ruby-expr-beg 'modifier)
|
||||||
|
t))
|
||||||
|
t)
|
||||||
|
(goto-char pnt)
|
||||||
|
(setq nest (cons (cons nil pnt) nest))
|
||||||
|
(setq depth (1+ depth)))
|
||||||
|
(goto-char pnt))
|
||||||
|
((looking-at ruby-block-beg-re)
|
||||||
|
(and
|
||||||
|
(or (not (looking-at "do\\>[^_]"))
|
||||||
|
(save-excursion
|
||||||
|
(back-to-indentation)
|
||||||
|
(not (looking-at ruby-non-block-do-re))))
|
||||||
(or (bolp)
|
(or (bolp)
|
||||||
(progn
|
(progn
|
||||||
(forward-char -1)
|
(forward-char -1)
|
||||||
|
@ -462,7 +499,7 @@ The variable ruby-indent-level controls the amount of indentation.
|
||||||
(goto-char (cdr (nth 1 state)))
|
(goto-char (cdr (nth 1 state)))
|
||||||
(forward-word -1) ; skip back a keyword
|
(forward-word -1) ; skip back a keyword
|
||||||
(cond
|
(cond
|
||||||
((looking-at "do") ; iter block is a special case
|
((looking-at "do\\>[^_]") ; iter block is a special case
|
||||||
(cond
|
(cond
|
||||||
((nth 3 state)
|
((nth 3 state)
|
||||||
(goto-char (nth 3 state))
|
(goto-char (nth 3 state))
|
||||||
|
|
6
node.h
6
node.h
|
@ -135,15 +135,15 @@ typedef struct RNode {
|
||||||
union {
|
union {
|
||||||
struct RNode *node;
|
struct RNode *node;
|
||||||
ID id;
|
ID id;
|
||||||
int argc;
|
long argc;
|
||||||
VALUE value;
|
VALUE value;
|
||||||
} u2;
|
} u2;
|
||||||
union {
|
union {
|
||||||
struct RNode *node;
|
struct RNode *node;
|
||||||
ID id;
|
ID id;
|
||||||
int state;
|
long state;
|
||||||
struct global_entry *entry;
|
struct global_entry *entry;
|
||||||
int cnt;
|
long cnt;
|
||||||
VALUE value;
|
VALUE value;
|
||||||
} u3;
|
} u3;
|
||||||
} NODE;
|
} NODE;
|
||||||
|
|
22
object.c
22
object.c
|
@ -159,9 +159,8 @@ inspect_i(id, value, str)
|
||||||
/* need not to show internal data */
|
/* need not to show internal data */
|
||||||
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
if (CLASS_OF(value) == 0) return ST_CONTINUE;
|
||||||
if (!rb_is_instance_id(id)) return ST_CONTINUE;
|
if (!rb_is_instance_id(id)) return ST_CONTINUE;
|
||||||
if (RSTRING(str)->ptr[0] == '-') {
|
if (RSTRING(str)->ptr[0] == '-') { /* first element */
|
||||||
RSTRING(str)->ptr[0] = '#';
|
RSTRING(str)->ptr[0] = '#';
|
||||||
rb_str_cat2(str, ": ");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_str_cat2(str, ", ");
|
rb_str_cat2(str, ", ");
|
||||||
|
@ -195,16 +194,17 @@ rb_obj_inspect(obj)
|
||||||
&& ROBJECT(obj)->iv_tbl
|
&& ROBJECT(obj)->iv_tbl
|
||||||
&& ROBJECT(obj)->iv_tbl->num_entries > 0) {
|
&& ROBJECT(obj)->iv_tbl->num_entries > 0) {
|
||||||
VALUE str;
|
VALUE str;
|
||||||
char *b;
|
char *c, *b;
|
||||||
|
|
||||||
b = rb_class2name(CLASS_OF(obj));
|
c = rb_class2name(CLASS_OF(obj));
|
||||||
if (rb_inspecting_p(obj)) {
|
if (rb_inspecting_p(obj)) {
|
||||||
char *buf = ALLOCA_N(char, strlen(b)+8);
|
b = ALLOCA_N(char, strlen(c)+8+16+1); /* 8:tags 16:addr 1:eos */
|
||||||
sprintf(buf, "#<%s:...>", b);
|
sprintf(b, "#<%s:0x%lx ...>", c, obj);
|
||||||
return rb_str_new2(buf);
|
return rb_str_new2(b);
|
||||||
}
|
}
|
||||||
str = rb_str_new2("-<");
|
b = ALLOCA_N(char, strlen(c)+4+16+1); /* 4:tags 16:addr 1:eos */
|
||||||
rb_str_cat2(str, b);
|
sprintf(b, "-<%s:0x%lx ", c, obj);
|
||||||
|
str = rb_str_new2(b);
|
||||||
return rb_protect_inspect(inspect_obj, obj, str);
|
return rb_protect_inspect(inspect_obj, obj, str);
|
||||||
}
|
}
|
||||||
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
|
return rb_funcall(obj, rb_intern("to_s"), 0, 0);
|
||||||
|
@ -630,6 +630,7 @@ rb_module_s_new(klass)
|
||||||
VALUE mod = rb_module_new();
|
VALUE mod = rb_module_new();
|
||||||
|
|
||||||
RBASIC(mod)->klass = klass;
|
RBASIC(mod)->klass = klass;
|
||||||
|
rb_obj_call_init(klass, 0, 0);
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,6 +652,7 @@ rb_class_s_new(argc, argv)
|
||||||
/* make metaclass */
|
/* make metaclass */
|
||||||
RBASIC(klass)->klass = rb_singleton_class_new(RBASIC(super)->klass);
|
RBASIC(klass)->klass = rb_singleton_class_new(RBASIC(super)->klass);
|
||||||
rb_singleton_class_attached(RBASIC(klass)->klass, klass);
|
rb_singleton_class_attached(RBASIC(klass)->klass, klass);
|
||||||
|
rb_obj_call_init(klass, argc, argv);
|
||||||
rb_funcall(super, rb_intern("inherited"), 1, klass);
|
rb_funcall(super, rb_intern("inherited"), 1, klass);
|
||||||
|
|
||||||
return klass;
|
return klass;
|
||||||
|
@ -1086,7 +1088,7 @@ Init_Object()
|
||||||
rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, 0);
|
rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, 0);
|
||||||
rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0);
|
rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0);
|
||||||
rb_define_private_method(rb_mKernel, "remove_instance_variable",
|
rb_define_private_method(rb_mKernel, "remove_instance_variable",
|
||||||
rb_obj_remove_instance_variable, 0);
|
rb_obj_remove_instance_variable, 1);
|
||||||
|
|
||||||
rb_define_method(rb_mKernel, "instance_of?", rb_obj_is_instance_of, 1);
|
rb_define_method(rb_mKernel, "instance_of?", rb_obj_is_instance_of, 1);
|
||||||
rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
|
rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
|
||||||
|
|
6
pack.c
6
pack.c
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
#ifdef NATINT_PACK
|
#ifdef NATINT_PACK
|
||||||
# define NATINT_LEN(type,len) (natint?sizeof(type):(len))
|
# define NATINT_LEN(type,len) (natint?sizeof(type):(len))
|
||||||
# ifndef WORDS_BIGENDIAN
|
# ifdef WORDS_BIGENDIAN
|
||||||
# define OFF16(p) ((char*)(p) + (natint?(sizeof(short) - 2):0))
|
# define OFF16(p) ((char*)(p) + (natint?0:(sizeof(short) - 2)))
|
||||||
# define OFF32(p) ((char*)(p) + (natint?(sizeof(long) - 4):0))
|
# define OFF32(p) ((char*)(p) + (natint?0:(sizeof(long) - 4)))
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define NATINT_LEN(type,len) sizeof(type)
|
# define NATINT_LEN(type,len) sizeof(type)
|
||||||
|
|
2
parse.y
2
parse.y
|
@ -2256,7 +2256,7 @@ parse_regx(term, paren)
|
||||||
case 'x':
|
case 'x':
|
||||||
options |= RE_OPTION_EXTENDED;
|
options |= RE_OPTION_EXTENDED;
|
||||||
break;
|
break;
|
||||||
case 'p': /* /p is obsolete, works as /m */
|
case 'p': /* /p is obsolete */
|
||||||
rb_warn("/p option is obsolete; use /m\n\tnote: /m does not change ^, $ behavior");
|
rb_warn("/p option is obsolete; use /m\n\tnote: /m does not change ^, $ behavior");
|
||||||
options |= RE_OPTION_POSIXLINE;
|
options |= RE_OPTION_POSIXLINE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -509,7 +509,7 @@ rb_f_fork(obj)
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
after_exec();
|
after_exec();
|
||||||
#endif
|
#endif
|
||||||
if (rb_iterator_p()) {
|
if (rb_block_given_p()) {
|
||||||
rb_yield(Qnil);
|
rb_yield(Qnil);
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
14
re.c
14
re.c
|
@ -1060,22 +1060,20 @@ static int
|
||||||
rb_reg_get_kcode(re)
|
rb_reg_get_kcode(re)
|
||||||
VALUE re;
|
VALUE re;
|
||||||
{
|
{
|
||||||
int kcode = 0;
|
int kcode;
|
||||||
|
|
||||||
switch (RBASIC(re)->flags & KCODE_MASK) {
|
switch (RBASIC(re)->flags & KCODE_MASK) {
|
||||||
case KCODE_NONE:
|
case KCODE_NONE:
|
||||||
kcode |= 16; break;
|
return 16;
|
||||||
case KCODE_EUC:
|
case KCODE_EUC:
|
||||||
kcode |= 32; break;
|
return 32;
|
||||||
case KCODE_SJIS:
|
case KCODE_SJIS:
|
||||||
kcode |= 48; break;
|
return 48;
|
||||||
case KCODE_UTF8:
|
case KCODE_UTF8:
|
||||||
kcode |= 64; break;
|
return 64;
|
||||||
default:
|
default:
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return kcode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
197
regex.c
197
regex.c
|
@ -232,27 +232,27 @@ re_set_casetable(table)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef isblank
|
#ifdef isblank
|
||||||
# define ISBLANK(c) (ISASCII (c) && isblank (c))
|
# define ISBLANK(c) (ISASCII(c) && isblank(c))
|
||||||
#else
|
#else
|
||||||
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||||
#endif
|
#endif
|
||||||
#ifdef isgraph
|
#ifdef isgraph
|
||||||
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
|
# define ISGRAPH(c) (ISASCII(c) && isgraph(c))
|
||||||
#else
|
#else
|
||||||
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
|
# define ISGRAPH(c) (ISASCII(c) && isprint(c) && !isspace(c))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef ISPRINT
|
#undef ISPRINT
|
||||||
#define ISPRINT(c) (ISASCII (c) && isprint (c))
|
#define ISPRINT(c) (ISASCII(c) && isprint(c))
|
||||||
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
|
#define ISDIGIT(c) (ISASCII(c) && isdigit(c))
|
||||||
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
|
#define ISALNUM(c) (ISASCII(c) && isalnum(c))
|
||||||
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
|
#define ISALPHA(c) (ISASCII(c) && isalpha(c))
|
||||||
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
|
#define ISCNTRL(c) (ISASCII(c) && iscntrl(c))
|
||||||
#define ISLOWER(c) (ISASCII (c) && islower (c))
|
#define ISLOWER(c) (ISASCII(c) && islower(c))
|
||||||
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
|
#define ISPUNCT(c) (ISASCII(c) && ispunct(c))
|
||||||
#define ISSPACE(c) (ISASCII (c) && isspace (c))
|
#define ISSPACE(c) (ISASCII(c) && isspace(c))
|
||||||
#define ISUPPER(c) (ISASCII (c) && isupper (c))
|
#define ISUPPER(c) (ISASCII(c) && isupper(c))
|
||||||
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
|
#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
# define NULL (void *)0
|
# define NULL (void *)0
|
||||||
|
@ -264,10 +264,10 @@ re_set_casetable(table)
|
||||||
(Per Bothner suggested the basic approach.) */
|
(Per Bothner suggested the basic approach.) */
|
||||||
#undef SIGN_EXTEND_CHAR
|
#undef SIGN_EXTEND_CHAR
|
||||||
#if __STDC__
|
#if __STDC__
|
||||||
# define SIGN_EXTEND_CHAR(c) ((signed char) (c))
|
# define SIGN_EXTEND_CHAR(c) ((signed char)(c))
|
||||||
#else /* not __STDC__ */
|
#else /* not __STDC__ */
|
||||||
/* As in Harbison and Steele. */
|
/* As in Harbison and Steele. */
|
||||||
# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
|
# define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These are the command codes that appear in compiled regular
|
/* These are the command codes that appear in compiled regular
|
||||||
|
@ -350,10 +350,7 @@ enum regexpcode
|
||||||
stop_paren, /* Place holder at the end of (?:..). */
|
stop_paren, /* Place holder at the end of (?:..). */
|
||||||
casefold_on, /* Turn on casefold flag. */
|
casefold_on, /* Turn on casefold flag. */
|
||||||
casefold_off, /* Turn off casefold flag. */
|
casefold_off, /* Turn off casefold flag. */
|
||||||
mline_on, /* Turn on multi line match (match with newlines). */
|
option_set, /* Turn on multi line match (match with newlines). */
|
||||||
mline_off, /* Turn off multi line match. */
|
|
||||||
posix_on, /* Turn on POSIXified line match (match with newlines). */
|
|
||||||
posix_off, /* Turn off POSIXified line match. */
|
|
||||||
start_nowidth, /* Save string point to the stack. */
|
start_nowidth, /* Save string point to the stack. */
|
||||||
stop_nowidth, /* Restore string place at the point start_nowidth. */
|
stop_nowidth, /* Restore string place at the point start_nowidth. */
|
||||||
pop_and_fail, /* Fail after popping nowidth entry from stack. */
|
pop_and_fail, /* Fail after popping nowidth entry from stack. */
|
||||||
|
@ -395,7 +392,7 @@ enum regexpcode
|
||||||
at SOURCE. */
|
at SOURCE. */
|
||||||
#define EXTRACT_NUMBER(destination, source) \
|
#define EXTRACT_NUMBER(destination, source) \
|
||||||
do { (destination) = *(source) & 0377; \
|
do { (destination) = *(source) & 0377; \
|
||||||
(destination) += SIGN_EXTEND_CHAR (*(char*)((source) + 1)) << 8; } while (0)
|
(destination) += SIGN_EXTEND_CHAR(*(char*)((source) + 1)) << 8; } while (0)
|
||||||
|
|
||||||
/* Same as EXTRACT_NUMBER, except increment the pointer for source to
|
/* Same as EXTRACT_NUMBER, except increment the pointer for source to
|
||||||
point to second byte of SOURCE. Note that SOURCE has to be a value
|
point to second byte of SOURCE. Note that SOURCE has to be a value
|
||||||
|
@ -538,7 +535,7 @@ print_mbc(c)
|
||||||
if (bufp->allocated == (1L<<16)) goto too_big; \
|
if (bufp->allocated == (1L<<16)) goto too_big; \
|
||||||
bufp->allocated *= 2; \
|
bufp->allocated *= 2; \
|
||||||
if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \
|
if (bufp->allocated > (1L<<16)) bufp->allocated = (1L<<16); \
|
||||||
bufp->buffer = (char*)xrealloc (bufp->buffer, bufp->allocated); \
|
bufp->buffer = (char*)xrealloc(bufp->buffer, bufp->allocated); \
|
||||||
if (bufp->buffer == 0) \
|
if (bufp->buffer == 0) \
|
||||||
goto memory_exhausted; \
|
goto memory_exhausted; \
|
||||||
b = (b - old_buffer) + bufp->buffer; \
|
b = (b - old_buffer) + bufp->buffer; \
|
||||||
|
@ -572,7 +569,7 @@ print_mbc(c)
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
#define STREQ(s1, s2) ((strcmp(s1, s2) == 0))
|
||||||
|
|
||||||
#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
||||||
|
|
||||||
|
@ -766,22 +763,12 @@ print_partial_compiled_pattern(start, end)
|
||||||
printf("/casefold_off");
|
printf("/casefold_off");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mline_on:
|
case option_set:
|
||||||
printf("/mline_on");
|
printf("/option_set/%d", *p++);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mline_off:
|
|
||||||
printf("/mline_off");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case posix_on:
|
|
||||||
printf("/posix_on");
|
|
||||||
|
|
||||||
case posix_off:
|
|
||||||
printf("/posix_off");
|
|
||||||
|
|
||||||
case start_nowidth:
|
case start_nowidth:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/start_nowidth//%d", mcnt);
|
printf("/start_nowidth//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -851,12 +838,12 @@ print_partial_compiled_pattern(start, end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case on_failure_jump:
|
case on_failure_jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/on_failure_jump//%d", mcnt);
|
printf("/on_failure_jump//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dummy_failure_jump:
|
case dummy_failure_jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/dummy_failure_jump//%d", mcnt);
|
printf("/dummy_failure_jump//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -865,56 +852,56 @@ print_partial_compiled_pattern(start, end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case finalize_jump:
|
case finalize_jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/finalize_jump//%d", mcnt);
|
printf("/finalize_jump//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case maybe_finalize_jump:
|
case maybe_finalize_jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/maybe_finalize_jump//%d", mcnt);
|
printf("/maybe_finalize_jump//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case jump_past_alt:
|
case jump_past_alt:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/jump_past_alt//%d", mcnt);
|
printf("/jump_past_alt//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case jump:
|
case jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/jump//%d", mcnt);
|
printf("/jump//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case succeed_n:
|
case succeed_n:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt2, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||||
printf("/succeed_n//%d//%d", mcnt, mcnt2);
|
printf("/succeed_n//%d//%d", mcnt, mcnt2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case jump_n:
|
case jump_n:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt2, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||||
printf("/jump_n//%d//%d", mcnt, mcnt2);
|
printf("/jump_n//%d//%d", mcnt, mcnt2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case set_number_at:
|
case set_number_at:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt2, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||||
printf("/set_number_at//%d//%d", mcnt, mcnt2);
|
printf("/set_number_at//%d//%d", mcnt, mcnt2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case try_next:
|
case try_next:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/try_next//%d", mcnt);
|
printf("/try_next//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case finalize_push:
|
case finalize_push:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
printf("/finalize_push//%d", mcnt);
|
printf("/finalize_push//%d", mcnt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case finalize_push_n:
|
case finalize_push_n:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt2, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt2, p);
|
||||||
printf("/finalize_push_n//%d//%d", mcnt, mcnt2);
|
printf("/finalize_push_n//%d//%d", mcnt, mcnt2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -971,7 +958,7 @@ print_compiled_pattern(bufp)
|
||||||
{
|
{
|
||||||
unsigned char *buffer = (unsigned char*)bufp->buffer;
|
unsigned char *buffer = (unsigned char*)bufp->buffer;
|
||||||
|
|
||||||
print_partial_compiled_pattern (buffer, buffer + bufp->used);
|
print_partial_compiled_pattern(buffer, buffer + bufp->used);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static char*
|
||||||
|
@ -1033,10 +1020,7 @@ calculate_must_string(start, end)
|
||||||
case push_dummy_failure:
|
case push_dummy_failure:
|
||||||
case start_paren:
|
case start_paren:
|
||||||
case stop_paren:
|
case stop_paren:
|
||||||
case mline_on:
|
case option_set:
|
||||||
case mline_off:
|
|
||||||
case posix_on:
|
|
||||||
case posix_off:
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case charset:
|
case charset:
|
||||||
|
@ -1050,11 +1034,11 @@ calculate_must_string(start, end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case on_failure_jump:
|
case on_failure_jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
if (mcnt > 0) p += mcnt;
|
if (mcnt > 0) p += mcnt;
|
||||||
if ((enum regexpcode)p[-3] == jump) {
|
if ((enum regexpcode)p[-3] == jump) {
|
||||||
p -= 3;
|
p -= 3;
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
if (mcnt > 0) p += mcnt;
|
if (mcnt > 0) p += mcnt;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1063,7 +1047,7 @@ calculate_must_string(start, end)
|
||||||
case succeed_n:
|
case succeed_n:
|
||||||
case try_next:
|
case try_next:
|
||||||
case jump:
|
case jump:
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||||
if (mcnt > 0) p += mcnt;
|
if (mcnt > 0) p += mcnt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1260,6 +1244,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
int had_char_class = 0;
|
int had_char_class = 0;
|
||||||
|
|
||||||
int options = bufp->options;
|
int options = bufp->options;
|
||||||
|
int old_options = 0;
|
||||||
|
|
||||||
bufp->fastmap_accurate = 0;
|
bufp->fastmap_accurate = 0;
|
||||||
bufp->must = 0;
|
bufp->must = 0;
|
||||||
|
@ -1273,7 +1258,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
bufp->allocated = INIT_BUF_SIZE;
|
bufp->allocated = INIT_BUF_SIZE;
|
||||||
if (bufp->buffer)
|
if (bufp->buffer)
|
||||||
/* EXTEND_BUFFER loses when bufp->allocated is 0. */
|
/* EXTEND_BUFFER loses when bufp->allocated is 0. */
|
||||||
bufp->buffer = (char*)xrealloc (bufp->buffer, INIT_BUF_SIZE);
|
bufp->buffer = (char*)xrealloc(bufp->buffer, INIT_BUF_SIZE);
|
||||||
else
|
else
|
||||||
/* Caller did not allocate a buffer. Do it for them. */
|
/* Caller did not allocate a buffer. Do it for them. */
|
||||||
bufp->buffer = (char*)xmalloc(INIT_BUF_SIZE);
|
bufp->buffer = (char*)xmalloc(INIT_BUF_SIZE);
|
||||||
|
@ -1286,7 +1271,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '$':
|
case '$':
|
||||||
if (bufp->options & RE_OPTION_POSIXLINE) {
|
if (bufp->options & RE_OPTION_SINGLELINE) {
|
||||||
BUFPUSH(endbuf);
|
BUFPUSH(endbuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1306,7 +1291,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '^':
|
case '^':
|
||||||
if (bufp->options & RE_OPTION_POSIXLINE)
|
if (bufp->options & RE_OPTION_SINGLELINE)
|
||||||
BUFPUSH(begbuf);
|
BUFPUSH(begbuf);
|
||||||
else
|
else
|
||||||
BUFPUSH(begline);
|
BUFPUSH(begline);
|
||||||
|
@ -1576,7 +1561,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
/* Leave room for the null. */
|
/* Leave room for the null. */
|
||||||
char str[CHAR_CLASS_MAX_LENGTH + 1];
|
char str[CHAR_CLASS_MAX_LENGTH + 1];
|
||||||
|
|
||||||
PATFETCH_RAW (c);
|
PATFETCH_RAW(c);
|
||||||
c1 = 0;
|
c1 = 0;
|
||||||
|
|
||||||
/* If pattern is `[[:'. */
|
/* If pattern is `[[:'. */
|
||||||
|
@ -1610,11 +1595,11 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
char is_upper = STREQ(str, "upper");
|
char is_upper = STREQ(str, "upper");
|
||||||
char is_xdigit = STREQ(str, "xdigit");
|
char is_xdigit = STREQ(str, "xdigit");
|
||||||
|
|
||||||
if (!IS_CHAR_CLASS (str))
|
if (!IS_CHAR_CLASS(str))
|
||||||
goto invalid_pattern;
|
goto invalid_pattern;
|
||||||
|
|
||||||
/* Throw away the ] at the end of the character class. */
|
/* Throw away the ] at the end of the character class. */
|
||||||
PATFETCH (c);
|
PATFETCH(c);
|
||||||
|
|
||||||
if (p == pend)
|
if (p == pend)
|
||||||
goto invalid_pattern;
|
goto invalid_pattern;
|
||||||
|
@ -1632,7 +1617,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
|| (is_space && ISSPACE(ch))
|
|| (is_space && ISSPACE(ch))
|
||||||
|| (is_upper && ISUPPER(ch))
|
|| (is_upper && ISUPPER(ch))
|
||||||
|| (is_xdigit && ISXDIGIT(ch)))
|
|| (is_xdigit && ISXDIGIT(ch)))
|
||||||
SET_LIST_BIT (ch);
|
SET_LIST_BIT(ch);
|
||||||
}
|
}
|
||||||
had_char_class = 1;
|
had_char_class = 1;
|
||||||
}
|
}
|
||||||
|
@ -1661,14 +1646,16 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
b[-1]--;
|
b[-1]--;
|
||||||
if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
|
if (b[-1] != (1 << BYTEWIDTH) / BYTEWIDTH)
|
||||||
memmove(&b[b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
|
memmove(&b[b[-1]], &b[(1 << BYTEWIDTH) / BYTEWIDTH],
|
||||||
2 + EXTRACT_UNSIGNED (&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
|
2 + EXTRACT_UNSIGNED(&b[(1 << BYTEWIDTH) / BYTEWIDTH])*8);
|
||||||
b += b[-1] + 2 + EXTRACT_UNSIGNED (&b[b[-1]])*8;
|
b += b[-1] + 2 + EXTRACT_UNSIGNED(&b[b[-1]])*8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '(':
|
case '(':
|
||||||
|
old_options = options;
|
||||||
PATFETCH(c);
|
PATFETCH(c);
|
||||||
if (c == '?') {
|
if (c == '?') {
|
||||||
int negative = 0;
|
int negative = 0;
|
||||||
|
int push_option = 0;
|
||||||
PATFETCH_RAW(c);
|
PATFETCH_RAW(c);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'x': case 'p': case 'm': case 'i': case '-':
|
case 'x': case 'p': case 'm': case 'i': case '-':
|
||||||
|
@ -1691,28 +1678,26 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (negative) {
|
if (negative) {
|
||||||
if (options&RE_OPTION_POSIXLINE) {
|
if ((options&RE_OPTION_POSIXLINE) == RE_OPTION_POSIXLINE) {
|
||||||
options &= ~RE_OPTION_POSIXLINE;
|
options &= ~RE_OPTION_POSIXLINE;
|
||||||
BUFPUSH(posix_off);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(options&RE_OPTION_POSIXLINE)) {
|
else if ((options&RE_OPTION_POSIXLINE) != RE_OPTION_POSIXLINE) {
|
||||||
options |= RE_OPTION_POSIXLINE;
|
options |= RE_OPTION_POSIXLINE;
|
||||||
BUFPUSH(posix_on);
|
|
||||||
}
|
}
|
||||||
|
push_option = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (negative) {
|
if (negative) {
|
||||||
if (options&RE_OPTION_MULTILINE) {
|
if (options&RE_OPTION_MULTILINE) {
|
||||||
options &= ~RE_OPTION_MULTILINE;
|
options &= ~RE_OPTION_MULTILINE;
|
||||||
BUFPUSH(mline_off);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(options&RE_OPTION_MULTILINE)) {
|
else if (!(options&RE_OPTION_MULTILINE)) {
|
||||||
options |= RE_OPTION_MULTILINE;
|
options |= RE_OPTION_MULTILINE;
|
||||||
BUFPUSH(mline_on);
|
|
||||||
}
|
}
|
||||||
|
push_option = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
|
@ -1757,6 +1742,10 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
default:
|
default:
|
||||||
FREE_AND_RETURN(stackb, "undefined (?...) sequence");
|
FREE_AND_RETURN(stackb, "undefined (?...) sequence");
|
||||||
}
|
}
|
||||||
|
if (push_option) {
|
||||||
|
BUFPUSH(option_set);
|
||||||
|
BUFPUSH(options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PATUNFETCH;
|
PATUNFETCH;
|
||||||
|
@ -1813,7 +1802,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*stackp++ = c;
|
*stackp++ = c;
|
||||||
*stackp++ = options;
|
*stackp++ = old_options;
|
||||||
fixup_alt_jump = 0;
|
fixup_alt_jump = 0;
|
||||||
laststart = 0;
|
laststart = 0;
|
||||||
begalt = b;
|
begalt = b;
|
||||||
|
@ -1822,14 +1811,13 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
case ')':
|
case ')':
|
||||||
if (stackp == stackb)
|
if (stackp == stackb)
|
||||||
FREE_AND_RETURN(stackb, "unmatched )");
|
FREE_AND_RETURN(stackb, "unmatched )");
|
||||||
if ((options ^ stackp[-1]) & RE_OPTION_IGNORECASE) {
|
|
||||||
BUFPUSH((options&RE_OPTION_IGNORECASE)?casefold_off:casefold_on);
|
if (options != stackp[-1]) {
|
||||||
}
|
if ((options ^ stackp[-1]) & RE_OPTION_IGNORECASE) {
|
||||||
if ((options ^ stackp[-1]) & RE_OPTION_POSIXLINE) {
|
BUFPUSH((options&RE_OPTION_IGNORECASE)?casefold_off:casefold_on);
|
||||||
BUFPUSH((options&RE_OPTION_MULTILINE)?posix_off:posix_on);
|
}
|
||||||
}
|
BUFPUSH(option_set);
|
||||||
if ((options ^ stackp[-1]) & RE_OPTION_MULTILINE) {
|
BUFPUSH(stackp[-1]);
|
||||||
BUFPUSH((options&RE_OPTION_MULTILINE)?mline_off:mline_on);
|
|
||||||
}
|
}
|
||||||
pending_exact = 0;
|
pending_exact = 0;
|
||||||
if (fixup_alt_jump) {
|
if (fixup_alt_jump) {
|
||||||
|
@ -2111,7 +2099,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
beg_interval = 0;
|
beg_interval = 0;
|
||||||
|
|
||||||
/* normal_char and normal_backslash need `c'. */
|
/* normal_char and normal_backslash need `c'. */
|
||||||
PATFETCH (c);
|
PATFETCH(c);
|
||||||
goto normal_char;
|
goto normal_char;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
|
@ -2195,7 +2183,7 @@ re_compile_pattern(pattern, size, bufp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Z':
|
case 'Z':
|
||||||
if ((bufp->options & RE_OPTION_POSIXLINE) == 0) {
|
if ((bufp->options & RE_OPTION_SINGLELINE) == 0) {
|
||||||
BUFPUSH(endbuf2);
|
BUFPUSH(endbuf2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2789,14 +2777,8 @@ re_compile_fastmap(bufp)
|
||||||
options ^= RE_OPTION_IGNORECASE;
|
options ^= RE_OPTION_IGNORECASE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case mline_on:
|
case option_set:
|
||||||
case mline_off:
|
options = *p++;
|
||||||
options ^= RE_OPTION_MULTILINE;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case posix_on:
|
|
||||||
case posix_off:
|
|
||||||
options ^= RE_OPTION_POSIXLINE;
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case endline:
|
case endline:
|
||||||
|
@ -2804,7 +2786,7 @@ re_compile_fastmap(bufp)
|
||||||
fastmap[translate['\n']] = 1;
|
fastmap[translate['\n']] = 1;
|
||||||
else
|
else
|
||||||
fastmap['\n'] = 1;
|
fastmap['\n'] = 1;
|
||||||
if ((options & RE_OPTION_POSIXLINE) == 0 && bufp->can_be_null == 0)
|
if ((options & RE_OPTION_SINGLELINE) == 0 && bufp->can_be_null == 0)
|
||||||
bufp->can_be_null = 2;
|
bufp->can_be_null = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2889,7 +2871,7 @@ re_compile_fastmap(bufp)
|
||||||
case anychar_repeat:
|
case anychar_repeat:
|
||||||
case anychar:
|
case anychar:
|
||||||
for (j = 0; j < (1 << BYTEWIDTH); j++) {
|
for (j = 0; j < (1 << BYTEWIDTH); j++) {
|
||||||
if (j != '\n' || (options & RE_OPTION_POSIXLINE))
|
if (j != '\n' || (options & RE_OPTION_MULTILINE))
|
||||||
fastmap[j] = 1;
|
fastmap[j] = 1;
|
||||||
}
|
}
|
||||||
if (bufp->can_be_null) {
|
if (bufp->can_be_null) {
|
||||||
|
@ -3167,7 +3149,7 @@ re_search(bufp, string, size, startpos, range, regs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bufp->options & RE_OPTIMIZE_ANCHOR) {
|
if (bufp->options & RE_OPTIMIZE_ANCHOR) {
|
||||||
if (bufp->options&RE_OPTION_POSIXLINE) {
|
if (bufp->options&RE_OPTION_SINGLELINE) {
|
||||||
goto begbuf_match;
|
goto begbuf_match;
|
||||||
}
|
}
|
||||||
anchor = 1;
|
anchor = 1;
|
||||||
|
@ -3783,9 +3765,8 @@ re_match(bufp, string_arg, size, pos, regs)
|
||||||
d += mbclen(*d);
|
d += mbclen(*d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!(options&RE_OPTION_MULTILINE) &&
|
if (!(options&RE_OPTION_MULTILINE)
|
||||||
!(options&RE_OPTION_POSIXLINE) &&
|
&& (TRANSLATE_P() ? translate[*d] : *d) == '\n')
|
||||||
(TRANSLATE_P() ? translate[*d] : *d) == '\n')
|
|
||||||
goto fail;
|
goto fail;
|
||||||
SET_REGS_MATCHED;
|
SET_REGS_MATCHED;
|
||||||
d++;
|
d++;
|
||||||
|
@ -4132,20 +4113,8 @@ re_match(bufp, string_arg, size, pos, regs)
|
||||||
options &= ~RE_OPTION_IGNORECASE;
|
options &= ~RE_OPTION_IGNORECASE;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case mline_on:
|
case option_set:
|
||||||
options |= RE_OPTION_MULTILINE;
|
options = *p++;
|
||||||
continue;
|
|
||||||
|
|
||||||
case mline_off:
|
|
||||||
options &= ~RE_OPTION_MULTILINE;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case posix_on:
|
|
||||||
options |= RE_OPTION_POSIXLINE;
|
|
||||||
continue;
|
|
||||||
|
|
||||||
case posix_off:
|
|
||||||
options &= ~RE_OPTION_POSIXLINE;
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case wordbound:
|
case wordbound:
|
||||||
|
@ -4308,7 +4277,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
||||||
case finalize_push:
|
case finalize_push:
|
||||||
case jump:
|
case jump:
|
||||||
p1++;
|
p1++;
|
||||||
EXTRACT_NUMBER_AND_INCR (mcnt, p1);
|
EXTRACT_NUMBER_AND_INCR(mcnt, p1);
|
||||||
|
|
||||||
if (mcnt >= 0) break; /* should be backward jump */
|
if (mcnt >= 0) break; /* should be backward jump */
|
||||||
p1 += mcnt;
|
p1 += mcnt;
|
||||||
|
|
10
regex.h
10
regex.h
|
@ -69,12 +69,14 @@
|
||||||
#define RE_OPTION_IGNORECASE (1L)
|
#define RE_OPTION_IGNORECASE (1L)
|
||||||
/* perl-style extended pattern available */
|
/* perl-style extended pattern available */
|
||||||
#define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
|
#define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
|
||||||
/* newline will be included for ., ^ and $ ignore newline */
|
|
||||||
#define RE_OPTION_POSIXLINE (RE_OPTION_EXTENDED<<1)
|
|
||||||
/* newline will be included for . */
|
/* newline will be included for . */
|
||||||
#define RE_OPTION_MULTILINE (RE_OPTION_POSIXLINE<<1)
|
#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
|
||||||
|
/* ^ and $ ignore newline */
|
||||||
|
#define RE_OPTION_SINGLELINE (RE_OPTION_MULTILINE<<1)
|
||||||
|
/* works line Perl's /s; it's called POSIX for wrong reason */
|
||||||
|
#define RE_OPTION_POSIXLINE (RE_OPTION_MULTILINE|RE_OPTION_SINGLELINE)
|
||||||
/* search for longest match, in accord with POSIX regexp */
|
/* search for longest match, in accord with POSIX regexp */
|
||||||
#define RE_OPTION_LONGEST (RE_OPTION_MULTILINE<<1)
|
#define RE_OPTION_LONGEST (RE_OPTION_POSIXLINE<<1)
|
||||||
|
|
||||||
#define RE_MAY_IGNORECASE (RE_OPTION_LONGEST<<1)
|
#define RE_MAY_IGNORECASE (RE_OPTION_LONGEST<<1)
|
||||||
#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
|
#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
|
||||||
|
|
4
ruby.1
4
ruby.1
|
@ -6,7 +6,7 @@ ruby - Interpreted object-oriented scripting language
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B ruby \c
|
.B ruby \c
|
||||||
[ \c
|
[ \c
|
||||||
.BI -version \c
|
.BI --version \c
|
||||||
] [ \c
|
] [ \c
|
||||||
.BI -c \c
|
.BI -c \c
|
||||||
] [ \c
|
] [ \c
|
||||||
|
@ -48,7 +48,7 @@ ruby - Interpreted object-oriented scripting language
|
||||||
] [ \c
|
] [ \c
|
||||||
.BI -x "[directory]"\c
|
.BI -x "[directory]"\c
|
||||||
] [ \c
|
] [ \c
|
||||||
.BI -X "directory"\c
|
.BI -C "directory"\c
|
||||||
]
|
]
|
||||||
[ \c
|
[ \c
|
||||||
.BI -y \c
|
.BI -y \c
|
||||||
|
|
1
ruby.c
1
ruby.c
|
@ -641,7 +641,6 @@ proc_options(argc, argv)
|
||||||
addpath(getenv("RUBYLIB"));
|
addpath(getenv("RUBYLIB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
process_sflag();
|
process_sflag();
|
||||||
xflag = 0;
|
xflag = 0;
|
||||||
}
|
}
|
||||||
|
|
2
ruby.h
2
ruby.h
|
@ -455,7 +455,7 @@ void rb_warning __((const char*, ...)); /* reports if `-w' specified */
|
||||||
|
|
||||||
VALUE rb_each _((VALUE));
|
VALUE rb_each _((VALUE));
|
||||||
VALUE rb_yield _((VALUE));
|
VALUE rb_yield _((VALUE));
|
||||||
int rb_iterator_p _((void));
|
int rb_block_given_p _((void));
|
||||||
VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
||||||
VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
||||||
VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
|
||||||
|
|
149
sample/cal.rb
149
sample/cal.rb
|
@ -1,9 +1,10 @@
|
||||||
#! /usr/local/bin/ruby
|
#! /usr/local/bin/ruby
|
||||||
|
|
||||||
# cal.rb: Written by Tadayoshi Funaba 1998, 1999
|
# cal.rb: Written by Tadayoshi Funaba 1998-2000
|
||||||
# $Id: cal.rb,v 1.6 1999/09/15 05:35:25 tadf Exp $
|
# $Id: cal.rb,v 1.10 2000/05/20 02:09:47 tadf Exp $
|
||||||
|
|
||||||
require 'date2'
|
require 'date2'
|
||||||
|
require 'getopts'
|
||||||
|
|
||||||
$tab =
|
$tab =
|
||||||
{
|
{
|
||||||
|
@ -31,89 +32,81 @@ $tab =
|
||||||
$cc = 'gb'
|
$cc = 'gb'
|
||||||
|
|
||||||
def usage
|
def usage
|
||||||
$stderr.puts 'usage: cal [-c iso3166] [-jy] [[month] year]'
|
$stderr.puts 'usage: cal [-c iso3166] [-jmty] [[month] year]'
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def cal(m, y, sg)
|
def pict(y, m, sg)
|
||||||
for d in 1..31
|
d = (1..31).detect{|d| Date.exist?(y, m, d, sg)}
|
||||||
break if jd = Date.exist?(y, m, d, sg)
|
fi = Date.new3(y, m, d, sg)
|
||||||
end
|
fi -= (fi.jd - $k + 1) % 7
|
||||||
fst = cur = Date.new1(jd, sg)
|
|
||||||
ti = Date::MONTHNAMES[m]
|
ve = (fi..fi + 6).collect{|cu|
|
||||||
ti << ' ' << y.to_s unless $yr
|
%w(S M Tu W Th F S)[cu.wday]
|
||||||
mo = ti.center((($w + 1) * 7) - 1) << "\n"
|
}
|
||||||
mo << ['S', 'M', 'Tu', 'W', 'Th', 'F', 'S'].
|
ve += (fi..fi + 41).collect{|cu|
|
||||||
collect{|x| x.rjust($w)}.join(' ') << "\n"
|
if cu.mon == m then cu.send($da) end.to_s
|
||||||
mo << ' ' * (($w + 1) * fst.wday)
|
}
|
||||||
while cur.mon == fst.mon
|
|
||||||
mo << (if $jd then cur.yday else cur.mday end).to_s.rjust($w)
|
ve = ve.collect{|e| e.rjust($dw)}
|
||||||
mo << (if (cur += 1).wday != 0 then "\s" else "\n" end)
|
|
||||||
end
|
gr = group(ve, 7)
|
||||||
mo << "\n" * (6 - ((fst.wday + (cur - fst)) / 7))
|
gr = trans(gr) if $OPT_t
|
||||||
mo
|
ta = gr.collect{|xs| xs.join(' ')}
|
||||||
|
|
||||||
|
ca = %w(January February March April
|
||||||
|
May June July August
|
||||||
|
September October November December)[m - 1]
|
||||||
|
ca = ca + ' ' + y.to_s if not $OPT_y
|
||||||
|
ca = ca.center($mw)
|
||||||
|
|
||||||
|
ta.unshift(ca)
|
||||||
end
|
end
|
||||||
|
|
||||||
def zip(xs)
|
def group(xs, n)
|
||||||
yr = ''
|
(0..xs.size / n - 1).collect{|i| xs[i * n, n]}
|
||||||
until xs.empty?
|
|
||||||
ln = (if $jd then l, r, *xs = xs; [l, r]
|
|
||||||
else l, c, r, *xs = xs; [l, c, r] end).
|
|
||||||
collect{|x| x.split(/\n/no, -1)}
|
|
||||||
8.times do
|
|
||||||
yr << ln.collect{|x|
|
|
||||||
x.shift.ljust((($w + 1) * 7) - 1)}.join(' ') << "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
yr
|
|
||||||
end
|
end
|
||||||
|
|
||||||
while /^-([^-].*)$/no =~ $*[0]
|
def trans(xs)
|
||||||
a = $1
|
(0..xs[0].size - 1).collect{|i| xs.collect{|x| x[i]}}
|
||||||
if /^c(.+)?$/no =~ a
|
|
||||||
if $1
|
|
||||||
$cc = $1.downcase
|
|
||||||
elsif $*.length >= 2
|
|
||||||
$cc = $*[1].downcase
|
|
||||||
$*.shift
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
end
|
|
||||||
else
|
|
||||||
a.scan(/./no) do |c|
|
|
||||||
case c
|
|
||||||
when 'j'; $jd = true
|
|
||||||
when 'y'; $yr = true
|
|
||||||
else usage
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
$*.shift
|
|
||||||
end
|
end
|
||||||
$*.shift if /^--/no =~ $*[0]
|
|
||||||
usage if (sg = $tab[$cc]).nil?
|
def unite(xs)
|
||||||
case $*.length
|
if xs.empty? then [] else xs[0] + unite(xs[1..-1]) end
|
||||||
when 0
|
|
||||||
td = Date.today
|
|
||||||
m = td.mon
|
|
||||||
y = td.year
|
|
||||||
when 1
|
|
||||||
y = $*[0].to_i
|
|
||||||
$yr = true
|
|
||||||
when 2
|
|
||||||
m = $*[0].to_i
|
|
||||||
y = $*[1].to_i
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
end
|
end
|
||||||
usage unless m.nil? or (1..12) === m
|
|
||||||
|
def block(xs, n)
|
||||||
|
unite(group(xs, n).collect{|ys| trans(ys).collect{|zs| zs.join(' ')}})
|
||||||
|
end
|
||||||
|
|
||||||
|
def unlines(xs)
|
||||||
|
xs.collect{|x| x + "\n"}.join
|
||||||
|
end
|
||||||
|
|
||||||
|
usage unless getopts('jmty', "c:#{$cc}")
|
||||||
|
|
||||||
|
y, m = ARGV.indexes(1, 0).compact.collect{|x| x.to_i}
|
||||||
|
$OPT_y ||= (y and not m)
|
||||||
|
|
||||||
|
to = Date.today
|
||||||
|
y ||= to.year
|
||||||
|
m ||= to.mon
|
||||||
|
|
||||||
|
usage unless m >= 1 and m <= 12
|
||||||
usage unless y >= -4712
|
usage unless y >= -4712
|
||||||
$w = if $jd then 3 else 2 end
|
usage unless sg = $tab[$OPT_c]
|
||||||
unless $yr
|
|
||||||
print cal(m, y, sg)
|
$dw = if $OPT_j then 3 else 2 end
|
||||||
else
|
$mw = ($dw + 1) * 7 - 1
|
||||||
print y.to_s.center(((($w + 1) * 7) - 1) *
|
$mn = if $OPT_j then 2 else 3 end
|
||||||
(if $jd then 2 else 3 end) +
|
$tw = ($mw + 2) * $mn - 2
|
||||||
(if $jd then 2 else 4 end)), "\n\n",
|
|
||||||
zip((1..12).collect{|m| cal(m, y, sg)}), "\n"
|
$k = if $OPT_m then 1 else 0 end
|
||||||
end
|
$da = if $OPT_j then :yday else :mday end
|
||||||
|
|
||||||
|
print (if not $OPT_y
|
||||||
|
unlines(pict(y, m, sg))
|
||||||
|
else
|
||||||
|
y.to_s.center($tw) + "\n\n" +
|
||||||
|
unlines(block((1..12).collect{|m| pict(y, m, sg)}, $mn)) + "\n"
|
||||||
|
end)
|
||||||
|
|
|
@ -971,7 +971,6 @@ File.unlink "script_tmp.bak" or `/bin/rm -f "script_tmp.bak"`
|
||||||
$bad = false
|
$bad = false
|
||||||
for script in Dir["{lib,sample}/**/*.rb"]
|
for script in Dir["{lib,sample}/**/*.rb"]
|
||||||
unless `./miniruby -c #{script}`.chomp == "Syntax OK"
|
unless `./miniruby -c #{script}`.chomp == "Syntax OK"
|
||||||
p `./miniruby -c #{script}`.chomp
|
|
||||||
$bad = true
|
$bad = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
66
string.c
66
string.c
|
@ -898,12 +898,13 @@ rb_str_aref_m(argc, argv, str)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE arg1, arg2;
|
if (argc == 2) {
|
||||||
|
return rb_str_substr(str, NUM2INT(argv[0]), NUM2INT(argv[1]));
|
||||||
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
|
|
||||||
return rb_str_substr(str, NUM2INT(arg1), NUM2INT(arg2));
|
|
||||||
}
|
}
|
||||||
return rb_str_aref(str, arg1);
|
if (argc != 1) {
|
||||||
|
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
||||||
|
}
|
||||||
|
return rb_str_aref(str, argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1029,6 +1030,9 @@ rb_str_aset_m(argc, argv, str)
|
||||||
rb_str_replace(str, beg, len, argv[2]);
|
rb_str_replace(str, beg, len, argv[2]);
|
||||||
return argv[2];
|
return argv[2];
|
||||||
}
|
}
|
||||||
|
if (argc != 2) {
|
||||||
|
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
||||||
|
}
|
||||||
return rb_str_aset(str, argv[0], argv[1]);
|
return rb_str_aset(str, argv[0], argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,43 +1042,20 @@ rb_str_slice_bang(argc, argv, str)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE str;
|
VALUE str;
|
||||||
{
|
{
|
||||||
VALUE arg1, arg2;
|
VALUE result;
|
||||||
long pos, len;
|
VALUE buf[3];
|
||||||
|
int i;
|
||||||
|
|
||||||
rb_str_modify(str);
|
if (argc < 1 || 2 < argc) {
|
||||||
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
|
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
||||||
pos = NUM2LONG(arg1);
|
|
||||||
len = NUM2LONG(arg2);
|
|
||||||
delete_pos_len:
|
|
||||||
if (pos < 0) {
|
|
||||||
pos = RSTRING(str)->len + pos;
|
|
||||||
}
|
|
||||||
if (pos < 0 || RSTRING(str)->len <= pos) {
|
|
||||||
rb_raise(rb_eIndexError, "index %d out of string", pos);
|
|
||||||
}
|
|
||||||
arg2 = rb_str_substr(str, pos, len);
|
|
||||||
rb_str_replace(str, pos, len, rb_str_new(0,0));
|
|
||||||
return arg2;
|
|
||||||
}
|
}
|
||||||
|
for (i=0; i<argc; i++) {
|
||||||
if (!FIXNUM_P(arg1) && rb_range_beg_len(arg1, &pos, &len, RSTRING(str)->len, 0)) {
|
buf[i] = argv[i];
|
||||||
goto delete_pos_len;
|
|
||||||
}
|
}
|
||||||
|
buf[i] = rb_str_new(0,0);
|
||||||
pos = NUM2LONG(arg1);
|
result = rb_str_aref_m(2, buf, str);
|
||||||
len = RSTRING(str)->len;
|
rb_str_aset_m(3, buf, str);
|
||||||
|
return result;
|
||||||
if (pos >= len) return Qnil;
|
|
||||||
if (pos < 0) pos += len;
|
|
||||||
if (pos < 0) return Qnil;
|
|
||||||
|
|
||||||
arg2 = INT2FIX(RSTRING(str)->ptr[pos] & 0xff);
|
|
||||||
memmove(RSTRING(str)->ptr + pos,
|
|
||||||
RSTRING(str)->ptr + pos + 1,
|
|
||||||
RSTRING(str)->len - (pos + 1));
|
|
||||||
RSTRING(str)->len--;
|
|
||||||
|
|
||||||
return arg2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1107,7 +1088,7 @@ rb_str_sub_bang(argc, argv, str)
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
long plen;
|
long plen;
|
||||||
|
|
||||||
if (argc == 1 && rb_iterator_p()) {
|
if (argc == 1 && rb_block_given_p()) {
|
||||||
iter = 1;
|
iter = 1;
|
||||||
}
|
}
|
||||||
else if (argc == 2) {
|
else if (argc == 2) {
|
||||||
|
@ -1177,7 +1158,7 @@ str_gsub(argc, argv, str, bang)
|
||||||
char *buf, *bp, *cp;
|
char *buf, *bp, *cp;
|
||||||
int tainted = 0;
|
int tainted = 0;
|
||||||
|
|
||||||
if (argc == 1 && rb_iterator_p()) {
|
if (argc == 1 && rb_block_given_p()) {
|
||||||
iter = 1;
|
iter = 1;
|
||||||
}
|
}
|
||||||
else if (argc == 2) {
|
else if (argc == 2) {
|
||||||
|
@ -2545,7 +2526,7 @@ rb_str_scan(str, pat)
|
||||||
VALUE match = Qnil;
|
VALUE match = Qnil;
|
||||||
|
|
||||||
pat = get_pat(pat);
|
pat = get_pat(pat);
|
||||||
if (!rb_iterator_p()) {
|
if (!rb_block_given_p()) {
|
||||||
VALUE ary = rb_ary_new();
|
VALUE ary = rb_ary_new();
|
||||||
|
|
||||||
while (!NIL_P(result = scan_once(str, pat, &start))) {
|
while (!NIL_P(result = scan_once(str, pat, &start))) {
|
||||||
|
@ -2849,7 +2830,6 @@ Init_String()
|
||||||
|
|
||||||
rb_define_method(rb_cString, "slice", rb_str_aref_m, -1);
|
rb_define_method(rb_cString, "slice", rb_str_aref_m, -1);
|
||||||
rb_define_method(rb_cString, "slice!", rb_str_slice_bang, -1);
|
rb_define_method(rb_cString, "slice!", rb_str_slice_bang, -1);
|
||||||
rb_define_method(rb_cString, "delete_at", rb_str_slice_bang, -1);
|
|
||||||
|
|
||||||
to_str = rb_intern("to_s");
|
to_str = rb_intern("to_s");
|
||||||
|
|
||||||
|
|
6
struct.c
6
struct.c
|
@ -52,7 +52,7 @@ rb_struct_s_members(obj)
|
||||||
|
|
||||||
member = iv_get(obj, "__member__");
|
member = iv_get(obj, "__member__");
|
||||||
if (NIL_P(member)) {
|
if (NIL_P(member)) {
|
||||||
rb_bug("non-initialized struct");
|
rb_bug("uninitialized struct");
|
||||||
}
|
}
|
||||||
ary = rb_ary_new2(RARRAY(member)->len);
|
ary = rb_ary_new2(RARRAY(member)->len);
|
||||||
p = RARRAY(member)->ptr; pend = p + RARRAY(member)->len;
|
p = RARRAY(member)->ptr; pend = p + RARRAY(member)->len;
|
||||||
|
@ -81,9 +81,9 @@ rb_struct_getmember(obj, id)
|
||||||
|
|
||||||
member = iv_get(class_of(obj), "__member__");
|
member = iv_get(class_of(obj), "__member__");
|
||||||
if (NIL_P(member)) {
|
if (NIL_P(member)) {
|
||||||
rb_bug("non-initialized struct");
|
rb_bug("uninitialized struct");
|
||||||
}
|
}
|
||||||
slot = INT2NUM(id);
|
slot = ID2SYM(id);
|
||||||
for (i=0; i<RARRAY(member)->len; i++) {
|
for (i=0; i<RARRAY(member)->len; i++) {
|
||||||
if (RARRAY(member)->ptr[i] == slot) {
|
if (RARRAY(member)->ptr[i] == slot) {
|
||||||
return RSTRUCT(obj)->ptr[i];
|
return RSTRUCT(obj)->ptr[i];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define RUBY_VERSION "1.5.4"
|
#define RUBY_VERSION "1.5.4"
|
||||||
#define RUBY_RELEASE_DATE "2000-05-18"
|
#define RUBY_RELEASE_DATE "2000-05-24"
|
||||||
#define RUBY_VERSION_CODE 154
|
#define RUBY_VERSION_CODE 154
|
||||||
#define RUBY_RELEASE_CODE 20000518
|
#define RUBY_RELEASE_CODE 20000524
|
||||||
|
|
Loading…
Add table
Reference in a new issue