git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-01-08 05:00:25 +00:00
Родитель a3da8465b4
Коммит a69b9bce31
12 изменённых файлов: 403 добавлений и 386 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Fri Jan 7 00:59:29 2000 Masahiro Tomita <tommy@tmtm.org>
* io.c (io_fread): TRAP_BEG/TRAP_END added around getc().
Thu Jan 6 00:39:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* random.c (rb_f_rand): should be initialized unless srand is
called before.
Wed Jan 5 02:14:46 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp> Wed Jan 5 02:14:46 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
* parse.y: Fix SEGV on empty parens with UMINUS or UPLUS. * parse.y: Fix SEGV on empty parens with UMINUS or UPLUS.

54
array.c
Просмотреть файл

@ -292,31 +292,6 @@ rb_ary_pop(ary)
return RARRAY(ary)->ptr[--RARRAY(ary)->len]; return RARRAY(ary)->ptr[--RARRAY(ary)->len];
} }
static VALUE
rb_ary_pop_m(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
int n = 1;
VALUE result;
if (argc == 0) {
return rb_ary_pop(ary);
}
if (argc > 2) {
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
}
n = NUM2INT(argv[0]);
if (RARRAY(ary)->len < n)
n = RARRAY(ary)->len;
result = rb_ary_new2(n);
while (n--) {
rb_ary_store(result, n, rb_ary_pop(ary));
}
return result;
}
VALUE VALUE
rb_ary_shift(ary) rb_ary_shift(ary)
VALUE ary; VALUE ary;
@ -339,31 +314,6 @@ rb_ary_shift(ary)
return top; return top;
} }
static VALUE
rb_ary_shift_m(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
int n = 1;
VALUE result;
if (argc == 0) {
return rb_ary_shift(ary);
}
if (argc > 2) {
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
}
n = NUM2INT(argv[0]);
if (RARRAY(ary)->len < n)
n = RARRAY(ary)->len;
result = rb_ary_new2(n);
while (n--) {
rb_ary_push(result, rb_ary_shift(ary));
}
return result;
}
VALUE VALUE
rb_ary_unshift(ary, item) rb_ary_unshift(ary, item)
VALUE ary, item; VALUE ary, item;
@ -1600,8 +1550,8 @@ Init_Array()
rb_define_method(rb_cArray, "concat", rb_ary_concat, 1); rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
rb_define_method(rb_cArray, "<<", rb_ary_push, 1); rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1); rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
rb_define_method(rb_cArray, "pop", rb_ary_pop_m, -1); rb_define_method(rb_cArray, "pop", rb_ary_pop, 0);
rb_define_method(rb_cArray, "shift", rb_ary_shift_m, -1); rb_define_method(rb_cArray, "shift", rb_ary_shift, 0);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift, 1); rb_define_method(rb_cArray, "unshift", rb_ary_unshift, 1);
rb_define_method(rb_cArray, "each", rb_ary_each, 0); rb_define_method(rb_cArray, "each", rb_ary_each, 0);
rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0); rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);

579
configure поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -4,5 +4,6 @@ RUBYCWDLL=rubycw.dll
miniruby$(EXEEXT): $(RUBYCWDLL) miniruby$(EXEEXT): $(RUBYCWDLL)
$(RUBYCWDLL): $(OBJS) dmyext.o
$(LDSHARED) $(DLDFLAGS) -o $(RUBYCWDLL) --output-lib=$(LIBRUBY_SO) --dllname=$(RUBYCWDLL) -Wl,-e,__cygwin_noncygwin_dll_entry@12 --add-stdcall-alias $(OBJS) dmyext.o $(LDSHARED) $(DLDFLAGS) -o $(RUBYCWDLL) --output-lib=$(LIBRUBY_SO) --dllname=$(RUBYCWDLL) -Wl,-e,__cygwin_noncygwin_dll_entry@12 --add-stdcall-alias $(OBJS) dmyext.o
@NM@ --extern-only $(OBJS) dmyext.o | sed -n '/^........ [CD] _\(.*\)$$/s//#define \1 (*__imp_\1)/p' >import.h @NM@ --extern-only $(OBJS) dmyext.o | sed -n '/^........ [CD] _\(.*\)$$/s//#define \1 (*__imp_\1)/p' >import.h

Просмотреть файл

@ -92,10 +92,13 @@ static void
sock_finalize(fptr) sock_finalize(fptr)
OpenFile *fptr; OpenFile *fptr;
{ {
if (!fptr->f) return; SOCKET s;
if (!fptr->f) return;
s = get_osfhandle(fileno(fptr->f));
myfdclose(fptr->f); myfdclose(fptr->f);
if(fptr->f2) myfdclose(fptr->f2); if (fptr->f2) myfdclose(fptr->f2);
closesocket(s);
} }
#endif #endif

7
file.c
Просмотреть файл

@ -403,8 +403,8 @@ eaccess(path, mode)
if (st.st_mode & mode) return 0; if (st.st_mode & mode) return 0;
return -1; return -1;
#else /* !NT*/ #else /* !NT */
return 0; return access(path, mode);
#endif #endif
} }
@ -1502,6 +1502,9 @@ rb_file_flock(obj, operation)
rb_secure(2); rb_secure(2);
GetOpenFile(obj, fptr); GetOpenFile(obj, fptr);
if (fptr->mode & FMODE_WRITABLE) {
fflush(GetWriteFile(fptr));
}
if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) { if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) {
#ifdef EWOULDBLOCK #ifdef EWOULDBLOCK
if (errno == EWOULDBLOCK) { if (errno == EWOULDBLOCK) {

5
io.c
Просмотреть файл

@ -454,7 +454,9 @@ io_fread(ptr, len, f)
if (!READ_DATA_PENDING(f)) { if (!READ_DATA_PENDING(f)) {
rb_thread_wait_fd(fileno(f)); rb_thread_wait_fd(fileno(f));
} }
TRAP_BEG;
c = getc(f); c = getc(f);
TRAP_END;
if (c == EOF) { if (c == EOF) {
*ptr = '\0'; *ptr = '\0';
break; break;
@ -1456,7 +1458,8 @@ pipe_open(pname, mode)
pipe_add_fptr(fptr); pipe_add_fptr(fptr);
if (modef & FMODE_READABLE) fptr->f = f; if (modef & FMODE_READABLE) fptr->f = f;
if (modef & FMODE_WRITABLE) { if (modef & FMODE_WRITABLE) {
fptr->f2 = f; if (fptr->f) fptr->f2 = f;
else fptr->f = f;
rb_io_synchronized(fptr); rb_io_synchronized(fptr);
} }
return (VALUE)port; return (VALUE)port;

Просмотреть файл

@ -109,7 +109,7 @@ class DEBUGGER__
def var_list(ary, binding) def var_list(ary, binding)
ary.sort! ary.sort!
if ary.size > 24 if false # ary.size < 0
f = open("|less", "w") f = open("|less", "w")
for v in ary for v in ary
f.printf " %s => %s\n", v, eval(v, binding).inspect f.printf " %s => %s\n", v, eval(v, binding).inspect
@ -125,7 +125,6 @@ class DEBUGGER__
def debug_variable_info(input, binding) def debug_variable_info(input, binding)
case input case input
when /^\s*g(?:lobal)?$/ when /^\s*g(?:lobal)?$/
f = open("|less", "w")
var_list(global_variables, binding) var_list(global_variables, binding)
when /^\s*l(?:ocal)?$/ when /^\s*l(?:ocal)?$/
@ -162,9 +161,9 @@ class DEBUGGER__
stdout.print "\n" stdout.print "\n"
else else
obj = debug_eval($', binding) obj = debug_eval(input, binding)
unless obj.kind_of? Module unless obj.kind_of? Module
stdout.print "should be Class/Module: ", $', "\n" stdout.print "should be Class/Module: ", input, "\n"
else else
len = 0 len = 0
for v in obj.instance_methods.sort for v in obj.instance_methods.sort

Просмотреть файл

@ -1430,6 +1430,7 @@ Init_Numeric()
rb_define_method(rb_cNumeric, "+@", num_uplus, 0); rb_define_method(rb_cNumeric, "+@", num_uplus, 0);
rb_define_method(rb_cNumeric, "-@", num_uminus, 0); rb_define_method(rb_cNumeric, "-@", num_uminus, 0);
rb_define_method(rb_cNumeric, "===", num_equal, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1); rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1); rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
rb_define_method(rb_cNumeric, "abs", num_abs, 0); rb_define_method(rb_cNumeric, "abs", num_abs, 0);

Просмотреть файл

@ -588,8 +588,7 @@ undef_list : fitem
$$ = block_append($1, NEW_UNDEF($4)); $$ = block_append($1, NEW_UNDEF($4));
} }
op : tDOT2 { $$ = tDOT2; } op : '|' { $$ = '|'; }
| '|' { $$ = '|'; }
| '^' { $$ = '^'; } | '^' { $$ = '^'; }
| '&' { $$ = '&'; } | '&' { $$ = '&'; }
| tCMP { $$ = tCMP; } | tCMP { $$ = tCMP; }

Просмотреть файл

@ -81,27 +81,13 @@ static int first = 1;
static char state[256]; static char state[256];
#endif #endif
static VALUE static int
rb_f_srand(argc, argv, obj) rand_init(seed)
int argc; long seed;
VALUE *argv;
VALUE obj;
{ {
VALUE a; int old;
unsigned int seed, old;
static unsigned int saved_seed; static unsigned int saved_seed;
if (rb_scan_args(argc, argv, "01", &a) == 0) {
static int n = 0;
struct timeval tv;
gettimeofday(&tv, 0);
seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
}
else {
seed = NUM2UINT(a);
}
#ifdef HAVE_RANDOM #ifdef HAVE_RANDOM
if (first == 1) { if (first == 1) {
initstate(1, state, sizeof state); initstate(1, state, sizeof state);
@ -116,6 +102,30 @@ rb_f_srand(argc, argv, obj)
old = saved_seed; old = saved_seed;
saved_seed = seed; saved_seed = seed;
return old;
}
static VALUE
rb_f_srand(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
VALUE a;
unsigned int seed, old;
if (rb_scan_args(argc, argv, "01", &a) == 0) {
static int n = 0;
struct timeval tv;
gettimeofday(&tv, 0);
seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
}
else {
seed = NUM2UINT(a);
}
old = rand_init(seed);
return rb_uint2inum(old); return rb_uint2inum(old);
} }
@ -125,6 +135,14 @@ rb_f_rand(obj, vmax)
{ {
long val, max; long val, max;
static initialized = 0;
if (first) {
struct timeval tv;
gettimeofday(&tv, 0);
rand_init(tv.tv_sec ^ tv.tv_usec ^ getpid());
}
switch (TYPE(vmax)) { switch (TYPE(vmax)) {
case T_FLOAT: case T_FLOAT:
if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN)

Просмотреть файл

@ -229,7 +229,6 @@ char *getlogin()
struct { struct {
int inuse; int inuse;
int pid; int pid;
HANDLE oshandle;
FILE *pipe; FILE *pipe;
} MyPopenRecord[MYPOPENSIZE]; } MyPopenRecord[MYPOPENSIZE];
@ -509,23 +508,11 @@ mypopen (char *cmd, char *mode)
sa.lpSecurityDescriptor = NULL; sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE; sa.bInheritHandle = TRUE;
if (!reading) {
FILE *fp;
fp = (_popen)(cmd, mode);
MyPopenRecord[slot].inuse = TRUE;
MyPopenRecord[slot].pipe = fp;
MyPopenRecord[slot].pid = -1;
if (!fp)
rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
return fp;
}
fRet = CreatePipe(&hInFile, &hOutFile, &sa, 2048L); fRet = CreatePipe(&hInFile, &hOutFile, &sa, 2048L);
if (!fRet) if (!fRet) {
rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); errno = GetLastError();
rb_sys_fail("mypopen: CreatePipe");
}
memset(&aStartupInfo, 0, sizeof (STARTUPINFO)); memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION)); memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
@ -547,46 +534,50 @@ mypopen (char *cmd, char *mode)
lpCommandLine = cmd; lpCommandLine = cmd;
if (NtHasRedirection(cmd) || isInternalCmd(cmd)) { if (NtHasRedirection(cmd) || isInternalCmd(cmd)) {
lpApplicationName = getenv("COMSPEC"); lpApplicationName = getenv("COMSPEC");
lpCmd2 = malloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c ")); lpCmd2 = xmalloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
if (lpCmd2 == NULL)
rb_fatal("Mypopen: malloc failed");
sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd); sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd);
lpCommandLine = lpCmd2; lpCommandLine = lpCmd2;
} }
fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa, fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa,
sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation); sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation);
errno = GetLastError();
if (lpCmd2)
free(lpCmd2);
CloseHandle(aProcessInformation.hThread);
if (!fRet) { if (!fRet) {
CloseHandle(hInFile); CloseHandle(hInFile);
CloseHandle(hOutFile); CloseHandle(hOutFile);
rb_fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno)); CloseHandle(aProcessInformation.hProcess);
return NULL;
} }
CloseHandle(aProcessInformation.hThread);
if (reading) { if (reading) {
fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode)); fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode));
CloseHandle(hOutFile); CloseHandle(hOutFile);
} }
else { else {
fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode)); fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
CloseHandle(hInFile); CloseHandle(hInFile);
} }
if (fd == -1) if (fd == -1) {
rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno)); CloseHandle(reading ? hInFile : hOutFile);
CloseHandle(aProcessInformation.hProcess);
rb_sys_fail("mypopen: _open_osfhandle");
}
if ((fp = (FILE *) fdopen(fd, mode)) == NULL) {
if ((fp = (FILE *) fdopen(fd, mode)) == NULL) _close(fd);
return NULL; CloseHandle(aProcessInformation.hProcess);
rb_sys_fail("mypopen: fdopen");
if (lpCmd2) }
free(lpCmd2);
MyPopenRecord[slot].inuse = TRUE; MyPopenRecord[slot].inuse = TRUE;
MyPopenRecord[slot].pipe = fp; MyPopenRecord[slot].pipe = fp;
MyPopenRecord[slot].oshandle = (reading ? hInFile : hOutFile);
MyPopenRecord[slot].pid = (int)aProcessInformation.hProcess; MyPopenRecord[slot].pid = (int)aProcessInformation.hProcess;
return fp; return fp;
} }
@ -638,14 +629,13 @@ mypclose(FILE *fp)
} }
} }
} }
CloseHandle((HANDLE)MyPopenRecord[i].pid);
#endif #endif
// //
// close the pipe // close the pipe
// //
// Closehandle() is done by fclose().
//CloseHandle(MyPopenRecord[i].oshandle);
fflush(fp); fflush(fp);
fclose(fp); fclose(fp);