summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-06-24 04:24:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-06-24 04:24:09 +0000
commit031d2e84df58ed54948671931544c41cf32da1ca (patch)
tree1118362b178f55bf14d142752b8d61976191b991 /ext
parent37bcc42c983987ec504efd9556f0cb884f0b424d (diff)
990624
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dbm/dbm.c3
-rw-r--r--ext/dbm/extconf.rb1
-rw-r--r--ext/etc/etc.c11
-rw-r--r--ext/extmk.rb.in3
-rw-r--r--ext/md5/md5init.c8
-rw-r--r--ext/socket/getaddrinfo.c1
-rw-r--r--ext/socket/socket.c3
-rw-r--r--ext/tcltklib/tcltklib.c59
-rw-r--r--ext/tk/lib/tk.rb13
-rw-r--r--ext/tk/lib/tkfont.rb14
-rw-r--r--ext/tk/lib/tktext.rb2
11 files changed, 74 insertions, 44 deletions
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index c4a47e8004..f873781d28 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -12,6 +12,9 @@
#include "ruby.h"
+#ifdef HAVE_CDEFS_H
+# include <cdefs.h>
+#endif
#include <ndbm.h>
#include <fcntl.h>
#include <errno.h>
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 2f6255b50f..c75412e680 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -6,6 +6,7 @@ end
have_library("gdbm", "dbm_open") or
have_library("db", "dbm_open") or
have_library("dbm", "dbm_open")
+have_header("cdefs.h")
if have_header("ndbm.h") and have_func("dbm_open")
have_func("dbm_clearerr")
create_makefile("dbm")
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 271602a294..e5f69f9285 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -125,7 +125,7 @@ static VALUE
etc_passwd(obj)
VALUE obj;
{
-#if defined(HAVE_GETPWENT)
+#ifdef HAVE_GETPWENT
struct passwd *pw;
if (rb_iterator_p()) {
@@ -136,12 +136,11 @@ etc_passwd(obj)
endpwent();
return obj;
}
- pw = getpwent();
- if (pw == 0) rb_raise(rb_eRuntimeError, "can't fetch next -- /etc/passwd");
- return setup_passwd(pw);
-#else
- return Qnil;
+ if (pw = getpwent()) {
+ return setup_passwd(pw);
+ }
#endif
+ return Qnil;
}
#ifdef HAVE_GETGRENT
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 8090c2ab19..fb7236441a 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -392,6 +392,7 @@ TARGET = #{target}
DLLIB = $(TARGET).#{$static ? "a" : "@DLEXT@"}
INSTALL = #{$dots}@INSTALL@
+INSTALL_DLLIB = @INSTALL_DLLIB@
INSTALL_DATA = @INSTALL_DATA@
binsuffix = @binsuffix@
@@ -414,7 +415,7 @@ install:
EOS
if !$static
mfile.printf "\
- $(INSTALL) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
+ $(INSTALL_DLLIB) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
"
end
install_rb(mfile)
diff --git a/ext/md5/md5init.c b/ext/md5/md5init.c
index e63258f3f1..552a407c6d 100644
--- a/ext/md5/md5init.c
+++ b/ext/md5/md5init.c
@@ -52,8 +52,7 @@ md5_hexdigest(obj)
{
MD5_CTX *md5, ctx;
unsigned char digest[16];
- char buf[35];
- char *p = buf;
+ char buf[33];
int i;
Data_Get_Struct(obj, MD5_CTX, md5);
@@ -61,7 +60,7 @@ md5_hexdigest(obj)
MD5Final(digest, &ctx);
for (i=0; i<16; i++) {
- sprintf(buf+i*2, "%x", digest[i]);
+ sprintf(buf+i*2, "%02x", digest[i]);
}
return rb_str_new(buf, 32);
}
@@ -70,7 +69,6 @@ static VALUE
md5_clone(obj)
VALUE obj;
{
- VALUE clone;
MD5_CTX *md5, *md5_new;
Data_Get_Struct(obj, MD5_CTX, md5);
@@ -86,7 +84,6 @@ md5_new(argc, argv, class)
VALUE* argv;
VALUE class;
{
- int i;
VALUE arg, obj;
MD5_CTX *md5;
@@ -103,6 +100,7 @@ md5_new(argc, argv, class)
return obj;
}
+void
Init_md5()
{
cMD5 = rb_define_class("MD5", rb_cObject);
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index 7ae41e6030..aab7207cdf 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -55,6 +55,7 @@
#include <unistd.h>
#else
#include <winsock2.h>
+#include <io.h>
#endif
#include <string.h>
#include <stdio.h>
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index adf622c118..f4ee19e11e 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -487,7 +487,7 @@ ip_addrsetup(host, port)
if (*name == 0) {
mkinetaddr(INADDR_ANY, hbuf, sizeof(hbuf));
}
- if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
+ else if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
mkinetaddr(INADDR_BROADCAST, hbuf, sizeof(hbuf));
}
else {
@@ -594,6 +594,7 @@ ruby_socket(domain, type, proto)
fd = socket(domain, type, proto);
}
}
+ return fd;
}
static int
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index 6652b9409a..352b0778db 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -44,8 +44,6 @@ int *tclDummyMathPtr = (int *) matherr;
/*---- module TclTkLib ----*/
-static VALUE main_thread;
-
struct invoke_queue {
int argc;
VALUE *argv;
@@ -55,35 +53,52 @@ struct invoke_queue {
VALUE thread;
struct invoke_queue *next;
};
-
+
static struct invoke_queue *iqueue;
+static VALUE main_thread;
-/* execute Tk_MainLoop */
-static VALUE
-lib_mainloop(self)
- VALUE self;
+/* Tk_ThreadTimer */
+static Tcl_TimerToken timer_token;
+
+/* timer callback */
+static void
+_timer_for_tcl(clientData)
+ ClientData clientData;
{
struct invoke_queue *q, *tmp;
VALUE thread;
- DUMP1("start Tk_Mainloop");
- while (Tk_GetNumMainWindows() > 0) {
- Tcl_DoOneEvent(TCL_DONT_WAIT);
- CHECK_INTS;
- q = iqueue;
- while (q) {
- tmp = q;
- q = q->next;
- if (!tmp->done) {
- tmp->done = 1;
- tmp->result = ip_invoke_real(tmp->argc, tmp->argv, tmp->obj);
- thread = tmp->thread;
- tmp = tmp->next;
- rb_thread_run(thread);
- }
+ Tk_DeleteTimerHandler(timer_token);
+ timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl,
+ (ClientData)0);
+
+ CHECK_INTS;
+ q = iqueue;
+ while (q) {
+ tmp = q;
+ q = q->next;
+ if (!tmp->done) {
+ tmp->done = 1;
+ tmp->result = ip_invoke_real(tmp->argc, tmp->argv, tmp->obj);
+ thread = tmp->thread;
+ tmp = tmp->next;
+ rb_thread_run(thread);
}
}
+ rb_thread_schedule();
+}
+
+/* execute Tk_MainLoop */
+static VALUE
+lib_mainloop(self)
+ VALUE self;
+{
+ timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl,
+ (ClientData)0);
+ DUMP1("start Tk_Mainloop");
+ Tk_MainLoop();
DUMP1("stop Tk_Mainloop");
+ Tk_DeleteTimerHandler(timer_token);
return Qnil;
}
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index dae2aeb0d8..1a1c6557d4 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -2005,11 +2005,9 @@ class TkLabel<TkWindow
end
class TkButton<TkLabel
- WidgetClassName = 'Button'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
-# def TkButton.to_eval
- def self.to_eval
- WidgetClassName
+ TkClassBind::WidgetClassNameTBL['Button'] = self
+ def TkButton.to_eval
+ 'Button'
end
def create_self
tk_call 'button', @path
@@ -2023,10 +2021,9 @@ class TkButton<TkLabel
end
class TkRadioButton<TkButton
- WidgetClassName = 'Radiobutton'.freeze
- TkClassBind::WidgetClassNameTBL[WidgetClassName] = self
+ TkClassBind::WidgetClassNameTBL['Radiobutton'] = self
def TkRadioButton.to_eval
- WidgetClassName
+ 'Radiobutton'
end
def create_self
tk_call 'radiobutton', @path
diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb
index 1526f68d88..c680d166e7 100644
--- a/ext/tk/lib/tkfont.rb
+++ b/ext/tk/lib/tkfont.rb
@@ -817,6 +817,7 @@ class TkFont
#if JAPANIZED_TK
if @kanjifont != ""
configure_core(@kanjifont, slot, value)
+ configure('size'=>configinfo('size')) # to reflect new configuration
else
#""
configure(slot, value)
@@ -841,10 +842,12 @@ class TkFont
def latin_replace(ltn)
latin_replace_core(ltn)
+ reset_pointadjust
end
def kanji_replace(knj)
kanji_replace_core(knj)
+ reset_pointadjust
end
def measure(text)
@@ -891,6 +894,17 @@ class TkFont
end
end
+ def reset_pointadjust
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
+ kanji_actual.assoc('size')[1].to_f )
+ end
+ rescue
+ end
+ self
+ end
+
###################################
# public alias
###################################
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index 8e07cf4347..324af90f85 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -429,7 +429,7 @@ class TkTextTag<TkObject
include TkTreatTagFont
$tk_text_tag = 'tag0000'
- def initialize(parent, keys=nil)
+ def initialize(parent, *args)
if not parent.kind_of?(TkText)
fail format("%s need to be TkText", parent.inspect)
end