Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Nov 8, 2000
1 parent 41e41d3 commit af328b1
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 43 deletions.
24 changes: 24 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Wed Nov 8 03:08:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* io.c (io_fflush): ensure fflush(3) would not block by calling
rb_thread_fd_writable().

Tue Nov 7 20:29:56 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>

* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30
Expand All @@ -6,6 +11,25 @@ Tue Nov 7 20:29:56 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>

* lib/net/http.rb: read header when also "100 Continue"

Tue Nov 7 04:32:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* bignum.c (bigdivrem): use bit shift to make y's MSB set.

Mon Nov 6 1:22:49 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* error.c (warn_print): do not use err_append(), to ensure output
to stderr.

* error.c (rb_warn): use warn_print() instead of err_print().

* error.c (rb_warning): ditto.

* error.c (rb_bug): ditto.

* eval.c (rb_load): re-raise exceptions during load.

* time.c (make_time_t): remove useless adjust

Thu Nov 2 18:01:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* random.c (rb_f_rand): half-baked float support fixed. This fix
Expand Down
35 changes: 22 additions & 13 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,31 +830,39 @@ bigdivrem(x, y, divp, modp)
zds = BDIGITS(z);
if (nx==ny) zds[nx+1] = 0;
while (!yds[ny-1]) ny--;
if ((dd = BIGRAD/(BDIGIT_DBL_SIGNED)(yds[ny-1]+1)) != 1) {

dd = 0;
q = yds[ny-1];
while ((q & (1<<(BITSPERDIG-1))) == 0) {
q <<= 1;
dd++;
}
if (dd) {
yy = rb_big_clone(y);
tds = BDIGITS(yy);
j = 0;
num = 0;
t2 = 0;
while (j<ny) {
num += (BDIGIT_DBL)yds[j]*dd;
tds[j++] = BIGLO(num);
num = BIGDN(num);
t2 += (BDIGIT_DBL)yds[j]<<dd;
tds[j++] = BIGLO(t2);
t2 = BIGDN(t2);
}
yds = tds;
j = 0;
num = 0;
t2 = 0;
while (j<nx) {
num += (BDIGIT_DBL)xds[j]*dd;
zds[j++] = BIGLO(num);
num = BIGDN(num);
t2 += (BDIGIT_DBL)xds[j]<<dd;
zds[j++] = BIGLO(t2);
t2 = BIGDN(t2);
}
zds[j] = (BDIGIT)num;
zds[j] = (BDIGIT)t2;
}
else {
zds[nx] = 0;
j = nx;
while (j--) zds[j] = xds[j];
}

j = nx==ny?nx+1:nx;
do {
if (zds[j] == yds[ny-1]) q = BIGRAD-1;
Expand Down Expand Up @@ -897,9 +905,10 @@ bigdivrem(x, y, divp, modp)
zds = BDIGITS(*modp);
t2 = 0; i = ny;
while(i--) {
t2 = BIGUP(t2) + zds[i];
zds[i] = (BDIGIT)(t2 / dd);
t2 %= dd;
t2 = (t2 | zds[i]) >> dd;
q = zds[i];
zds[i] = BIGLO(t2);
t2 = BIGUP(q);
}
}
RBIGNUM(*modp)->len = ny;
Expand Down
19 changes: 16 additions & 3 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ rb_compile_error_append(fmt, va_alist)
err_append(buf);
}

static void
warn_print(fmt, args)
const char *fmt;
va_list args;
{
char buf[BUFSIZ];

err_snprintf(buf, BUFSIZ, fmt, args);
fputs(buf, stderr);
fputs("\n", stderr);
fflush(stderr);
}

void
#ifdef HAVE_STDARG_PROTOTYPES
rb_warn(const char *fmt, ...)
Expand All @@ -115,7 +128,7 @@ rb_warn(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt);

va_init_list(args, fmt);
err_print(buf, args);
warn_print(buf, args);
va_end(args);
}

Expand All @@ -137,7 +150,7 @@ rb_warning(fmt, va_alist)
snprintf(buf, BUFSIZ, "warning: %s", fmt);

va_init_list(args, fmt);
err_print(buf, args);
warn_print(buf, args);
va_end(args);
}

Expand All @@ -157,7 +170,7 @@ rb_bug(fmt, va_alist)
ruby_in_eval = 0;

va_init_list(args, fmt);
err_print(buf, args);
warn_print(buf, args);
va_end(args);
ruby_show_version();
abort();
Expand Down
3 changes: 3 additions & 0 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,7 @@ rb_load(fname, wrap)
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
}

ruby_errinfo = Qnil; /* ensure */
PUSH_VARS();
PUSH_CLASS();
wrapper = ruby_wrapper;
Expand Down Expand Up @@ -5013,6 +5014,8 @@ rb_load(fname, wrap)
}
TMP_PROTECT_END;
if (state) JUMP_TAG(state);
if (!NIL_P(ruby_errinfo)) /* exception during load */
rb_exc_raise(ruby_errinfo);
}

void
Expand Down
6 changes: 3 additions & 3 deletions ext/dbm/dbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ fdbm_s_open(argc, argv, klass)
dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
}
if (!dbm) {
mode = 0666;
dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, mode);
dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, 0);
}
if (!dbm) {
dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, mode);
dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
}

if (!dbm) {
printf("mode: %o\n", mode);
if (mode == -1) return Qnil;
rb_sys_fail(RSTRING(file)->ptr);
}
Expand Down
4 changes: 2 additions & 2 deletions ext/gdbm/gdbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ fgdbm_s_open(argc, argv, klass)
O_RDWR|O_CREAT, mode, MY_FATAL_FUNC);
if (!dbm)
dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
O_RDWR, mode, MY_FATAL_FUNC);
O_RDWR, 0, MY_FATAL_FUNC);
if (!dbm)
dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
O_RDONLY, mode, MY_FATAL_FUNC);
O_RDONLY, 0, MY_FATAL_FUNC);

if (!dbm) {
if (mode == -1) return Qnil;
Expand Down
4 changes: 2 additions & 2 deletions ext/sdbm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ fsdbm_s_open(argc, argv, klass)
if (mode >= 0)
dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
if (!dbm)
dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, mode);
dbm = sdbm_open(RSTRING(file)->ptr, O_RDWR, 0);
if (!dbm)
dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, mode);
dbm = sdbm_open(RSTRING(file)->ptr, O_RDONLY, 0);

if (!dbm) {
if (mode == -1) return Qnil;
Expand Down
1 change: 0 additions & 1 deletion ext/socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ ruby_connect(fd, sockaddr, len, socks)
}
}
#ifdef HAVE_FCNTL
mode &= ~NONBLOCKING;
fcntl(fd, F_SETFL, mode);
#endif
return status;
Expand Down
39 changes: 31 additions & 8 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ extern int ReadDataPending();
}\
} while(0)

#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
#endif

#ifdef O_NDELAY
# define NONBLOCKING O_NDELAY
#else
#ifdef O_NBIO
# define NONBLOCKING O_NBIO
#else
# define NONBLOCKING O_NONBLOCK
#endif
#endif

void
rb_eof_error()
{
Expand Down Expand Up @@ -194,6 +208,15 @@ rb_dup(orig)
return fd;
}

static void
io_fflush(f, path)
FILE *f;
const char *path;
{
rb_thread_fd_writable(fileno(f));
if (fflush(f) == EOF) rb_sys_fail(path);
}

/* writing functions */
static VALUE
io_write(io, str)
Expand Down Expand Up @@ -235,7 +258,7 @@ io_write(io, str)
}
#endif
if (fptr->mode & FMODE_SYNC) {
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
io_fflush(f, fptr->path);
}

return INT2FIX(n);
Expand Down Expand Up @@ -266,8 +289,8 @@ rb_io_flush(io)
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);

if (fflush(f) == EOF) rb_sys_fail(fptr->path);
io_fflush(f, fptr->path);

return io;
}
Expand Down Expand Up @@ -1779,10 +1802,10 @@ io_reopen(io, nfile)
pos = ftell(orig->f);
}
if (orig->f2) {
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
io_fflush(orig->f2, orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
io_fflush(orig->f, orig->path);
}
rb_thread_fd_close(fileno(fptr->f));

Expand Down Expand Up @@ -1905,10 +1928,10 @@ rb_io_clone(io)
MakeOpenFile(clone, fptr);

if (orig->f2) {
if (fflush(orig->f2) == EOF) rb_sys_fail(orig->path);
io_fflush(orig->f2, orig->path);
}
else if (orig->mode & FMODE_WRITABLE) {
if (fflush(orig->f) == EOF) rb_sys_fail(orig->path);
io_fflush(orig->f, orig->path);
}

/* copy OpenFile structure */
Expand Down Expand Up @@ -2033,7 +2056,7 @@ rb_io_putc(io, ch)
if (fputc(c, f) == EOF)
rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC) {
if (fflush(f) == EOF) rb_sys_fail(fptr->path);
io_fflush(f, fptr->path);
}

return ch;
Expand Down
6 changes: 3 additions & 3 deletions lib/jcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE

def _regex_quote(str)
str.gsub(/\W/){|s|
if s == "-" then s elsif s == "\\" then "\\\\" else "\\\\#{s}" end
str.gsub(/[][.\\|*?+{}()]/n){|s|
if s == "\\" then "\\\\" else "\\\\#{s}" end
}
end
private :_regex_quote
Expand Down Expand Up @@ -93,7 +93,7 @@ def succ

def _expand_ch str
a = []
str.scan(/(.|\n)-(.|\n)|(.|\n)/) do |r|
str.scan(/(.)-(.)|(.)/m) do |r|
if $3
a.push $3
elsif $1.length != $2.length
Expand Down
2 changes: 1 addition & 1 deletion lib/open3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def popen3(*cmd)
pi = [pw[1], pr[0], pe[0]]
if defined? yield
begin
return yield *pi
return yield(*pi)
ensure
pi.each{|p| p.close unless p.closed?}
end
Expand Down
5 changes: 0 additions & 5 deletions time.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@ make_time_t(tptr, utc_or_local)
tm = localtime(&guess);
if (!tm) goto error;
guess -= tm->tm_gmtoff;
tm = localtime(&guess);
if (!tm) goto error;
if (tm->tm_hour != tptr->tm_hour) {
guess += (tptr->tm_hour - tm->tm_hour)*3600;
}
#else
struct tm gt, lt;
long tzsec;
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.2"
#define RUBY_RELEASE_DATE "2000-11-04"
#define RUBY_RELEASE_DATE "2000-11-08"
#define RUBY_VERSION_CODE 162
#define RUBY_RELEASE_CODE 20001104
#define RUBY_RELEASE_CODE 20001108

0 comments on commit af328b1

Please sign in to comment.