diff --git a/ChangeLog b/ChangeLog index f717b0d8ea..c39119037b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Tue Aug 15 01:45:28 2000 Yukihiro Matsumoto + + * io.c (argf_eof): should return true at the end of ARGF without + checking stdout if arguments are given. + +Mon Aug 14 10:34:32 2000 Yukihiro Matsumoto + + * eval.c (rb_thread_status): status should return false for normal + termination, nil for termination by exception. + +Fri Aug 11 15:43:46 2000 Yukihiro Matsumoto + + * eval.c (rb_undef): give warning for undefining __id__, __send__. + Thu Aug 10 08:05:03 2000 Yukihiro Matsumoto * eval.c (rb_callcc): returned current thread instaed of diff --git a/eval.c b/eval.c index eb00963279..7ff72995c2 100644 --- a/eval.c +++ b/eval.c @@ -1460,6 +1460,10 @@ rb_undef(klass, id) rb_raise(rb_eSecurityError, "Insecure: can't undef"); } frozen_class_p(klass); + if (id == __id__ || id == __send__) { + rb_warn("undefining `%s' may cause serious problem", + rb_id2name(id)); + } body = search_method(ruby_class, id, &origin); if (!body || !body->nd_body) { char *s0 = " class"; @@ -2784,7 +2788,7 @@ rb_eval(self, n) rb_raise(rb_eTypeError, "no class to add method"); } if (ruby_class == rb_cObject && node->nd_mid == init) { - rb_warn("re-defining Object#initialize may cause infinite loop"); + rb_warn("redefining Object#initialize may cause infinite loop"); } if (node->nd_mid == __id__ || node->nd_mid == __send__) { rb_warn("redefining `%s' may cause serious problem", @@ -2856,7 +2860,7 @@ rb_eval(self, n) klass = rb_singleton_class(recv); if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) { if (rb_safe_level() >= 4) { - rb_raise(rb_eSecurityError, "re-defining method prohibited"); + rb_raise(rb_eSecurityError, "redefining method prohibited"); } if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node->nd_mid)); @@ -7778,8 +7782,8 @@ rb_thread_status(thread) if (rb_thread_dead(th)) { if (NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) - return Qfalse; - return Qnil; + return Qnil; + return Qfalse; } if (th->status == THREAD_STOPPED) diff --git a/io.c b/io.c index 642dd05f5d..9f03c09a96 100644 --- a/io.c +++ b/io.c @@ -89,7 +89,7 @@ struct timeval rb_time_interval _((VALUE)); static VALUE filename, current_file; static int gets_lineno; -static int init_p = 0, next_p = 0; +static int init_p = 0, next_p = 0, first_p = 1; static VALUE lineno; #ifdef _STDIO_USES_IOSTREAM /* GNU libc */ @@ -2362,6 +2362,7 @@ next_argv() current_file = rb_stdin; } init_p = 1; + first_p = 0; gets_lineno = 0; } @@ -3168,8 +3169,12 @@ argf_readchar() static VALUE argf_eof() { - if (init_p == 0 && !next_argv()) + int first = first_p; + + if (!next_argv()) return Qtrue; + if (!first && next_p == -1) { return Qtrue; + } if (TYPE(current_file) != T_FILE) { return argf_forward(); } diff --git a/lib/debug.rb b/lib/debug.rb index f8c0e4e408..feb30c71db 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -452,7 +452,8 @@ class DEBUGGER__ print < set breakpoint to some position + b[reak] [file|method:] + set breakpoint to some position wat[ch] set watchpoint to some expression b[reak] list breakpoints del[ele][ nnn] delete some or all breakpoints @@ -475,7 +476,7 @@ Commands v[ar] i[nstance] show instance variables of object v[ar] c[onst] show constants of object m[ethod] i[nstance] show methods of object - m[ethod] show instance methods of class or module + m[ethod] show instance methods of class or module th[read] l[ist] list all threads th[read] c[ur[rent]] show current threads th[read] stop thread nnn diff --git a/ruby.c b/ruby.c index 7319889da6..2bd485a6c2 100644 --- a/ruby.c +++ b/ruby.c @@ -93,14 +93,13 @@ usage(name) "-x[directory] strip off text before #!ruby line and perhaps cd to directory", "--copyright print the copyright", "--version print the version", -"\n", NULL }; char **p = usage_msg; - printf("\nUsage: %s [switches] [--] [programfile] [arguments]", name); + printf("Usage: %s [switches] [--] [programfile] [arguments]\n", name); while (*p) - printf("\n %s", *p++); + printf(" %s\n", *p++); } extern VALUE rb_load_path; diff --git a/time.c b/time.c index 32b3f0b794..6598919977 100644 --- a/time.c +++ b/time.c @@ -956,22 +956,9 @@ time_s_times(obj) rb_float_new((double)buf.tms_stime / HZ), rb_float_new((double)buf.tms_cutime / HZ), rb_float_new((double)buf.tms_cstime / HZ)); -#else -#ifdef NT - FILETIME create, exit, kernel, user; - HANDLE hProc; - - hProc = GetCurrentProcess(); - GetProcessTimes(hProc,&create, &exit, &kernel, &user); - return rb_struct_new(S_Tms, - rb_float_new((double)(kernel.dwHighDateTime*2e32+kernel.dwLowDateTime)/2e6), - rb_float_new((double)(user.dwHighDateTime*2e32+user.dwLowDateTime)/2e6), - rb_float_new((double)0), - rb_float_new((double)0)); #else rb_notimplement(); #endif -#endif } static VALUE diff --git a/win32/config.h.in b/win32/config.h.in index a85038882b..57dcea2858 100644 --- a/win32/config.h.in +++ b/win32/config.h.in @@ -28,7 +28,7 @@ #define HAVE_GETCWD 1 /* #define HAVE_TRUNCATE 1 */ #define HAVE_CHSIZE 1 -/* #define HAVE_TIMES 1 */ +#define HAVE_TIMES 1 /* #define HAVE_UTIMES 1 */ /* #define HAVE_FCNTL 1 */ /* #define HAVE_SETITIMER 1 */ diff --git a/win32/win32.c b/win32/win32.c index d7f12d3f0b..e07d0086df 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -155,17 +155,6 @@ flock(int fd, int oper) //#undef const //FILE *fdopen(int, const char *); -#if 0 -void -sleep(unsigned int len) -{ - time_t end; - - end = time((time_t *)0) + len; - while (time((time_t *)0) < end) - ; -} -#endif // // Initialization stuff @@ -2480,3 +2469,33 @@ done: return res; } + +static long +filetime_to_clock(FILETIME *ft) +{ + __int64 qw = ft->dwHighDateTime; + qw <<= 32; + qw |= ft->dwLowDateTime; + qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */ + return (long) qw; +} + +int +mytimes(struct tms *tmbuf) +{ + FILETIME create, exit, kernel, user; + + if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) { + tmbuf->tms_utime = filetime_to_clock(&user); + tmbuf->tms_stime = filetime_to_clock(&kernel); + tmbuf->cutime = 0; + tmbuf->cstime = 0; + } + else { + tmbuf->utime = clock(); + tmbuf->stime = 0; + tmbuf->cutime = 0; + tmbuf->cstime = 0; + } + return 0; +} diff --git a/win32/win32.h b/win32/win32.h index 9e6e153489..0435e0cb97 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -414,4 +414,16 @@ extern char *mystrerror(int); #endif #define rename myrename +struct tms { + long tms_utime; + long tms_stime; + long tms_cutime; + long tms_cstime; +}; + +#ifdef times +#undef times +#endif +#define times mytimes + #endif