From 9b0f8ddc5c46cb59c8ee67ec483db29199d1d46c Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Wed, 24 Nov 1999 07:22:11 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'ruby_1_4_3_pre1'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/ruby_1_4_3_pre1@567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 123 +++ MANIFEST | 1 + Makefile.in | 2 + array.c | 25 +- configure | 176 +++-- configure.in | 26 +- dir.c | 167 +++- dln.c | 2 +- enum.c | 20 +- error.c | 23 +- eval.c | 43 +- ext/Win32API/Win32API.c | 16 +- ext/Win32API/depend | 1 - ext/curses/MANIFEST | 1 + ext/kconv/kconv.c | 2017 +++++++++++++++++++++++++++++++++++++++++++++++ ext/nkf/depend | 2 +- ext/nkf/nkf.c | 26 +- ext/pty/MANIFEST | 1 + ext/readline/MANIFEST | 1 + ext/sdbm/MANIFEST | 1 + ext/socket/extconf.rb | 6 +- ext/tcltklib/extconf.rb | 2 + ext/tk/lib/tkfont.rb | 15 +- hash.c | 10 +- intern.h | 8 +- io.c | 40 +- lib/debug.rb | 14 +- lib/net/pop.rb | 207 ++++- lib/net/session.rb | 267 ++++++- lib/net/smtp.rb | 103 ++- lib/pstore.rb | 33 +- lib/singleton.rb | 1 + marshal.c | 22 +- misc/ruby-mode.el | 7 +- node.h | 8 + process.c | 18 +- random.c | 12 +- re.c | 27 +- re.h | 3 + regex.c | 10 +- ruby.c | 11 +- rubytest.rb | 2 + sample/io.rb | 44 -- sample/mine.rb | 175 ---- sample/rename.rb | 297 ------- signal.c | 2 +- string.c | 21 +- version.h | 8 +- win32/config.status | 65 -- win32/ruby.def | 1 + win32/win32.c | 27 - 51 files changed, 3214 insertions(+), 926 deletions(-) delete mode 100644 ext/Win32API/depend create mode 100644 ext/kconv/kconv.c delete mode 100644 sample/io.rb delete mode 100644 sample/mine.rb delete mode 100644 sample/rename.rb delete mode 100644 win32/config.status diff --git a/ChangeLog b/ChangeLog index 900a94ea97..4ae0e2ae31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,122 @@ +Thu Nov 18 16:18:27 1999 Yukihiro Matsumoto + + * lib/pstore.rb: mutual lock by flock(2). + +Thu Nov 18 11:44:13 1999 Masahiro Tomita + + * io.c (read_all): should check bytes too. + +Mon Nov 15 16:50:34 1999 Yukihiro Matsumoto + + * enum.c (enum_grep): grep with block returns collection of + evaluated values of block over matched elements. + +Mon Nov 15 04:50:33 1999 Koji Arai + + * re.c (rb_reg_source): should not call rb_reg_expr_str() + everytime. + +Fri Nov 12 23:52:19 1999 Katsuyuki Komatsu + + * process.c (rb_f_system): argument check for NT, __EMX__, DJGPP. + +Wed Nov 10 21:54:11 1999 EGUCHI Osamu + + * hash.c (rb_any_cmp): Fixed return without value. + +Tue Nov 9 13:21:04 1999 EGUCHI Osamu + + * configure.in: AC_MINIX move to before AC_EXEEXT and AC_OBJEXT. + +Mon Nov 8 19:52:29 1999 EGUCHI Osamu + + * configure.in: Renamed AC_CHAR_UNSIGNED to AC_C_CHAR_UNSIGNED. + + * configure.in: Added default to AC_CHECK_SIZEOF(). + +Mon Nov 8 14:28:18 1999 Yukihiro Matsumoto + + * eval.c (rb_f_eval): fake outer scope when eval() called without + bindings. + + * eval.c (rb_f_binding): should copy last_class in the outer frame too. + +Sun Nov 7 18:31:04 1999 Yasuhiro Fukuma + + * eval.c (is_defined): last_class may be 0. + +Sat Nov 6 19:26:55 1999 EGUCHI Osamu + + * Makefile.in: Added depend entry make parse.@OBJEXT@ from parse.c + for UCB make + +Wed Nov 3 08:52:57 1999 Masaki Fukushima + + * io.c (Init_IO): forgot to use INT2FIX() around SEEK_SET, etc. + +Wed Nov 3 00:25:20 1999 Yukihiro Matsumoto + + * string.c (rb_str_split_method): use mbclen2() to handle kcode + option of regexp objects. + +Sun Oct 31 13:12:42 1999 WATANABE Hirofumi + + * regex.c (re_compile_pattern): wrong [\W] match. + +Thu Oct 28 13:35:40 1999 Yukihiro Matsumoto + + * string.c (rb_str_split_method): should be mbchar aware with + single char separators. + +Wed Oct 27 12:57:21 1999 Yukihiro Matsumoto + + * random.c (rb_f_srand): random seed should be unsigned. + +Tue Oct 26 19:20:54 1999 Koji Arai + + * marshal.c (r_object): should register class/module objects. + +Sat Oct 23 15:59:39 1999 Takaaki Tateishi + + * process.c (rb_f_system): should require at least one argument. + +Thu Oct 21 16:14:19 1999 Yukihiro Matsumoto + + * dir.c (fnmatch): use eban's fnmatch; do not depend on systems's + fnmatch (which may have portability problem) anymore. + +Wed Oct 20 15:14:24 1999 Yukihiro Matsumoto + + * marshal.c (marshal_load): should protect the generated object + table (arg->data) from GC. + +Mon Oct 18 16:15:52 1999 Yukihiro Matsumoto + + * ext/nkf/nkf.c (rb_nkf_kconv): output should be NUL terminated. + +Fri Oct 15 22:50:41 1999 WATANABE Hirofumi + + * error.c (sys_nerr): on CYGWIN, it is _sys_nerr. + +Fri Oct 15 01:32:31 1999 WATANABE Hirofumi + + * ext/Win32API/Win32API.c (Win32API_Call): need to use NUM2ULONG, + not NUM2INT. + +Tue Oct 12 22:29:04 1999 Yukihiro Matsumoto + + * eval.c (block_pass): should copy block to prevent modifications. + tag in the structure should be updated from latest prot_tag. + + * eval.c (proc_s_new): tag in struct BLOCK should not point into + unused stack. + + * io.c (io_read): length may be 0 or negative. + +Tue Oct 12 13:26:27 1999 Jun-ichiro itojun Hagino + + * signal.c (posix_signal): RETSIGTYPE may be void. + Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada * parse.y (rb_intern): should generate distinct ID_ATTRSET symbols @@ -16,6 +135,10 @@ Mon Oct 4 12:42:32 1999 Kazuhiko Izawa * pack.c (pack_unpack): % in printf format should be %%. +Wed Oct 6 17:13:19 1999 Nobuyoshi Nakada + + * ruby.c (addpath): rubylib_mangled_path() modified. + Mon Oct 4 10:01:40 1999 Yukihiro Matsumoto * variable.c (rb_obj_instance_variables): should always return diff --git a/MANIFEST b/MANIFEST index 335b570bed..c6f6ff37c8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -89,6 +89,7 @@ lib/Env.rb lib/README lib/base64.rb lib/cgi.rb +lib/cgi/session.rb lib/cgi-lib.rb lib/complex.rb lib/date.rb diff --git a/Makefile.in b/Makefile.in index e846d8d72f..5b66caa96b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -141,6 +141,8 @@ parse.c: parse.y $(YACC) $< mv -f y.tab.c parse.c +parse.@OBJEXT@: parse.c + alloca.@OBJEXT@: @srcdir@/missing/alloca.c $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c @srcdir@/missing/alloca.c diff --git a/array.c b/array.c index 9cc0ac1815..f3bd553872 100644 --- a/array.c +++ b/array.c @@ -280,6 +280,7 @@ VALUE rb_ary_pop(ary) VALUE ary; { + rb_ary_modify(ary); if (RARRAY(ary)->len == 0) return Qnil; if (RARRAY(ary)->len * 10 < RARRAY(ary)->capa && RARRAY(ary)->capa > ARY_DEFAULT_SIZE) { RARRAY(ary)->capa = RARRAY(ary)->len * 2; @@ -294,6 +295,7 @@ rb_ary_shift(ary) { VALUE top; + rb_ary_modify(ary); if (RARRAY(ary)->len == 0) return Qnil; top = RARRAY(ary)->ptr[0]; @@ -821,6 +823,7 @@ rb_ary_reverse(ary) VALUE *p1, *p2; VALUE tmp; + rb_ary_modify(ary); if (RARRAY(ary)->len == 0) return ary; p1 = RARRAY(ary)->ptr; @@ -940,22 +943,19 @@ rb_ary_delete_at(ary, at) VALUE ary; VALUE at; { - long i1, i2, pos; + long i, pos = NUM2LONG(at), len = RARRAY(ary)->len; VALUE del = Qnil; rb_ary_modify(ary); - pos = NUM2LONG(at); - for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) { - if (i1 == pos) { - del = RARRAY(ary)->ptr[i1]; - continue; - } - if (i1 != i2) { - RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1]; - } - i2++; + if (pos >= len) return Qnil; + if (pos < 0) pos += len; + if (pos < 0) return Qnil; + + del = RARRAY(ary)->ptr[pos]; + for (i = pos + 1; i < len; i++, pos++) { + RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i]; } - RARRAY(ary)->len = i2; + RARRAY(ary)->len = pos; return del; } @@ -1005,6 +1005,7 @@ static VALUE rb_ary_clear(ary) VALUE ary; { + rb_ary_modify(ary); RARRAY(ary)->len = 0; if (ARY_DEFAULT_SIZE*3 < RARRAY(ary)->capa) { RARRAY(ary)->capa = ARY_DEFAULT_SIZE * 2; diff --git a/configure b/configure index 462280501c..06cf738036 100644 --- a/configure +++ b/configure @@ -1175,13 +1175,64 @@ else fi +# checks for UNIX variants that set C preprocessor variables +ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 +echo "configure:1182: checking for minix/config.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1192: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + MINIX=yes +else + echo "$ac_t""no" 1>&6 +MINIX= +fi + +if test "$MINIX" = yes; then + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_1_SOURCE 2 +EOF + + cat >> confdefs.h <<\EOF +#define _MINIX 1 +EOF + +fi + + echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1180: checking for Cygwin environment" >&5 +echo "configure:1231: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -1209,19 +1260,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1213: checking for mingw32 environment" >&5 +echo "configure:1264: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1240,7 +1291,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1244: checking for executable suffix" >&5 +echo "configure:1295: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1250,7 +1301,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1271,13 +1322,13 @@ echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1275: checking for object suffix" >&5 +echo "configure:1326: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1295,64 +1346,13 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext -# checks for UNIX variants that set C preprocessor variables -ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 -echo "configure:1302: checking for minix/config.h" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1312: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - MINIX=yes -else - echo "$ac_t""no" 1>&6 -MINIX= -fi - -if test "$MINIX" = yes; then - cat >> confdefs.h <<\EOF -#define _POSIX_SOURCE 1 -EOF - - cat >> confdefs.h <<\EOF -#define _POSIX_1_SOURCE 2 -EOF - - cat >> confdefs.h <<\EOF -#define _MINIX 1 -EOF - -fi - - echo $ac_n "checking size of int""... $ac_c" 1>&6 echo "configure:1351: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_int=4 else cat > conftest.$ac_ext <&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_short=2 else cat > conftest.$ac_ext <&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_long=4 else cat > conftest.$ac_ext <&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_voidp=4 else cat > conftest.$ac_ext <&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_float=4 else cat > conftest.$ac_ext <&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } + ac_cv_sizeof_double=8 else cat > conftest.$ac_ext <&5 fi rb_cv_dlopen=yes ;; netbsd*) LDSHARED="ld -shared" + case "$host_cpu" in + alpha) + LDFLAGS="-export-dynamic" ;; + esac rb_cv_dlopen=yes ;; openbsd*) LDSHARED="ld -Bforcearchive -Bshareable" rb_cv_dlopen=yes ;; @@ -4093,7 +4097,7 @@ echo "configure:4028: checking whether OS depend dynamic link works" >&5 rb_cv_dlopen=yes ;; esac ;; bsdi*) LDSHARED="ld -shared" - LDFLAGS="-rdynamic -Wl,-rpath,/usr/local/lib/ruby/1.4/i386-bsdi4.0" + LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0' rb_cv_dlopen=yes ;; nextstep*) LDSHARED='cc -r -nostdlib' LDFLAGS="-u libsys_s" @@ -4141,12 +4145,12 @@ if test "$ac_cv_header_a_out_h" = yes; then if test "$with_dln_a_out" = yes || test "$rb_cv_dlopen" = unknown; then cat confdefs.h > config.h echo $ac_n "checking whether matz's dln works""... $ac_c" 1>&6 -echo "configure:4145: checking whether matz's dln works" >&5 +echo "configure:4149: checking whether matz's dln works" >&5 if eval "test \"`echo '$''{'rb_cv_dln_a_out'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4164: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* rb_cv_dln_a_out=yes else @@ -4263,7 +4267,7 @@ fi case "$host_os" in human*) echo $ac_n "checking for _harderr in -lsignal""... $ac_c" 1>&6 -echo "configure:4267: checking for _harderr in -lsignal" >&5 +echo "configure:4271: checking for _harderr in -lsignal" >&5 ac_lib_var=`echo signal'_'_harderr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4271,7 +4275,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsignal $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4310,7 +4314,7 @@ else fi echo $ac_n "checking for hmemset in -lhmem""... $ac_c" 1>&6 -echo "configure:4314: checking for hmemset in -lhmem" >&5 +echo "configure:4318: checking for hmemset in -lhmem" >&5 ac_lib_var=`echo hmem'_'hmemset | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4318,7 +4322,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lhmem $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4359,12 +4363,12 @@ fi for ac_func in select do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4363: checking for $ac_func" >&5 +echo "configure:4367: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4412,7 +4416,7 @@ fi done echo $ac_n "checking whether PD libc _dtos18 fail to convert big number""... $ac_c" 1>&6 -echo "configure:4416: checking whether PD libc _dtos18 fail to convert big number" >&5 +echo "configure:4420: checking whether PD libc _dtos18 fail to convert big number" >&5 if eval "test \"`echo '$''{'rb_cv_missing__dtos18'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4420,7 +4424,7 @@ else rb_cv_missing__dtos18=no else cat > conftest.$ac_ext < @@ -4432,7 +4436,7 @@ main () } EOF -if { (eval echo configure:4436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_missing__dtos18=yes else @@ -4454,7 +4458,7 @@ EOF fi echo $ac_n "checking whether PD libc fconvert fail to round""... $ac_c" 1>&6 -echo "configure:4458: checking whether PD libc fconvert fail to round" >&5 +echo "configure:4462: checking whether PD libc fconvert fail to round" >&5 if eval "test \"`echo '$''{'rb_cv_missing_fconvert'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4462,7 +4466,7 @@ else rb_cv_missing_fconvert=no else cat > conftest.$ac_ext < @@ -4475,7 +4479,7 @@ main () } EOF -if { (eval echo configure:4479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rb_cv_missing_fconvert=yes else diff --git a/configure.in b/configure.in index 00b6ff12ce..31018157eb 100644 --- a/configure.in +++ b/configure.in @@ -77,18 +77,18 @@ AC_CHECK_PROGS(AR, ar aal, ar) AC_PROG_LN_S AC_PROG_MAKE_SET -AC_EXEEXT -AC_OBJEXT - # checks for UNIX variants that set C preprocessor variables AC_MINIX -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(void*) -AC_CHECK_SIZEOF(float) -AC_CHECK_SIZEOF(double) +AC_EXEEXT +AC_OBJEXT + +AC_CHECK_SIZEOF(int, 4) +AC_CHECK_SIZEOF(short, 2) +AC_CHECK_SIZEOF(long, 4) +AC_CHECK_SIZEOF(void*, 4) +AC_CHECK_SIZEOF(float, 4) +AC_CHECK_SIZEOF(double, 8) AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes, [AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);], @@ -253,7 +253,7 @@ test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o" AC_C_BIGENDIAN AC_C_CONST -AC_CHAR_UNSIGNED +AC_C_CHAR_UNSIGNED AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign, [AC_TRY_RUN([ @@ -429,6 +429,10 @@ if test "$with_dln_a_out" != yes; then fi rb_cv_dlopen=yes ;; netbsd*) LDSHARED="ld -shared" + case "$host_cpu" in + alpha) + LDFLAGS="-export-dynamic" ;; + esac rb_cv_dlopen=yes ;; openbsd*) LDSHARED="ld -Bforcearchive -Bshareable" rb_cv_dlopen=yes ;; @@ -437,7 +441,7 @@ if test "$with_dln_a_out" != yes; then rb_cv_dlopen=yes ;; esac ;; bsdi*) LDSHARED="ld -shared" - LDFLAGS="-rdynamic -Wl,-rpath,/usr/local/lib/ruby/1.4/i386-bsdi4.0" + LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0' rb_cv_dlopen=yes ;; nextstep*) LDSHARED='cc -r -nostdlib' LDFLAGS="-u libsys_s" diff --git a/dir.c b/dir.c index 31116a9fff..a771534155 100644 --- a/dir.c +++ b/dir.c @@ -47,12 +47,6 @@ # endif #endif -#ifdef HAVE_FNMATCH_H -#include -#else -#include "missing/fnmatch.h" -#endif - #include #ifdef USE_CWGUSI # include @@ -66,6 +60,167 @@ char *getenv(); char *strchr _((char*,char)); #endif +#include + +#define FNM_NOESCAPE 0x01 +#define FNM_PATHNAME 0x02 +#define FNM_PERIOD 0x04 +#define FNM_NOCASE 0x08 + +#define FNM_NOMATCH 1 +#define FNM_ERROR 2 + +#define downcase(c) (nocase && isupper(c) ? tolower(c) : (c)) + +#if defined DOSISH +#define isdirsep(c) ((c) == '/' || (c) == '\\') +static char * +find_dirsep(s) + char *s; +{ + while (*s) { + if (isdirsep(*s)) + return s; + s++; + } + return 0; +} +#else +#define isdirsep(c) ((c) == '/') +#define find_dirsep(s) strchr(s, '/') +#endif + +static char * +range(pat, test, flags) + char *pat; + char test; + int flags; +{ + int not, ok = 0; + int nocase = flags & FNM_NOCASE; + int escape = !(flags & FNM_NOESCAPE); + + not = *pat == '!' || *pat == '^'; + if (not) + pat++; + + test = downcase(test); + + while (*pat) { + int cstart, cend; + cstart = cend = *pat++; + if (cstart == ']') + return ok == not ? 0 : pat; + else if (escape && cstart == '\\') + cstart = cend = *pat++; + if (*pat == '-' && pat[1] != ']') { + if (escape && pat[1] == '\\') + pat++; + cend = pat[1]; + if (!cend) + return 0; + pat += 2; + } + if (downcase(cstart) <= test && test <= downcase(cend)) + ok = 1; + } + return 0; +} + +#define PERIOD(s) (period && *(s) == '.' && \ + ((s) == string || pathname && isdirsep(*(s)))) +static int +fnmatch(pat, string, flags) + char *pat; + char *string; + int flags; +{ + int c; + int test; + char *s = string; + int escape = !(flags & FNM_NOESCAPE); + int pathname = flags & FNM_PATHNAME; + int period = flags & FNM_PERIOD; + int nocase = flags & FNM_NOCASE; + + while (c = *pat++) { + switch (c) { + case '?': + if (!*s || pathname && isdirsep(*s) || PERIOD(s)) + return FNM_NOMATCH; + s++; + break; + case '*': + while ((c = *pat++) == '*') + ; + + if (PERIOD(s)) + return FNM_NOMATCH; + + if (!c) { + if (pathname && find_dirsep(s)) + return FNM_NOMATCH; + else + return 0; + } + else if (pathname && isdirsep(c)) { + s = find_dirsep(s); + if (s) + break; + return FNM_NOMATCH; + } + + test = escape && c == '\\' ? *pat : c; + test = downcase(test); + pat--; + while (*s) { + if ((c == '[' || downcase(*s) == test) && + !fnmatch(pat, s, flags & ~FNM_PERIOD)) + return 0; + else if (pathname && isdirsep(*s)) + break; + s++; + } + return FNM_NOMATCH; + + case '[': + if (!*s || pathname && isdirsep(*s) || PERIOD(s)) + return FNM_NOMATCH; + pat = range(pat, *s, flags); + if (!pat) + return FNM_NOMATCH; + s++; + break; + + case '\\': + if (escape +#if defined DOSISH + && *pat && strchr("*?[\\", *pat) +#endif + ) { + c = *pat; + if (!c) + c = '\\'; + else + pat++; + } + /* FALLTHROUGH */ + + default: +#if defined DOSISH + if (pathname && isdirsep(c) && isdirsep(*s)) + ; + else +#endif + if(downcase(c) != downcase(*s)) + return FNM_NOMATCH; + s++; + break; + } + } + return !*s ? 0 : FNM_NOMATCH; +} + VALUE rb_cDir; static void diff --git a/dln.c b/dln.c index e6c7adde70..02ef484b36 100644 --- a/dln.c +++ b/dln.c @@ -80,7 +80,7 @@ int eaccess(); #endif #ifndef FUNCNAME_PATTERN -# if defined(__hp9000s300) || (defined(__NetBSD__) && (!defined(__alpha__) && !defined(__mips__))) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__) +# if defined(__hp9000s300) || (defined(__NetBSD__) && (!defined(__alpha__) && !defined(__mips__))) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__) # define FUNCNAME_PATTERN "_Init_%.200s" # else # define FUNCNAME_PATTERN "Init_%.200s" diff --git a/enum.c b/enum.c index dc7e2112a4..682c9f4318 100644 --- a/enum.c +++ b/enum.c @@ -33,11 +33,11 @@ grep_i(i, arg) } static VALUE -grep_iter_i(i, pat) - VALUE i, pat; +grep_iter_i(i, arg) + VALUE i, *arg; { - if (RTEST(rb_funcall(pat, id_eqq, 1, i))) { - rb_yield(i); + if (RTEST(rb_funcall(arg[0], id_eqq, 1, i))) { + rb_ary_push(arg[1], rb_yield(i)); } return Qnil; } @@ -46,19 +46,17 @@ static VALUE enum_grep(obj, pat) VALUE obj, pat; { + VALUE tmp, arg[2]; + + arg[0] = pat; arg[1] = tmp = rb_ary_new(); if (rb_iterator_p()) { - rb_iterate(rb_each, obj, grep_iter_i, pat); - return obj; + rb_iterate(rb_each, obj, grep_iter_i, (VALUE)arg); } else { - VALUE tmp, arg[2]; - - arg[0] = pat; arg[1] = tmp = rb_ary_new(); rb_iterate(rb_each, obj, grep_i, (VALUE)arg); - if (RARRAY(tmp)->len == 0) return Qnil; - return tmp; } + return tmp; } struct find_arg { diff --git a/error.c b/error.c index 6a48210b4e..feb3778d54 100644 --- a/error.c +++ b/error.c @@ -26,6 +26,13 @@ int sys_nerr = 256; #endif +#if defined __CYGWIN__ +# include +# if (CYGWIN_VERSION_API_MAJOR > 0) || (CYGWIN_VERSION_API_MINOR >= 8) +# define sys_nerr _sys_nerr +# endif +#endif + int ruby_nerrs; static void @@ -34,14 +41,20 @@ err_snprintf(buf, len, fmt, args) int len; va_list args; { + int n; + if (!ruby_sourcefile) { vsnprintf(buf, len, fmt, args); + return; + } + else if (ruby_sourceline == 0) { + n = snprintf(buf, len, "%s: ", ruby_sourcefile); } else { - int n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline); - if (len > n) { - vsnprintf((char*)buf+n, len-n, fmt, args); - } + n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline); + } + if (len > n) { + vsnprintf((char*)buf+n, len-n, fmt, args); } } @@ -432,7 +445,7 @@ static const syserr_index_entry syserr_index[]= { static VALUE *syserr_list; #endif -#ifndef NT +#if !defined NT && !defined sys_nerr extern int sys_nerr; #endif diff --git a/eval.c b/eval.c index f225bf47bd..c6c2b98cd3 100644 --- a/eval.c +++ b/eval.c @@ -292,10 +292,15 @@ rb_enable_super(klass, name) ID mid = rb_intern(name); body = search_method(klass, mid, &origin); - if (!body || !body->nd_body || origin != klass) { + if (!body) { print_undef(klass, mid); } - body->nd_noex &= ~NOEX_UNDEF; + if (!body->nd_body) { + remove_method(klass, mid); + } + else { + body->nd_noex &= ~NOEX_UNDEF; + } } static void @@ -1511,6 +1516,7 @@ is_defined(self, node, buf) case NODE_SUPER: case NODE_ZSUPER: if (ruby_frame->last_func == 0) return 0; + else if (ruby_frame->last_class == 0) return 0; else if (rb_method_boundp(RCLASS(ruby_frame->last_class)->super, ruby_frame->last_func, 0)) { if (nd_type(node) == NODE_SUPER) { @@ -1707,7 +1713,7 @@ call_trace_func(event, file, line, self, id, klass) prev = ruby_frame; PUSH_FRAME(); - *ruby_frame = *_frame.prev; + *ruby_frame = *prev; ruby_frame->prev = prev; if (file) { @@ -4369,7 +4375,7 @@ rb_f_eval(argc, argv, self) VALUE *argv; VALUE self; { - VALUE src, scope, vfile, vline; + VALUE src, scope, vfile, vline, val; char *file = "(eval)"; int line = 1; @@ -4383,6 +4389,19 @@ rb_f_eval(argc, argv, self) } Check_SafeStr(src); + if (NIL_P(scope) && ruby_frame->prev) { + struct FRAME *prev; + VALUE val; + + prev = ruby_frame; + PUSH_FRAME(); + *ruby_frame = *prev->prev; + ruby_frame->prev = prev; + val = eval(self, src, scope, file, line); + POP_FRAME(); + + return val; + } return eval(self, src, scope, file, line); } @@ -5310,6 +5329,7 @@ Init_eval() rb_define_global_function("untrace_var", rb_f_untrace_var, -1); rb_define_global_function("set_trace_func", set_trace_func, 1); + rb_global_variable(&trace_func); rb_define_virtual_variable("$SAFE", safe_getter, safe_setter); } @@ -5475,6 +5495,7 @@ rb_f_binding(self) frame_dup(&data->frame); if (ruby_frame->prev) { data->frame.last_func = ruby_frame->prev->last_func; + data->frame.last_class = ruby_frame->prev->last_class; } if (data->iter) { @@ -5549,6 +5570,7 @@ proc_s_new(klass) data->orig_thread = rb_thread_current(); data->iter = data->prev?Qtrue:Qfalse; + data->tag = 0; /* should not point into stack */ frame_dup(&data->frame); if (data->iter) { blk_copy_prev(data); @@ -5589,6 +5611,7 @@ proc_call(proc, args) VALUE proc, args; /* OK */ { struct BLOCK * volatile old_block; + struct BLOCK _block; struct BLOCK *data; volatile VALUE result = Qnil; int state; @@ -5600,7 +5623,8 @@ proc_call(proc, args) /* PUSH BLOCK from data */ old_block = ruby_block; - ruby_block = data; + _block = *data; + ruby_block = &_block; PUSH_ITER(ITER_CUR); ruby_frame->iter = ITER_CUR; @@ -5625,6 +5649,7 @@ proc_call(proc, args) } PUSH_TAG(PROT_NONE); + _block.tag = prot_tag; state = EXEC_TAG(); if (state == 0) { proc_set_safe_level(proc); @@ -5690,6 +5715,7 @@ block_pass(self, node) { VALUE block = rb_eval(self, node->nd_body); struct BLOCK * volatile old_block; + struct BLOCK _block; struct BLOCK *data; volatile VALUE result = Qnil; int state; @@ -5712,11 +5738,13 @@ block_pass(self, node) /* PUSH BLOCK from data */ old_block = ruby_block; - ruby_block = data; + _block = *data; + ruby_block = &_block; PUSH_ITER(ITER_PRE); ruby_frame->iter = ITER_PRE; PUSH_TAG(PROT_NONE); + _block.tag = prot_tag; state = EXEC_TAG(); if (state == 0) { proc_set_safe_level(block); @@ -5724,7 +5752,7 @@ block_pass(self, node) } POP_TAG(); POP_ITER(); - if (ruby_block->tag->dst == state) { + if (_block.tag->dst == state) { state &= TAG_MASK; orphan = 2; } @@ -6085,6 +6113,7 @@ thread_mark(th) rb_gc_mark(th->errinfo); rb_gc_mark(th->last_line); rb_gc_mark(th->last_match); + rb_gc_mark(th->trace); rb_mark_tbl(th->locals); /* mark data in copied stack */ diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index 9f75653132..8efb3ddad6 100644 --- a/ext/Win32API/Win32API.c +++ b/ext/Win32API/Win32API.c @@ -140,7 +140,7 @@ Win32API_Call(argc, argv, obj) obj_proc = rb_iv_get(obj, "__proc__"); - ApiFunction = (FARPROC)NUM2INT(obj_proc); + ApiFunction = (FARPROC)NUM2ULONG(obj_proc); obj_import = rb_iv_get(obj, "__import__"); obj_export = rb_iv_get(obj, "__export__"); @@ -159,7 +159,7 @@ Win32API_Call(argc, argv, obj) switch (timport) { case _T_NUMBER: case _T_INTEGER: - lParam = NUM2INT(rb_ary_entry(args, i)); + lParam = NUM2ULONG(rb_ary_entry(args, i)); #if defined(_MSC_VER) || defined(__LCC__) _asm { mov eax, lParam @@ -173,9 +173,15 @@ Win32API_Call(argc, argv, obj) break; case _T_POINTER: str = rb_ary_entry(args, i); - Check_Type(str, T_STRING); - rb_str_modify(str); - pParam = RSTRING(str)->ptr; + if (NIL_P(str)) { + pParam = 0; + } else if (FIXNUM_P(str)){ + pParam = (char *)NUM2ULONG(str); + } else { + Check_Type(str, T_STRING); + rb_str_modify(str); + pParam = RSTRING(str)->ptr; + } #if defined(_MSC_VER) || defined(__LCC__) _asm { mov eax, dword ptr pParam diff --git a/ext/Win32API/depend b/ext/Win32API/depend deleted file mode 100644 index b224bb66c9..0000000000 --- a/ext/Win32API/depend +++ /dev/null @@ -1 +0,0 @@ -Win32API.o : Win32API.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h diff --git a/ext/curses/MANIFEST b/ext/curses/MANIFEST index db5e54ffe8..e1a25d962d 100644 --- a/ext/curses/MANIFEST +++ b/ext/curses/MANIFEST @@ -1,5 +1,6 @@ MANIFEST curses.c +depend extconf.rb hello.rb rain.rb diff --git a/ext/kconv/kconv.c b/ext/kconv/kconv.c new file mode 100644 index 0000000000..969c2cb504 --- /dev/null +++ b/ext/kconv/kconv.c @@ -0,0 +1,2017 @@ +/** Network Kanji Filter. (PDS Version) +************************************************************************ +** Copyright (C) 1987, Fujitsu LTD. (Itaru ICHIKAWA) +** 連絡先: (株)富士通研究所 ソフト3研 市川 至 +** (E-Mail Address: ichikawa@flab.fujitsu.co.jp) +** Copyright (C) 1996 +** 連絡先: 琉球大学情報工学科 河野 真治 mine/X0208 support +** (E-Mail Address: kono@ie.u-ryukyu.ac.jp) +** 連絡先: COW for DOS & Win16 & Win32 & OS/2 +** (E-Mail Address: GHG00637@niftyserve.or.jp) +** 営利を目的としない限り、このソースのいかなる +** 複写,改変,修正も許諾します。その際には、この部分を残すこと。 +** このプログラムについては特に何の保証もしない、悪しからず。 +** Everyone is permitted to do anything on this program +** including copying, modifying, improving +** as long as you don't try to make money off it, +** or pretend that you wrote it. +** i.e., the above copyright notice has to appear in all copies. +** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. +***********************************************************************/ + +/*********************************************************************** +** 1996/03/10 modified for Kconv - by Ikuo Nakagawa +***********************************************************************/ +/*********************************************************************** +** 1996/12/18 modified for kconv(ruby) - by matz@ruby.club.or.jp +***********************************************************************/ + +static char *CopyRight = + "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),1996 S. Kono, COW"; +static char *Version = + "1.62"; +static char *Patchlevel = + "5/9612/Shinji Kono, COW matz"; + +#include "ruby.h" + +/* +** +** +** +** USAGE: nkf [flags] [file] +** +** Flags: +** b Output is bufferred (DEFAULT) +** u Output is unbufferred +** +** t no operation +** +** j Outout code is JIS 7 bit (DEFAULT SELECT) +** s Output code is MS Kanji (DEFAULT SELECT) +** e Output code is AT&T JIS (DEFAULT SELECT) +** l Output code is JIS 7bit and ISO8859-1 Latin-1 +** +** m MIME conversion for ISO-2022-JP +** i_ Output sequence to designate JIS-kanji (DEFAULT_J) +** o_ Output sequence to designate single-byte roman characters (DEFAULT_R) +** +** r {de/en}crypt ROT13/47 +** +** v display Version +** +** T Text mode output (for MS-DOS) +** +** x Do not convert X0201 kana into X0208 +** Z Convert X0208 alphabet to ASCII +** +** f60 fold option +** +** m MIME decode +** B try to fix broken JIS, missing Escape +** B[1-9] broken level +** +** O Output to 'nkf.out' file +** d Delete \r in line feed +** c Add \r in line feed +**/ +/******************************/ +/* デフォルトの出力コード選択 */ +/* Select DEFAULT_CODE */ +#define DEFAULT_CODE_JIS +/* #define DEFAULT_CODE_SJIS */ +/* #define DEFAULT_CODE_EUC */ +/******************************/ + +/* for Kconv: _AUTO, _EUC, _SJIS, _JIS */ +#define _AUTO 0 +#define _JIS 1 +#define _EUC 2 +#define _SJIS 3 +#define _BINARY 4 +#define _NOCONV 4 +#define _UNKNOWN _AUTO + +#if (defined(__TURBOC__) || defined(LSI_C)) && !defined(MSDOS) +#define MSDOS +#endif + +#include + +#if defined(MSDOS) || defined(__OS2__) +#include +#include +#include +#endif + +#ifdef MSDOS +#ifdef LSI_C +#define setbinmode(fp) fsetbin(fp) +#else /* Microsoft C, Turbo C */ +#define setbinmode(fp) setmode(fileno(fp), O_BINARY) +#endif +#else /* UNIX,OS/2 */ +#define setbinmode(fp) +#endif + +#ifdef _IOFBF /* SysV and MSDOS */ +#define setvbuffer(fp, buf, size) setvbuf(fp, buf, _IOFBF, size) +#else /* BSD */ +#define setvbuffer(fp, buf, size) setbuffer(fp, buf, size) +#endif + +/*Borland C++ 4.5 EasyWin*/ +#if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */ +#define EASYWIN +#include +#endif + +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif + +/* state of output_mode and input_mode */ + +#define ASCII 0 +#define X0208 1 +#define X0201 2 +#define NO_X0201 3 +#define JIS_INPUT 4 +#define SJIS_INPUT 5 +#define LATIN1_INPUT 6 +#define FIXED_MIME 7 +#define DOUBLE_SPACE -2 + +#define NL 0x0a +#define ESC 0x1b +#define SP 0x20 +#define AT 0x40 +#define SSP 0xa0 +#define DEL 0x7f +#define SI 0x0f +#define SO 0x0e +#define SSO 0x8e + +#define HOLD_SIZE 32 +#define IOBUF_SIZE 16384 + +#define DEFAULT_J 'B' +#define DEFAULT_R 'B' + +#define SJ0162 0x00e1 /* 01 - 62 ku offset */ +#define SJ6394 0x0161 /* 63 - 94 ku offset */ + + +/* MIME preprocessor */ + +#define _GETC() (inlen-- ? (int)(*inptr++) : EOF) +#define _UNGETC(c) (inlen++, *--inptr = (c)) +#define PUTCHAR(c) (outlen + 1 < outsiz ? \ + ((outptr[outlen++] = (c)), (outptr[outlen] = '\0')) : EOF) +#define GETC() ((!mime_mode)?_GETC():mime_getc()) +#define UNGETC(c) ((!mime_mode)?_UNGETC(c):mime_ungetc(c)) + +#ifdef EASYWIN /*Easy Win */ +extern POINT _BufferSize; +#endif + +/* buffers */ + +static unsigned char hold_buf[HOLD_SIZE*2]; +static int hold_count; +static unsigned char *inptr; +static int inlen; +static char *outptr; +static int outsiz; +static int outlen; + +/* MIME preprocessor fifo */ + +#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */ +#define MIME_BUF_MASK (MIME_BUF_SIZE-1) +#define Fifo(n) mime_buf[(n)&MIME_BUF_MASK] +static unsigned char mime_buf[MIME_BUF_SIZE]; +static unsigned int mime_top = 0; +static unsigned int mime_last = 0; /* decoded */ +static unsigned int mime_input = 0; /* undecoded */ + +/* flags */ +static int unbuf_f = FALSE; +static int estab_f = FALSE; +static int rot_f = FALSE; /* rot14/43 mode */ +static int input_f = FALSE; /* non fixed input code */ +static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */ +static int mime_f = FALSE; /* convert MIME B base64 or Q */ +static int mimebuf_f = FALSE; /* MIME buffered input */ +static int broken_f = FALSE; /* convert ESC-less broken JIS */ +static int iso8859_f = FALSE; /* ISO8859 through */ +#if defined(MSDOS) || defined(__OS2__) +static int x0201_f = TRUE; /* Assume JISX0201 kana */ +#else +static int x0201_f = NO_X0201; /* Assume NO JISX0201 */ +#endif + +/* X0208 -> ASCII converter */ + +static int c1_return; + +/* fold parameter */ +static int line = 0; /* chars in line */ +static int prev = 0; +static int fold_f = FALSE; +static int fold_len = 0; + +/* options */ +static char kanji_intro = DEFAULT_J, + ascii_intro = DEFAULT_R; + +/* Folding */ + +#define FOLD_MARGIN 10 +#define DEFAULT_FOLD 60 + +/* Global states */ +static int output_mode = ASCII, /* output kanji mode */ + input_mode = ASCII, /* input kanji mode */ + shift_mode = FALSE; /* TRUE shift out, or X0201 */ +static int mime_mode = FALSE; /* MIME mode B base64, Q hex */ + +/* X0208 -> ASCII translation table */ +/* X0201 / X0208 conversion tables */ + +/* X0201 kana conversion table */ +/* 90-9F A0-DF */ +static unsigned char cv[]= { +0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57, +0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21, +0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29, +0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43, +0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26, +0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d, +0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35, +0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d, +0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46, +0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c, +0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52, +0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e, +0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62, +0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69, +0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d, +0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c, +0x00,0x00}; + + +/* X0201 kana conversion table for daguten */ +/* 90-9F A0-DF */ +static unsigned char dv[]= { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e, +0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36, +0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e, +0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47, +0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53, +0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00}; + +/* X0201 kana conversion table for han-daguten */ +/* 90-9F A0-DF */ +static unsigned char ev[]= { +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54, +0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00}; + + +/* X0208 kigou conversion table */ +/* 0x8140 - 0x819e */ +static unsigned char fv[] = { +0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a, +0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00, +0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f, +0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27, +0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d, +0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00, +0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +} ; + + +/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */ + +static unsigned char *mime_pattern[] = { + (unsigned char *)"\075?ISO-8859-1?Q?", + (unsigned char *)"\075?ISO-2022-JP?B?", + (unsigned char *)"\075?ISO-2022-JP?Q?", + NULL +}; + +static int mime_encode[] = { + 'Q', 'B', 'Q', + 0 +}; + +static int add_cr = FALSE; +static int del_cr = FALSE; + +static void (*iconv) _((register int c2,register int c1)); /* s_iconv or oconv */ +static void (*oconv) _((register int c2,register int c1)); /* [ejs]_oconv */ +static int do_kconv _((VALUE, VALUE, int out_code, int in_code)); +static void h_conv _((register int c2,register int c1)); +static int push_hold_buf _((int c2,int c1)); +static void s_iconv _((register int c2,register int c1)); +static void e_oconv _((register int c2,register int c1)); +static void s_oconv _((register int c2,register int c1)); +static void j_oconv _((register int c2,register int c1)); +static int fold _((register int c2,register int c1)); +static int pre_convert _((register int c1,register int c2)); +static int mime_begin _((void)); +static int mime_getc _((void)); +static int mime_ungetc _((unsigned int c)); +static int mime_integrity _((unsigned char *p)); +static int base64decode _((int c)); + +#ifdef notdef +main (argc, argv) + int argc; + char **argv; +{ + register FILE *fin; + register char *cp; + +#ifdef EASYWIN /*Easy Win */ + _BufferSize.y = 400;/*Set Scroll Buffer Size*/ +#endif +#ifdef DEFAULT_CODE_JIS + oconv = j_oconv; /* DEFAULT Code is JIS */ +#endif +#ifdef DEFAULT_CODE_SJIS + oconv = s_oconv; /* DEFAULT Code is S-JIS */ +#endif +#ifdef DEFAULT_CODE_EUC + oconv = e_oconv; /* DEFAULT Code is EUC */ +#endif + + for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) { + cp = *argv; + while (*cp) { + switch (*cp++) { + case 'b': /* buffered mode */ + unbuf_f = FALSE; + continue; + case 'u': /* non bufferd mode */ + unbuf_f = TRUE; + continue; + case 'j': /* JIS output */ + case 'n': + oconv = j_oconv; + continue; + case 'e': /* AT&T EUC output */ + oconv = e_oconv; + continue; + case 's': /* SJIS output */ + oconv = s_oconv; + continue; + case 'l': /* ISO8859 Latin-1 support, no conversion */ + iso8859_f = TRUE; /* Only compatible with ISO-2022-JP */ + input_f = LATIN1_INPUT; + continue; + case 'i': /* Kanji IN ESC-$-@/B */ + if(*cp=='@'||*cp=='B') + kanji_intro = *cp++; + continue; + case 'o': /* ASCII IN ESC-(-J/B */ + if(*cp=='J'||*cp=='B'||*cp=='H') + ascii_intro = *cp++; + continue; + case 'r': + rot_f = TRUE; + continue; +#if defined(MSDOS) || defined(__OS2__) + case 'T': + binmode_f = FALSE; + continue; +#endif + case 'v': + usage(); + exit(1); + break; + /* Input code assumption */ + case 'J': /* JIS input */ + case 'E': /* AT&T EUC input */ + input_f = JIS_INPUT; + continue; + case 'S': /* MS Kanji input */ + input_f = SJIS_INPUT; + if(x0201_f==NO_X0201) x0201_f=TRUE; + continue; + case 'Z': /* Convert X0208 alphabet to asii */ + /* bit:0 Convert X0208 + bit:1 Convert Kankaku to one space + bit:2 Convert Kankaku to two spaces + */ + if('9'>= *cp && *cp>='0') + alpha_f |= 1<<(*cp++ -'0'); + else + alpha_f |= TRUE; + continue; + case 'x': /* Convert X0201 kana to X0208 or X0201 Conversion */ + x0201_f = FALSE; /* No X0201->X0208 conversion */ + /* accept X0201 + ESC-(-I in JIS, EUC, MS Kanji + SI/SO in JIS, EUC, MS Kanji + SSO in EUC, JIS, not in MS Kanji + MS Kanji (0xa0-0xdf) + output X0201 + ESC-(-I in JIS (0x20-0x5f) + SSO in EUC (0xa0-0xdf) + 0xa0-0xd in MS Kanji (0xa0-0xdf) + */ + continue; + case 'X': /* Assume X0201 kana */ + /* Default value is NO_X0201 for EUC/MS-Kanji mix */ + x0201_f = TRUE; + continue; + case 'f': /* folding -f60 or -f */ + fold_f = TRUE; + fold_len = atoi(cp); + if(!(0= *cp && *cp>='0') + broken_f |= 1<<(*cp++ -'0'); + else + broken_f |= TRUE; + continue; + case 'O':/* for Output file */ + file_out = TRUE; + continue; + case 'c':/* add cr code */ + add_cr = TRUE; + continue; + case 'd':/* delete cr code */ + del_cr = TRUE; + continue; + default: + /* bogus option but ignored */ + continue; + } + } + } + + if(iso8859_f && (oconv != j_oconv || !x0201_f )) { + fprintf(stderr,"Mixed ISO8859/JISX0201/SJIS/EUC output is not allowed.\n"); + exit(1); + } + + if(binmode_f == TRUE) +#ifdef __OS2__ + if(freopen("","wb",stdout) == NULL) + return (-1); +#else + setbinmode(stdout); +#endif + + if(unbuf_f) + setbuf (stdout, (char *) NULL); + else + setvbuffer (stdout, stdobuf, IOBUF_SIZE); + + if(argc == 0) { + if(binmode_f == TRUE) +#ifdef __OS2__ + if(freopen("","rb",stdin) == NULL) return (-1); +#else + setbinmode(stdin); +#endif + setvbuffer (stdin, stdibuf, IOBUF_SIZE); + convert (stdin); + } else { + while (argc--) { + if((fin = fopen (*argv++, "r")) == NULL) { + perror (*--argv); + return (-1); + } else { +/* reopen file for stdout */ + if(file_out == TRUE){ + if(argc == 1 ) { + if(freopen(*argv++, "w", stdout) == NULL) { + perror (*--argv); + return (-1); + } + argc--; + } else { + if(freopen("nkf.out", "w", stdout) == NULL) { + perror (*--argv); + return (-1); + } + } + if(binmode_f == TRUE) { +#ifdef __OS2__ + if(freopen("","wb",stdout) == NULL) + return (-1); +#else + setbinmode(stdout); +#endif + } + } + if(binmode_f == TRUE) +#ifdef __OS2__ + if(freopen("","rb",fin) == NULL) + return (-1); +#else + setbinmode(fin); +#endif + setvbuffer (fin, stdibuf, IOBUF_SIZE); + convert (fin); + fclose (fin); + } + } + } +#ifdef EASYWIN /*Easy Win */ + if(file_out == FALSE) + scanf("%d",&end_check); + else + fclose(stdout); +#else /* for Other OS */ + if(file_out == TRUE) + fclose(stdout); +#endif + return (0); +} +#endif /* notdef */ + +static int +do_kconv(in, out, out_code, in_code) + VALUE in, out; + int out_code, in_code; +{ + register int c1, c2; + + c2 = 0; + + inptr = (unsigned char *)RSTRING(in)->ptr; /* input buffer */ + inlen = RSTRING(in)->len; /* input buffer size*/ + outptr = RSTRING(out)->ptr; /* output buffer */ + outsiz = RSTRING(out)->len; /* output buffer size */ + outlen = 0; /* current length of output string */ + + if (inlen <= 0) { + return 0; + } + *outptr = '\0'; + + x0201_f = TRUE; /* don't assume JISX0201 kana */ + rot_f = FALSE; /* rot14/43 mode */ + input_f = FALSE; /* non fixed input code */ + alpha_f = FALSE; /* convert JISX0208 alphbet to ASCII */ + mime_f = TRUE; /* convert MIME base64 */ + broken_f = FALSE; /* convert ESC-less broken JIS */ + + switch (out_code) { + case _SJIS: + oconv = s_oconv; + break; + case _EUC: + oconv = e_oconv; + break; + default: + oconv = j_oconv; + break; + } + + switch (in_code) { + case _SJIS: + input_f = SJIS_INPUT; + x0201_f = TRUE; + break; + case _EUC: + case _JIS: + input_f = JIS_INPUT; + break; + default: + input_f = FALSE; + break; + } + + if(input_f == JIS_INPUT || input_f == LATIN1_INPUT) { + estab_f = TRUE; iconv = oconv; + } else if(input_f == SJIS_INPUT) { + estab_f = TRUE; iconv = s_iconv; + } else { + estab_f = FALSE; iconv = oconv; + } + input_mode = ASCII; + output_mode = ASCII; + shift_mode = FALSE; + mime_mode = FALSE; + +#define NEXT continue /* no output, get next */ +#define SEND ; /* output c1 and c2, get next */ +#define LAST break /* end of loop, go closing */ + + while ((c1 = GETC()) != EOF) { + if(!c2 && !input_mode && c1 DEL) { + /* in case of 8th bit is on */ + if(!estab_f) { + /* in case of not established yet */ + if(c1 > SSP) { + /* It is still ambiguious */ + h_conv (c2, c1); + c2 = 0; + NEXT; + } else if(c1 < AT) { + /* ignore bogus code */ + c2 = 0; + NEXT; + } else { + /* established */ + /* it seems to be MS Kanji */ + estab_f = TRUE; + iconv = s_iconv; + SEND; + } + } else + /* in case of already established */ + if(c1 < AT) { + /* ignore bogus code */ + c2 = 0; + NEXT; + } else + SEND; + } else + /* 7 bit code */ + /* it might be kanji shitfted */ + if((c1 == DEL) || (c1 <= SP)) { + /* ignore bogus first code */ + c2 = 0; + NEXT; + } else + SEND; + } else { + /* first byte */ + if(c1 > DEL) { + /* 8 bit code */ + if(!estab_f && !iso8859_f) { + /* not established yet */ + if(c1 < SSP) { + /* it seems to be MS Kanji */ + estab_f = TRUE; + iconv = s_iconv; + } else if(c1 < 0xe0) { + /* it seems to be EUC */ + estab_f = TRUE; + iconv = oconv; + } else { + /* still ambiguious */ + } + c2 = c1; + NEXT; + } else { /* estab_f==TRUE */ + if(iso8859_f) { + SEND; + } else if(SSP<=c1 && c1<0xe0 && iconv == s_iconv) { + /* SJIS X0201 Case... */ + /* This is too arrogant, but ... */ + if(x0201_f==NO_X0201) { + iconv = oconv; + c2 = c1; + NEXT; + } else + if(x0201_f) { + if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) { + /* look ahead for X0201/X0208conversion */ + if((c2 = GETC()) == EOF) { + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + LAST; + } else if(c2==(0xde)) { /* 濁点 */ + (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]); + c2=0; + NEXT; + } else if(c2==(0xdf)&&ev[(c1-SSP)*2]) { + /* 半濁点 */ + (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]); + c2=0; + NEXT; + } + UNGETC(c2); c2 = 0; + } + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + NEXT; + } else + SEND; + } else if(c1==SSO && iconv != s_iconv) { + /* EUC X0201 Case */ + /* This is too arrogant + if(x0201_f == NO_X0201) { + estab_f = FALSE; + c2 = 0; + NEXT; + } */ + c1 = GETC(); /* skip SSO */ + euc_1byte_check: + if(x0201_f && SSP<=c1 && c1<0xe0) { + if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) { + if((c2 = GETC()) == EOF) { + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + LAST; + } + /* forward lookup 濁点/半濁点 */ + if(c2 != SSO) { + UNGETC(c2); c2 = 0; + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + NEXT; + } else if((c2 = GETC()) == EOF) { + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + (*oconv)(0,SSO); + LAST; + } else if(c2==(0xde)) { /* 濁点 */ + (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]); + c2=0; + NEXT; + } else if(c2==(0xdf)&&ev[(c1-SSP)*2]) { + /* 半濁点 */ + (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]); + c2=0; + NEXT; + } else { + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + /* we have to check this c2 */ + /* and no way to push back SSO */ + c1 = c2; c2 = 0; + goto euc_1byte_check; + } + } + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + NEXT; + } else + SEND; + } else if(c1 < SSP && iconv != s_iconv) { + /* strange code in EUC */ + iconv = s_iconv; /* try SJIS */ + c2 = c1; + NEXT; + } else { + /* already established */ + c2 = c1; + NEXT; + } + } + } else if((c1 > SP) && (c1 != DEL)) { + /* in case of Roman characters */ + if(shift_mode) { + c1 |= 0x80; + /* output 1 shifted byte */ + if(x0201_f && (!iso8859_f||input_mode==X0201) && + SSP<=c1 && c1<0xe0 ) { + if(dv[(c1-SSP)*2]||ev[(c1-SSP)*2]) { + if((c2 = GETC()) == EOF) { + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + LAST; + } else if(c2==(0xde&0x7f)) { /* 濁点 */ + (*oconv)(dv[(c1-SSP)*2],dv[(c1-SSP)*2+1]); + c2=0; + NEXT; + } else if(c2==(0xdf&0x7f)&&ev[(c1-SSP)*2]) { + /* 半濁点 */ + (*oconv)(ev[(c1-SSP)*2],ev[(c1-SSP)*2+1]); + c2=0; + NEXT; + } + UNGETC(c2); c2 = 0; + } + (*oconv)(cv[(c1-SSP)*2],cv[(c1-SSP)*2+1]); + NEXT; + } else + SEND; + } else if(c1 == '(' && broken_f && input_mode == X0208 + && !mime_mode ) { + /* Try to recover missing escape */ + if((c1 = GETC()) == EOF) { + (*oconv) (0, '('); + LAST; + } else { + if(c1 == 'B' || c1 == 'J' || c1 == 'H') { + input_mode = ASCII; shift_mode = FALSE; + NEXT; + } else { + (*oconv) (0, '('); + /* do not modify various input_mode */ + /* It can be vt100 sequence */ + SEND; + } + } + } else if(input_mode == X0208) { + /* in case of Kanji shifted */ + c2 = c1; + NEXT; + /* goto next_byte */ + } else if(c1 == '=' && mime_f && !mime_mode ) { + if((c1 = _GETC()) == EOF) { + (*oconv) (0, '='); + LAST; + } else if(c1 == '?') { + /* =? is mime conversion start sequence */ + if(mime_begin() == EOF) /* check in detail */ + LAST; + else + NEXT; + } else { + (*oconv) (0, '='); + _UNGETC(c1); + NEXT; + } + } else if(c1 == '$' && broken_f && !mime_mode) { + /* try to recover missing escape */ + if((c1 = GETC()) == EOF) { + (*oconv) (0, '$'); + LAST; + } else if(c1 == '@'|| c1 == 'B') { + /* in case of Kanji in ESC sequence */ + input_mode = X0208; + shift_mode = FALSE; + NEXT; + } else { + /* sorry */ + (*oconv) (0, '$'); + (*oconv) (0, c1); + NEXT; + } + } else + SEND; + } else if(c1 == SI) { + shift_mode = FALSE; + NEXT; + } else if(c1 == SO) { + shift_mode = TRUE; + NEXT; + } else if(c1 == ESC ) { + if((c1 = GETC()) == EOF) { + (*oconv) (0, ESC); + LAST; + } else if(c1 == '$') { + if((c1 = GETC()) == EOF) { + (*oconv) (0, ESC); + (*oconv) (0, '$'); + LAST; + } else if(c1 == '@'|| c1 == 'B') { + /* This is kanji introduction */ + input_mode = X0208; + shift_mode = FALSE; + NEXT; + } else if(broken_f&0x2) { + input_mode = X0208; + shift_mode = FALSE; + NEXT; + } else { + (*oconv) (0, ESC); + (*oconv) (0, '$'); + (*oconv) (0, c1); + NEXT; + } + } else if(c1 == '(') { + if((c1 = GETC()) == EOF) { + (*oconv) (0, ESC); + (*oconv) (0, '('); + LAST; + } else { + if(c1 == 'I') { + /* This is X0201 kana introduction */ + input_mode = X0201; shift_mode = X0201; + NEXT; + } else if(c1 == 'B' || c1 == 'J' || c1 == 'H') { + /* This is X0208 kanji introduction */ + input_mode = ASCII; shift_mode = FALSE; + NEXT; + } else if(broken_f&0x2) { + input_mode = ASCII; shift_mode = FALSE; + NEXT; + } else { + (*oconv) (0, ESC); + (*oconv) (0, '('); + /* maintain various input_mode here */ + SEND; + } + } + } else { + /* lonely ESC */ + (*oconv) (0, ESC); + SEND; + } + } else if(c1 == NL && broken_f&4) { + input_mode = ASCII; + SEND; + } else + SEND; + } + /* send: */ + if(input_mode == X0208) + (*oconv) (c2, c1); /* this is JIS, not SJIS/EUC case */ + else + (*iconv) (c2, c1); /* can be EUC/SJIS */ + c2 = 0; + continue; + /* goto next_word */ + } + + /* epilogue */ + (*iconv) (EOF, 0); + return outlen; +} + + +static void +h_conv (c2, c1) + register int c1, + c2; +{ + register int wc; + + + /** it must NOT be in the kanji shifte sequence */ + /** it must NOT be written in JIS7 */ + /** and it must be after 2 byte 8bit code */ + + hold_count = 0; + push_hold_buf (c2, c1); + c2 = 0; + + while ((c1 = GETC()) != EOF) { + if(c2) { + /* second byte */ + if(!estab_f) { + /* not established */ + if(c1 > SSP) { + /* it is still ambiguious yet */ + SEND; + } else if(c1 < AT) { + /* ignore bogus first byte */ + c2 = 0; + SEND; + } else { + /* now established */ + /* it seems to be MS Kanji */ + estab_f = TRUE; + iconv = s_iconv; + SEND; + } + } else + SEND; + } else { + /* First byte */ + if(c1 > DEL) { + /* 8th bit is on */ + if(c1 < SSP) { + /* it seems to be MS Kanji */ + estab_f = TRUE; + iconv = s_iconv; + } else if(c1 < 0xe0) { + /* it seems to be EUC */ + estab_f = TRUE; + iconv = oconv; + } else { + /* still ambiguious */ + } + c2 = c1; + NEXT; + } else + /* 7 bit code , then send without any process */ + SEND; + } + /* send: */ + if((push_hold_buf (c2, c1) == EOF) || estab_f) + break; + c2 = 0; + continue; + } + + /** now, + ** 1) EOF is detected, or + ** 2) Code is established, or + ** 3) Buffer is FULL (but last word is pushed) + ** + ** in 1) and 3) cases, we continue to use + ** Kanji codes by oconv and leave estab_f unchanged. + **/ + + for (wc = 0; wc < hold_count; wc += 2) { + c2 = hold_buf[wc]; + c1 = hold_buf[wc+1]; + (*iconv) (c2, c1); + } + return; +} + + + +static int +push_hold_buf (c2, c1) + int c2, + c1; +{ + if(hold_count >= HOLD_SIZE*2) + return (EOF); + hold_buf[hold_count++] = c2; + hold_buf[hold_count++] = c1; + return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count); +} + + +static void +s_iconv (c2, c1) + register int c2, + c1; +{ + if((c2 == EOF) || (c2 == 0)) { + /* NOP */ + } else { + c2 = c2 + c2 - ((c2 <= 0x9f) ? SJ0162 : SJ6394); + if(c1 < 0x9f) + c1 = c1 - ((c1 > DEL) ? SP : 0x1f); + else { + c1 = c1 - 0x7e; + c2++; + } + } + (*oconv) (c2, c1); +} + + +static void +e_oconv (c2, c1) + register int c2, + c1; +{ + c2 = pre_convert(c1,c2); c1 = c1_return; + if(fold_f) { + switch(fold(c2,c1)) { + case '\n': + if(add_cr == TRUE) { + PUTCHAR('\r'); + c1 = '\n'; + } + PUTCHAR('\n'); + break; + case 0: return; + case '\r': + c1 = '\n'; c2 = 0; + break; + case '\t': + case ' ': + c1 = ' '; c2 = 0; + break; + } + } + if(c2==DOUBLE_SPACE) { + PUTCHAR(' '); PUTCHAR(' '); + return; + } + if(c2 == EOF) + return; + else if(c2 == 0 && (c1&0x80)) { + PUTCHAR(SSO); PUTCHAR(c1); + } else if(c2 == 0) { + if(c1 == '\n' && add_cr == TRUE) + PUTCHAR('\r'); + if(c1 != '\r') + PUTCHAR(c1); + else if(del_cr == FALSE) + PUTCHAR(c1); + } else { + if((c1<0x20 || 0x7e> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1))); + PUTCHAR((c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e))); + } +} + +static void +j_oconv (c2, c1) + register int c2, + c1; +{ + c2 = pre_convert(c1,c2); c1 = c1_return; + if(fold_f) { + switch(fold(c2,c1)) { + case '\n': + if(output_mode) { + PUTCHAR(ESC); + PUTCHAR('('); + PUTCHAR(ascii_intro); + } + if(add_cr == TRUE) { + PUTCHAR('\r'); + c1 = '\n'; + } + PUTCHAR('\n'); + output_mode = ASCII; + break; + case '\r': + c1 = '\n'; c2 = 0; + break; + case '\t': + case ' ': + c1 = ' '; c2 = 0; + break; + case 0: return; + } + } + if(c2 == EOF) { + if(output_mode) { + PUTCHAR(ESC); + PUTCHAR('('); + PUTCHAR(ascii_intro); + } + } else if(c2 == 0 && (c1 & 0x80)) { + if(input_mode==X0201 || !iso8859_f) { + if(output_mode!=X0201) { + PUTCHAR(ESC); + PUTCHAR('('); + PUTCHAR('I'); + output_mode = X0201; + } + c1 &= 0x7f; + } else { + /* iso8859 introduction, or 8th bit on */ + /* Can we convert in 7bit form using ESC-'-'-A ? + Is this popular? */ + } + PUTCHAR(c1); + } else if(c2 == 0) { + if(output_mode) { + PUTCHAR(ESC); + PUTCHAR('('); + PUTCHAR(ascii_intro); + output_mode = ASCII; + } + if(c1 == '\n' && add_cr == TRUE) + PUTCHAR('\r'); + if(c1 != '\r') + PUTCHAR(c1); + else if(del_cr == FALSE) + PUTCHAR(c1); + } else if(c2 == DOUBLE_SPACE) { + if(output_mode) { + PUTCHAR(ESC); + PUTCHAR('('); + PUTCHAR(ascii_intro); + output_mode = ASCII; + } + PUTCHAR(' '); + if(c1 == '\n' && add_cr == TRUE) + PUTCHAR('\r'); + if(c1 != '\r') + PUTCHAR(c1); + else if(del_cr == FALSE) + PUTCHAR(c1); + } else { + if(output_mode != X0208) { + PUTCHAR(ESC); + PUTCHAR('$'); + PUTCHAR(kanji_intro); + output_mode = X0208; + } + if(c1<0x20 || 0x7e0x80 Japanese (X0208/X0201) + <0x80 ASCII + \n new line + ' ' space + + This fold algorthm does not preserve heading space in a line. + This is the main difference from fmt. +*/ + +static int +fold(c2,c1) +register int c2,c1; +{ + int prev0; + if(c1=='\r') + return 0; /* ignore cr */ + if(c1== 8) { + if(line>0) line--; + return 1; + } + if(c2==EOF && line != 0) /* close open last line */ + return '\n'; + /* new line */ + if(c1=='\n') { + if(prev == c1) { /* duplicate newline */ + if(line) { + line = 0; + return '\n'; /* output two newline */ + } else { + line = 0; + return 1; + } + } else { + if(prev&0x80) { /* Japanese? */ + prev = c1; + return 0; /* ignore given single newline */ + } else if(prev==' ') { + return 0; + } else { + prev = c1; + if(++line<=fold_len) + return ' '; + else { + line = 0; + return '\r'; /* fold and output nothing */ + } + } + } + } + if(c1=='\f') { + prev = '\n'; + if(line==0) + return 1; + line = 0; + return '\n'; /* output newline and clear */ + } + /* X0208 kankaku or ascii space */ + if( (c2==0&&c1==' ')|| + (c2==0&&c1=='\t')|| + (c2==DOUBLE_SPACE)|| + (c2=='!'&& c1=='!')) { + if(prev == ' ') { + return 0; /* remove duplicate spaces */ + } + prev = ' '; + if(++line<=fold_len) + return ' '; /* output ASCII space only */ + else { + prev = ' '; line = 0; + return '\r'; /* fold and output nothing */ + } + } + prev0 = prev; /* we still need this one... , but almost done */ + prev = c1; + if(c2 || (SSP<=c1 && c1<=0xdf)) + prev |= 0x80; /* this is Japanese */ + line += (c2==0)?1:2; + if(line<=fold_len) { /* normal case */ + return 1; + } + if(line>=fold_len+FOLD_MARGIN) { /* too many kinsou suspension */ + line = (c2==0)?1:2; + return '\n'; /* We can't wait, do fold now */ + } + /* simple kinsoku rules return 1 means no folding */ + if(c2==0) { + if(c1==0xde) return 1; /* ゛*/ + if(c1==0xdf) return 1; /* ゜*/ + if(c1==0xa4) return 1; /* 。*/ + if(c1==0xa3) return 1; /* ,*/ + if(c1==0xa1) return 1; /* 」*/ + if(c1==0xb0) return 1; /* - */ + if(SSP<=c1 && c1<=0xdf) { /* X0201 */ + line = 1; + return '\n';/* add one new line before this character */ + } + /* fold point in ASCII { [ ( */ + if(( c1!=')'&& + c1!=']'&& + c1!='}'&& + c1!='.'&& + c1!=','&& + c1!='!'&& + c1!='?'&& + c1!='/'&& + c1!=':'&& + c1!=';')&& + ((prev0=='\n')|| (prev0==' ')|| /* ignored new line */ + (prev0&0x80)) /* X0208 - ASCII */ + ) { + line = 1; + return '\n';/* add one new line before this character */ + } + return 1; /* default no fold in ASCII */ + } else { + if(c2=='!') { + if(c1=='"') return 1; /* 、 */ + if(c1=='#') return 1; /* 。 */ + if(c1=='$') return 1; /* , */ + if(c1=='%') return 1; /* . */ + if(c1=='\'') return 1; /* + */ + if(c1=='(') return 1; /* ; */ + if(c1==')') return 1; /* ? */ + if(c1=='*') return 1; /* ! */ + if(c1=='+') return 1; /* ゛ */ + if(c1==',') return 1; /* ゜ */ + } + line = 2; + return '\n'; /* add one new line before this character */ + } +} + +static int +pre_convert(c1,c2) +register int c1,c2; +{ + if(c2) c1 &= 0x7f; + c1_return = c1; + if(c2==EOF) return c2; + c2 &= 0x7f; + if(rot_f) { + if(c2) { + c1 = rot47(c1); + c2 = rot47(c2); + } else { + if(!(c1 & 0x80)) + c1 = rot13(c1); + } + c1_return = c1; + } + /* JISX0208 Alphabet */ + if(alpha_f && c2 == 0x23 ) return 0; + /* JISX0208 Kigou */ + if(alpha_f && c2 == 0x21 ) { + if(0x21==c1) { + if(alpha_f&0x2) { + c1_return = ' '; + return 0; + } else if(alpha_f&0x4) { + c1_return = ' '; + return DOUBLE_SPACE; + } else { + return c2; + } + } else if(0x20' ';i++) { /* start at =? */ + if( ((r[i] = c1 = _GETC())==EOF) || nkf_toupper(c1) != p[i] ) { + /* pattern fails, try next one */ + q = p; + while (p = mime_pattern[++j]) { + for(k=2;k i */ + if(p[k]!=q[k]) break; + if(k==i && nkf_toupper(c1)==p[k]) break; + } + if(p) continue; /* found next one, continue */ + /* all fails, output from recovery buffer */ + _UNGETC(c1); + for(j=0;j> 4) & 0x03); + if(c2 != '=') { + Fifo(mime_last++) = cc; + cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f); + if(c3 != '=') { + Fifo(mime_last++) = cc; + cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f); + if(c4 != '=') + Fifo(mime_last++) = cc; + } + } else { + return c1; + } + return Fifo(mime_top++); +} + +static int +mime_ungetc(c) +unsigned int c; +{ + Fifo(mime_last++) = c; + return c; +} + + +static int +mime_integrity(p) +unsigned char *p; +{ + int c,d; + unsigned int q; + /* In buffered mode, read until =? or NL or buffer full + */ + mime_input = mime_top; + mime_last = mime_top; + while(*p) Fifo(mime_input++) = *p++; + d = 0; + q = mime_input; + while((c=_GETC())!=EOF) { + if(((mime_input-mime_top)&MIME_BUF_MASK)==0) break; + if(c=='=' && d=='?') { + /* checked. skip header, start decode */ + Fifo(mime_input++) = c; + mime_input = q; + return 1; + } + if(!( (c=='+'||c=='/'|| c=='=' || c=='?' || + ('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9')))) + break; + /* Should we check length mod 4? */ + Fifo(mime_input++) = c; + d=c; + } + /* In case of Incomplete MIME, no MIME decode */ + Fifo(mime_input++) = c; + mime_last = mime_input; /* point undecoded buffer */ + mime_mode = 1; /* no decode on Fifo last in mime_getc */ + return 1; +} + +static int +base64decode(c) + int c; +{ + int i; + if(c > '@') + if(c < '[') + i = c - 'A'; /* A..Z 0-25 */ + else + i = c - 'G' /* - 'a' + 26 */ ; /* a..z 26-51 */ + else if(c > '/') + i = c - '0' + '4' /* - '0' + 52 */ ; /* 0..9 52-61 */ + else if(c == '+') + i = '>' /* 62 */ ; /* + 62 */ + else + i = '?' /* 63 */ ; /* / 63 */ + return (i); +} + +#ifdef notdef +int +usage() +{ + fprintf(stderr,"USAGE: nkf(nkf32,wnkf,nkf2) -[flags] [in file] .. [out file for -O flag]\n"); + fprintf(stderr,"Flags:\n"); + fprintf(stderr,"b,u Output is bufferred (DEFAULT),Output is unbufferred\n"); +#ifdef DEFAULT_CODE_SJIS + fprintf(stderr,"j,s,e Outout code is JIS 7 bit, Shift JIS (DEFAULT), AT&T JIS (EUC)\n"); +#endif +#ifdef DEFAULT_CODE_JIS + fprintf(stderr,"j,s,e Outout code is JIS 7 bit (DEFAULT), Shift JIS, AT&T JIS (EUC)\n"); +#endif +#ifdef DEFAULT_CODE_EUC + fprintf(stderr,"j,s,e Outout code is JIS 7 bit, Shift JIS, AT&T JIS (EUC) (DEFAULT)\n"); +#endif + fprintf(stderr,"J,S,E Input assumption is JIS 7 bit , Shift JIS, AT&T JIS (EUC)\n"); + fprintf(stderr,"t no conversion\n"); + fprintf(stderr,"i_ Output sequence to designate JIS-kanji (DEFAULT B)\n"); + fprintf(stderr,"o_ Output sequence to designate ASCII (DEFAULT B)\n"); + fprintf(stderr,"r {de/en}crypt ROT13/47\n"); + fprintf(stderr,"v Show this usage\n"); + fprintf(stderr,"m[BQ] MIME decode [B:base64 stream,Q:quoted stream]\n"); + fprintf(stderr,"l ISO8859-1 (Latin-1) support\n"); + fprintf(stderr,"f Folding: -f60 or -f\n"); + fprintf(stderr,"Z[0-2] Convert X0208 alphabet to ASCII 1: Kankaku to space,2: 2 spaces\n"); + fprintf(stderr,"X,x Assume X0201 kana in MS-Kanji, -x preserves X0201\n"); + fprintf(stderr,"B[0-2] Broken input 0: missing ESC,1: any X on ESC-[($]-X,2: ASCII on NL\n"); +#ifdef MSDOS + fprintf(stderr,"T Text mode output\n"); +#endif + fprintf(stderr,"O Output to File (DEFAULT 'nkf.out')\n"); + fprintf(stderr,"d,c Delete \\r in line feed, Add \\r in line feed\n"); + fprintf(stderr,"Network Kanji Filter Version %s (%s) " +#if defined(MSDOS) && !defined(_Windows) + "for DOS" +#endif +#if !defined(__WIN32__) && defined(_Windows) + "for Win16" +#endif +#if defined(__WIN32__) && defined(_Windows) + "for Win32" +#endif +#ifdef __OS2__ + "for OS/2" +#endif + ,Version,Patchlevel); + fprintf(stderr,"\n%s\n",CopyRight); + return 0; +} +#endif /* notdef */ + +static VALUE +kconv_kconv(argc, argv) + int argc; + VALUE *argv; +{ + VALUE src, dst; + VALUE in, out; + int in_code, out_code; + char *codename = 0; + + rb_scan_args(argc, argv, "12", &src, &out, &in); + Check_Type(src, T_STRING); + + if (NIL_P(out)) { + codename = rb_get_kcode(); + goto codeselect; + } + else if (TYPE(out) == T_STRING) { + codename = RSTRING(out)->ptr; + codeselect: + switch (codename[0]) { + case 'E': case 'e': + out_code = _EUC; + break; + case 'S': case 's': + out_code = _SJIS; + break; + case 'J': case 'j': + default: + out_code = _JIS; + break; + } + } + else { + out_code = NUM2INT(out); + if (out_code == _NOCONV) return (VALUE)src; + } + if (NIL_P(in)) { + in_code = _AUTO; + } + else if (TYPE(in) == T_STRING) { + switch (RSTRING(in)->ptr[0]) { + case 'E': case 'e': + in_code = _EUC; + break; + case 'S': case 's': + in_code = _SJIS; + break; + case 'J': case 'j': + in_code = _JIS; + break; + default: + in_code = _AUTO; + break; + } + } + else { + in_code = NUM2INT(in); + if (in_code == _NOCONV) return (VALUE)src; + } + + dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ + RSTRING(dst)->len = do_kconv(src, dst, out_code, in_code); + + return dst; +} + +static VALUE +kconv_tojis(obj, src) + VALUE obj, src; +{ + VALUE dst; + + Check_Type(src, T_STRING); + + dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ + RSTRING(dst)->len = do_kconv(src, dst, _JIS, _AUTO); + + return dst; +} + +static VALUE +kconv_toeuc(obj, src) + VALUE obj, src; +{ + VALUE dst; + + Check_Type(src, T_STRING); + + dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ + RSTRING(dst)->len = do_kconv(src, dst, _EUC, _AUTO); + + return (VALUE)dst; +} + +static VALUE +kconv_tosjis(obj, src) + VALUE obj, src; +{ + VALUE dst; + + Check_Type(src, T_STRING); + + dst = str_new(0, RSTRING(src)->len*3+10); /* large enough? */ + RSTRING(dst)->len = do_kconv(src, dst, _SJIS, _AUTO); + + return dst; +} + +/* + * Character code detection - Algorithm described in: + * Ken Lunde. `Understanding Japanese Information Processing' + * O'Reilly & Associates, Sebastopol, CA. + */ + +static VALUE +kconv_guess(obj, src) + VALUE obj, src; +{ + unsigned char *p; + unsigned char *pend; + int sequence_counter = 0; + + Check_Type(src, T_STRING); + + p = RSTRING(src)->ptr; + pend = p + RSTRING(src)->len; + +#define INCR do {\ + p++;\ + if (p==pend) return INT2FIX(_UNKNOWN);\ + sequence_counter++;\ + if (sequence_counter % 2 == 1 && *p != 0xa4)\ + sequence_counter = 0;\ + if (6 <= sequence_counter) {\ + sequence_counter = 0;\ + return INT2FIX(_EUC);\ + }\ +} while (0) + + if (*p == 0xa4) + sequence_counter = 1; + + while (p= 0x40) { + if (*p >= 0x81) { + if (*p <= 0x8d || (0x8f <= *p && *p <= 0x9f)) { + return INT2FIX(_SJIS); + } + else if (0xfd <= *p && *p <= 0xfe) { + return INT2FIX(_EUC); + } + } + INCR; + } + } + else if (*p <= 0x9f) { + return INT2FIX(_SJIS); + } + } + else if (0xf0 <= *p && *p <= 0xfe) { + return INT2FIX(_EUC); + } + else if (0xe0 <= *p && *p <= 0xef) { + INCR; + if ((0x40 <= *p && *p <= 0x7e) || + (0x80 <= *p && *p <= 0xa0)) { + return INT2FIX(_SJIS); + } + if (0xfd <= *p && *p <= 0xfe) { + return INT2FIX(_EUC); + } + } + INCR; + } + return INT2FIX(_UNKNOWN); +} + +void +Init_kconv() +{ + VALUE mKconv = rb_define_module("Kconv"); + + rb_define_module_function(mKconv, "kconv", kconv_kconv, -1); + rb_define_module_function(mKconv, "tojis", kconv_tojis, 1); + rb_define_module_function(mKconv, "toeuc", kconv_toeuc, 1); + rb_define_module_function(mKconv, "tosjis", kconv_tosjis, 1); + rb_define_module_function(mKconv, "guess", kconv_guess, 1); + + rb_define_const(mKconv, "AUTO", INT2FIX(_AUTO)); + rb_define_const(mKconv, "JIS", INT2FIX(_JIS)); + rb_define_const(mKconv, "EUC", INT2FIX(_EUC)); + rb_define_const(mKconv, "SJIS", INT2FIX(_SJIS)); + rb_define_const(mKconv, "BINARY", INT2FIX(_BINARY)); + rb_define_const(mKconv, "NOCONV", INT2FIX(_NOCONV)); + rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN)); +} + +/** + ** パッチ制作者 + ** void@merope.pleiades.or.jp (Kusakabe Youichi) + ** NIDE Naoyuki + ** ohta@src.ricoh.co.jp (Junn Ohta) + ** inouet@strl.nhk.or.jp (Tomoyuki Inoue) + ** kiri@pulser.win.or.jp (Tetsuaki Kiriyama) + ** Kimihiko Sato + ** a_kuroe@kuroe.aoba.yokohama.jp (Akihiko Kuroe) + ** kono@ie.u-ryukyu.ac.jp (Shinji Kono) + ** GHG00637@nifty-serve.or.jp (COW) + ** j_kuro@pluto.ai.kyutech.ac.jp (Jun Kuroda) + ** + ** 最終更新日 + ** 1996.12.18 + **/ + +/* end */ diff --git a/ext/nkf/depend b/ext/nkf/depend index 645bc869c8..13e32e6074 100644 --- a/ext/nkf/depend +++ b/ext/nkf/depend @@ -1 +1 @@ -nkf.o : nkf.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h nkf1.7/nkf.c +nkf.o : nkf.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(srcdir)/nkf1.7/nkf.c diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c index 80d0d2e4be..b59688cb03 100644 --- a/ext/nkf/nkf.c +++ b/ext/nkf/nkf.c @@ -31,14 +31,12 @@ rb_nkf_putchar(c) { if (output_ctr >= o_len) { o_len += incsize; - rb_str_cat(dst, "", incsize); + rb_str_cat(dst, 0, incsize); + output = RSTRING(dst)->ptr; incsize *= 2; } - output[output_ctr++] = c; -/* -printf("[[%c][%c][%d]]\n", c, output[output_ctr - 1], output_ctr); -*/ + return c; } @@ -51,6 +49,7 @@ rb_nkf_kconv(obj, opt, src) { int i; char *opt_ptr, *opt_end; + volatile VALUE v; reinit(); opt_ptr = str2cstr(opt, &i); @@ -66,7 +65,8 @@ rb_nkf_kconv(obj, opt, src) input_ctr = 0; input = str2cstr(src, &i_len); - dst = rb_str_new(0, i_len*3 + 10); /* large enough? */ + dst = rb_str_new(0, i_len*3 + 10); + v = dst; output_ctr = 0; output = RSTRING(dst)->ptr; @@ -78,18 +78,8 @@ rb_nkf_kconv(obj, opt, src) } kanji_convert(NULL); - if (output_ctr > 0) output_ctr--; - if (output[output_ctr] == '\0') { -/* -printf("([%c][%d])\n", output[output_ctr], output_ctr); -*/ - RSTRING(dst)->len = output_ctr; - } else { -/* -printf("<[%c][%d]>\n", output[output_ctr], output_ctr); -*/ - RSTRING(dst)->len = output_ctr + 1; - } + RSTRING(dst)->ptr[output_ctr] = '\0'; + RSTRING(dst)->len = output_ctr; return dst; } diff --git a/ext/pty/MANIFEST b/ext/pty/MANIFEST index 5e5af7dd6b..f46d611e5b 100644 --- a/ext/pty/MANIFEST +++ b/ext/pty/MANIFEST @@ -3,6 +3,7 @@ README README.expect README.expect.jp README.jp +depend expect_sample.rb extconf.rb lib/expect.rb diff --git a/ext/readline/MANIFEST b/ext/readline/MANIFEST index f73a899abb..f8bfd1ea2c 100644 --- a/ext/readline/MANIFEST +++ b/ext/readline/MANIFEST @@ -1,4 +1,5 @@ MANIFEST README +depend extconf.rb readline.c diff --git a/ext/sdbm/MANIFEST b/ext/sdbm/MANIFEST index d0ed99ba77..8888e69ad4 100644 --- a/ext/sdbm/MANIFEST +++ b/ext/sdbm/MANIFEST @@ -1,5 +1,6 @@ MANIFEST _sdbm.c +depend extconf.rb init.c sdbm.h diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 47addfeff8..6975994ef8 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -148,7 +148,6 @@ EOF $CFLAGS="-DHAVE_SA_LEN "+$CFLAGS end -have_header("sys/sysctl.h") have_header("netinet/tcp.h") have_header("netinet/udp.h") @@ -160,6 +159,10 @@ if try_run(< #include +#ifndef AF_LOCAL +#define AF_LOCAL AF_UNIX +#endif + main() { int passive, gaierr, inet4 = 0, inet6 = 0; @@ -176,6 +179,7 @@ main() goto bad; } for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_family == AF_LOCAL) continue; if (ai->ai_addr == NULL || ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index e1086855ba..713cc811e5 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -21,6 +21,7 @@ def find_tcl(tcllib) find_library(tcllib, func, *paths) else find_library("tcl", func, *paths) or + find_library("tcl8.2", func, *paths) or find_library("tcl8.0", func, *paths) or find_library("tcl7.6", func, *paths) end @@ -33,6 +34,7 @@ def find_tk(tklib) find_library(tklib, func, *paths) else find_library("tk", func, *paths) or + find_library("tk8.2", func, *paths) or find_library("tk8.0", func, *paths) or find_library("tk4.2", func, *paths) end diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb index c680d166e7..2683260d69 100644 --- a/ext/tk/lib/tkfont.rb +++ b/ext/tk/lib/tkfont.rb @@ -667,7 +667,20 @@ class TkFont alias measure_core measure_core_tk8x alias metrics_core metrics_core_tk8x - when /^8\.1/ + when /^8\.[12]/ + alias create_latinfont create_latinfont_tk8x + alias create_kanjifont create_kanjifont_tk81 + alias create_compoundfont create_compoundfont_tk81 + alias actual_core actual_core_tk8x + alias configure_core configure_core_tk8x + alias configinfo_core configinfo_core_tk8x + alias delete_core delete_core_tk8x + alias latin_replace_core latin_replace_core_tk8x + alias kanji_replace_core kanji_replace_core_tk81 + alias measure_core measure_core_tk8x + alias metrics_core metrics_core_tk8x + + when /^8\.*/ alias create_latinfont create_latinfont_tk8x alias create_kanjifont create_kanjifont_tk81 alias create_compoundfont create_compoundfont_tk81 diff --git a/hash.c b/hash.c index a0d11c06dd..b06b3535ea 100644 --- a/hash.c +++ b/hash.c @@ -79,19 +79,17 @@ static int rb_any_cmp(a, b) VALUE a, b; { + VALUE args[2]; if (FIXNUM_P(a)) { if (FIXNUM_P(b)) return a != b; } else if (TYPE(a) == T_STRING) { if (TYPE(b) == T_STRING) return rb_str_cmp(a, b); } - else { - VALUE args[2]; - args[0] = a; - args[1] = b; - return !rb_with_disable_interrupt(eql, (VALUE)args); - } + args[0] = a; + args[1] = b; + return !rb_with_disable_interrupt(eql, (VALUE)args); } static int diff --git a/intern.h b/intern.h index 4bfefa2fd1..93fb5c2ffd 100644 --- a/intern.h +++ b/intern.h @@ -82,7 +82,7 @@ VALUE rb_singleton_class _((VALUE)); /* enum.c */ VALUE rb_enum_length _((VALUE)); /* error.c */ -extern int ruby_nerrs; +EXTERN int ruby_nerrs; VALUE rb_exc_new _((VALUE, const char*, long)); VALUE rb_exc_new2 _((VALUE, const char*)); VALUE rb_exc_new3 _((VALUE, VALUE)); @@ -210,6 +210,12 @@ VALUE rb_Array _((VALUE)); /* parse.y */ extern int ruby_sourceline; extern char *ruby_sourcefile; +#define yyparse rb_yyparse +#define yylex rb_yylex +#define yyerror rb_yyerror +#define yylval rb_yylval +#define yychar rb_yychar +#define yydebug rb_yydebug int yyparse _((void)); ID rb_id_attrset _((ID)); void rb_parser_append_print _((void)); diff --git a/io.c b/io.c index c1c7d511db..9d098b331a 100644 --- a/io.c +++ b/io.c @@ -426,7 +426,7 @@ read_all(port) TRAP_BEG; n = fread(RSTRING(str)->ptr+bytes, 1, siz-bytes, fptr->f); TRAP_END; - if (n == 0) { + if (n == 0 && bytes == 0) { if (feof(fptr->f)) return Qnil; rb_sys_fail(fptr->path); } @@ -452,15 +452,15 @@ io_fread(ptr, len, f) int c; while (n--) { + if (!READ_DATA_PENDING(f)) { + rb_thread_wait_fd(fileno(f)); + } c = getc(f); if (c == EOF) { *ptr = '\0'; break; } *ptr++ = c; - if (!READ_DATA_PENDING(f)) { - rb_thread_wait_fd(fileno(f)); - } } return len - n - 1; @@ -482,11 +482,15 @@ io_read(argc, argv, io) } len = NUM2INT(length); + if (len < 0) { + rb_raise(rb_eArgError, "negative length %d given", len); + } GetOpenFile(io, fptr); rb_io_check_readable(fptr); if (feof(fptr->f)) return Qnil; str = rb_str_new(0, len); + if (len == 0) return str; READ_CHECK(fptr->f); n = io_fread(RSTRING(str)->ptr, len, fptr->f); @@ -1088,7 +1092,7 @@ VALUE rb_io_binmode(io) VALUE io; { -#if defined(NT) || defined(DJGPP) || defined(__CYGWIN32__)\ +#if defined(NT) || defined(DJGPP) || defined(__CYGWIN__)\ || defined(__human68k__) || defined(USE_CWGUSI) || defined(__EMX__) OpenFile *fptr; @@ -1334,7 +1338,7 @@ rb_file_sysopen(fname, flags, mode) return rb_file_sysopen_internal(rb_cFile, fname, flags, mode); } -#if defined (NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) +#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) static struct pipe_list { OpenFile *fptr; struct pipe_list *next; @@ -1393,7 +1397,7 @@ static void pipe_finalize(fptr) OpenFile *fptr; { -#if !defined (__CYGWIN32__) +#if !defined (__CYGWIN__) if (fptr->f != NULL) { pclose(fptr->f); } @@ -1524,7 +1528,7 @@ pipe_open(pname, mode) if (fptr->f) fptr->f2 = f; else fptr->f = f; } -#if defined (__CYGWIN32__) +#if defined (__CYGWIN__) fptr->finalize = pipe_finalize; pipe_add_fptr(fptr); #endif @@ -2283,13 +2287,13 @@ next_argv() fstat(fileno(fr), &st); if (*ruby_inplace_mode) { str = rb_str_new2(fn); -#if defined(MSDOS) || defined(__CYGWIN32__) || defined(NT) +#if defined(MSDOS) || defined(__CYGWIN__) || defined(NT) ruby_add_suffix(str, ruby_inplace_mode); #else rb_str_cat(str, ruby_inplace_mode, strlen(ruby_inplace_mode)); #endif -#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN32__) || defined(NT) || defined(__human68k__) || defined(__EMX__) +#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__) (void)fclose(fr); (void)unlink(RSTRING(str)->ptr); (void)rename(fn, RSTRING(str)->ptr); @@ -2304,7 +2308,7 @@ next_argv() #endif } else { -#if !defined(MSDOS) && !defined(__BOW__) && !defined(__CYGWIN32__) && !defined(NT) && !defined(__human68k__) +#if !defined(MSDOS) && !defined(__BOW__) && !defined(__CYGWIN__) && !defined(NT) && !defined(__human68k__) if (unlink(fn) < 0) { rb_warn("Can't remove %s: %s, skipping file", fn, strerror(errno)); @@ -2316,7 +2320,7 @@ next_argv() #endif } fw = rb_fopen(fn, "w"); -#if !defined(MSDOS) && !defined(__CYGWIN32__) && !(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__) +#if !defined(MSDOS) && !defined(__CYGWIN__) && !(NT) && !defined(__human68k__) && !defined(USE_CWGUSI) && !defined(__BEOS__) && !defined(__EMX__) fstat(fileno(fw), &st2); fchmod(fileno(fw), st.st_mode); if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) { @@ -2623,7 +2627,7 @@ rb_io_ctl(io, req, arg, io_p) int io_p; { #if !defined(MSDOS) && !defined(__human68k__) - int cmd = NUM2INT(req); + int cmd = NUM2ULONG(req); OpenFile *fptr; int len = 0; int fd; @@ -2669,7 +2673,7 @@ rb_io_ctl(io, req, arg, io_p) fd = fileno(fptr->f); #ifdef HAVE_FCNTL TRAP_BEG; -# ifdef USE_CWGUSI +# if defined(USE_CWGUSI) || defined(__CYGWIN__) retval = io_p?ioctl(fd, cmd, (void*) narg):fcntl(fd, cmd, narg); # else retval = io_p?ioctl(fd, cmd, narg):fcntl(fd, cmd, narg); @@ -3250,9 +3254,9 @@ Init_IO() rb_define_method(rb_cIO, "flush", rb_io_flush, 0); rb_define_method(rb_cIO, "tell", rb_io_tell, 0); rb_define_method(rb_cIO, "seek", rb_io_seek, 2); - rb_define_const(rb_cIO, "SEEK_SET", SEEK_SET); - rb_define_const(rb_cIO, "SEEK_CUR", SEEK_CUR); - rb_define_const(rb_cIO, "SEEK_END", SEEK_END); + rb_define_const(rb_cIO, "SEEK_SET", INT2FIX(SEEK_SET)); + rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR)); + rb_define_const(rb_cIO, "SEEK_END", INT2FIX(SEEK_END)); rb_define_method(rb_cIO, "rewind", rb_io_rewind, 0); rb_define_method(rb_cIO, "pos", rb_io_tell, 0); rb_define_method(rb_cIO, "pos=", rb_io_set_pos, 1); @@ -3330,7 +3334,7 @@ Init_IO() rb_define_virtual_variable("$-i", opt_i_get, opt_i_set); -#if defined (NT) || defined(DJGPP) || defined(__CYGWIN32__) || defined(__human68k__) +#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) atexit(pipe_atexit); #endif diff --git a/lib/debug.rb b/lib/debug.rb index d2f1da83ff..f257e0c777 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -25,6 +25,8 @@ class DEBUGGER__ @last_file = nil @last = [nil, nil] @scripts = {} + @no_step = nil + @finish_pos = 0 end DEBUG_LAST_CMD = [] @@ -254,9 +256,13 @@ class DEBUGGER__ STDOUT.printf "#%d %s\n", frame_pos, info when /^fi(?:nish)?$/ - @finish_pos = @frames.size - frame_pos - frame_pos = 0 - return + if frame_pos == 0 + STDOUT.print "\"finish\" not meaningful in the outermost frame.\n" + else + @finish_pos = @frames.size - frame_pos + frame_pos = 0 + return + end when /^q(?:uit)?$/ input = readline("really quit? (y/n) ", false) @@ -383,10 +389,10 @@ class DEBUGGER__ @frames.unshift binding when 'return', 'end' + @frames.shift if @frames.size == @finish_pos @stop_next = 1 end - @frames.shift when 'raise' excn_handle(file, line, id, binding) diff --git a/lib/net/pop.rb b/lib/net/pop.rb index bd4551571d..c492a4cd20 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -1,8 +1,14 @@ -# -# pop.rb version 1.0.1 -# -# author: Minero Aoki -# +=begin + += Net module version 1.0.2 reference manual + +pop.rb written by Minero Aoki + +This library is distributed under the terms of Ruby style license. +You can freely distribute/modify/copy this file. + +=end + require 'net/session' require 'md5' @@ -10,8 +16,44 @@ require 'md5' module Net +=begin + +== Net::POP3Session + +=== Super Class + +Net::Session + +=== Class Methods + +: new( address = 'localhost', port = 110 ) + + This method create a new POP3Session object but this will not open connection. + +=end + class POP3Session < Session + +=begin + +=== Methods + +: start( account, password ) + + This method start POP session. + +: each{|popmail| ...} + + This method is equals to "POP3Session.mails.each" + +: mails + + This method returns an array of POP3Session::POPMail. + This array is renewed when login. + +=end + attr :mails def each() @mails.each{|m| yield m} end @@ -44,6 +86,17 @@ module Net end +=begin + +== Net::POP3Session::POPMail + +A class of mail which exists on POP server. + +=== Super Class + +Object + +=end class POPMail @@ -55,6 +108,39 @@ module Net @deleted = false end +=begin + +=== Method + +: all +: pop +: mail + + This method fetches a mail and return it. + +: header + + This method fetches only mail header. + +: top( lines ) + + This method fetches mail header and 'lines' lines body. + +: delete +: delete! + + This method deletes mail. + +: size + + size of mail(bytes) + +: deleted? + + true if mail was deleted + +=end + attr :size def all( dest = '' ) @@ -83,8 +169,23 @@ module Net end - end + end # POP3Session + + POPSession = POP3Session + POP3 = POP3Session + +=begin + +== Net::APOP3Session + +This class has no new methods. Only way of authetication is changed. + +=== Super Class + +Net::POP3Session + +=end class APOPSession < POP3Session @@ -95,14 +196,85 @@ module Net end + APOP = APOPSession - POPSession = POP3Session - POP3 = POP3Session +=begin + +== Net::POP3Command + +POP3 protocol class. + +=== Super Class + +Net::Command + +=== Class Methods +: new( socket ) + + This method creates new POP3Command object. 'socket' must be ProtocolSocket. + +=end class POP3Command < Command + +=begin + +=== Methods + +: auth( account, password ) + + This method do POP authorization (no RPOP) + In case of failed authorization, raises Protocol::ProtocolError exception. + +: list + + a list of mails which existing on server. + The list is an array like "array[ number ] = size". + + ex: + + The list from server is + + 1 2452 + 2 3355 + 4 9842 + : + + then, an array is + + [ nil, 2452, 3355, nil, 9842, ... ] + +: quit + + This method finishes POP3 session. + +: rset + + This method reset all changes done in current session, + by sending 'RSET' command. + +: top( num, lines = 0 ) + + This method gets all mail header and 'lines' lines body + by sending 'TOP' command. 'num' is mail number. + + WARNING: the TOP command is 'Optional' in RFC1939 (POP3) + + +: retr( num : Integer ) + + This method gets a mail by 'RETR' command. 'num' is mail number. + + +: dele( num : Integer ) + + This method deletes a mail on server by 'DELE'. + +=end + def auth( acnt, pass ) @socket.writeline( 'USER ' + acnt ) check_reply_auth @@ -190,6 +362,23 @@ module Net end +=begin + +== APOPCommand + +=== Super Class + +POP3 + +=== Methods + +: auth( account, password ) + + This method do authorization by sending 'APOP' command. + If server is not APOP server, this raises Net::ProtoAuthError exception. + On other errors, raises Net::ProtocolError. + +=end class APOPCommand < POP3Command @@ -223,7 +412,7 @@ module Net end - unless Session::Version == '1.0.1' then + unless Session::Version == '1.0.2' then $stderr.puts "WARNING: wrong version of session.rb & pop.rb" end diff --git a/lib/net/session.rb b/lib/net/session.rb index b0977e7e14..3f7ef7f51f 100644 --- a/lib/net/session.rb +++ b/lib/net/session.rb @@ -1,8 +1,14 @@ -# -# session.rb version 1.0.1 -# -# author: Minero Aoki -# +=begin + += Net module version 1.0.2 reference manual + +session.rb written by Minero Aoki + +This library is distributed under the terms of Ruby style license. +You can freely distribute/modify/copy this file. + +=end + require 'socket' @@ -19,16 +25,47 @@ class String end +=begin -module Net +== Net::Session + +the abstruct class for Internet session + +=== Super Class + +Object + +=== Constants + +: Version + + The version of Session class. It is a string like "1.0.2". + +=end - DEBUG = $DEBUG - # DEBUG = false +module Net class Session - Version = '1.0.1' + Version = '1.0.2' + +=begin + +=== Class Methods + +: new( address = 'localhost', port = nil ) + + This method Create a new Session object. + +: start( address = 'localhost', port = nil, *args ) +: start( address = 'localhost', port = nil, *args ){|session| .... } + + This method create a new Session object and start session. + If you call this method with block, Session object give itself + to block and finish session when block returns. + +=end def initialize( addr = 'localhost', port = nil ) proto_initialize @@ -50,6 +87,19 @@ module Net end end +=begin + +=== Methods + +: address + + the address of connecting server (FQDN). + +: port + + connecting port number + +=end attr :address attr :port @@ -59,21 +109,45 @@ module Net attr :proto_type attr :proto, true +=begin + +: start( *args ) + + This method start session. If you call this method when the session + is already started, this only returns false without doing anything. + + '*args' are specified in subclasses. + +: finish + + This method finish session. If you call this method before session starts, + it only return false without doing anything. + +: active? + + true if session have been started + +=end + def start( *args ) return false if active? + @active = true if ProtocolSocket === args[0] then @socket = args.shift + @socket.pipe = @pipe else - @socket = ProtocolSocket.open( @address, @port ) + @socket = ProtocolSocket.open( @address, @port, @pipe ) end + @pipe = nil + @proto = @proto_type.new( @socket ) do_start( *args ) - - @active = true end def finish + @active = false + if @proto then do_finish @proto = nil @@ -86,9 +160,36 @@ module Net def active?() @active end + def set_pipe( arg ) + @pipe = arg + end + end +=begin + +== Net::Command + +=== Super Class + +Object + +=== Class Methods + +: new( socket ) + + This method create new Command object. 'socket' must be ProtocolSocket. + This method is abstract class. + + +=== Methods + +: quit + + This method finishes protocol. + +=end class Command @@ -181,12 +282,28 @@ MES end +=begin + +== Net::ProtocolSocket + +=== Super Class + +Object + +=== Class Methods + +: new( address = 'localhost', port = nil ) + + This create new ProtocolSocket object, and connect to server. + +=end class ProtocolSocket - def initialize( addr, port ) + def initialize( addr, port, pipe = nil ) @address = addr @port = port + @pipe = pipe @ipaddr = '' @closed = false @@ -195,14 +312,39 @@ MES @socket = TCPsocket.new( addr, port ) @ipaddr = @socket.addr[3] - - @dout = Net::DEBUG end + attr :pipe, true + class << self alias open new end +=begin + +=== Methods + +: close + + This method closes socket. + +: addr + + a FQDN address of server + +: ipaddr + + an IP address of server + +: port + + connecting port number. + +: closed? + + true if ProtocolSokcet have been closed already + +=end attr :socket, true @@ -225,6 +367,36 @@ MES TERMEXP = /\n|\r\n|\r/o +=begin + +: read( length ) + + This method read 'length' bytes and return the string. + +: readuntil( target ) + + This method read until find 'target'. Returns read string. + +: readline + + read until "\r\n" and returns it without "\r\n". + +: read_pendstr + + This method read until "\r\n.\r\n". + At the same time, delete period at line head and final line ("\r\n.\r\n"). + +: read_pendlist +: read_pendlist{|line| .... } + + This method read until "\r\n.\r\n". This method resembles to 'read_pendstr', + but 'read_pendlist' don't check period at line head, and returns array which + each element is one line. + + When this method was called with block, evaluate it for each reading a line. + +=end + def read( len, ret = '' ) rsize = 0 @@ -256,7 +428,7 @@ MES def read_pendstr( dest = '' ) - $stderr.puts "reading pendstr" if pre = @dout ; @dout = false + @pipe << "reading text...\n" if pre = @pipe ; @pipe = nil rsize = 0 @@ -266,12 +438,14 @@ MES dest << str end - $stderr.puts "read pendstr #{rsize} bytes" if @dout = pre + @pipe << "read #{rsize} bytes\n" if @pipe = pre return dest end def read_pendlist + @pipe << "reading list...\n" if pre = @pipe ; @pipe = nil + arr = [] str = nil call = iterator? @@ -282,6 +456,7 @@ MES yield str if iterator? end + @pipe << "read #{arr.size} lines\n" if @pipe = pre return arr end @@ -300,16 +475,34 @@ MES ret = @buffer[ 0, len ] @buffer = @buffer[ len, bsi - len ] - if @dout then - $stderr.print 'read "' - debugout ret - $stderr.print "\"\n" - end + @pipe << %{read "#{debugstr ret}"\n} if @pipe return ret end - ### write +=begin + +: write( src ) + + This method send 'src'. ProtocolSocket read strings from 'src' by 'each' + iterator. This method returns written bytes. + +: writebin( src ) + + This method send 'src'. ProtocolSokcet read string from 'src' by 'each' + iterator. This method returns written bytes. + +: writeline( str ) + + This method writes 'str'. There has not to be bare "\r" or "\n" in 'str'. + +: write_pendstr( src ) + + This method writes 'src' as a mail. + ProtocolSocket reads strings from 'src' by 'each' iterator. + This returns written bytes. + +=end public @@ -341,8 +534,7 @@ MES def write_pendstr( src ) - $stderr.puts "writing pendstr from #{src.type}" if pre = @dout - @dout = false + @pipe << "writing text from #{src.type}" if pre = @pipe ; @pipe = nil do_write_beg each_crlf_line( src ) do |line| @@ -352,7 +544,7 @@ MES do_write_do D_CRLF wsize = do_write_fin - $stderr.puts "wrote pendstr #{wsize} bytes" if @dout = pre + @pipe << "wrote #{wsize} bytes text" if @pipe = pre return wsize end @@ -382,7 +574,7 @@ MES buf << "\n" unless /\n|\r/o === buf[-1,1] beg = 0 - while pos = buf.index(TERMEXP, beg) do + while pos = buf.index( TERMEXP, beg ) do pos += $&.size tmp = buf[ beg, pos - beg ] tmp.chop! @@ -393,39 +585,46 @@ MES def do_write_beg - $stderr.print 'write "' if @dout + @wtmp = 'write "' if @pipe @writtensize = 0 @sending = '' end def do_write_do( arg ) - debugout arg if @dout + @wtmp << debugstr( arg ) if @pipe if @sending.size < 128 then @sending << arg else @sending << '...' unless @sending[-1] == ?. end + s = @socket.write( arg ) @writtensize += s return s end def do_write_fin - $stderr.puts if @dout + if @pipe then + @wtmp << "\n" + @pipe << @wtmp + @wtmp = nil + end @socket.flush return @writtensize end - def debugout( ret ) - while ret and tmp = ret[ 0, 50 ] do - ret = ret[ 50, ret.size - 50 ] + def debugstr( str ) + ret = '' + while str and tmp = str[ 0, 50 ] do + str = str[ 50, str.size - 50 ] tmp = tmp.inspect - $stderr.print tmp[ 1, tmp.size - 2 ] + ret << tmp[ 1, tmp.size - 2 ] end + ret end end diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 9f534c20c0..de97feaa23 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -1,12 +1,34 @@ -# -# smtp.rb version 1.0.1 -# -# author Minero Aoki -# +=begin + += Net module version 1.0.2 reference manual + +smtp.rb written by Minero Aoki + +This library is distributed under the terms of Ruby style license. +You can freely redistribute/modify/copy this file. + +=end + require 'net/session' +=begin + +== Net::SMTPSession + +=== Super Class + +Net::Session + +=== Class Methods + +: new( address = 'localhost', port = 25 ) + + This method create new SMTPSession object. + +=end + module Net class SMTPSession < Session @@ -16,6 +38,33 @@ module Net @port = 25 end +=begin + +=== Methods + +: start( helo_domain = ENV['HOSTNAME'] ) + + This method opens TCP connection and start SMTP session. + If session had been started, do nothing and return false. + +: sendmail( mailsrc, from_domain, to_addrs ) + + This method sends 'mailsrc' as mail. SMTPSession read strings from 'mailsrc' + by calling 'each' iterator, and convert them into "\r\n" terminated string when write. + + SMTPSession's Exceptions are: + * Protocol::ProtoSyntaxError: syntax error (errno.500) + * Protocol::ProtoFatalError: fatal error (errno.550) + * Protocol::ProtoUnknownError: unknown error + * Protocol::ProtoServerBusy: temporary error (errno.420/450) + +: finish + + This method closes SMTP session. + If session had not started, do nothind and return false. + +=end + def sendmail( mailsrc, fromaddr, toaddrs ) @proto.mailfrom( fromaddr ) @proto.rcpt( toaddrs ) @@ -43,6 +92,48 @@ module Net SMTP = SMTPSession +=begin + +== Net::SMTPCommand + +=== Super Class + +Net::Command + +=== Class Methods + +: new( socket ) + + This method creates new SMTPCommand object, and open SMTP session. + + +=== Methods + +: helo( helo_domain ) + + This method send "HELO" command and start SMTP session.
+ helo_domain is localhost's FQDN. + +: mailfrom( from_addr ) + + This method sends "MAIL FROM" command.
+ from_addr is your mail address(????@????). + +: rcpt( to_addrs ) + + This method sends "RCPT TO" command.
+ to_addrs is array of mail address(???@???) of destination. + +: data( mailsrc ) + + This method send 'mailsrc' as mail. SMTP reads strings from 'mailsrc' + by calling 'each' iterator. + +: quit + + This method sends "QUIT" command and ends SMTP session. + +=end class SMTPCommand < Command @@ -121,7 +212,7 @@ module Net end - unless Session::Version == '1.0.1' then + unless Session::Version == '1.0.2' then $stderr.puts "WARNING: wrong version of session.rb & smtp.rb" end diff --git a/lib/pstore.rb b/lib/pstore.rb index 2aa9864b58..566de8d8f9 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -13,6 +13,7 @@ # end require "marshal" +require "ftools" class PStore class Error < StandardError @@ -77,12 +78,19 @@ class PStore raise PStore::Error, "nested transaction" if @transaction begin @transaction = true - value = file = nil - begin - File::open(@filename, "r") do |file| - @table = Marshal.load(file) - end - rescue Errno::ENOENT + value = nil + backup = @filename+"~" + if File::exist?(@filename) + file = File::open(@filename, "r+") + orig = true + else + file = File::open(@filename, "w+") + end + file.flock(File::LOCK_EX) + if orig + File::copy @filename, backup + @table = Marshal::load(file) + else @table = {} end begin @@ -95,16 +103,10 @@ class PStore ensure unless @abort begin - File::rename @filename, @filename+"~" - rescue Errno::ENOENT - no_orig = true - end - begin - File::open(@filename, "w") do |file| - Marshal::dump(@table, file) - end + file.rewind + Marshal::dump(@table, file) rescue - File::rename @filename+"~", @filename unless no_orig + File::rename backup, @filename if File::exist?(backup) end end @abort = false @@ -112,6 +114,7 @@ class PStore ensure @table = nil @transaction = false + file.close end value end diff --git a/lib/singleton.rb b/lib/singleton.rb index 8167a01aa8..4aea574e7a 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -14,6 +14,7 @@ module Singleton def Singleton.append_features(klass) klass.private_class_method(:new) klass.instance_eval %{ + @__instance__ = nil def instance unless @__instance__ @__instance__ = new diff --git a/marshal.c b/marshal.c index 82d6907276..4f13724a27 100644 --- a/marshal.c +++ b/marshal.c @@ -449,7 +449,7 @@ struct load_arg { FILE *fp; char *ptr, *end; st_table *symbol; - st_table *data; + VALUE data; VALUE proc; }; @@ -602,7 +602,7 @@ r_regist(v, arg) if (arg->proc) { rb_funcall(arg->proc, rb_intern("call"), 1, v); } - st_insert(arg->data, arg->data->num_entries, v); + rb_hash_aset(arg->data, INT2FIX(RHASH(arg->data)->tbl->num_entries), v); return v; } @@ -612,14 +612,17 @@ r_object(arg) { VALUE v; int type = r_byte(arg); + long id; switch (type) { case TYPE_LINK: - if (st_lookup(arg->data, r_long(arg), &v)) { - return v; + id = r_long(arg); + v = rb_hash_aref(arg->data, INT2FIX(id)); + if (NIL_P(v)) { + rb_raise(rb_eArgError, "dump format error (unlinked)"); } - rb_raise(rb_eArgError, "dump format error (unlinked)"); - break; + return v; + break; case TYPE_UCLASS: { @@ -789,7 +792,7 @@ r_object(arg) { char *buf; r_bytes(buf, arg); - return rb_path2class(buf); + return r_regist(rb_path2class(buf), arg); } default: @@ -811,7 +814,6 @@ load_ensure(arg) struct load_arg *arg; { st_free_table(arg->symbol); - st_free_table(arg->data); return 0; } @@ -846,11 +848,13 @@ marshal_load(argc, argv) major = r_byte(&arg); if (major == MARSHAL_MAJOR) { + volatile VALUE hash; /* protect from GC */ + if (r_byte(&arg) != MARSHAL_MINOR) { rb_warn("Old marshal file format (can be read)"); } arg.symbol = st_init_numtable(); - arg.data = st_init_numtable(); + arg.data = hash = rb_hash_new(); if (NIL_P(proc)) arg.proc = 0; else arg.proc = proc; v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg); diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 50e4f50e87..aef84affea 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -180,12 +180,7 @@ The variable ruby-indent-level controls the amount of indentation. (back-to-indentation) (setq top (current-column)) (skip-chars-backward " \t") - (cond - ((>= x shift) - (setq shift 0)) - ((>= shift top) - (setq shift (- shift top))) - (t (setq shift 0))) + (if (>= shift top) (setq shift (- shift top))) (if (and (bolp) (= x top)) (move-to-column (+ x shift)) diff --git a/node.h b/node.h index 4add37b47c..ea44a454d5 100644 --- a/node.h +++ b/node.h @@ -13,6 +13,10 @@ #ifndef NODE_H #define NODE_H +#if defined(__cplusplus) +extern "C" { +#endif + enum node_type { NODE_METHOD, NODE_FBODY, @@ -331,4 +335,8 @@ VALUE rb_gvar_get _((struct global_entry *)); VALUE rb_gvar_set _((struct global_entry *, VALUE)); VALUE rb_gvar_defined _((struct global_entry *)); +#if defined(__cplusplus) +} /* extern "C" { */ +#endif + #endif diff --git a/process.c b/process.c index d5c2d5eb8a..211445b88d 100644 --- a/process.c +++ b/process.c @@ -600,6 +600,13 @@ rb_f_system(argc, argv) VALUE cmd; int state; + fflush(stdout); + fflush(stderr); + if (argc == 0) { + rb_last_status = INT2FIX(0); + rb_raise(rb_eArgError, "wrong # of arguments"); + } + if (TYPE(argv[0]) == T_ARRAY) { if (RARRAY(argv[0])->len != 2) { rb_raise(rb_eArgError, "wrong first argument"); @@ -619,6 +626,11 @@ rb_f_system(argc, argv) VALUE cmd; int state; + if (argc == 0) { + rb_last_status = INT2FIX(0); + rb_raise(rb_eArgError, "wrong # of arguments"); + } + if (TYPE(argv[0]) == T_ARRAY) { if (RARRAY(argv[0])->len != 2) { rb_raise(rb_eArgError, "wrong first argument"); @@ -644,7 +656,7 @@ rb_f_system(argc, argv) fflush(stderr); if (argc == 0) { rb_last_status = INT2FIX(0); - return INT2FIX(0); + rb_raise(rb_eArgError, "wrong # of arguments"); } if (TYPE(argv[0]) == T_ARRAY) { @@ -667,7 +679,7 @@ rb_f_system(argc, argv) #if defined(USE_CWGUSI) rb_notimplement(); #else - volatile VALUE prog = 0; + volatile VALUE prog = 0; int pid; int i; @@ -675,7 +687,7 @@ rb_f_system(argc, argv) fflush(stderr); if (argc == 0) { rb_last_status = INT2FIX(0); - return INT2FIX(0); + rb_raise(rb_eArgError, "wrong # of arguments"); } if (TYPE(argv[0]) == T_ARRAY) { diff --git a/random.c b/random.c index e977094eaa..fbfa94e4e9 100644 --- a/random.c +++ b/random.c @@ -87,11 +87,11 @@ rb_f_srand(argc, argv, obj) VALUE *argv; VALUE obj; { - VALUE seed; - int old; - static int saved_seed; + VALUE a; + unsigned int seed, old; + static unsigned int saved_seed; - if (rb_scan_args(argc, argv, "01", &seed) == 0) { + if (rb_scan_args(argc, argv, "01", &a) == 0) { static int n = 0; struct timeval tv; @@ -99,7 +99,7 @@ rb_f_srand(argc, argv, obj) seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++; } else { - seed = NUM2UINT(seed); + seed = NUM2UINT(a); } #ifdef HAVE_RANDOM @@ -116,7 +116,7 @@ rb_f_srand(argc, argv, obj) old = saved_seed; saved_seed = seed; - return rb_int2inum(old); + return rb_uint2inum(old); } static VALUE diff --git a/re.c b/re.c index ac73732d39..540ae2848d 100644 --- a/re.c +++ b/re.c @@ -182,6 +182,21 @@ kcode_reset_option() } } +int +rb_mbclen2(c, re) + unsigned char c; + VALUE re; +{ + int len; + + if (!FL_TEST(re, KCODE_FIXED)) + return mbclen(c); + kcode_set_option(re); + len = mbclen(c); + kcode_reset_option(); + return len; +} + extern int ruby_in_compile; static void @@ -260,10 +275,7 @@ static VALUE rb_reg_source(re) VALUE re; { - VALUE str = rb_str_new(0,0); - rb_reg_expr_str(str, RREGEXP(re)->str,RREGEXP(re)->len); - - return str; + return rb_str_new(RREGEXP(re)->str,RREGEXP(re)->len); } static VALUE @@ -538,6 +550,7 @@ rb_reg_search(reg, str, pos, reverse) } result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len, pos, range, regs); + if (FL_TEST(reg, KCODE_FIXED)) kcode_reset_option(); @@ -710,7 +723,7 @@ static VALUE match_string(match) VALUE match; { - return rb_str_dup(RMATCH(match)->str); + return RMATCH(match)->str; /* str is frozen */ } VALUE rb_cRegexp; @@ -1263,7 +1276,9 @@ Init_Regexp() rb_global_variable(®_cache); rb_global_variable(&matchcache); - rb_cMatch = rb_define_class("MatchingData", rb_cData); + rb_cMatch = rb_define_class("MatchingData", rb_cObject); + rb_undef_method(CLASS_OF(rb_cMatch), "new"); + rb_define_method(rb_cMatch, "clone", match_clone, 0); rb_define_method(rb_cMatch, "size", match_size, 0); rb_define_method(rb_cMatch, "length", match_size, 0); diff --git a/re.h b/re.h index dc4cd17354..9d3b77f519 100644 --- a/re.h +++ b/re.h @@ -36,4 +36,7 @@ VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *)); int rb_kcode _((void)); extern int ruby_ignorecase; + +int rb_mbclen2 _((unsigned char, VALUE)); +#define mbclen2(c,re) rb_mbclen2((c),(re)) #endif diff --git a/regex.c b/regex.c index fd8a447b05..9988be2d2a 100644 --- a/regex.c +++ b/regex.c @@ -48,13 +48,6 @@ # include #endif -#if defined(STDC_HEADERS) -# include -#else -/* We need this for `regex.h', and perhaps for the Emacs include files. */ -# include -#endif - #ifndef __STDC__ # define volatile #endif @@ -1406,7 +1399,8 @@ re_compile_pattern(pattern, size, bufp) case 'W': for (c = 0; c < (1 << BYTEWIDTH); c++) { if (SYNTAX(c) != Sword && - (current_mbctype || SYNTAX(c) != Sword2)) + (current_mbctype && !re_mbctab[c] || + !current_mbctype && SYNTAX(c) != Sword2)) SET_LIST_BIT(c); } last = -1; diff --git a/ruby.c b/ruby.c index 0b4d486ec8..752b2b18fc 100644 --- a/ruby.c +++ b/ruby.c @@ -176,8 +176,11 @@ rubylib_mangle(s, l) strcpy(ret + newl, s + oldl); return ret; } +#define rubylib_mangled_path(s, l) rb_str_new2(rubylib_mangle((s), (l))) +#define rubylib_mangled_path2(s) rb_str_new2(rubylib_mangle((s), 0)) #else -#define rubylib_mangle(s, l) (s) +#define rubylib_mangled_path(s, l) rb_str_new((s), (l)) +#define rubylib_mangled_path2(s) rb_str_new2(s) #endif static void @@ -202,18 +205,18 @@ addpath(path) while (*p) { while (*p == sep) p++; if (s = strchr(p, sep)) { - rb_ary_push(ary, rb_str_new(rubylib_mangle(p, (int)(s-p)), (int)(s-p))); + rb_ary_push(ary, rubylib_mangled_path(p, (int)(s-p))); p = s + 1; } else { - rb_ary_push(ary, rb_str_new2(rubylib_mangle(p, 0))); + rb_ary_push(ary, rubylib_mangled_path2(p)); break; } } rb_load_path = rb_ary_plus(ary, rb_load_path); } else { - rb_ary_unshift(rb_load_path, rb_str_new2(rubylib_mangle(path, 0))); + rb_ary_unshift(rb_load_path, rubylib_mangled_path2(path)); } } diff --git a/rubytest.rb b/rubytest.rb index 7b886fd3f4..20032e303e 100644 --- a/rubytest.rb +++ b/rubytest.rb @@ -9,6 +9,8 @@ if File.exist? CONFIG['LIBRUBY_SO'] dldpath = "SHLIB_PATH" when /-aix/ dldpath = "LIBPATH" + when /-beos/ + dldpath = "LIBRARY_PATH" else dldpath = "LD_LIBRARY_PATH" end diff --git a/sample/io.rb b/sample/io.rb deleted file mode 100644 index 0b38d2112d..0000000000 --- a/sample/io.rb +++ /dev/null @@ -1,44 +0,0 @@ -# IO test -# usage: ruby io.rb file.. - -home = ENV["HOME"] -home.sub("m", "&&") -print(home, "\n") -print(home.reverse, "\n") - -if File.s("io.rb") - print(File.s("io.rb"), ": io.rb\n") -end - -$/="f\n" -for i in "abc\n\ndef\nghi\n" - print("tt: ", i) -end - -printf("%s:(%d)%s\n", $0, ARGV.length, ARGV[0]) -passwd = open(ARGV[0], "r") -#printf("%s", passwd.find{i|i =~ /\*/}) - -n = 1 -for i in passwd #.grep(/^\*/) - printf("%6d: %s", n, i) - n = n + 1; -end - -fp = open("|-", "r") - -if fp == nil - for i in 1..5 - print(i, "\n") - end -else - for line in fp - print(line) - end -end - -def printUsage() - if $USAGE - apply($USAGE); - end -end diff --git a/sample/mine.rb b/sample/mine.rb deleted file mode 100644 index 7d02e5bfc9..0000000000 --- a/sample/mine.rb +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/ruby -Ke - -class Board - def clr - print "\e[2J" - end - def pos(x,y) - printf "\e[%d;%dH", y+1, x*2+1 - end - def colorstr(id,s) - printf "\e[%dm%s\e[0m", id, s - end - def put(x, y, col, str) - pos(x,y); colorstr(43,str) - pos(0,@hi); print "残り:",@mc,"/",@total," " - pos(x,y) - end - private :clr, :pos, :colorstr, :put - CHR=["・","1","2","3","4","5","6","7","8","★","●","@@"] - COL=[46,43,45] # default,opened,over - def initialize(h,w,m) - # ゲーム盤の生成(h:縦,w:横,m:爆弾の数) - @hi=h; @wi=w; @m=m - reset - end - def reset - # ゲーム盤を(再)初期化する - srand() - @cx=0; @cy=0; @mc=@m - @over=false - @data=Array.new(@hi*@wi) - @state=Array.new(@hi*@wi) - @total=@hi*@wi - @total.times {|i| @data[i]=0} - @m.times do - loop do - j=rand(@total-1) - if @data[j] == 0 then - @data[j]=1 - break - end - end - end - clr; pos(0,0) - @hi.times{|y| pos(0,y); colorstr(COL[0],CHR[0]*@wi)} - pos(@cx,@cy) - end - def mark - # 現在のカーソル位置にマークをつける - if @state[@wi*@cy+@cx] != nil then return end - @state[@wi*@cy+@cx] = "MARK" - @mc=@mc-1; - @total=@total-1; - put(@cx, @cy, COL[1], CHR[9]) - end - def open(x=@cx,y=@cy) - # 現在のカーソル位置をオープンにする - # 爆弾があればゲームオーバー - if @state[@wi*y+x] =="OPEN" then return 0 end - if @state[@wi*y+x] == nil then @total=@total-1 end - if @state[@wi*y+x] =="MARK" then @mc=@mc+1 end - @state[@wi*y+x]="OPEN" - if fetch(x,y) == 1 then @over = 1; return end - c = count(x,y) - put(x, y, COL[1], CHR[c]) - return 0 if c != 0 - if x > 0 && y > 0 then open(x-1,y-1) end - if y > 0 then open(x, y-1) end - if x < @wi-1 && y > 0 then open(x+1,y-1) end - if x > 0 then open(x-1,y) end - if x < @wi-1 then open(x+1,y) end - if x > 0 && y < @hi-1 then open(x-1,y+1) end - if y < @hi -1 then open(x,y+1) end - if x < @wi-1 && y < @hi-1 then open(x+1,y+1) end - pos(@cx,@cy) - end - def fetch(x,y) - # (x,y)の位置の爆弾の数(0 or 1)を返す - if x < 0 then 0 - elsif x >= @wi then 0 - elsif y < 0 then 0 - elsif y >= @hi then 0 - else - @data[x*@wi+y] - end - end - def count(x,y) - # (x,y)に隣接する爆弾の数を返す - fetch(x-1,y-1)+fetch(x,y-1)+fetch(x+1,y-1)+ - fetch(x-1,y) + fetch(x+1,y)+ - fetch(x-1,y+1)+fetch(x,y+1)+fetch(x+1,y+1) - end - def over(win) - # ゲームの終了 - quit - unless win - pos(@cx,@cy); print CHR[11] - end - pos(0,@hi) - if win then print "*** YOU WIN !! ***" - else print "*** GAME OVER ***" - end - end - def over? - # ゲームの終了チェック - # 終了処理も呼び出す - remain = (@mc+@total == 0) - if @over || remain - over(remain) - true - else - false - end - end - def quit - # ゲームの中断(または終了) - # 盤面を全て見せる - @hi.times do|y| - pos(0,y) - @wi.times do|x| - colorstr(if @state[y*@wi+x] == "MARK" then COL[1] else COL[2] end, - if fetch(x,y)==1 then CHR[10] else CHR[count(x,y)] end) - end - end - end - def down - # カーソルを下に - if @cy < @hi-1 then @cy=@cy+1; pos(@cx, @cy) end - end - def up - # カーソルを上に - if @cy > 0 then @cy=@cy-1; pos(@cx, @cy) end - end - def left - # カーソルを左に - if @cx > 0 then @cx=@cx-1; pos(@cx, @cy) end - end - def right - # カーソルを右に - if @cx < @wi-1 then @cx=@cx+1; pos(@cx, @cy) end - end -end - -bd=Board.new(10,10,10) -system("stty raw -echo") -begin - loop do - case STDIN.getc - when ?n # new game - bd.reset - when ?m # mark - bd.mark - when ?j - bd.down - when ?k - bd.up - when ?h - bd.left - when ?l - bd.right - when ?\s - bd.open - when ?q,?\C-c # quit game - bd.quit - break - end - if bd.over? - if STDIN.getc == ?q then break end - bd.reset - end - end -ensure - system("stty -raw echo") -end -print "\n" diff --git a/sample/rename.rb b/sample/rename.rb deleted file mode 100644 index cacb2b7508..0000000000 --- a/sample/rename.rb +++ /dev/null @@ -1,297 +0,0 @@ -#! /usr/local/bin/ruby -p -gsub!(/\bary_aref\b/,"rb_ary_aref") -gsub!(/\bary_assoc\b/,"rb_ary_assoc") -gsub!(/\bary_concat\b/,"rb_ary_concat") -gsub!(/\bary_delete\b/,"rb_ary_delete") -gsub!(/\bary_delete_at\b/,"rb_ary_delete_at") -gsub!(/\bary_each\b/,"rb_ary_each") -gsub!(/\bary_entry\b/,"rb_ary_entry") -gsub!(/\bary_freeze\b/,"rb_ary_freeze") -gsub!(/\bary_includes\b/,"rb_ary_includes") -gsub!(/\bary_join\b/,"rb_ary_join") -gsub!(/\bary_new([234])?\b/,"rb_ary_new\\1") -gsub!(/\bary_plus\b/,"rb_ary_plus") -gsub!(/\bary_pop\b/,"rb_ary_pop") -gsub!(/\bary_push\b/,"rb_ary_push") -gsub!(/\bary_rassoc\b/,"rb_ary_rassoc") -gsub!(/\bary_reverse\b/,"rb_ary_reverse") -gsub!(/\bary_shift\b/,"rb_ary_shift") -gsub!(/\bary_sort\b/,"rb_ary_sort") -gsub!(/\bary_store\b/,"rb_ary_store") -gsub!(/\bary_to_s\b/,"rb_ary_to_s") -gsub!(/\bary_unshift\b/,"rb_ary_unshift") -gsub!(/\bassoc_new\b/,"rb_assoc_new") -gsub!(/\bcArray\b/,"rb_cArray") -gsub!(/\bmemclear\b/,"rb_mem_clear") -gsub!(/\bbig2dbl\b/,"rb_big2dbl") -gsub!(/\bbig2long\b/,"rb_big2long") -gsub!(/\bbig2str\b/,"rb_big2str") -gsub!(/\bbig2ulong\b/,"rb_big2ulong") -gsub!(/\bbig_2comp\b/,"rb_big_2comp") -gsub!(/\bbig_and\b/,"rb_big_and") -gsub!(/\bbig_clone\b/,"rb_big_clone") -gsub!(/\bbig_lshift\b/,"rb_big_lshift") -gsub!(/\bbig_minus\b/,"rb_big_minus") -gsub!(/\bbig_mul\b/,"rb_big_mul") -gsub!(/\bbig_norm\b/,"rb_big_norm") -gsub!(/\bbig_or\b/,"rb_big_or") -gsub!(/\bbig_plus\b/,"rb_big_plus") -gsub!(/\bbig_pow\b/,"rb_big_pow") -gsub!(/\bbig_rand\b/,"rb_big_rand") -gsub!(/\bbig_xor\b/,"rb_big_xor") -gsub!(/\bcBignum\b/,"rb_cBignum") -gsub!(/\bdbl2big\b/,"rb_dbl2big") -gsub!(/\bint2big\b/,"rb_int2big") -gsub!(/\bint2inum\b/,"rb_int2inum") -gsub!(/\bstr2inum\b/,"rb_str2inum") -gsub!(/\buint2big\b/,"rb_uint2big") -gsub!(/\buint2inum\b/,"rb_uint2inum") -gsub!(/\bclass_instance_methods\b/,"rb_class_instance_methods") -gsub!(/\bclass_new\b/,"rb_class_new") -gsub!(/\bclass_private_instance_methods\b/,"rb_class_private_instance_methods") -gsub!(/\bclass_protected_instance_methods\b/,"rb_class_protected_instance_methods") -gsub!(/\bmod_ancestors\b/,"rb_mod_ancestors") -gsub!(/\bmod_included_modules\b/,"rb_mod_included_modules") -gsub!(/\bmodule_new\b/,"rb_module_new") -gsub!(/\bobj_singleton_methods\b/,"rb_obj_singleton_methods") -gsub!(/\bsingleton_class\b/,"rb_singleton_class") -gsub!(/\bmComparable\b/,"rb_mComparable") -gsub!(/\bcDir\b/,"rb_cDir") -gsub!(/\benum_length\b/,"rb_enum_length") -gsub!(/\bmEnumerable\b/,"rb_mEnumerable") -gsub!(/\bBug\b/,"rb_bug") -gsub!(/\brb_check_type\b/,"rb_check_type") -gsub!(/\beArgError\b/,"rb_eArgError") -gsub!(/\beException\b/,"rb_eException") -gsub!(/\beFatal\b/,"rb_eFatal") -gsub!(/\beIndexError\b/,"rb_eIndexError") -gsub!(/\beInterrupt\b/,"rb_eInterrupt") -gsub!(/\beLoadError\b/,"rb_eLoadError") -gsub!(/\beNameError\b/,"rb_eNameError") -gsub!(/\beNotImpError\b/,"rb_eNotImpError") -gsub!(/\beRuntimeError\b/,"rb_eRuntimeError") -gsub!(/\beSecurityError\b/,"rb_eSecurityError") -gsub!(/\beStandardError\b/,"rb_eStandardError") -gsub!(/\beSyntaxError\b/,"rb_eSyntaxError") -gsub!(/\beSystemCallError\b/,"rb_eSystemCallError") -gsub!(/\beSystemExit\b/,"rb_eSystemExit") -gsub!(/\beTypeError\b/,"rb_eTypeError") -gsub!(/\bexc_new([23]?)\b/,"rb_exc_new\\1") -gsub!(/\bFatal\b/,"rb_fatal") -gsub!(/\bLoadError\b/,"rb_loaderror") -gsub!(/\bmErrno\b/,"rb_mErrno") -gsub!(/\bRaise\b/,"rb_raise") -gsub!(/\bWarn(ing)?\b/,"rb_warn\\1") -gsub!(/\bnerrs\b/,"ruby_nerrs") -gsub!(/\bcProc\b/,"rb_cProc") -gsub!(/\bcThread\b/,"rb_cThread") -gsub!(/\brb_check_safe_str\b/,"rb_check_safe_str") -gsub!(/\bclass_new_instance\b/,"rb_class_new_instance") -gsub!(/\bdyna_var_asgn\b/,"rb_dvar_asgn") -gsub!(/\bdyna_var_defined\b/,"rb_dvar_defined") -gsub!(/\bdyna_var_push\b/,"rb_dvar_push") -gsub!(/\bdyna_var_ref\b/,"rb_dvar_ref") -gsub!(/\bf_lambda\b/,"rb_f_lambda") -gsub!(/\bf_load\b/,";xxx_need_modify;rb_load") -gsub!(/\bf_require\b/,"rb_f_require") -gsub!(/\bgc_mark_threads\b/,"rb_gc_mark_threads") -gsub!(/\biterator_p\b/,"rb_iterator_p") -gsub!(/\bobj_call_init\b/,"rb_obj_call_init") -gsub!(/\brb_set_end_proc\b/,"rb_set_end_proc") -gsub!(/\brb_set_safe_level\b/,"rb_set_safe_level") -gsub!(/\bthread_alone\b/,"rb_thread_alone") -gsub!(/\bthread_create\b/,"rb_thread_create") -gsub!(/\bthread_critical\b/,"rb_thread_critical") -gsub!(/\bthread_fd_writable\b/,"rb_thread_fd_writable") -gsub!(/\bthread_interrupt\b/,"rb_thread_interrupt") -gsub!(/\bthread_schedule\b/,"rb_thread_schedule") -gsub!(/\bthread_select\b/,"rb_thread_select") -gsub!(/\bthread_sleep\b/,"rb_thread_sleep") -gsub!(/\bthread_sleep_forever\b/,"rb_thread_sleep_forever") -gsub!(/\bthread_trap_eval\b/,"rb_thread_trap_eval") -gsub!(/\bthread_wait_fd\b/,"rb_thread_wait_fd") -gsub!(/\bthread_wait_for\b/,"rb_thread_wait_for") -gsub!(/\bthe_class\b/,"ruby_class") -gsub!(/\bthe_dyna_vars\b/,"ruby_dyna_vars") -gsub!(/\bthe_frame\b/,"ruby_frame") -gsub!(/\bthe_init\b/,"ruby_init") -gsub!(/\bthe_scope\b/,"ruby_scope") -gsub!(/\bcFile\b/,"rb_cFile") -gsub!(/\bfile_open\b/,"rb_file_open") -gsub!(/\bfile_s_expand_path\b/,"rb_file_s_expand_path") -gsub!(/\bmFileTest\b/,"rb_mFileTest") -gsub!(/\bdata_object_alloc\b/,"rb_data_object_alloc") -gsub!(/\bgc_call_finalizer_at_exit\b/,"rb_gc_call_finalizer_at_exit") -gsub!(/\bgc_force_recycle\b/,"rb_gc_force_recycle") -gsub!(/\bgc_gc\b/,"rb_gc") -gsub!(/\bgc_mark\b/,"rb_gc_mark") -gsub!(/\bgc_stack_start\b/,"rb_gc_stack_start") -gsub!(/\bmGC\b/,"rb_mGC") -gsub!(/\bcHash\b/,"rb_cHash") -gsub!(/\benv_path_tainted\b/,"rb_env_path_tainted") -gsub!(/\bhash_aref\b/,"rb_hash_aref") -gsub!(/\bhash_aset\b/,"rb_hash_aset") -gsub!(/\bhash_freeze\b/,"rb_hash_freeze") -gsub!(/\bhash_new\b/,"rb_hash_new") -gsub!(/\bcIO\b/,"rb_cIO") -gsub!(/\beEOFError\b/,"rb_eEOFError") -gsub!(/\beIOError\b/,"rb_eIOError") -gsub!(/\beof_error\b/,"rb_eof_error") -gsub!(/\bf_gets\b/,"rb_f_gets") -gsub!(/\bio_binmode\b/,"rb_io_binmode") -gsub!(/\bio_check_closed\b/,"rb_io_check_closed") -gsub!(/\bio_readable\b/,"rb_io_check_readable") -gsub!(/\bio_writable\b/,"rb_io_check_writable") -gsub!(/\bio_close\b/,"rb_io_close") -gsub!(/\bio_fptr_finalize\b/,"rb_io_fptr_finalize") -gsub!(/\bio_getc\b/,"rb_io_getc") -gsub!(/\bio_gets\b/,"rb_io_gets") -gsub!(/\bio_gets_method\b/,"rb_io_gets_method") -gsub!(/\bio_mode_flags\b/,"rb_io_mode_flags") -gsub!(/\bio_reopen\b/,"rb_io_reopen") -gsub!(/\bio_unbuffered\b/,"rb_io_unbuffered") -gsub!(/\bio_ungetc\b/,"rb_io_ungetc") -gsub!(/\bio_write\b/,"rb_io_write") -gsub!(/\bRS_default\b/,"ruby_default_rs") -gsub!(/\bOFS\b/,"ruby_output_fs") -gsub!(/\bORS\b/,"ruby_output_rs") -gsub!(/\bFS\b/,"ruby_fs") -gsub!(/\bRS\b/,"ruby_rs") -gsub!(/\bmMath\b/,"rb_mMath") -gsub!(/\bcFixnum\b/,"rb_cFixnum") -gsub!(/\bcFloat\b/,"rb_cFloat") -gsub!(/\bcInteger\b/,"rb_cInteger") -gsub!(/\bcNumeric\b/,"rb_cNumeric") -gsub!(/\beZeroDiv\b/,"rb_eZeroDiv") -gsub!(/\bfix2int\b/,"rb_fix2int") -gsub!(/\bfix2str\b/,"rb_fix2str") -gsub!(/\bfix_upto\b/,"rb_fix_upto") -gsub!(/\bfloat_new\b/,"rb_float_new") -gsub!(/\bnum2fix\b/,"rb_num2fix") -gsub!(/\bnum2int\b/,"rb_num2int") -gsub!(/\bnum2long\b/,"rb_num2long") -gsub!(/\bnum2ulong\b/,"rb_num2ulong") -gsub!(/\bnum_coerce_bin\b/,"rb_num_coerce_bin") -gsub!(/\bnum_zerodiv\b/,"rb_num_zerodiv") -gsub!(/\bany_to_s\b/,"rb_any_to_s") -gsub!(/\bcClass\b/,"rb_cClass") -gsub!(/\bcData\b/,"rb_cData") -gsub!(/\bcFalseClass\b/,"rb_cFalseClass") -gsub!(/\bcModule\b/,"rb_cModule") -gsub!(/\bcNilClass\b/,"rb_cNilClass") -gsub!(/\bcObject\b/,"rb_cObject") -gsub!(/\bcTrueClass\b/,"rb_cTrueClass") -gsub!(/\bmKernel\b/,"rb_mKernel") -gsub!(/\bnum2dbl\b/,"rb_num2dbl") -gsub!(/\bobj_alloc\b/,"rb_obj_alloc") -gsub!(/\bobj_equal\b/,"rb_obj_equal") -gsub!(/\bobj_is_instance_of\b/,"rb_obj_is_instance_of") -gsub!(/\bobj_is_kind_of\b/,"rb_obj_is_kind_of") -gsub!(/\bstr2cstr\b/,"rb_str2cstr") -gsub!(/\bTopSelf\b/,"rb_top_self") -gsub!(/\bbackref_get\b/,"rb_backref_get") -gsub!(/\bbackref_set\b/,"rb_backref_set") -gsub!(/\bcompile_file\b/,"rb_compile_file") -gsub!(/\bcompile_string\b/,"rb_compile_string") -gsub!(/\bid_attrset\b/,"rb_id_attrset") -gsub!(/\bis_const_id\b/,"rb_is_const_id") -gsub!(/\bis_instance_id\b/,"rb_is_instance_id") -gsub!(/\blastline_get\b/,"rb_lastline_get") -gsub!(/\blastline_set\b/,"rb_lastline_set") -gsub!(/\bnode_newnode\b/,"rb_node_newnode") -gsub!(/\byyappend_print\b/,"rb_parser_append_print") -gsub!(/\byywhile_loop\b/,"rb_parser_while_loop") -gsub!(/\brb_reserved_word\b/,"rb_reserved_word") -gsub!(/\bsourcefile\b/,"ruby_sourcefile") -gsub!(/\bsourceline\b/,"ruby_sourceline") -gsub!(/\bmProcess\b/,"rb_mProcess") -gsub!(/\bcRange\b/,"rb_cRange") -gsub!(/\brange_beg_end\b/,"rb_range_beg_end") -gsub!(/\brange_new\b/,"rb_range_new") -gsub!(/\bcRegexp\b/,"rb_cRegexp") -gsub!(/\bignorecase\b/,"rb_ignorecase") -gsub!(/\breg_free\b/,"rb_reg_free") -gsub!(/\breg_last_match\b/,"rb_reg_last_match") -gsub!(/\breg_match\b/,"rb_reg_match") -gsub!(/\breg_new\b/,"rb_reg_new") -gsub!(/\breg_nth_defined\b/,"rb_reg_nth_defined") -gsub!(/\breg_nth_match\b/,"rb_reg_nth_match") -gsub!(/\breg_options\b/,"rb_reg_options") -gsub!(/\breg_prepare_re\b/,"rb_reg_prepare_re") -gsub!(/\breg_regcomp\b/,"rb_reg_regcomp") -gsub!(/\breg_regsub\b/,"rb_reg_regsub") -gsub!(/\breg_search\b/,"rb_reg_search") -gsub!(/\bstr_cicmp\b/,"rb_str_cicmp") -gsub!(/\bf_kill\b/,"rb_f_kill") -gsub!(/\bgc_mark_trap_list\b/,"rb_gc_mark_trap_list") -gsub!(/\bprohibit_interrupt\b/,"rb_prohibit_interrupt") -gsub!(/\btrap_exec\b/,"rb_trap_exec") -gsub!(/\btrap_exit\b/,"rb_trap_exit") -gsub!(/\btrap_immediate\b/,"rb_trap_immediate") -gsub!(/\btrap_pending\b/,"rb_trap_pending") -gsub!(/\btrap_restore_mask\b/,"rb_trap_restore_mask") -gsub!(/\bposix_signal\b/,"ruby_posix_signal") -gsub!(/\bf_sprintf\b/,"rb_f_sprintf") -gsub!(/\bcString\b/,"rb_cString") -gsub!(/\bobj_as_string\b/,"rb_obj_as_string") -gsub!(/\bstr_cat\b/,"rb_str_cat") -gsub!(/\bstr_cmp\b/,"rb_str_cmp") -gsub!(/\bstr_concat\b/,"rb_str_concat") -gsub!(/\bstr_dup\b/,"rb_str_dup") -gsub!(/\bstr_dup_frozen\b/,"rb_str_dup_frozen") -gsub!(/\bstr_freeze\b/,"rb_str_freeze") -gsub!(/\bstr_hash\b/,"rb_str_hash") -gsub!(/\bstr_inspect\b/,"rb_str_inspect") -gsub!(/\bstr_modify\b/,"rb_str_modify") -gsub!(/\bstr_new([234]?)\b/,"rb_str_new\\1") -gsub!(/\bstr_plus\b/,"rb_str_plus") -gsub!(/\bstr_resize\b/,"rb_str_resize") -gsub!(/\bstr_split\b/,"rb_str_split") -gsub!(/\bstr_substr\b/,"rb_str_substr") -gsub!(/\bstr_taint\b/,"rb_obj_taint") -gsub!(/\bstr_tainted\b/,"rb_obj_tainted") -gsub!(/\bstr_times\b/,"rb_str_times") -gsub!(/\bstr_to_str\b/,"rb_str_to_str") -gsub!(/\bstr_upto\b/,"rb_str_upto") -gsub!(/\bcStruct\b/,"rb_cStruct") -gsub!(/\bstruct_alloc\b/,"rb_struct_alloc") -gsub!(/\bstruct_aref\b/,"rb_struct_aref") -gsub!(/\bstruct_aset\b/,"rb_struct_aset") -gsub!(/\bstruct_define\b/,"rb_struct_define") -gsub!(/\bstruct_getmember\b/,"rb_struct_getmember") -gsub!(/\bstruct_new\b/,"rb_struct_new") -gsub!(/\bcTime\b/,"rb_cTime") -gsub!(/\btime_new\b/,"rb_time_new") -gsub!(/\btime_timeval\b/,"rb_time_timeval") -gsub!(/\bscan_hex\b/,"ruby_scan_hex") -gsub!(/\bscan_oct\b/,"ruby_scan_oct") -gsub!(/\bconst_defined\b/,"rb_const_defined") -gsub!(/\bconst_defined_at\b/,"rb_const_defined_at") -gsub!(/\bconst_get\b/,"rb_const_get") -gsub!(/\bconst_get_at\b/,"rb_const_get_at") -gsub!(/\bconst_set\b/,"rb_const_set") -gsub!(/\bf_autoload\b/,"rb_f_autoload") -gsub!(/\bf_global_variables\b/,"rb_f_global_variables") -gsub!(/\bf_trace_var\b/,"rb_f_trace_var") -gsub!(/\bf_untrace_var\b/,"rb_f_untrace_var") -gsub!(/\bmod_const_at\b/,"rb_mod_const_at") -gsub!(/\bmod_const_of\b/,"rb_mod_const_of") -gsub!(/\bmod_constants\b/,"rb_mod_constants") -gsub!(/\bmod_name\b/,"rb_mod_name") -gsub!(/\bmod_remove_const\b/,"rb_mod_remove_const") -gsub!(/\bobj_instance_variables\b/,"rb_obj_instance_variables") -gsub!(/\bobj_remove_instance_variable\b/,"rb_obj_remove_instance_variable") -gsub!(/\bshow_copyright\b/,"ruby_show_copyright") -gsub!(/\bshow_version\b/,"ruby_show_version") -gsub!(/\bdebug\b/,"ruby_debug") -gsub!(/\bverbose\b/,"ruby_verbose") -gsub!(/\bFail\(/,"rb_raise(rb_eRuntimeError, ") -gsub!(/\bArgError\(/,"rb_raise(rb_eArgError, ") -gsub!(/\bTypeError\(/,"rb_raise(rb_eTypeError, ") -gsub!(/\bNameError\(/,"rb_raise(rb_eNameError, ") -gsub!(/\bIndexError\(/,"rb_raise(rb_eIndexError, ") -gsub!(/\bError\b/,"rb_compile_error") -gsub!(/\bErrorAppend\b/,"rb_compile_error_append") -gsub!(/\bTRUE\b/,"Qtrue") -gsub!(/\bFALSE\b/,"Qfalse") -gsub!(/\berrinfo\b/,"ruby_errinfo") diff --git a/signal.c b/signal.c index 6489760bc6..fe1107d46d 100644 --- a/signal.c +++ b/signal.c @@ -298,7 +298,7 @@ posix_signal(signum, handler) sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ #endif #ifdef SA_NOCLDWAIT - if (signum == SIGCHLD && handler == (RETSIGTYPE)SIG_IGN) + if (signum == SIGCHLD && handler == SIG_IGN) sigact.sa_flags |= SA_NOCLDWAIT; #endif sigaction(signum, &sigact, 0); diff --git a/string.c b/string.c index f7366cf99a..3214c20adb 100644 --- a/string.c +++ b/string.c @@ -112,9 +112,10 @@ rb_str_new4(orig) str->ptr = RSTRING(orig)->ptr; RSTRING(orig)->orig = (VALUE)str; str->orig = 0; - if (FL_TEST(str, FL_TAINT)) { + if (FL_TEST(orig, FL_TAINT)) { FL_SET(str, FL_TAINT); } + FL_SET(str, STR_FREEZE); return (VALUE)str; } } @@ -756,6 +757,7 @@ rb_str_upto(beg, end, excl) int excl; { VALUE current; + ID succ = rb_intern("succ"); if (TYPE(end) != T_STRING) end = rb_str_to_str(end); @@ -763,7 +765,7 @@ rb_str_upto(beg, end, excl) while (rb_str_cmp(current, end) <= 0) { rb_yield(current); if (!excl && rb_str_equal(current, end)) break; - current = rb_str_succ(current); + current = rb_funcall(current, succ, 0, 0); if (excl && rb_str_equal(current, end)) break; if (RSTRING(current)->len > RSTRING(end)->len) break; @@ -1110,7 +1112,7 @@ rb_str_gsub_bang(argc, argv, str) * Always consume at least one character of the input string * in order to prevent infinite loops. */ - len = mbclen(RSTRING(str)->ptr[END(0)]); + len = mbclen2(RSTRING(str)->ptr[END(0)], pat); if (RSTRING(str)->len > END(0)) { memcpy(bp, RSTRING(str)->ptr+END(0), len); bp += len; @@ -1343,12 +1345,6 @@ rb_str_inspect(str) *b++ = *p++; } } -#if 0 - else if ((c & 0x80) && rb_kcode() != MBCTYPE_EUC) { - CHECK(1); - *b++ = c; - } -#endif else if (c == '"'|| c == '\\') { CHECK(2); *b++ = '\\'; @@ -2069,6 +2065,7 @@ rb_str_split_method(argc, argv, str) if (!NIL_P(limit) && lim <= ++i) break; } end++; + if (ismbchar(*ptr)) ptr++; } } } @@ -2082,11 +2079,11 @@ rb_str_split_method(argc, argv, str) regs = RMATCH(rb_backref_get())->regs; if (start == end && BEG(0) == END(0)) { if (last_null == 1) { - rb_ary_push(result, rb_str_substr(str, beg, mbclen(RSTRING(str)->ptr[beg]))); + rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat))); beg = start; } else { - start += mbclen(RSTRING(str)->ptr[start]); + start += mbclen2(RSTRING(str)->ptr[start],spat); last_null = 1; continue; } @@ -2396,7 +2393,7 @@ scan_once(str, pat, start) /* * Always consume at least one character of the input string */ - *start = END(0)+mbclen(RSTRING(str)->ptr[END(0)]); + *start = END(0)+mbclen2(RSTRING(str)->ptr[END(0)],pat); } else { *start = END(0); diff --git a/version.h b/version.h index 0d5ed1f1eb..2c61ea7414 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ -#define RUBY_VERSION "1.4.2" -#define RUBY_RELEASE_DATE "1999-09-18" -#define RUBY_VERSION_CODE 142 -#define RUBY_RELEASE_CODE 19990918 +#define RUBY_VERSION "1.4.3" +#define RUBY_RELEASE_DATE "1999-11-24" +#define RUBY_VERSION_CODE 143 +#define RUBY_RELEASE_CODE 19991124 diff --git a/win32/config.status b/win32/config.status deleted file mode 100644 index 9b959ff4bb..0000000000 --- a/win32/config.status +++ /dev/null @@ -1,65 +0,0 @@ -ac_given_srcdir=. -s%@SHELL@%%g -s%@CFLAGS@%-nologo -DNT=1 -Ox%g -s%@CPPFLAGS@%%g -s%@CXXFLAGS@%%g -s%@FFLAGS@%%g -s%@DEFS@% - -DUSE_THREAD -DSIZEOF_INT=4 -DSIZEOF_SHORT=2 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_STDLIB_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=int -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -DHAVE_FMOD=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_CHSIZE=1 -DHAVE_GETGROUPS=1 -DHAVE_GETLOGIN=1 -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".dll\" -DRUBY_LIB=\"/usr/local/lib/ruby/1.4\" -DRUBY_ARCHLIB=\"/usr/local/lib/ruby/1.4/i386-mswin32\" -DRUBY_PLATFORM=\"i386-mswin32\" %g -s%@LDFLAGS@%%g -s%@LIBS@%advapi32.lib wsock32.lib%g -s%@exec_prefix@%${prefix}%g -s%@prefix@%/usr/local%g -s%@program_transform_name@%s,x,x,%g -s%@bindir@%${exec_prefix}/bin%g -s%@sbindir@%${exec_prefix}/sbin%g -s%@libexecdir@%${exec_prefix}/libexec%g -s%@datadir@%${prefix}/share%g -s%@sysconfdir@%${prefix}/etc%g -s%@sharedstatedir@%${prefix}/com%g -s%@localstatedir@%${prefix}/var%g -s%@libdir@%${exec_prefix}/lib%g -s%@includedir@%${prefix}/include%g -s%@oldincludedir@%/usr/include%g -s%@infodir@%${prefix}/info%g -s%@mandir@%${prefix}/man%g -s%@host@%i386-pc-mswin32%g -s%@host_alias@%i386-mswin32%g -s%@host_cpu@%i386%g -s%@host_vendor@%pc%g -s%@host_os@%mswin32%g -s%@CC@%cl%g -s%@CPP@%cl -E%g -s%@YACC@%byacc%g -s%@RANLIB@%rem%g -s%@AR@%lib -nologo%g -s%@LN_S@%%g -s%@SET_MAKE@%%g -s%@LIBOBJS@% crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj%g -s%@ALLOCA@%%g -s%@DEFAULT_KCODE@%%g -s%@EXEEXT@%.exe%g -s%@OBJEXT@%obj%g -s%@XLDFLAGS@%%g -s%@DLDFLAGS@%%g -s%@STATIC@%%g -s%@CCDLFLAGS@%-DIMPORT%g -s%@LDSHARED@%cl -LD%g -s%@DLEXT@%dll%g -s%@STRIP@%%g -s%@EXTSTATIC@%%g -s%@setup@%Setup%g -s%@LIBRUBY_LDSHARED@%%g -s%@LIBRUBY_DLDFLAGS@%%g -s%@RUBY_INSTALL_NAME@%ruby%g -s%@LIBRUBY_A@%lib$(RUBY_INSTALL_NAME).lib%g -s%@LIBRUBY_SO@%%g -s%@LIBRUBY_ALIASES@%%g -s%@LIBRUBY@%libruby.lib%g -s%@LIBRUBYARG@%libruby.lib%g -s%@SOLIBS@%%g -s%@arch@%i386-mswin32%g -s%@configure_args@%--with-make-prog=nmake%g -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g diff --git a/win32/ruby.def b/win32/ruby.def index 1c79697fd7..008452fa8d 100644 --- a/win32/ruby.def +++ b/win32/ruby.def @@ -31,6 +31,7 @@ EXPORTS rb_eSystemCallError rb_eZeroDivError rb_mErrno + ruby_nerrs ;eval.c rb_cProc ruby_frame diff --git a/win32/win32.c b/win32/win32.c index a28006ce86..864fbfb5df 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1218,12 +1218,6 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd) // UNIX compatible directory access functions for NT // -// -// File names are converted to lowercase if the -// CONVERT_TO_LOWER_CASE variable is defined. -// - -#define CONVERT_TO_LOWER_CASE #define PATHLEN 1024 // @@ -1246,8 +1240,6 @@ opendir(char *filename) char root[PATHLEN]; char volname[PATHLEN]; DWORD serial, maxname, flags; - BOOL downcase; - char *dummy; // // check to see if we\'ve got a directory @@ -1258,21 +1250,6 @@ opendir(char *filename) return NULL; } - // - // check out the file system characteristics - // - if (GetFullPathName(filename, PATHLEN, root, &dummy)) { - if (dummy = strchr(root, '\\')) - *++dummy = '\0'; - if (GetVolumeInformation(root, volname, PATHLEN, - &serial, &maxname, &flags, 0, 0)) { - downcase = !(flags & FS_CASE_SENSITIVE); - } - } - else { - downcase = TRUE; - } - // // Get us a DIR structure // @@ -1309,8 +1286,6 @@ opendir(char *filename) idx = strlen(FindData.cFileName)+1; p->start = ALLOC_N(char, idx); strcpy (p->start, FindData.cFileName); - if (downcase) - strlwr(p->start); p->nfiles++; // @@ -1334,8 +1309,6 @@ opendir(char *filename) rb_fatal ("opendir: malloc failed!\n"); } strcpy(&p->start[idx], FindData.cFileName); - if (downcase) - strlwr(&p->start[idx]); p->nfiles++; idx += len+1; } -- cgit v1.2.3