Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Aug 15, 2000
1 parent 844cd0c commit e2eceef
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 36 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Tue Aug 15 01:45:28 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* 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 <matz@ruby-lang.org>

* 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 <matz@ruby-lang.org>

* eval.c (rb_undef): give warning for undefining __id__, __send__.

Thu Aug 10 08:05:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_callcc): returned current thread instaed of
Expand Down
12 changes: 8 additions & 4 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -2362,6 +2362,7 @@ next_argv()
current_file = rb_stdin;
}
init_p = 1;
first_p = 0;
gets_lineno = 0;
}

Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 3 additions & 2 deletions lib/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ def debug_print_help
print <<EOHELP
Debugger help v.-0.002b
Commands
b[reak] [file or method:]<line> set breakpoint to some position
b[reak] [file|method:]<line|method>
set breakpoint to some position
wat[ch] <expression> set watchpoint to some expression
b[reak] list breakpoints
del[ele][ nnn] delete some or all breakpoints
Expand All @@ -475,7 +476,7 @@ def debug_print_help
v[ar] i[nstance] <object> show instance variables of object
v[ar] c[onst] <object> show constants of object
m[ethod] i[nstance] <obj> show methods of object
m[ethod] <class or module> show instance methods of class or module
m[ethod] <class|module> show instance methods of class or module
th[read] l[ist] list all threads
th[read] c[ur[rent]] show current threads
th[read] <nnn> stop thread nnn
Expand Down
5 changes: 2 additions & 3 deletions ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 0 additions & 13 deletions time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion win32/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
41 changes: 30 additions & 11 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2480,3 +2469,33 @@ myrename(const char *oldpath, const char *newpath)

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;
}
12 changes: 12 additions & 0 deletions win32/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e2eceef

Please sign in to comment.