mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
990531
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1307f8d555
commit
8a4cbc7331
39 changed files with 746 additions and 398 deletions
50
ChangeLog
50
ChangeLog
|
@ -1,3 +1,51 @@
|
|||
Mon May 31 16:06:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* version 1.3.4 - preliminary release for 1.4
|
||||
|
||||
Mon May 31 15:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_io_fptr_close): close on IO which main_thread is
|
||||
waiting cause serious exception, that vanishes the actual fd
|
||||
closing. Invocation of rb_thread_fd_close() is deferred
|
||||
a little.
|
||||
|
||||
Sat May 29 18:27:13 1999 Koji Arai <JCA02266@nifty.ne.jp>
|
||||
|
||||
* regex.c (re_match): stack boundary check needed.
|
||||
|
||||
Sat May 29 12:27:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* ext/tcltklib/tcltklib.c (ip_invoke): proper ref count management
|
||||
to avoid leak.
|
||||
|
||||
* eval.c (ruby_run): moved ruby_require_libraries() to handle `-r'
|
||||
from ruby_options() to avoid stack corruption for threads
|
||||
created in libraries.
|
||||
|
||||
Sat May 29 02:22:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* eval.c (rb_yield_0): when `for' appeared in blocks, it
|
||||
introduced new scope for local variables.
|
||||
|
||||
Fri May 28 17:16:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* string.c (rb_str_squeeze_bang): squeeze AND of the arguments.
|
||||
UNDOCUMENTED.
|
||||
|
||||
* string.c (rb_str_count): new UNDOCUMENTED method.
|
||||
|
||||
* string.c (rb_str_delete_bang): delete AND of the arg ranges.
|
||||
UNDOCUMENTED FEATURE for 1.3.x.
|
||||
|
||||
* ext/socket/socket.c (setipaddr): re-wrote using ip_addrsetup().
|
||||
|
||||
* ext/sockt/socket.c (ip_addrsetup): decode symbolic address
|
||||
<broadcast>.
|
||||
|
||||
Thu May 27 12:27:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* string.c (tr_trans): should handle NUL (\0) within strings.
|
||||
|
||||
Tue May 25 16:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* io.c (rb_f_syscall): syscall may return values other than zero
|
||||
|
@ -224,6 +272,8 @@ Mon May 3 09:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
|||
|
||||
Fri Apr 30 18:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
|
||||
|
||||
* version 1.3.3
|
||||
|
||||
* string.c (rb_str_rindex): position should be END point, not
|
||||
START point.
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ XLDFLAGS = @XLDFLAGS@
|
|||
EXTLIBS =
|
||||
LIBS = @LIBS@ $(EXTLIBS)
|
||||
MISSING = @LIBOBJS@ @ALLOCA@
|
||||
LDSHARED = @LDSHARED@
|
||||
DLDFLAGS = @DLDFLAGS@
|
||||
LDSHARED = @LIBRUBY_LDSHARED@
|
||||
DLDFLAGS = @LIBRUBY_DLDFLAGS@
|
||||
SOLIBS = @SOLIBS@
|
||||
|
||||
RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
|
||||
|
|
15
config_h.dj
15
config_h.dj
|
@ -1,8 +1,12 @@
|
|||
#define USE_THREAD 1
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define HAVE_PROTOTYPES 1
|
||||
#define TOKEN_PASTE(x,y) x##y
|
||||
#define HAVE_STDARG_PROTOTYPES 1
|
||||
#define HAVE_ATTR_NORETURN 1
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
@ -38,6 +42,9 @@
|
|||
#define HAVE_STRSTR 1
|
||||
#define HAVE_STRTOUL 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_ISINF 1
|
||||
#define HAVE_ISNAN 1
|
||||
#define HAVE_FINITE 1
|
||||
#define HAVE_FMOD 1
|
||||
#define HAVE_RANDOM 1
|
||||
#define HAVE_WAITPID 1
|
||||
|
@ -57,8 +64,8 @@
|
|||
#define RSHIFT(x,y) ((x)>>y)
|
||||
#define FILE_COUNT _cnt
|
||||
#define DLEXT ".o"
|
||||
#define RUBY_LIB "/usr/local/lib/ruby"
|
||||
#define RUBY_SITE_LIB "/usr/local/lib/ruby/site_ruby"
|
||||
#define RUBY_ARCHLIB "/usr/local/lib/ruby/i386-djgpp"
|
||||
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/site_ruby/i386-djgpp"
|
||||
#define RUBY_LIB "/usr/local/lib/ruby/1.3"
|
||||
#define RUBY_SITE_LIB "/usr/local/lib/ruby/1.3/site_ruby"
|
||||
#define RUBY_PLATFORM "i386-djgpp"
|
||||
#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.3/i386-djgpp"
|
||||
#define RUBY_SITE_ARCHLIB "/usr/local/lib/1.3/ruby/site_ruby/i386-djgpp"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
s%@CFLAGS@%-g -O2%g
|
||||
s%@CFLAGS@%-O2%g
|
||||
s%@CPPFLAGS@%%g
|
||||
s%@CXXFLAGS@%%g
|
||||
s%@DEFS@% -DUSE_THREAD=1 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_ATTR_NORETURN=1 -DHAVE_DIRENT_H=1 -DSTDC_HEADERS=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_PWD_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_TIMES_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_WAIT_H=1 -DHAVE_STRING_H=1 -DHAVE_UTIME_H=1 -DHAVE_MEMORY_H=1 -DHAVE_DIRECT_H=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=gid_t -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -Dvfork=fork -DHAVE_DUP2=1 -DHAVE_SETENV=1 -DHAVE_MEMMOVE=1 -DHAVE_MKDIR=1 -DHAVE_STRCASECMP=1 -DHAVE_STRERROR=1 -DHAVE_STRFTIME=1 -DHAVE_STRCHR=1 -DHAVE_STRSTR=1 -DHAVE_STRTOUL=1 -DHAVE_STRDUP=1 -DHAVE_FMOD=1 -DHAVE_RANDOM=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_TRUNCATE=1 -DHAVE_CHSIZE=1 -DHAVE_TIMES=1 -DHAVE_UTIMES=1 -DHAVE_FCNTL=1 -DHAVE_SETITIMER=1 -DHAVE_GETGROUPS=1 -DHAVE_SIGPROCMASK=1 -DHAVE_SIGACTION=1 -DHAVE_SETSID=1 -DPOSIX_SIGNAL=1 -DBSD_SETPGRP=setpgrp -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".so\" -DRUBY_LIB=\"/usr/local/lib/ruby\" -DRUBY_SITE_LIB=\"/usr/local/lib/ruby/site_ruby\" -DRUBY_ARCHLIB=\"/usr/local/lib/ruby/i386-djgpp\" -DRUBY_SITE_ARCHLIB=\"/usr/local/lib/ruby/site_ruby/i386-djgpp\" -DRUBY_PLATFORM=\"i386-djgpp\" %g
|
||||
|
|
17
configure
vendored
17
configure
vendored
|
@ -4453,6 +4453,8 @@ if test "$host_os" = "beos"; then
|
|||
esac
|
||||
fi
|
||||
|
||||
LIBRUBY_LDSHARED=$LDSHARED
|
||||
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
||||
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
|
||||
# Check whether --enable-enable-shared or --disable-enable-shared was given.
|
||||
|
@ -4480,6 +4482,17 @@ if test "$enable_shared" = 'yes'; then
|
|||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
|
||||
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
|
||||
;;
|
||||
aix*)
|
||||
if test "$GCC" = yes; then
|
||||
LIBRUBY_LDSHARED='$(CC) -shared'
|
||||
LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
|
||||
else
|
||||
LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
|
||||
LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
|
||||
fi
|
||||
LIBRUBYARG='-L./ -Wl,lib$(RUBY_INSTALL_NAME).so'
|
||||
SOLIBS='-lm -lc'
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
@ -4507,6 +4520,8 @@ esac
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
ri_prefix=
|
||||
test "$program_prefix" != NONE &&
|
||||
ri_prefix=$program_prefix
|
||||
|
@ -4740,6 +4755,8 @@ s%@STRIP@%$STRIP%g
|
|||
s%@EXTSTATIC@%$EXTSTATIC%g
|
||||
s%@binsuffix@%$binsuffix%g
|
||||
s%@setup@%$setup%g
|
||||
s%@LIBRUBY_LDSHARED@%$LIBRUBY_LDSHARED%g
|
||||
s%@LIBRUBY_DLDFLAGS@%$LIBRUBY_DLDFLAGS%g
|
||||
s%@RUBY_INSTALL_NAME@%$RUBY_INSTALL_NAME%g
|
||||
s%@LIBRUBY_A@%$LIBRUBY_A%g
|
||||
s%@LIBRUBY_SO@%$LIBRUBY_SO%g
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
@echo off
|
||||
sed -f top.sed Makefile.in >Makefile
|
||||
sed -f top.sed ext/extmk.rb.in > ext\extmk.rb
|
||||
sed -n "/VERSION/s/[^0-9.]\+//gp" < version.h > version.out
|
||||
cut -d. -f1 version.out > major.out
|
||||
cut -d. -f2 version.out > minor.out
|
||||
cut -d. -f3 version.out > teeny.out
|
||||
sed "s/^/s,@MAJOR@,/;s/$/,/g" major.out >> top.sed
|
||||
sed "s/^/s,@MINOR@,/;s/$/,/g" minor.out >> top.sed
|
||||
sed "s/^/s,@TEENY@,/;s/$/,/g" teeny.out >> top.sed
|
||||
rm version.out major.out minor.out teeny.out
|
||||
sed -f top.sed < Makefile.in > Makefile
|
||||
sed -f top.sed < ext\extmk.rb.in > ext\extmk.rb
|
||||
copy ext\Setup.dj ext\Setup
|
||||
copy config_h.dj config.h
|
||||
copy config_s.dj config.status
|
||||
if not (%OS%) == (Windows_NT) goto LFN
|
||||
copy missing\vsnprintf.c missing\vsnprint.c
|
||||
copy config_s.dj config.sta
|
||||
goto end
|
||||
:LFN
|
||||
copy config_s.dj config.status
|
||||
:end
|
||||
|
|
15
configure.in
15
configure.in
|
@ -652,6 +652,8 @@ if test "$host_os" = "beos"; then
|
|||
esac
|
||||
fi
|
||||
|
||||
LIBRUBY_LDSHARED=$LDSHARED
|
||||
LIBRUBY_DLDFLAGS=$DLDFLAGS
|
||||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
|
||||
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
|
||||
AC_ARG_ENABLE(enable-shared,
|
||||
|
@ -676,6 +678,17 @@ if test "$enable_shared" = 'yes'; then
|
|||
LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
|
||||
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
|
||||
;;
|
||||
aix*)
|
||||
if test "$GCC" = yes; then
|
||||
LIBRUBY_LDSHARED='$(CC) -shared'
|
||||
LIBRUBY_DLDFLAGS='-Wl,-bE:ruby.imp'
|
||||
else
|
||||
LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
|
||||
LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
|
||||
fi
|
||||
LIBRUBYARG='-L./ -Wl,lib$(RUBY_INSTALL_NAME).so'
|
||||
SOLIBS='-lm -lc'
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
@ -695,6 +708,8 @@ case "$host_os" in
|
|||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(LIBRUBY_LDSHARED)
|
||||
AC_SUBST(LIBRUBY_DLDFLAGS)
|
||||
AC_SUBST(RUBY_INSTALL_NAME)
|
||||
AC_SUBST(LIBRUBY_A)
|
||||
AC_SUBST(LIBRUBY_SO)
|
||||
|
|
2
dln.c
2
dln.c
|
@ -30,9 +30,11 @@ char *dln_argv0;
|
|||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifndef xmalloc
|
||||
void *xmalloc();
|
||||
void *xcalloc();
|
||||
void *xrealloc();
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef NT
|
||||
|
|
47
eval.c
47
eval.c
|
@ -411,6 +411,7 @@ struct BLOCK {
|
|||
struct tag *tag;
|
||||
int iter;
|
||||
int vmode;
|
||||
int d_scope;
|
||||
struct RVarmap *d_vars;
|
||||
VALUE orig_thread;
|
||||
struct BLOCK *prev;
|
||||
|
@ -428,10 +429,11 @@ static struct BLOCK *ruby_block;
|
|||
_block.frame.file = ruby_sourcefile;\
|
||||
_block.frame.line = ruby_sourceline;\
|
||||
_block.scope = ruby_scope; \
|
||||
_block.d_vars = ruby_dyna_vars; \
|
||||
_block.prev = ruby_block; \
|
||||
_block.iter = ruby_iter->iter; \
|
||||
_block.vmode = scope_vmode; \
|
||||
_block.d_scope = Qtrue; \
|
||||
_block.d_vars = ruby_dyna_vars; \
|
||||
ruby_block = &_block;
|
||||
|
||||
#define POP_BLOCK() \
|
||||
|
@ -440,7 +442,6 @@ static struct BLOCK *ruby_block;
|
|||
|
||||
#define PUSH_BLOCK2(b) { \
|
||||
struct BLOCK * volatile _old; \
|
||||
struct BLOCK * volatile _old_call; \
|
||||
_old = ruby_block; \
|
||||
ruby_block = b;
|
||||
|
||||
|
@ -459,27 +460,20 @@ struct RVarmap *ruby_dyna_vars;
|
|||
}
|
||||
|
||||
static struct RVarmap*
|
||||
new_dvar(id, value)
|
||||
new_dvar(id, value, prev)
|
||||
ID id;
|
||||
VALUE value;
|
||||
struct RVarmap *prev;
|
||||
{
|
||||
NEWOBJ(vars, struct RVarmap);
|
||||
OBJSETUP(vars, 0, T_VARMAP);
|
||||
vars->id = id;
|
||||
vars->val = value;
|
||||
vars->next = ruby_dyna_vars;
|
||||
vars->next = prev;
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
static void
|
||||
mark_dvar(vars)
|
||||
struct RVarmap *vars;
|
||||
{
|
||||
ruby_dyna_vars = new_dvar(0, 0);
|
||||
ruby_dyna_vars->next = vars;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_dvar_defined(id)
|
||||
ID id;
|
||||
|
@ -513,7 +507,7 @@ rb_dvar_push(id, value)
|
|||
ID id;
|
||||
VALUE value;
|
||||
{
|
||||
ruby_dyna_vars = new_dvar(id, value);
|
||||
ruby_dyna_vars = new_dvar(id, value, ruby_dyna_vars);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -942,13 +936,8 @@ ruby_options(argc, argv)
|
|||
|
||||
PUSH_TAG(PROT_NONE)
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
NODE *save;
|
||||
|
||||
ruby_process_options(argc, argv);
|
||||
ext_init = 1; /* Init_ext() called in ruby_process_options */
|
||||
save = ruby_eval_tree;
|
||||
ruby_require_modules();
|
||||
ruby_eval_tree = save;
|
||||
}
|
||||
POP_TAG();
|
||||
if (state) {
|
||||
|
@ -999,7 +988,12 @@ ruby_run()
|
|||
PUSH_TAG(PROT_NONE);
|
||||
PUSH_ITER(ITER_NOT);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
NODE *save;
|
||||
|
||||
if (!ext_init) Init_ext();
|
||||
save = ruby_eval_tree;
|
||||
ruby_require_libraries();
|
||||
ruby_eval_tree = save;
|
||||
eval_node(ruby_top_self);
|
||||
}
|
||||
POP_ITER();
|
||||
|
@ -1940,6 +1934,7 @@ rb_eval(self, node)
|
|||
char *file = ruby_sourcefile;
|
||||
int line = ruby_sourceline;
|
||||
|
||||
_block.d_scope = Qfalse;
|
||||
recv = rb_eval(self, node->nd_iter);
|
||||
PUSH_ITER(ITER_PRE);
|
||||
ruby_sourcefile = file;
|
||||
|
@ -3157,7 +3152,14 @@ rb_yield_0(val, self, klass)
|
|||
old_scope = ruby_scope;
|
||||
ruby_scope = block->scope;
|
||||
ruby_block = block->prev;
|
||||
mark_dvar(block->d_vars);
|
||||
if (block->d_scope) {
|
||||
/* put place holder for dynamic (in-block) local variables */
|
||||
ruby_dyna_vars = new_dvar(0, 0, block->d_vars);
|
||||
}
|
||||
else {
|
||||
/* FOR does not introduce new scope */
|
||||
ruby_dyna_vars = block->d_vars;
|
||||
}
|
||||
ruby_class = klass?klass:block->klass;
|
||||
if (!self) self = block->self;
|
||||
node = block->body;
|
||||
|
@ -6195,7 +6197,8 @@ rb_thread_fd_close(fd)
|
|||
th_raise_file = ruby_sourcefile;
|
||||
th_raise_line = ruby_sourceline;
|
||||
curr_thread = th;
|
||||
rb_thread_restore_context(main_thread, RESTORE_RAISE);
|
||||
rb_thread_ready(th);
|
||||
rb_thread_restore_context(curr_thread, RESTORE_RAISE);
|
||||
}
|
||||
}
|
||||
END_FOREACH(th);
|
||||
|
@ -6265,7 +6268,7 @@ rb_thread_schedule()
|
|||
}
|
||||
|
||||
if (num_waiting_on_fd > 0 || num_waiting_on_timer > 0) {
|
||||
fd_set readfds;
|
||||
fd_set readfds, writefds, exceptfds;
|
||||
struct timeval delay_tv, *delay_ptr;
|
||||
double delay, now; /* OK */
|
||||
|
||||
|
@ -7008,8 +7011,8 @@ rb_thread_cleanup()
|
|||
|
||||
FOREACH_THREAD(th) {
|
||||
if (th != curr_thread && th->status != THREAD_KILLED) {
|
||||
rb_thread_ready(th);
|
||||
th->status = THREAD_TO_KILL;
|
||||
th->wait_for = 0;
|
||||
}
|
||||
}
|
||||
END_FOREACH(th);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#option nodynamic
|
||||
|
||||
interbase
|
||||
#GD
|
||||
#curses
|
||||
#dbm
|
||||
|
|
|
@ -3,10 +3,12 @@ option nodynamic
|
|||
#GD
|
||||
#curses
|
||||
dbm
|
||||
gdbm
|
||||
#etc
|
||||
fcntl
|
||||
kconv
|
||||
nkf
|
||||
marshal
|
||||
md5
|
||||
sdbm
|
||||
#socket
|
||||
#tkutil
|
||||
|
|
|
@ -30,4 +30,4 @@ def extract(nm, out)
|
|||
exp.close
|
||||
nm.close
|
||||
end
|
||||
extract(open("|/usr/ccs/bin/nm -p ../*.o"), "../ruby.imp")
|
||||
extract(open("|/usr/ccs/bin/nm -p ../libruby.a"), "../ruby.imp")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[00mMANIFEST[00m
|
||||
[00mREADME[00m
|
||||
[00mdepend[00m
|
||||
[00mextconf.rb[00m
|
||||
[00mgdbm.c[00m
|
||||
MANIFEST
|
||||
README
|
||||
depend
|
||||
extconf.rb
|
||||
gdbm.c
|
||||
|
|
|
@ -125,6 +125,11 @@
|
|||
#define NI_NUMERICSERV 0x00000008
|
||||
#define NI_DGRAM 0x00000010
|
||||
|
||||
#ifdef NT
|
||||
#define IN_EXPERIMENTAL(x) 0
|
||||
#define IN_LOOPBACKNET 0
|
||||
#endif
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
|
|
|
@ -39,22 +39,28 @@
|
|||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef NT
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYSCTL_H
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#ifndef NT
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "addrinfo.h"
|
||||
|
@ -355,7 +361,7 @@ getaddrinfo(hostname, servname, hints, res)
|
|||
pai->ai_socktype = SOCK_DGRAM;
|
||||
pai->ai_protocol = IPPROTO_UDP;
|
||||
}
|
||||
port = htons(atoi(servname));
|
||||
port = htons((unsigned short)atoi(servname));
|
||||
} else {
|
||||
struct servent *sp;
|
||||
char *proto;
|
||||
|
@ -561,7 +567,9 @@ get_addr(hostname, af, res, pai, port0)
|
|||
int i, error = 0, h_error;
|
||||
char *ap;
|
||||
#ifndef INET6
|
||||
#ifndef NT
|
||||
extern int h_errno;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
top = NULL;
|
||||
|
|
|
@ -35,12 +35,20 @@
|
|||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef NT
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#endif
|
||||
#ifdef NT
|
||||
#include <winsock2.h>
|
||||
#include <stdio.h>
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -125,7 +133,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
|
|||
int h_error;
|
||||
char numserv[512];
|
||||
char numaddr[512];
|
||||
#ifndef NT
|
||||
extern int h_errno;
|
||||
#endif
|
||||
|
||||
if (sa == NULL)
|
||||
return ENI_NOSOCKET;
|
||||
|
|
|
@ -84,12 +84,16 @@ sock_finalize(fptr)
|
|||
OpenFile *fptr;
|
||||
{
|
||||
SOCKET s;
|
||||
extern int errno;
|
||||
|
||||
if (!fptr->f) return;
|
||||
s = fileno(fptr->f);
|
||||
free(fptr->f);
|
||||
if (fptr->f2) free(fptr->f2);
|
||||
|
||||
myfdclose(fptr->f);
|
||||
if(fptr->f2) myfdclose(fptr->f);
|
||||
/*
|
||||
s = get_osfhandle(fileno(fptr->f));
|
||||
closesocket(s);
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -423,19 +427,110 @@ bsock_recv(argc, argv, sock)
|
|||
return s_recv(sock, argc, argv, RECV_RECV);
|
||||
}
|
||||
|
||||
static void
|
||||
mkipaddr0(addr, buf, len)
|
||||
struct sockaddr *addr;
|
||||
char *buf;
|
||||
size_t len;
|
||||
{
|
||||
int error;
|
||||
|
||||
error = getnameinfo(addr, SA_LEN(addr), buf, len, NULL, 0,
|
||||
NI_NUMERICHOST);
|
||||
if (error) {
|
||||
rb_raise(rb_eSocket, "%s", gai_strerror(error));
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
mkipaddr(addr)
|
||||
struct sockaddr *addr;
|
||||
{
|
||||
char buf[1024];
|
||||
int error;
|
||||
|
||||
error = getnameinfo(addr, SA_LEN(addr), buf, sizeof(buf), NULL, 0,
|
||||
NI_NUMERICHOST);
|
||||
mkipaddr0(addr, buf, sizeof(buf));
|
||||
return rb_str_new2(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
mkinetaddr(host, buf, len)
|
||||
long host;
|
||||
char *buf;
|
||||
size_t len;
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
MEMZERO(&sin, struct sockaddr_in, 1);
|
||||
sin.sin_family = AF_INET;
|
||||
SET_SIN_LEN(&sin, sizeof(sin));
|
||||
sin.sin_addr.s_addr = host;
|
||||
mkipaddr0((struct sockaddr *)&sin, buf, len);
|
||||
}
|
||||
|
||||
static struct addrinfo*
|
||||
ip_addrsetup(host, port)
|
||||
VALUE host, port;
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
char *hostp, *portp;
|
||||
int error;
|
||||
char hbuf[1024], pbuf[16];
|
||||
|
||||
if (NIL_P(host)) {
|
||||
hostp = NULL;
|
||||
}
|
||||
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
|
||||
struct sockaddr_in sin;
|
||||
long i = NUM2LONG(host);
|
||||
|
||||
mkinetaddr(htonl(i), hbuf, sizeof(hbuf));
|
||||
}
|
||||
else {
|
||||
char *name = STR2CSTR(host);
|
||||
|
||||
if (*name == 0) {
|
||||
mkinetaddr(INADDR_ANY, hbuf, sizeof(hbuf));
|
||||
}
|
||||
if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
|
||||
mkinetaddr(INADDR_BROADCAST, hbuf, sizeof(hbuf));
|
||||
}
|
||||
else {
|
||||
strcpy(hbuf, name);
|
||||
}
|
||||
}
|
||||
hostp = hbuf;
|
||||
if (NIL_P(port)) {
|
||||
portp = 0;
|
||||
}
|
||||
else if (FIXNUM_P(port)) {
|
||||
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
|
||||
portp = pbuf;
|
||||
}
|
||||
else {
|
||||
portp = STR2CSTR(port);
|
||||
}
|
||||
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
error = getaddrinfo(hostp, portp, &hints, &res);
|
||||
if (error) {
|
||||
rb_raise(rb_eSocket, "%s", gai_strerror(error));
|
||||
}
|
||||
return rb_str_new2(buf);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
setipaddr(name, addr)
|
||||
VALUE name;
|
||||
struct sockaddr *addr;
|
||||
{
|
||||
struct addrinfo *res = ip_addrsetup(name, Qnil);
|
||||
|
||||
/* just take the first one */
|
||||
memcpy(addr, res->ai_addr, res->ai_addrlen);
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -479,40 +574,6 @@ ipaddr(sockaddr)
|
|||
return ary;
|
||||
}
|
||||
|
||||
static void
|
||||
setipaddr(name, addr)
|
||||
char *name;
|
||||
struct sockaddr *addr;
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
struct sockaddr_in *sin;
|
||||
int error;
|
||||
|
||||
sin = (struct sockaddr_in *)addr;
|
||||
if (name[0] == 0) {
|
||||
MEMZERO(sin, struct sockaddr_in, 1);
|
||||
sin->sin_family = AF_INET;
|
||||
SET_SIN_LEN(sin, sizeof(*sin));
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
else if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
|
||||
sin->sin_family = AF_INET;
|
||||
SET_SIN_LEN(sin, sizeof(*sin));
|
||||
sin->sin_addr.s_addr = INADDR_BROADCAST;
|
||||
}
|
||||
else {
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
error = getaddrinfo(name, NULL, &hints, &res);
|
||||
if (error) {
|
||||
rb_raise(rb_eSocket, "%s", gai_strerror(error));
|
||||
}
|
||||
/* just take the first one */
|
||||
memcpy(addr, res->ai_addr, res->ai_addrlen);
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
thread_write_select(fd)
|
||||
int fd;
|
||||
|
@ -632,8 +693,8 @@ open_inet(class, h, serv, type)
|
|||
continue;
|
||||
if (type == INET_SERVER) {
|
||||
status = 1;
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&status,
|
||||
sizeof(status));
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char*)&status, sizeof(status));
|
||||
status = bind(fd, res->ai_addr, res->ai_addrlen);
|
||||
syscall = "bind(2)";
|
||||
}
|
||||
|
@ -713,7 +774,7 @@ tcp_s_gethostbyname(obj, host)
|
|||
sin->sin_addr.s_addr = htonl(i);
|
||||
}
|
||||
else {
|
||||
setipaddr(STR2CSTR(host), (struct sockaddr *)&addr);
|
||||
setipaddr(host, &addr);
|
||||
}
|
||||
switch (addr.ss_family) {
|
||||
case AF_INET:
|
||||
|
@ -947,19 +1008,7 @@ ip_s_getaddress(obj, host)
|
|||
{
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
if (rb_obj_is_kind_of(host, rb_cInteger)) {
|
||||
long i = NUM2LONG(host);
|
||||
struct sockaddr_in *sin;
|
||||
sin = (struct sockaddr_in *)&addr;
|
||||
MEMZERO(sin, struct sockaddr_in, 1);
|
||||
sin->sin_family = AF_INET;
|
||||
SET_SIN_LEN(sin, sizeof(*sin));
|
||||
sin->sin_addr.s_addr = htonl(i);
|
||||
}
|
||||
else {
|
||||
setipaddr(STR2CSTR(host), (struct sockaddr *)&addr);
|
||||
}
|
||||
|
||||
setipaddr(host, &addr);
|
||||
return mkipaddr((struct sockaddr *)&addr);
|
||||
}
|
||||
|
||||
|
@ -978,56 +1027,6 @@ udp_s_open(argc, argv, class)
|
|||
return sock_new(class, socket(socktype, SOCK_DGRAM, 0));
|
||||
}
|
||||
|
||||
static struct addrinfo *
|
||||
udp_addrsetup(fptr, host, port)
|
||||
OpenFile *fptr; /* use for AF check? */
|
||||
VALUE host, port;
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
int error;
|
||||
char *hostp, *portp;
|
||||
char hbuf[1024], pbuf[1024];
|
||||
|
||||
if (NIL_P(host)) {
|
||||
hostp = NULL;
|
||||
}
|
||||
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
|
||||
struct sockaddr_in sin;
|
||||
long i = NUM2LONG(host);
|
||||
MEMZERO(&sin, struct sockaddr_in, 1);
|
||||
sin.sin_family = AF_INET;
|
||||
SET_SIN_LEN(&sin, sizeof(sin));
|
||||
sin.sin_addr.s_addr = htonl(i);
|
||||
error = getnameinfo((struct sockaddr *)&sin, SIN_LEN(&sin),
|
||||
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST);
|
||||
if (error) {
|
||||
rb_raise(rb_eSocket, "%s", gai_strerror(error));
|
||||
}
|
||||
hostp = hbuf;
|
||||
}
|
||||
else {
|
||||
strcpy(hbuf, STR2CSTR(host));
|
||||
hostp = hbuf;
|
||||
}
|
||||
if (FIXNUM_P(port)) {
|
||||
snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port));
|
||||
portp = pbuf;
|
||||
}
|
||||
else {
|
||||
portp = STR2CSTR(port);
|
||||
}
|
||||
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
hints.ai_family = PF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
error = getaddrinfo(hostp, portp, &hints, &res);
|
||||
if (error) {
|
||||
rb_raise(rb_eSocket, "%s", gai_strerror(error));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
udp_connect(sock, host, port)
|
||||
VALUE sock, host, port;
|
||||
|
@ -1038,7 +1037,7 @@ udp_connect(sock, host, port)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fd = fileno(fptr->f);
|
||||
res0 = udp_addrsetup(fptr, host, port);
|
||||
res0 = ip_addrsetup(host, port);
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
|
||||
freeaddrinfo(res0);
|
||||
|
@ -1059,7 +1058,7 @@ udp_bind(sock, host, port)
|
|||
struct addrinfo *res0, *res;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
res0 = udp_addrsetup(fptr, host, port);
|
||||
res0 = ip_addrsetup(host, port);
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) {
|
||||
continue;
|
||||
|
@ -1092,7 +1091,7 @@ udp_send(argc, argv, sock)
|
|||
rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port);
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
res0 = udp_addrsetup(fptr, host, port);
|
||||
res0 = ip_addrsetup(host, port);
|
||||
f = GetWriteFile(fptr);
|
||||
m = rb_str2cstr(mesg, &mlen);
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
|
@ -1532,7 +1531,7 @@ sock_s_gethostbyname(obj, host)
|
|||
sin->sin_addr.s_addr = htonl(i);
|
||||
}
|
||||
else {
|
||||
setipaddr(STR2CSTR(host), (struct sockaddr *)&addr);
|
||||
setipaddr(host, (struct sockaddr *)&addr);
|
||||
}
|
||||
switch (addr.ss_family) {
|
||||
case AF_INET:
|
||||
|
|
|
@ -27,8 +27,8 @@ fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); }
|
|||
*/
|
||||
|
||||
/* for callback break & continue */
|
||||
VALUE eTkCallbackBreak;
|
||||
VALUE eTkCallbackContinue;
|
||||
static VALUE eTkCallbackBreak;
|
||||
static VALUE eTkCallbackContinue;
|
||||
|
||||
/* from tkAppInit.c */
|
||||
|
||||
|
@ -49,15 +49,18 @@ typedef struct {
|
|||
} Tk_TimerData;
|
||||
|
||||
/* timer callback */
|
||||
void _timer_for_tcl(clientData)
|
||||
static void
|
||||
_timer_for_tcl(clientData)
|
||||
ClientData clientData;
|
||||
{
|
||||
Tk_TimerData *timer = (Tk_TimerData*)clientData;
|
||||
|
||||
timer->flag = 0;
|
||||
CHECK_INTS;
|
||||
if (!rb_thread_critical) rb_thread_schedule();
|
||||
|
||||
if (timer->flag) {
|
||||
Tk_DeleteTimerHandler(timer->token);
|
||||
}
|
||||
timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl,
|
||||
(ClientData)timer);
|
||||
timer->flag = 1;
|
||||
|
@ -70,7 +73,7 @@ lib_mainloop(self)
|
|||
{
|
||||
Tk_TimerData *timer;
|
||||
|
||||
timer = (Tk_TimerData *) ckalloc(sizeof(Tk_TimerData));
|
||||
timer = (Tk_TimerData *)ALLOC(Tk_TimerData);
|
||||
timer->flag = 0;
|
||||
timer->token = Tk_CreateTimerHandler(200, _timer_for_tcl,
|
||||
(ClientData)timer);
|
||||
|
@ -79,12 +82,14 @@ lib_mainloop(self)
|
|||
DUMP1("start Tk_Mainloop");
|
||||
while (Tk_GetNumMainWindows() > 0) {
|
||||
Tcl_DoOneEvent(0);
|
||||
CHECK_INTS;
|
||||
}
|
||||
DUMP1("stop Tk_Mainloop");
|
||||
|
||||
if (timer->flag) {
|
||||
Tk_DeleteTimerHandler(timer->token);
|
||||
Tk_DeleteTimerHandler(timer->token);
|
||||
}
|
||||
free(timer);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -150,11 +155,11 @@ ip_ruby(clientData, interp, argc, argv)
|
|||
VALUE eclass = CLASS_OF(failed);
|
||||
Tcl_AppendResult(interp, STR2CSTR(failed), (char*)NULL);
|
||||
if (eclass == eTkCallbackBreak) {
|
||||
return TCL_BREAK;
|
||||
return TCL_BREAK;
|
||||
} else if (eclass == eTkCallbackContinue) {
|
||||
return TCL_CONTINUE;
|
||||
return TCL_CONTINUE;
|
||||
} else {
|
||||
return TCL_ERROR;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +250,7 @@ ip_eval(self, str)
|
|||
DUMP2("Tcl_Eval(%s)", buf);
|
||||
ptr->return_value = Tcl_Eval(ptr->ip, buf);
|
||||
if (ptr->return_value == TCL_ERROR) {
|
||||
rb_raise(rb_eRuntimeError, ptr->ip->result);
|
||||
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
||||
}
|
||||
DUMP2("(TCL_Eval result) %d", ptr->return_value);
|
||||
|
||||
|
@ -260,33 +265,29 @@ ip_toUTF8(self, str, encodename)
|
|||
VALUE str;
|
||||
VALUE encodename;
|
||||
{
|
||||
#ifndef TCL_UTF_MAX
|
||||
return str;
|
||||
#else
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Encoding encoding;
|
||||
Tcl_DString dstr;
|
||||
struct tcltkip *ptr;
|
||||
char *buff1,*buff2;
|
||||
#ifdef TCL_UTF_MAX
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Encoding encoding;
|
||||
Tcl_DString dstr;
|
||||
struct tcltkip *ptr;
|
||||
char *buf;
|
||||
|
||||
Data_Get_Struct(self,struct tcltkip, ptr);
|
||||
interp = ptr->ip;
|
||||
Data_Get_Struct(self,struct tcltkip, ptr);
|
||||
interp = ptr->ip;
|
||||
|
||||
encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
|
||||
buff1 = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
|
||||
strcpy(buff1,STR2CSTR(str));
|
||||
encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
|
||||
buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
|
||||
strcpy(buf,STR2CSTR(str));
|
||||
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_ExternalToUtfDString(encoding,buff1,strlen(buff1),&dstr);
|
||||
buff2 = ALLOCA_N(char,Tcl_DStringLength(&dstr)+1);
|
||||
strcpy(buff2,Tcl_DStringValue(&dstr));
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr);
|
||||
str = rb_str_new2(Tcl_DStringValue(&dstr));
|
||||
|
||||
Tcl_FreeEncoding(encoding);
|
||||
Tcl_DStringFree(&dstr);
|
||||
|
||||
return rb_str_new2(buff2);
|
||||
Tcl_FreeEncoding(encoding);
|
||||
Tcl_DStringFree(&dstr);
|
||||
#endif
|
||||
return str;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -295,33 +296,30 @@ ip_fromUTF8(self, str, encodename)
|
|||
VALUE str;
|
||||
VALUE encodename;
|
||||
{
|
||||
#ifndef TCL_UTF_MAX
|
||||
return str;
|
||||
#else
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Encoding encoding;
|
||||
Tcl_DString dstr;
|
||||
struct tcltkip *ptr;
|
||||
char *buff1,*buff2;
|
||||
#ifdef TCL_UTF_MAX
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Encoding encoding;
|
||||
Tcl_DString dstr;
|
||||
struct tcltkip *ptr;
|
||||
char *buf;
|
||||
|
||||
Data_Get_Struct(self,struct tcltkip, ptr);
|
||||
interp = ptr->ip;
|
||||
Data_Get_Struct(self,struct tcltkip, ptr);
|
||||
interp = ptr->ip;
|
||||
|
||||
encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
|
||||
buff1 = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
|
||||
strcpy(buff1,STR2CSTR(str));
|
||||
encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
|
||||
buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
|
||||
strcpy(buf,STR2CSTR(str));
|
||||
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_UtfToExternalDString(encoding,buff1,strlen(buff1),&dstr);
|
||||
buff2 = ALLOCA_N(char,Tcl_DStringLength(&dstr)+1);
|
||||
strcpy(buff2,Tcl_DStringValue(&dstr));
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr);
|
||||
str = rb_str_new2(Tcl_DStringValue(&dstr));
|
||||
|
||||
Tcl_FreeEncoding(encoding);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_FreeEncoding(encoding);
|
||||
Tcl_DStringFree(&dstr);
|
||||
|
||||
return rb_str_new2(buff2);
|
||||
#endif
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,24 +357,25 @@ ip_invoke(argc, argv, obj)
|
|||
/* memory allocation for arguments of this command */
|
||||
if (object) {
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
/* object interface */
|
||||
ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
|
||||
for (i = 0; i < argc; ++i) {
|
||||
char *s = STR2CSTR(argv[i]);
|
||||
ov[i] = Tcl_NewStringObj(s, strlen(s));
|
||||
}
|
||||
ov[argc] = (Tcl_Obj *)NULL;
|
||||
/* object interface */
|
||||
ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
|
||||
for (i = 0; i < argc; ++i) {
|
||||
char *s = STR2CSTR(argv[i]);
|
||||
ov[i] = Tcl_NewStringObj(s, strlen(s));
|
||||
Tcl_IncrRefCount(ov[i]);
|
||||
}
|
||||
ov[argc] = (Tcl_Obj *)NULL;
|
||||
#endif
|
||||
} else {
|
||||
/* string interface */
|
||||
av = (char **)ALLOCA_N(char *, argc+1);
|
||||
for (i = 0; i < argc; ++i) {
|
||||
char *s = STR2CSTR(argv[i]);
|
||||
av = (char **)ALLOCA_N(char *, argc+1);
|
||||
for (i = 0; i < argc; ++i) {
|
||||
char *s = STR2CSTR(argv[i]);
|
||||
|
||||
av[i] = ALLOCA_N(char, strlen(s)+1);
|
||||
strcpy(av[i], s);
|
||||
}
|
||||
av[argc] = (char *)NULL;
|
||||
av[i] = ALLOCA_N(char, strlen(s)+1);
|
||||
strcpy(av[i], s);
|
||||
}
|
||||
av[argc] = (char *)NULL;
|
||||
}
|
||||
|
||||
Tcl_ResetResult(ptr->ip);
|
||||
|
@ -384,26 +383,31 @@ ip_invoke(argc, argv, obj)
|
|||
/* Invoke the C procedure */
|
||||
if (object) {
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
int dummy;
|
||||
ptr->return_value = (*info.objProc)(info.objClientData,
|
||||
ptr->ip, argc, ov);
|
||||
int dummy;
|
||||
ptr->return_value = (*info.objProc)(info.objClientData,
|
||||
ptr->ip, argc, ov);
|
||||
|
||||
/* get the string value from the result object */
|
||||
resultPtr = Tcl_GetObjResult(ptr->ip);
|
||||
Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
|
||||
TCL_VOLATILE);
|
||||
/* get the string value from the result object */
|
||||
resultPtr = Tcl_GetObjResult(ptr->ip);
|
||||
Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
|
||||
TCL_VOLATILE);
|
||||
|
||||
for (i=0; i<argc; i++) {
|
||||
Tcl_DecrRefCount(ov[i]);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ptr->return_value = (*info.proc)(info.clientData,
|
||||
ptr->ip, argc, av);
|
||||
}
|
||||
else {
|
||||
ptr->return_value = (*info.proc)(info.clientData,
|
||||
ptr->ip, argc, av);
|
||||
}
|
||||
|
||||
if (ptr->return_value == TCL_ERROR) {
|
||||
rb_raise(rb_eRuntimeError, ptr->ip->result);
|
||||
rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
|
||||
}
|
||||
|
||||
/* pass back the result (as string) */
|
||||
return(rb_str_new2(ptr->ip->result));
|
||||
return rb_str_new2(ptr->ip->result);
|
||||
}
|
||||
|
||||
/* get return code from Tcl_Eval() */
|
||||
|
@ -423,13 +427,14 @@ ip_retval(self)
|
|||
static void
|
||||
_macinit()
|
||||
{
|
||||
tcl_macQdPtr = &qd; /* setup QuickDraw globals */
|
||||
Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
|
||||
tcl_macQdPtr = &qd; /* setup QuickDraw globals */
|
||||
Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---- initialization ----*/
|
||||
void Init_tcltklib()
|
||||
void
|
||||
Init_tcltklib()
|
||||
{
|
||||
extern VALUE rb_argv0; /* the argv[0] */
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ module TkComm
|
|||
return format("rb_out %s", id);
|
||||
end
|
||||
def uninstall_cmd(id)
|
||||
id = $1 if /rb_out (c\d+)/
|
||||
Tk_CMDTBL[id] = nil
|
||||
end
|
||||
private :install_cmd, :uninstall_cmd
|
||||
|
@ -2116,7 +2117,7 @@ class TkScrollbar<TkWindow
|
|||
end
|
||||
|
||||
def get
|
||||
ary1 = tk_send('get', path).split
|
||||
ary1 = tk_send('get').split
|
||||
ary2 = []
|
||||
for i in ary1
|
||||
ary2.push number(i)
|
||||
|
|
|
@ -272,7 +272,7 @@ class TkText<TkTextWin
|
|||
end
|
||||
|
||||
def tag_cget(tag, key)
|
||||
tk_tcl2ruby tk_call @t.path, 'tag', 'cget', tag, "-#{key}"
|
||||
tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}"
|
||||
end
|
||||
|
||||
def tag_configure(tag, key, val=None)
|
||||
|
@ -289,7 +289,7 @@ class TkText<TkTextWin
|
|||
|| key == 'latinfont' || key == 'asciifont' )
|
||||
tagfont_configure({key=>val})
|
||||
else
|
||||
tk_call 'tag', 'configure', tag, "-#{key}", val
|
||||
tk_send 'tag', 'configure', tag, "-#{key}", val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ tk_s_new(argc, argv, class)
|
|||
{
|
||||
VALUE obj = rb_obj_alloc(class);
|
||||
|
||||
rb_funcall2(obj, rb_intern("initialize"), argc, argv);
|
||||
rb_obj_call_init(obj, argc, argv);
|
||||
if (rb_iterator_p()) rb_obj_instance_eval(0, 0, obj);
|
||||
return obj;
|
||||
}
|
||||
|
|
20
gc.c
20
gc.c
|
@ -50,6 +50,10 @@ static void run_final();
|
|||
static unsigned long malloc_memories = 0;
|
||||
static unsigned long alloc_objects = 0;
|
||||
|
||||
static int malloc_called = 0;
|
||||
static int free_called = 0;
|
||||
|
||||
#ifndef xmalloc
|
||||
void *
|
||||
xmalloc(size)
|
||||
size_t size;
|
||||
|
@ -64,6 +68,7 @@ xmalloc(size)
|
|||
if (malloc_memories > GC_MALLOC_LIMIT && alloc_objects > GC_NEWOBJ_LIMIT) {
|
||||
rb_gc();
|
||||
}
|
||||
malloc_called++;
|
||||
mem = malloc(size);
|
||||
if (!mem) {
|
||||
rb_gc();
|
||||
|
@ -111,6 +116,15 @@ xrealloc(ptr, size)
|
|||
return mem;
|
||||
}
|
||||
|
||||
static void
|
||||
xfree(x)
|
||||
void *x;
|
||||
{
|
||||
free_called++;
|
||||
free(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The way of garbage collecting which allows use of the cstack is due to */
|
||||
/* Scheme In One Defun, but in C this time.
|
||||
|
||||
|
@ -661,7 +675,7 @@ gc_sweep()
|
|||
if (p->as.basic.flags) {
|
||||
obj_free((VALUE)p);
|
||||
}
|
||||
if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
|
||||
if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
|
||||
p->as.free.flag = FL_MARK; /* remain marked */
|
||||
p->as.free.next = final_list;
|
||||
final_list = p;
|
||||
|
@ -1118,6 +1132,10 @@ rb_gc_call_finalizer_at_exit()
|
|||
DATA_PTR(p) &&
|
||||
RANY(p)->as.data.dfree)
|
||||
(*RANY(p)->as.data.dfree)(DATA_PTR(p));
|
||||
#if 0
|
||||
else if (BUILTIN_TYPE(p))
|
||||
obj_free((VALUE)p);
|
||||
#endif
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
|
2
intern.h
2
intern.h
|
@ -245,7 +245,7 @@ void ruby_script _((char*));
|
|||
void ruby_prog_init _((void));
|
||||
void ruby_set_argv _((int, char**));
|
||||
void ruby_process_options _((int, char**));
|
||||
void ruby_require_modules _((void));
|
||||
void ruby_require_libraries _((void));
|
||||
void ruby_load_script _((void));
|
||||
/* signal.c */
|
||||
VALUE rb_f_kill _((int, VALUE*));
|
||||
|
|
13
io.c
13
io.c
|
@ -55,8 +55,12 @@ struct timeval {
|
|||
#include <sys/errno.h>
|
||||
#include <unix.mac.h>
|
||||
#include <compat.h>
|
||||
extern char* strdup(const char*);
|
||||
#endif
|
||||
|
||||
#ifndef strdup
|
||||
char *strdup();
|
||||
#endif
|
||||
|
||||
extern void Init_File _((void));
|
||||
|
||||
#ifdef __BEOS__
|
||||
|
@ -866,9 +870,11 @@ static void
|
|||
rb_io_fptr_close(fptr)
|
||||
OpenFile *fptr;
|
||||
{
|
||||
if (fptr->f == NULL && fptr->f2 == NULL) return;
|
||||
rb_thread_fd_close(fileno(fptr->f));
|
||||
int fd;
|
||||
|
||||
if (fptr->f == NULL && fptr->f2 == NULL) return;
|
||||
|
||||
fd = fileno(fptr->f);
|
||||
if (fptr->finalize) {
|
||||
(*fptr->finalize)(fptr);
|
||||
}
|
||||
|
@ -876,6 +882,7 @@ rb_io_fptr_close(fptr)
|
|||
fptr_finalize(fptr);
|
||||
}
|
||||
fptr->f = fptr->f2 = NULL;
|
||||
rb_thread_fd_close(fd);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
module Open3
|
||||
#[stdin, stdout, stderr] = popen3(command);
|
||||
def popen3(cmd)
|
||||
pw = pipe # pipe[0] for read, pipe[1] for write
|
||||
pr = pipe
|
||||
pe = pipe
|
||||
pw = IO::pipe # pipe[0] for read, pipe[1] for write
|
||||
pr = IO::pipe
|
||||
pe = IO::pipe
|
||||
|
||||
pid = fork
|
||||
if pid == nil then # child
|
||||
|
|
2
main.c
2
main.c
|
@ -11,7 +11,7 @@
|
|||
#include "ruby.h"
|
||||
|
||||
#ifdef DJGPP
|
||||
unsigned int _stklen = 0x100000;
|
||||
unsigned int _stklen = 0x180000;
|
||||
#endif
|
||||
|
||||
#ifdef __human68k__
|
||||
|
|
6
parse.c
6
parse.c
|
@ -4696,6 +4696,9 @@ yyerrhandle:
|
|||
#include <sys/types.h>
|
||||
#include "regex.h"
|
||||
#include "util.h"
|
||||
#ifndef strdup
|
||||
char *strdup();
|
||||
#endif
|
||||
|
||||
#define is_identchar(c) (((int)(c))!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c)))
|
||||
|
||||
|
@ -4840,7 +4843,6 @@ rb_compile_file(f, file, start)
|
|||
return yycompile(strdup(f));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nextc()
|
||||
{
|
||||
|
@ -7255,7 +7257,7 @@ top_local_setup()
|
|||
int i;
|
||||
|
||||
if (len > 0) {
|
||||
i = lvtbl->tbl[0];
|
||||
i = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
|
||||
|
||||
if (i < len) {
|
||||
if (i == 0 || ruby_scope->flag == SCOPE_ALLOCA) {
|
||||
|
|
6
parse.y
6
parse.y
|
@ -1624,6 +1624,9 @@ none : /* none */
|
|||
#include <sys/types.h>
|
||||
#include "regex.h"
|
||||
#include "util.h"
|
||||
#ifndef strdup
|
||||
char *strdup();
|
||||
#endif
|
||||
|
||||
#define is_identchar(c) (((int)(c))!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c)))
|
||||
|
||||
|
@ -1768,7 +1771,6 @@ rb_compile_file(f, file, start)
|
|||
return yycompile(strdup(f));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
nextc()
|
||||
{
|
||||
|
@ -4183,7 +4185,7 @@ top_local_setup()
|
|||
int i;
|
||||
|
||||
if (len > 0) {
|
||||
i = lvtbl->tbl[0];
|
||||
i = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
|
||||
|
||||
if (i < len) {
|
||||
if (i == 0 || ruby_scope->flag == SCOPE_ALLOCA) {
|
||||
|
|
9
regex.c
9
regex.c
|
@ -57,11 +57,6 @@
|
|||
|
||||
#ifndef __STDC__
|
||||
# define volatile
|
||||
# ifdef __GNUC__
|
||||
# define const __const__
|
||||
# else
|
||||
# define const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
|
@ -70,10 +65,12 @@
|
|||
# define _(args) ()
|
||||
#endif
|
||||
|
||||
#ifndef xmalloc
|
||||
void *xmalloc _((unsigned long));
|
||||
void *xcalloc _((unsigned long,unsigned long));
|
||||
void *xrealloc _((void*,unsigned long));
|
||||
void free _((void*));
|
||||
#endif
|
||||
|
||||
/* #define NO_ALLOCA */ /* try it out for now */
|
||||
#ifndef NO_ALLOCA
|
||||
|
@ -3764,7 +3761,7 @@ re_match(bufp, string_arg, size, pos, regs)
|
|||
case jump:
|
||||
nofinalize:
|
||||
EXTRACT_NUMBER_AND_INCR(mcnt, p);
|
||||
if (mcnt < 0 && stackp[-2] == d) /* avoid infinit loop */
|
||||
if (mcnt < 0 && stackp > stackb && stackp[-2] == d) /* avoid infinit loop */
|
||||
goto fail;
|
||||
p += mcnt;
|
||||
continue;
|
||||
|
|
13
ruby.c
13
ruby.c
|
@ -238,7 +238,7 @@ add_modules(mod)
|
|||
}
|
||||
|
||||
void
|
||||
ruby_require_modules()
|
||||
ruby_require_libraries()
|
||||
{
|
||||
struct req_list *list = req_list_head.next;
|
||||
struct req_list *tmp;
|
||||
|
@ -821,10 +821,15 @@ ruby_libpath()
|
|||
strcpy(libpath, __dos_argv0);
|
||||
#endif
|
||||
p = strrchr(libpath, '\\');
|
||||
if (p)
|
||||
if (p) {
|
||||
*p = 0;
|
||||
if (!strcasecmp(p-4, "\\bin"))
|
||||
p -= 4;
|
||||
if (!strcasecmp(p-4, "\\bin"))
|
||||
p -= 4;
|
||||
} else {
|
||||
strcpy(libpath, ".");
|
||||
p = libpath + 1;
|
||||
}
|
||||
|
||||
strcpy(p, "\\lib");
|
||||
#if defined(__CYGWIN32__)
|
||||
p = (char *)malloc(strlen(libpath)+10);
|
||||
|
|
|
@ -848,6 +848,10 @@ $x = []
|
|||
x = proc{binding}.call
|
||||
eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
|
||||
ok($x[4].call == 8)
|
||||
x = proc{binding}.call
|
||||
eval "for i6 in 1..1; j6=i6; end", x
|
||||
ok(eval("defined? i6", x))
|
||||
ok(eval("defined? j6", x))
|
||||
|
||||
proc {
|
||||
p = binding
|
||||
|
@ -861,20 +865,20 @@ proc {
|
|||
ok(eval("foo22") == 55)
|
||||
}.call
|
||||
|
||||
p1 = proc{i6 = 0; proc{i6}}.call
|
||||
p1 = proc{i7 = 0; proc{i7}}.call
|
||||
ok(p1.call == 0)
|
||||
eval "i6=5", p1
|
||||
eval "i7=5", p1
|
||||
ok(p1.call == 5)
|
||||
ok(!defined?(i6))
|
||||
ok(!defined?(i7))
|
||||
|
||||
p1 = proc{i6 = 0; proc{i6}}.call
|
||||
i6 = nil
|
||||
p1 = proc{i7 = 0; proc{i7}}.call
|
||||
i7 = nil
|
||||
ok(p1.call == 0)
|
||||
eval "i6=1", p1
|
||||
eval "i7=1", p1
|
||||
ok(p1.call == 1)
|
||||
eval "i6=5", p1
|
||||
eval "i7=5", p1
|
||||
ok(p1.call == 5)
|
||||
ok(i6 == nil)
|
||||
ok(i7 == nil)
|
||||
|
||||
check "system"
|
||||
ok(`echo foobar` == "foobar\n")
|
||||
|
|
28
st.c
28
st.c
|
@ -45,9 +45,11 @@ static struct st_hash_type type_strhash = {
|
|||
strhash,
|
||||
};
|
||||
|
||||
#ifndef xmalloc
|
||||
void *xmalloc();
|
||||
void *xcalloc();
|
||||
void *xrealloc();
|
||||
#endif
|
||||
static void rehash();
|
||||
|
||||
#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))
|
||||
|
@ -220,19 +222,19 @@ st_lookup(table, key, value)
|
|||
|
||||
#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
|
||||
{\
|
||||
st_table_entry *tbl;\
|
||||
st_table_entry *entry;\
|
||||
if (table->num_entries/table->num_bins > ST_DEFAULT_MAX_DENSITY) {\
|
||||
rehash(table);\
|
||||
bin_pos = hash_val % table->num_bins;\
|
||||
}\
|
||||
\
|
||||
tbl = alloc(st_table_entry);\
|
||||
entry = alloc(st_table_entry);\
|
||||
\
|
||||
tbl->hash = hash_val;\
|
||||
tbl->key = key;\
|
||||
tbl->record = value;\
|
||||
tbl->next = table->bins[bin_pos];\
|
||||
table->bins[bin_pos] = tbl;\
|
||||
entry->hash = hash_val;\
|
||||
entry->key = key;\
|
||||
entry->record = value;\
|
||||
entry->next = table->bins[bin_pos];\
|
||||
table->bins[bin_pos] = entry;\
|
||||
table->num_entries++;\
|
||||
}
|
||||
|
||||
|
@ -301,7 +303,7 @@ st_copy(old_table)
|
|||
st_table *old_table;
|
||||
{
|
||||
st_table *new_table;
|
||||
st_table_entry *ptr, *tbl;
|
||||
st_table_entry *ptr, *entry;
|
||||
int i, num_bins = old_table->num_bins;
|
||||
|
||||
new_table = alloc(st_table);
|
||||
|
@ -322,15 +324,15 @@ st_copy(old_table)
|
|||
new_table->bins[i] = 0;
|
||||
ptr = old_table->bins[i];
|
||||
while (ptr != 0) {
|
||||
tbl = alloc(st_table_entry);
|
||||
if (tbl == 0) {
|
||||
entry = alloc(st_table_entry);
|
||||
if (entry == 0) {
|
||||
free(new_table->bins);
|
||||
free(new_table);
|
||||
return 0;
|
||||
}
|
||||
*tbl = *ptr;
|
||||
tbl->next = new_table->bins[i];
|
||||
new_table->bins[i] = tbl;
|
||||
*entry = *ptr;
|
||||
entry->next = new_table->bins[i];
|
||||
new_table->bins[i] = entry;
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
|
214
string.c
214
string.c
|
@ -1032,7 +1032,7 @@ rb_str_sub(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_sub_bang(argc, argv, str = rb_str_dup(str));
|
||||
VALUE val = rb_str_sub_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1139,7 +1139,7 @@ rb_str_gsub(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_gsub_bang(argc, argv, str = rb_str_dup(str));
|
||||
VALUE val = rb_str_gsub_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1186,8 +1186,8 @@ rb_f_sub(argc, argv)
|
|||
{
|
||||
VALUE line, v;
|
||||
|
||||
line = rb_str_dup(uscore_get());
|
||||
v = rb_str_sub_bang(argc, argv, line);
|
||||
line = uscore_get();
|
||||
v = rb_str_sub_bang(argc, argv, rb_str_dup(line));
|
||||
if (NIL_P(v)) return line;
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
|
@ -1208,8 +1208,8 @@ rb_f_gsub(argc, argv)
|
|||
{
|
||||
VALUE line, v;
|
||||
|
||||
line = rb_str_dup(uscore_get());
|
||||
v = rb_str_gsub_bang(argc, argv, line);
|
||||
line = uscore_get();
|
||||
v = rb_str_gsub_bang(argc, argv, rb_str_dup(line));
|
||||
if (NIL_P(v)) return line;
|
||||
rb_lastline_set(v);
|
||||
return v;
|
||||
|
@ -1513,7 +1513,7 @@ static VALUE
|
|||
rb_str_upcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_upcase_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_upcase_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1547,7 +1547,7 @@ static VALUE
|
|||
rb_str_downcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_downcase_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_downcase_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1583,7 +1583,7 @@ static VALUE
|
|||
rb_str_capitalize(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_capitalize_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_capitalize_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1621,7 +1621,7 @@ static VALUE
|
|||
rb_str_swapcase(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_swapcase_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_swapcase_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1665,7 +1665,7 @@ trnext(t)
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE rb_str_delete_bang _((VALUE,VALUE));
|
||||
static VALUE rb_str_delete_bang _((int,VALUE*,VALUE));
|
||||
|
||||
static VALUE
|
||||
tr_trans(str, src, repl, sflag)
|
||||
|
@ -1674,7 +1674,7 @@ tr_trans(str, src, repl, sflag)
|
|||
{
|
||||
struct tr trsrc, trrepl;
|
||||
int cflag = 0;
|
||||
char trans[256];
|
||||
int trans[256];
|
||||
int i, c, modify = 0;
|
||||
char *s, *send;
|
||||
|
||||
|
@ -1686,7 +1686,9 @@ tr_trans(str, src, repl, sflag)
|
|||
trsrc.p++;
|
||||
}
|
||||
if (TYPE(repl) != T_STRING) repl = rb_str_to_str(repl);
|
||||
if (RSTRING(repl)->len == 0) return rb_str_delete_bang(str, src);
|
||||
if (RSTRING(repl)->len == 0) {
|
||||
return rb_str_delete_bang(1, &src, str);
|
||||
}
|
||||
trrepl.p = RSTRING(repl)->ptr;
|
||||
trrepl.pend = trrepl.p + RSTRING(repl)->len;
|
||||
trsrc.gen = trrepl.gen = 0;
|
||||
|
@ -1698,12 +1700,12 @@ tr_trans(str, src, repl, sflag)
|
|||
trans[i] = 1;
|
||||
}
|
||||
while ((c = trnext(&trsrc)) >= 0) {
|
||||
trans[c & 0xff] = 0;
|
||||
trans[c & 0xff] = -1;
|
||||
}
|
||||
while ((c = trnext(&trrepl)) >= 0)
|
||||
/* retrieve last replacer */;
|
||||
for (i=0; i<256; i++) {
|
||||
if (trans[i] != 0) {
|
||||
if (trans[i] >= 0) {
|
||||
trans[i] = trrepl.now;
|
||||
}
|
||||
}
|
||||
|
@ -1712,7 +1714,7 @@ tr_trans(str, src, repl, sflag)
|
|||
int r;
|
||||
|
||||
for (i=0; i<256; i++) {
|
||||
trans[i] = 0;
|
||||
trans[i] = -1;
|
||||
}
|
||||
while ((c = trnext(&trsrc)) >= 0) {
|
||||
r = trnext(&trrepl);
|
||||
|
@ -1728,10 +1730,10 @@ tr_trans(str, src, repl, sflag)
|
|||
|
||||
while (s < send) {
|
||||
c0 = *s++;
|
||||
if ((c = trans[c0 & 0xff] & 0xff) != 0) {
|
||||
if ((c = trans[c0 & 0xff]) >= 0) {
|
||||
if (last == c) continue;
|
||||
last = c;
|
||||
*t++ = c;
|
||||
*t++ = c & 0xff;
|
||||
modify = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -1747,8 +1749,8 @@ tr_trans(str, src, repl, sflag)
|
|||
}
|
||||
else {
|
||||
while (s < send) {
|
||||
if ((c = trans[*s & 0xff] & 0xff) != 0) {
|
||||
*s = c;
|
||||
if ((c = trans[*s & 0xff]) >= 0) {
|
||||
*s = c & 0xff;
|
||||
modify = 1;
|
||||
}
|
||||
s++;
|
||||
|
@ -1770,51 +1772,70 @@ static VALUE
|
|||
rb_str_tr(str, src, repl)
|
||||
VALUE str, src, repl;
|
||||
{
|
||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 0);
|
||||
VALUE val = tr_trans(rb_str_dup(str), src, repl, 0);
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
tr_setup_table(str, table)
|
||||
tr_setup_table(str, table, init)
|
||||
VALUE str;
|
||||
char table[256];
|
||||
int init;
|
||||
{
|
||||
char buf[256];
|
||||
struct tr tr;
|
||||
int i, cflag = 0;
|
||||
int c;
|
||||
int i, c;
|
||||
int cflag = 0;
|
||||
|
||||
tr.p = RSTRING(str)->ptr; tr.pend = tr.p + RSTRING(str)->len;
|
||||
tr.gen = tr.now = tr.max = 0;
|
||||
if (RSTRING(str)->len > 1 && RSTRING(str)->ptr[0] == '^') {
|
||||
cflag++;
|
||||
cflag = 1;
|
||||
tr.p++;
|
||||
}
|
||||
|
||||
for (i=0; i<256; i++) {
|
||||
table[i] = cflag ? 1 : 0;
|
||||
if (init) {
|
||||
for (i=0; i<256; i++) {
|
||||
table[i] = 1;
|
||||
}
|
||||
}
|
||||
for (i=0; i<256; i++) {
|
||||
buf[i] = cflag;
|
||||
}
|
||||
while ((c = trnext(&tr)) >= 0) {
|
||||
table[c & 0xff] = cflag ? 0 : 1;
|
||||
buf[c & 0xff] = !cflag;
|
||||
}
|
||||
for (i=0; i<256; i++) {
|
||||
table[i] = table[i]&&buf[i];
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_delete_bang(str1, str2)
|
||||
VALUE str1, str2;
|
||||
rb_str_delete_bang(argc, argv, str)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
char *s, *send, *t;
|
||||
char squeez[256];
|
||||
int modify = 0;
|
||||
int init = 1;
|
||||
int i;
|
||||
|
||||
if (TYPE(str2) != T_STRING) str2 = rb_str_to_str(str2);
|
||||
tr_setup_table(str2, squeez);
|
||||
for (i=0; i<argc; i++) {
|
||||
VALUE s = argv[i];
|
||||
|
||||
rb_str_modify(str1);
|
||||
if (TYPE(s) != T_STRING)
|
||||
s = rb_str_to_str(s);
|
||||
tr_setup_table(s, squeez, init);
|
||||
init = 0;
|
||||
}
|
||||
|
||||
s = t = RSTRING(str1)->ptr;
|
||||
send = s + RSTRING(str1)->len;
|
||||
rb_str_modify(str);
|
||||
s = t = RSTRING(str)->ptr;
|
||||
send = s + RSTRING(str)->len;
|
||||
while (s < send) {
|
||||
if (squeez[*s & 0xff])
|
||||
modify = 1;
|
||||
|
@ -1823,45 +1844,56 @@ rb_str_delete_bang(str1, str2)
|
|||
s++;
|
||||
}
|
||||
*t = '\0';
|
||||
RSTRING(str1)->len = t - RSTRING(str1)->ptr;
|
||||
RSTRING(str)->len = t - RSTRING(str)->ptr;
|
||||
|
||||
if (modify) return str1;
|
||||
if (modify) return str;
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_delete(str1, str2)
|
||||
VALUE str1, str2;
|
||||
rb_str_delete(argc, argv, str)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_delete_bang(str1 = rb_str_dup(str1), str2);
|
||||
VALUE val = rb_str_delete_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str1;
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
tr_squeeze(str1, str2)
|
||||
VALUE str1, str2;
|
||||
rb_str_squeeze_bang(argc, argv, str)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
char squeez[256];
|
||||
char *s, *send, *t;
|
||||
char c, save, modify = 0;
|
||||
int init = 1;
|
||||
int i;
|
||||
|
||||
if (!NIL_P(str2)) {
|
||||
tr_setup_table(str2, squeez);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
|
||||
if (argc == 0) {
|
||||
for (i=0; i<256; i++) {
|
||||
squeez[i] = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i=0; i<argc; i++) {
|
||||
VALUE s = argv[i];
|
||||
|
||||
rb_str_modify(str1);
|
||||
if (TYPE(s) != T_STRING)
|
||||
s = rb_str_to_str(s);
|
||||
tr_setup_table(s, squeez, init);
|
||||
init = 0;
|
||||
}
|
||||
}
|
||||
|
||||
s = t = RSTRING(str1)->ptr;
|
||||
send = s + RSTRING(str1)->len;
|
||||
rb_str_modify(str);
|
||||
|
||||
s = t = RSTRING(str)->ptr;
|
||||
send = s + RSTRING(str)->len;
|
||||
save = -1;
|
||||
while (s < send) {
|
||||
c = *s++ & 0xff;
|
||||
|
@ -1870,36 +1902,22 @@ tr_squeeze(str1, str2)
|
|||
}
|
||||
}
|
||||
*t = '\0';
|
||||
if (t - RSTRING(str1)->ptr != RSTRING(str1)->len) {
|
||||
RSTRING(str1)->len = t - RSTRING(str1)->ptr;
|
||||
if (t - RSTRING(str)->ptr != RSTRING(str)->len) {
|
||||
RSTRING(str)->len = t - RSTRING(str)->ptr;
|
||||
modify = 1;
|
||||
}
|
||||
|
||||
if (modify) return str1;
|
||||
if (modify) return str;
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_squeeze_bang(argc, argv, str1)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str1;
|
||||
{
|
||||
VALUE str2;
|
||||
|
||||
if (rb_scan_args(argc, argv, "01", &str2) == 1 && TYPE(str2) != T_STRING) {
|
||||
str2 = rb_str_to_str(str2);
|
||||
}
|
||||
return tr_squeeze(str1, str2);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_squeeze(argc, argv, str)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_squeeze_bang(argc, argv, str = rb_str_dup(str));
|
||||
VALUE val = rb_str_squeeze_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -1916,12 +1934,47 @@ static VALUE
|
|||
rb_str_tr_s(str, src, repl)
|
||||
VALUE str, src, repl;
|
||||
{
|
||||
VALUE val = tr_trans(str = rb_str_dup(str), src, repl, 1);
|
||||
VALUE val = tr_trans(rb_str_dup(str), src, repl, 1);
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_count(argc, argv, str)
|
||||
int argc;
|
||||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE a1, a2;
|
||||
char table[256];
|
||||
char *s, *send;
|
||||
int init = 1;
|
||||
int i;
|
||||
|
||||
if (argc < 0) {
|
||||
rb_raise(rb_eArgError, "wrong # of arguments");
|
||||
}
|
||||
for (i=0; i<argc; i++) {
|
||||
VALUE s = argv[i];
|
||||
|
||||
if (TYPE(s) != T_STRING)
|
||||
s = rb_str_to_str(s);
|
||||
tr_setup_table(s, table, init);
|
||||
init = 0;
|
||||
}
|
||||
|
||||
s = RSTRING(str)->ptr;
|
||||
send = s + RSTRING(str)->len;
|
||||
i = 0;
|
||||
while (s < send) {
|
||||
if (table[*s++ & 0xff]) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return INT2NUM(i);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_split_method(argc, argv, str)
|
||||
int argc;
|
||||
|
@ -2170,7 +2223,7 @@ static VALUE
|
|||
rb_str_chop(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_chop_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_chop_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -2186,8 +2239,8 @@ rb_f_chop_bang(str)
|
|||
static VALUE
|
||||
rb_f_chop()
|
||||
{
|
||||
VALUE str = rb_str_dup(uscore_get());
|
||||
VALUE val = rb_str_chop_bang(str);
|
||||
VALUE str = uscore_get();
|
||||
VALUE val = rb_str_chop_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
rb_lastline_set(val);
|
||||
|
@ -2243,7 +2296,7 @@ rb_str_chomp(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, str = rb_str_dup(str));
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -2262,8 +2315,8 @@ rb_f_chomp(argc, argv)
|
|||
int argc;
|
||||
VALUE *argv;
|
||||
{
|
||||
VALUE str = rb_str_dup(uscore_get());
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, str);
|
||||
VALUE str = uscore_get();
|
||||
VALUE val = rb_str_chomp_bang(argc, argv, rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
rb_lastline_set(val);
|
||||
|
@ -2310,7 +2363,7 @@ static VALUE
|
|||
rb_str_strip(str)
|
||||
VALUE str;
|
||||
{
|
||||
VALUE val = rb_str_strip_bang(str = rb_str_dup(str));
|
||||
VALUE val = rb_str_strip_bang(rb_str_dup(str));
|
||||
|
||||
if (NIL_P(val)) return str;
|
||||
return val;
|
||||
|
@ -2611,12 +2664,13 @@ Init_String()
|
|||
|
||||
rb_define_method(rb_cString, "tr", rb_str_tr, 2);
|
||||
rb_define_method(rb_cString, "tr_s", rb_str_tr_s, 2);
|
||||
rb_define_method(rb_cString, "delete", rb_str_delete, 1);
|
||||
rb_define_method(rb_cString, "delete", rb_str_delete, -1);
|
||||
rb_define_method(rb_cString, "squeeze", rb_str_squeeze, -1);
|
||||
rb_define_method(rb_cString, "count", rb_str_count, -1);
|
||||
|
||||
rb_define_method(rb_cString, "tr!", rb_str_tr_bang, 2);
|
||||
rb_define_method(rb_cString, "tr_s!", rb_str_tr_s_bang, 2);
|
||||
rb_define_method(rb_cString, "delete!", rb_str_delete_bang, 1);
|
||||
rb_define_method(rb_cString, "delete!", rb_str_delete_bang, -1);
|
||||
rb_define_method(rb_cString, "squeeze!", rb_str_squeeze_bang, -1);
|
||||
|
||||
rb_define_method(rb_cString, "each_line", rb_str_each_line, -1);
|
||||
|
|
6
struct.c
6
struct.c
|
@ -250,10 +250,14 @@ rb_struct_initialize(self, values)
|
|||
|
||||
size = iv_get(klass, "__size__");
|
||||
n = FIX2INT(size);
|
||||
if (n != RARRAY(values)->len) {
|
||||
if (n < RARRAY(values)->len) {
|
||||
rb_raise(rb_eArgError, "struct size differs");
|
||||
}
|
||||
MEMCPY(RSTRUCT(self)->ptr, RARRAY(values)->ptr, VALUE, RARRAY(values)->len);
|
||||
if (n > RARRAY(values)->len) {
|
||||
rb_mem_clear(RSTRUCT(self)->ptr+RARRAY(values)->len,
|
||||
n-RARRAY(values)->len);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
|
8
top.sed
8
top.sed
|
@ -1,7 +1,7 @@
|
|||
/^SHELL/s,/bin/sh,$(COMPSEC),
|
||||
s/@srcdir@/./g
|
||||
s/@top_srcdir@/../
|
||||
s%@CFLAGS@%-g -O2%g
|
||||
s%@CFLAGS@%-O2%g
|
||||
s%@CPPFLAGS@%%g
|
||||
s%@LDFLAGS@%%g
|
||||
s%@LIBS@%-lm %g
|
||||
|
@ -35,6 +35,7 @@ s%@INSTALL_DATA@%${INSTALL} -m 644%g
|
|||
s%@SET_MAKE@%%g
|
||||
s%@LIBOBJS@% crypt.o flock.o vsnprintf.o%g
|
||||
s%@ALLOCA@%%g
|
||||
s%@XLDFLAGS@%%g
|
||||
s%@DLDFLAGS@%%g
|
||||
s%@STATIC@%%g
|
||||
s%@CCDLFLAGS@%%g
|
||||
|
@ -44,7 +45,9 @@ s%@STRIP@%strip%g
|
|||
s%@EXTSTATIC@%%g
|
||||
s%@binsuffix@%.exe%g
|
||||
s%@setup@%Setup.dj%g
|
||||
s%@RUBY_INSTALL_NAME@%ruby%g
|
||||
s%@LIBRUBY@%libruby.a%g
|
||||
s%@LIBRUBY_A@%libruby.a%g
|
||||
s%@LIBRUBYARG@%libruby.a%g
|
||||
s%@SOLIBS@%%g
|
||||
s%@arch@%i386-djgpp%g
|
||||
|
@ -55,4 +58,7 @@ s%@archlib@%/usr/local/lib/ruby/i386-djgpp%
|
|||
s,/dev/null 2>&1, nul,
|
||||
s,2> /dev/null,,
|
||||
}
|
||||
/^config.status/ {
|
||||
N;N;N;N;N;d
|
||||
}
|
||||
s%y\.tab\.c%y_tab.c%
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "node.h"
|
||||
#include "st.h"
|
||||
|
||||
#ifdef USE_CWGUSI
|
||||
char* strdup(const char*);
|
||||
#ifndef strdup
|
||||
char *strdup();
|
||||
#endif
|
||||
|
||||
static st_table *rb_global_tbl;
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define RUBY_VERSION "1.3.3"
|
||||
#define RUBY_RELEASE_DATE "1999-05-25"
|
||||
#define RUBY_VERSION "1.3.4"
|
||||
#define RUBY_RELEASE_DATE "1999-05-31"
|
||||
|
|
134
win32/win32.c
134
win32/win32.c
|
@ -33,6 +33,8 @@
|
|||
#define bool int
|
||||
#endif
|
||||
|
||||
#define TO_SOCKET(x) _get_osfhandle(x)
|
||||
|
||||
bool NtSyncProcess = TRUE;
|
||||
#if 0 // declared in header file
|
||||
extern char **environ;
|
||||
|
@ -302,6 +304,14 @@ isInternalCmd(char *cmd)
|
|||
}
|
||||
|
||||
|
||||
SOCKET
|
||||
myget_osfhandle(int fh)
|
||||
{
|
||||
return _get_osfhandle(fh);
|
||||
|
||||
}
|
||||
|
||||
|
||||
FILE *
|
||||
mypopen (char *cmd, char *mode)
|
||||
{
|
||||
|
@ -1582,18 +1592,79 @@ valid_filename(char *s)
|
|||
// if we can prevent perl from trying to do stdio on sockets.
|
||||
//
|
||||
|
||||
EXTERN_C int __cdecl _alloc_osfhnd(void);
|
||||
EXTERN_C int __cdecl _set_osfhnd(int fh, long value);
|
||||
EXTERN_C void __cdecl _lock_fhandle(int);
|
||||
EXTERN_C void __cdecl _unlock_fhandle(int);
|
||||
EXTERN_C void __cdecl _unlock(int);
|
||||
|
||||
typedef struct {
|
||||
long osfhnd; /* underlying OS file HANDLE */
|
||||
char osfile; /* attributes of file (e.g., open in text mode?) */
|
||||
char pipech; /* one char buffer for handles opened on pipes */
|
||||
#if defined (_MT) && !defined (DLL_FOR_WIN32S)
|
||||
int lockinitflag;
|
||||
CRITICAL_SECTION lock;
|
||||
#endif /* defined (_MT) && !defined (DLL_FOR_WIN32S) */
|
||||
} ioinfo;
|
||||
|
||||
EXTERN_C ioinfo * __pioinfo[];
|
||||
|
||||
#define IOINFO_L2E 5
|
||||
#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
|
||||
#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1)))
|
||||
#define _osfile(i) (_pioinfo(i)->osfile)
|
||||
|
||||
#define FOPEN 0x01 /* file handle open */
|
||||
#define FAPPEND 0x20 /* file handle opened O_APPEND */
|
||||
#define FDEV 0x40 /* file handle refers to device */
|
||||
#define FTEXT 0x80 /* file handle is in text mode */
|
||||
|
||||
static int
|
||||
my_open_osfhandle(long osfhandle, int flags)
|
||||
{
|
||||
int fh;
|
||||
char fileflags; /* _osfile flags */
|
||||
|
||||
/* copy relevant flags from second parameter */
|
||||
fileflags = FDEV;
|
||||
|
||||
if (flags & O_APPEND)
|
||||
fileflags |= FAPPEND;
|
||||
|
||||
if (flags & O_TEXT)
|
||||
fileflags |= FTEXT;
|
||||
|
||||
/* attempt to allocate a C Runtime file handle */
|
||||
if ((fh = _alloc_osfhnd()) == -1) {
|
||||
errno = EMFILE; /* too many open files */
|
||||
_doserrno = 0L; /* not an OS error */
|
||||
return -1; /* return error to caller */
|
||||
}
|
||||
|
||||
/* the file is open. now, set the info in _osfhnd array */
|
||||
_set_osfhnd(fh, osfhandle);
|
||||
|
||||
fileflags |= FOPEN; /* mark as open */
|
||||
|
||||
_osfile(fh) = fileflags; /* set osfile entry */
|
||||
// _unlock_fhandle(fh);
|
||||
|
||||
return fh; /* return handle */
|
||||
}
|
||||
|
||||
FILE *
|
||||
myfdopen (int fd, const char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
char sockbuf[80];
|
||||
int optlen;
|
||||
int retval;
|
||||
int fh;
|
||||
extern int errno;
|
||||
|
||||
//fprintf(stderr, "myfdopen()\n");
|
||||
|
||||
optlen = sizeof(sockbuf);
|
||||
optlen = sizeof(sockbuf);
|
||||
retval = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen);
|
||||
if (retval == SOCKET_ERROR) {
|
||||
int iRet;
|
||||
|
@ -1606,17 +1677,16 @@ myfdopen (int fd, const char *mode)
|
|||
//
|
||||
// If we get here, then fd is actually a socket.
|
||||
//
|
||||
fp = xcalloc(sizeof(FILE), 1);
|
||||
#if _MSC_VER < 800
|
||||
fileno(fp) = fd;
|
||||
#else
|
||||
fp->_file = fd;
|
||||
#endif
|
||||
if (*mode == 'r')
|
||||
fp->_flag = _IOREAD;
|
||||
else
|
||||
fp->_flag = _IOWRT;
|
||||
return fp;
|
||||
|
||||
fh = my_open_osfhandle((SOCKET)fd, O_RDWR|O_BINARY);
|
||||
return _fdopen(fh, mode); // return file pointer
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
myfdclose(FILE *fp)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1738,6 +1808,7 @@ StartSockets () {
|
|||
WORD version;
|
||||
WSADATA retdata;
|
||||
int ret;
|
||||
int iSockOpt;
|
||||
|
||||
//
|
||||
// initalize the winsock interface and insure that it\'s
|
||||
|
@ -1753,6 +1824,13 @@ StartSockets () {
|
|||
rb_fatal("could not find version 1 of winsock dll\n");
|
||||
|
||||
atexit((void (*)(void)) WSACleanup);
|
||||
|
||||
iSockOpt = SO_SYNCHRONOUS_NONALERT;
|
||||
/*
|
||||
* Enable the use of sockets as filehandles
|
||||
*/
|
||||
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
|
||||
(char *)&iSockOpt, sizeof(iSockOpt));
|
||||
}
|
||||
|
||||
#undef accept
|
||||
|
@ -1765,7 +1843,7 @@ myaccept (SOCKET s, struct sockaddr *addr, int *addrlen)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = accept (s, addr, addrlen)) == INVALID_SOCKET)
|
||||
if ((r = accept (TO_SOCKET(s), addr, addrlen)) == INVALID_SOCKET)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1809,7 +1887,7 @@ mygetpeername (SOCKET s, struct sockaddr *addr, int *addrlen)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = getpeername (s, addr, addrlen)) == SOCKET_ERROR)
|
||||
if ((r = getpeername (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1823,7 +1901,7 @@ mygetsockname (SOCKET s, struct sockaddr *addr, int *addrlen)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = getsockname (s, addr, addrlen)) == SOCKET_ERROR)
|
||||
if ((r = getsockname (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1851,7 +1929,7 @@ myioctlsocket (SOCKET s, long cmd, u_long *argp)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = ioctlsocket (s, cmd, argp)) == SOCKET_ERROR)
|
||||
if ((r = ioctlsocket (TO_SOCKET(s), cmd, argp)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1879,7 +1957,7 @@ myrecv (SOCKET s, char *buf, int len, int flags)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = recv (s, buf, len, flags)) == SOCKET_ERROR)
|
||||
if ((r = recv (TO_SOCKET(s), buf, len, flags)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1894,7 +1972,7 @@ myrecvfrom (SOCKET s, char *buf, int len, int flags,
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = recvfrom (s, buf, len, flags, from, fromlen)) == SOCKET_ERROR)
|
||||
if ((r = recvfrom (TO_SOCKET(s), buf, len, flags, from, fromlen)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1908,7 +1986,7 @@ mysend (SOCKET s, char *buf, int len, int flags)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = send (s, buf, len, flags)) == SOCKET_ERROR)
|
||||
if ((r = send (TO_SOCKET(s), buf, len, flags)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1923,7 +2001,7 @@ mysendto (SOCKET s, char *buf, int len, int flags,
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = sendto (s, buf, len, flags, to, tolen)) == SOCKET_ERROR)
|
||||
if ((r = sendto (TO_SOCKET(s), buf, len, flags, to, tolen)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1937,7 +2015,8 @@ mysetsockopt (SOCKET s, int level, int optname, char *optval, int optlen)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = setsockopt (s, level, optname, optval, optlen)) == SOCKET_ERROR)
|
||||
if ((r = setsockopt (s, level, optname, optval, optlen))
|
||||
== SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -1951,7 +2030,7 @@ myshutdown (SOCKET s, int how)
|
|||
if (!NtSocketsInitialized++) {
|
||||
StartSockets();
|
||||
}
|
||||
if ((r = shutdown (s, how)) == SOCKET_ERROR)
|
||||
if ((r = shutdown (TO_SOCKET(s), how)) == SOCKET_ERROR)
|
||||
errno = WSAGetLastError();
|
||||
return r;
|
||||
}
|
||||
|
@ -2121,7 +2200,7 @@ waitpid (pid_t pid, int *stat_loc, int options)
|
|||
|
||||
#include <sys/timeb.h>
|
||||
|
||||
void _cdecl
|
||||
int _cdecl
|
||||
gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
struct timeb tb;
|
||||
|
@ -2129,6 +2208,8 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
|
|||
ftime(&tb);
|
||||
tv->tv_sec = tb.time;
|
||||
tv->tv_usec = tb.millitm * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -2171,16 +2252,17 @@ str_grow(struct RString *str, size_t new_size)
|
|||
}
|
||||
|
||||
int
|
||||
chown(char *path, int owner, int group)
|
||||
chown(const char *path, int owner, int group)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <signal.h>
|
||||
int
|
||||
kill(int pid, int sig)
|
||||
{
|
||||
#if 1
|
||||
if (pid == GetCurrentProcessId())
|
||||
if ((unsigned int)pid == GetCurrentProcessId())
|
||||
return raise(sig);
|
||||
|
||||
if (sig == 2 && pid > 0)
|
||||
|
|
|
@ -85,6 +85,11 @@
|
|||
#undef except
|
||||
#undef finally
|
||||
#undef leave
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -94,6 +99,12 @@
|
|||
#include <math.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utime.h>
|
||||
#include <io.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define UIDTYPE int
|
||||
#define GIDTYPE int
|
||||
|
@ -150,16 +161,17 @@
|
|||
#define pclose _pclose
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
|
||||
/* these are defined in nt.c */
|
||||
|
||||
extern int NtMakeCmdVector(char *, char ***, int);
|
||||
/* extern void NtInitialize(int *, char ***); */
|
||||
extern void NtInitialize(int *, char ***);
|
||||
extern char *NtGetLib(void);
|
||||
extern char *NtGetBin(void);
|
||||
extern FILE *mypopen(char *, char *);
|
||||
extern int mypclose(FILE *);
|
||||
extern int flock(int fd, int oper);
|
||||
extern FILE * myfdopen(int, char*);
|
||||
extern FILE * myfdopen(int, const char *);
|
||||
extern void myfdclose(FILE *);
|
||||
extern SOCKET myaccept(SOCKET, struct sockaddr *, int *);
|
||||
extern int mybind(SOCKET, struct sockaddr *, int);
|
||||
extern int myconnect(SOCKET, struct sockaddr *, int);
|
||||
|
@ -175,6 +187,7 @@ extern int mysendto(SOCKET, char *, int, int, struct sockaddr *, int);
|
|||
extern int mysetsockopt(SOCKET, int, int, char *, int);
|
||||
extern int myshutdown(SOCKET, int);
|
||||
extern SOCKET mysocket(int, int, int);
|
||||
extern SOCKET myget_osfhandle(int);
|
||||
extern struct hostent * mygethostbyaddr(char *, int, int);
|
||||
extern struct hostent * mygethostbyname(char *);
|
||||
extern int mygethostname(char *, int);
|
||||
|
@ -183,6 +196,16 @@ extern struct protoent * mygetprotobynumber(int);
|
|||
extern struct servent * mygetservbyname(char *, char *);
|
||||
extern struct servent * mygetservbyport(int, char *);
|
||||
|
||||
extern int chown(const char *, int, int);
|
||||
extern int link(char *, char *);
|
||||
extern int gettimeofday(struct timeval *, struct timezone *);
|
||||
extern pid_t waitpid (pid_t, int *, int);
|
||||
extern int do_spawn(char *);
|
||||
extern int kill(int, int);
|
||||
extern int isinf(double);
|
||||
extern int isnan(double);
|
||||
|
||||
|
||||
//
|
||||
// define this so we can do inplace editing
|
||||
//
|
||||
|
@ -345,4 +368,9 @@ extern char *mystrerror(int);
|
|||
#undef getservbyport
|
||||
#endif
|
||||
#define getservbyport mygetservbyport
|
||||
|
||||
#ifdef get_osfhandle
|
||||
#undef get_osfhandle
|
||||
#endif
|
||||
#define get_osfhandle myget_osfhandle
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue