summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/nkf/nkf.c2
-rw-r--r--ext/nkf/nkf1.7/nkf.c3
-rw-r--r--ext/socket/getaddrinfo.c4
-rw-r--r--ext/socket/getnameinfo.c4
-rw-r--r--ext/socket/socket.c17
5 files changed, 28 insertions, 2 deletions
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 35d9295a748..80d0d2e4be1 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -10,7 +10,7 @@
#undef getc
#undef ungetc
-#define getc(f) (input_ctr>i_len?-1:input[input_ctr++])
+#define getc(f) (input_ctr<i_len?input[input_ctr++]:-1)
#define ungetc(c,f) input_ctr--
#undef putchar
diff --git a/ext/nkf/nkf1.7/nkf.c b/ext/nkf/nkf1.7/nkf.c
index 26ef6570214..09419f40a7c 100644
--- a/ext/nkf/nkf1.7/nkf.c
+++ b/ext/nkf/nkf1.7/nkf.c
@@ -871,7 +871,7 @@ kanji_convert(f)
} else if(c1 == SO) {
shift_mode = TRUE;
NEXT;
- } else if(c1 == ESC ) {
+ } else if(c1 == ESC) {
if((c1 = GETC(f)) == EOF) {
(*oconv)(0, ESC);
LAST;
@@ -1826,6 +1826,7 @@ reinit()
file_out = FALSE;
add_cr = FALSE;
del_cr = FALSE;
+ line = 0;
}
#ifndef PERL_XS
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index c71a56ca80c..501ebd5006e 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -67,6 +67,10 @@
#include <stddef.h>
#include <ctype.h>
+#ifdef SOCKS5
+#include <socks.h>
+#endif
+
#include "config.h"
#include "addrinfo.h"
#include "sockport.h"
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index abadd8f4423..cb65e4c0709 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -56,6 +56,10 @@
#include <string.h>
#include <stddef.h>
+#ifdef SOCKS5
+#include <socks.h>
+#endif
+
#include "config.h"
#include "addrinfo.h"
#include "sockport.h"
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 3ff6af441e2..f7840948f89 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -780,6 +780,20 @@ socks_s_open(class, host, serv)
Check_SafeStr(host);
return open_inet(class, host, serv, INET_SOCKS);
}
+
+#ifdef SOCKS5
+static VALUE
+socks_s_close(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+
+ GetOpenFile(sock, fptr);
+ shutdown(fileno(fptr->f), 2);
+ shutdown(fileno(fptr->f2), 2);
+ return rb_io_close(sock);
+}
+#endif
#endif
/*
@@ -1876,6 +1890,9 @@ Init_socket()
rb_define_global_const("SOCKSsocket", rb_cSOCKSSocket);
rb_define_singleton_method(rb_cSOCKSSocket, "open", socks_s_open, 2);
rb_define_singleton_method(rb_cSOCKSSocket, "new", socks_s_open, 2);
+#ifdef SOCKS5
+ rb_define_method(rb_cSOCKSSocket, "close", socks_s_close, 0);
+#endif
#endif
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);