summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-02 10:05:37 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-02 10:05:37 +0000
commit46c4975d9c25f7f336a23bde080420c5ed29ab0e (patch)
treeebd8f7cd175a477da19c8871a44adab3e933077e
parente6ab550ac5504c4e5f3b2946749f8381513448ff (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--array.c2
-rw-r--r--bignum.c1
-rw-r--r--class.c5
-rw-r--r--error.c1
-rw-r--r--eval.c10
-rw-r--r--ext/socket/socket.c89
-rw-r--r--file.c3
-rw-r--r--gc.c2
-rw-r--r--io.c5
-rw-r--r--marshal.c6
-rw-r--r--numeric.c3
-rw-r--r--object.c1
-rw-r--r--pack.c2
-rw-r--r--range.c4
-rw-r--r--re.c4
-rw-r--r--ruby.h55
-rw-r--r--string.c4
-rw-r--r--struct.c1
-rw-r--r--time.c1
-rw-r--r--variable.c2
21 files changed, 106 insertions, 102 deletions
diff --git a/ChangeLog b/ChangeLog
index 0725722b9b..517f389d19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jun 2 16:00:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (udp_addrsetup): error check enhanced.
+
+ * ext/socket/socket.c (sock_s_getservbyaname): use strtoul(), if
+ possible.
+
Sat May 30 07:10:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (reg_prepare_re): no more needless regular expression
diff --git a/array.c b/array.c
index 5a00590095..a278e3395d 100644
--- a/array.c
+++ b/array.c
@@ -1294,8 +1294,6 @@ ary_flatten(ary)
return v;
}
-extern VALUE mEnumerable;
-
void
Init_Array()
{
diff --git a/bignum.c b/bignum.c
index 7bbe95b254..e0cc7c9f9c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -12,7 +12,6 @@
#include <math.h>
#include <ctype.h>
-extern VALUE cInteger;
VALUE cBignum;
typedef unsigned short USHORT;
diff --git a/class.c b/class.c
index 6b1ccd22f7..fefc99d65e 100644
--- a/class.c
+++ b/class.c
@@ -21,9 +21,6 @@
extern st_table *rb_class_tbl;
-extern VALUE cClass;
-extern VALUE cModule;
-
VALUE
class_new(super)
VALUE super;
@@ -537,8 +534,6 @@ rb_define_module_function(module, name, func, argc)
rb_define_singleton_method(module, name, func, argc);
}
-extern VALUE mKernel;
-
void
rb_define_global_function(name, func, argc)
char *name;
diff --git a/error.c b/error.c
index d8a96e5080..277e431b9d 100644
--- a/error.c
+++ b/error.c
@@ -219,7 +219,6 @@ rb_check_type(x, t)
/* exception classes */
#include "errno.h"
-extern VALUE cString;
VALUE eException;
VALUE eSystemExit, eInterrupt, eFatal;
VALUE eStandardError;
diff --git a/eval.c b/eval.c
index a8a5813522..6f287b9b81 100644
--- a/eval.c
+++ b/eval.c
@@ -364,18 +364,8 @@ extern NODE *eval_tree0;
extern NODE *eval_tree;
extern int nerrs;
-extern VALUE mKernel;
-extern VALUE cModule;
-extern VALUE eFatal;
-extern VALUE eStandardError;
-extern VALUE eInterrupt;
-extern VALUE eSystemExit;
-extern VALUE eException;
-extern VALUE eRuntimeError;
-extern VALUE eSyntaxError;
static VALUE eLocalJumpError;
static VALUE eSysStackError;
-extern VALUE eSecurityError;
extern VALUE TopSelf;
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 39b4efa34e..f9903654b6 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -135,8 +135,7 @@ bsock_shutdown(argc, argv, sock)
static VALUE
bsock_setsockopt(sock, lev, optname, val)
- VALUE sock, lev, optname;
- struct RString *val;
+ VALUE sock, lev, optname, val;
{
int level, option;
OpenFile *fptr;
@@ -160,8 +159,7 @@ bsock_setsockopt(sock, lev, optname, val)
v = (char*)&i; vlen = sizeof(i);
break;
default:
- Check_Type(val, T_STRING);
- v = val->ptr; vlen = val->len;
+ v = str2cstr(val, &vlen);
}
GetOpenFile(sock, fptr);
@@ -229,17 +227,17 @@ bsock_send(argc, argv, sock)
VALUE *argv;
VALUE sock;
{
- struct RString *msg, *to;
+ VALUE msg, to;
VALUE flags;
OpenFile *fptr;
FILE *f;
int fd, n;
+ char *m, *t;
+ int mlen, tlen;
rb_secure(4);
rb_scan_args(argc, argv, "21", &msg, &flags, &to);
- Check_Type(msg, T_STRING);
-
GetOpenFile(sock, fptr);
f = fptr->f2?fptr->f2:fptr->f;
fd = fileno(f);
@@ -247,13 +245,14 @@ bsock_send(argc, argv, sock)
#ifdef THREAD
thread_fd_writable(fd);
#endif
+ m = str2cstr(msg, &mlen);
if (RTEST(to)) {
- Check_Type(to, T_STRING);
- n = sendto(fd, msg->ptr, msg->len, NUM2INT(flags),
- (struct sockaddr*)to->ptr, to->len);
+ t = str2cstr(to, &tlen);
+ n = sendto(fd, m, mlen, NUM2INT(flags),
+ (struct sockaddr*)t, tlen);
}
else {
- n = send(fd, msg->ptr, msg->len, NUM2INT(flags));
+ n = send(fd, m, mlen, NUM2INT(flags));
}
if (n < 0) {
switch (errno) {
@@ -491,12 +490,14 @@ open_inet(class, h, serv, type)
servport = FIX2UINT(serv);
goto setup_servent;
}
- Check_Type(serv, T_STRING);
- servent = getservbyname(RSTRING(serv)->ptr, "tcp");
+ servent = getservbyname(STR2CSTR(serv), "tcp");
if (servent == NULL) {
- servport = strtoul(RSTRING(serv)->ptr, 0, 0);
- if (servport == -1) {
- Raise(eSocket, "no such servce %s", RSTRING(serv)->ptr);
+ char *s = STR2CSTR(serv);
+ char *end;
+
+ servport = strtoul(s, &end, 0);
+ if (*end != '\0') {
+ Raise(eSocket, "no such servce %s", s);
}
setup_servent:
_servent.s_port = htons(servport);
@@ -814,8 +815,7 @@ ip_s_getaddress(obj, host)
addr.sin_addr.s_addr = htonl(i);
}
else {
- Check_Type(host, T_STRING);
- setipaddr(RSTRING(host)->ptr, &addr);
+ setipaddr(STR2CSTR(host), &addr);
}
return mkipaddr(addr.sin_addr.s_addr);
@@ -845,8 +845,7 @@ udp_addrsetup(host, port, addr)
addr->sin_addr.s_addr = htonl(i);
}
else {
- Check_Type(host, T_STRING);
- setipaddr(RSTRING(host)->ptr, addr);
+ setipaddr(STR2CSTR(host), addr);
}
if (FIXNUM_P(port)) {
addr->sin_port = htons(FIX2INT(port));
@@ -854,16 +853,18 @@ udp_addrsetup(host, port, addr)
else {
struct servent *servent;
- Check_Type(port, T_STRING);
- servent = getservbyname(RSTRING(port)->ptr, "udp");
+ servent = getservbyname(STR2CSTR(port), "udp");
if (servent) {
addr->sin_port = servent->s_port;
}
else {
- int port = strtoul(RSTRING(port)->ptr, 0, 0);
+ char *s = STR2CSTR(port);
+ char *end;
+ int portno;
- if (port == -1) {
- Raise(eSocket, "no such servce %s", RSTRING(port)->ptr);
+ portno = strtoul(s, &end, 0);
+ if (*end != '\0') {
+ Raise(eSocket, "no such servce %s", s);
}
addr->sin_port = htons(port);
}
@@ -924,19 +925,21 @@ udp_send(argc, argv, sock)
OpenFile *fptr;
FILE *f;
int n;
+ char *m;
+ int mlen;
if (argc == 2) {
return bsock_send(argc, argv, sock);
}
rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port);
- Check_Type(mesg, T_STRING);
udp_addrsetup(host, port, &addr);
GetOpenFile(sock, fptr);
f = fptr->f2?fptr->f2:fptr->f;
+ m = str2cstr(mesg, &mlen);
retry:
- n = sendto(fileno(f), RSTRING(mesg)->ptr, RSTRING(mesg)->len,
- NUM2INT(flags), (struct sockaddr*)&addr, sizeof(addr));
+ n = sendto(fileno(f), m, mlen, NUM2INT(flags),
+ (struct sockaddr*)&addr, sizeof(addr));
if (n < 0) {
switch (errno) {
case EINTR:
@@ -1347,8 +1350,7 @@ sock_s_gethostbyname(obj, host)
addr.sin_addr.s_addr = htonl(i);
}
else {
- Check_Type(host, T_STRING);
- setipaddr(RSTRING(host)->ptr, &addr);
+ setipaddr(STR2CSTR(host), &addr);
}
h = gethostbyaddr((char *)&addr.sin_addr,
sizeof(addr.sin_addr),
@@ -1364,12 +1366,12 @@ sock_s_gethostbyaddr(argc, argv)
{
VALUE vaddr, vtype;
int type;
-
- struct sockaddr_in *addr;
+ char *addr;
+ int alen;
struct hostent *h;
rb_scan_args(argc, argv, "11", &addr, &vtype);
- Check_Type(addr, T_STRING);
+ addr = str2cstr(vaddr, &alen);
if (!NIL_P(vtype)) {
type = NUM2INT(vtype);
}
@@ -1377,7 +1379,7 @@ sock_s_gethostbyaddr(argc, argv)
type = AF_INET;
}
- h = gethostbyaddr(RSTRING(addr)->ptr, RSTRING(addr)->len, type);
+ h = gethostbyaddr(addr, alen, type);
return mkhostent(h);
}
@@ -1393,15 +1395,22 @@ sock_s_getservbyaname(argc, argv)
int port;
rb_scan_args(argc, argv, "11", &service, &protocol);
- Check_Type(service, T_STRING);
if (NIL_P(protocol)) proto = "tcp";
- else proto = RSTRING(protocol)->ptr;
+ else proto = STR2CSTR(protocol);
- sp = getservbyname(RSTRING(service)->ptr, proto);
- if (!sp) {
- Raise(eSocket, "service/proto not found");
+ sp = getservbyname(STR2CSTR(service), proto);
+ if (sp) {
+ port = ntohs(sp->s_port);
+ }
+ else {
+ char *s = STR2CSTR(service);
+ char *end;
+
+ port = strtoul(s, &end, 0);
+ if (*end != '\0') {
+ Raise(eSocket, "no such servce %s/%s", s, proto);
+ }
}
- port = ntohs(sp->s_port);
return INT2FIX(port);
}
diff --git a/file.c b/file.c
index 449d888814..0b761953e7 100644
--- a/file.c
+++ b/file.c
@@ -55,7 +55,6 @@ char *strrchr _((char*,char));
extern int utimes();
#endif
-extern VALUE cIO;
VALUE cFile;
VALUE mFileTest;
static VALUE sStat;
@@ -1574,8 +1573,6 @@ f_test(argc, argv)
return Qnil; /* not reached */
}
-extern VALUE mKernel;
-
void
Init_File()
{
diff --git a/gc.c b/gc.c
index 6579b44858..5347585a00 100644
--- a/gc.c
+++ b/gc.c
@@ -1047,8 +1047,6 @@ id2ref(obj, id)
return (VALUE)ptr;
}
-extern VALUE cModule;
-
void
Init_GC()
{
diff --git a/io.c b/io.c
index 9bce9b5315..8f8a1e9442 100644
--- a/io.c
+++ b/io.c
@@ -65,7 +65,6 @@ struct timeval {
#endif
VALUE cIO;
-extern VALUE cFile;
VALUE eEOFError;
VALUE eIOError;
@@ -2559,10 +2558,6 @@ opt_i_set(val)
inplace = RSTRING(val)->ptr;
}
-extern VALUE mKernel;
-extern VALUE mEnumerable;
-extern VALUE eStandardError;
-
void
Init_IO()
{
diff --git a/marshal.c b/marshal.c
index b2c5addd40..b1d09e2f25 100644
--- a/marshal.c
+++ b/marshal.c
@@ -38,11 +38,6 @@
#define TYPE_LINK '@'
-extern VALUE cString;
-extern VALUE cRegexp;
-extern VALUE cArray;
-extern VALUE cHash;
-
VALUE rb_path2class _((char*));
static ID s_dump, s_load;
@@ -168,7 +163,6 @@ w_unique(s, arg)
}
static void w_object _((VALUE,struct dump_arg*,int));
-extern VALUE cIO, cBignum, cStruct;
static int
hash_each(key, value, arg)
diff --git a/numeric.c b/numeric.c
index 104e069eee..eab105d8e2 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1303,9 +1303,6 @@ fix_zero_p(num)
return FALSE;
}
-extern VALUE mComparable;
-extern VALUE eStandardError;
-
void
Init_Numeric()
{
diff --git a/object.c b/object.c
index d6526eab25..027ddd658e 100644
--- a/object.c
+++ b/object.c
@@ -22,7 +22,6 @@ VALUE cObject;
#endif
VALUE cModule;
VALUE cClass;
-extern VALUE cFixnum;
VALUE cData;
static VALUE cNilClass;
diff --git a/pack.c b/pack.c
index 393b6e0c27..400d81c8b9 100644
--- a/pack.c
+++ b/pack.c
@@ -74,8 +74,6 @@ endian()
#endif
#endif
-extern VALUE cString, cArray;
-
static char *toofew = "too few arguments";
static void encodes _((VALUE,char*,int,int));
diff --git a/range.c b/range.c
index fbf6b4a280..759dc8f0ab 100644
--- a/range.c
+++ b/range.c
@@ -13,8 +13,6 @@
#include "ruby.h"
static VALUE cRange;
-extern VALUE cNumeric;
-
static ID upto;
static VALUE
@@ -203,8 +201,6 @@ range_length(rng)
return size;
}
-extern VALUE mEnumerable;
-
void
Init_Range()
{
diff --git a/re.c b/re.c
index 1eee2cb8d6..b7aa11f58a 100644
--- a/re.c
+++ b/re.c
@@ -437,7 +437,7 @@ reg_search(reg, str, start, reverse)
start, range, regs);
kcode_reset_option();
- if (start == -2) {
+ if (result == -2) {
reg_raise(RREGEXP(reg)->str, RREGEXP(reg)->len,
"Stack overfow in regexp matcher", reg);
}
@@ -1010,8 +1010,6 @@ match_setter(val)
backref_set(val);
}
-extern VALUE eStandardError;
-
void
Init_Regexp()
{
diff --git a/ruby.h b/ruby.h
index 477816fa52..55b56d9d9b 100644
--- a/ruby.h
+++ b/ruby.h
@@ -147,12 +147,6 @@ VALUE int2inum _((long));
# define RTEST(v) rb_test_false_or_nil((VALUE)(v))
#define NIL_P(v) ((VALUE)(v) == Qnil)
-#ifdef __MACOS__ /* name conflict, AERegistory.h */
-extern VALUE cRubyObject;
-#else
-extern VALUE cObject;
-#endif
-
VALUE rb_class_of _((VALUE));
#define CLASS_OF(v) rb_class_of((VALUE)(v))
@@ -492,6 +486,55 @@ VALUE rb_iterate _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
+extern VALUE mKernel;
+extern VALUE mComparable;
+extern VALUE mEnumerable;
+extern VALUE mErrno;
+extern VALUE mFileTest;
+extern VALUE mGC;
+extern VALUE mMath;
+extern VALUE mProcess;
+
+#ifdef __MACOS__ /* name conflict, AERegistory.h */
+extern VALUE cRubyObject;
+#else
+extern VALUE cObject;
+#endif
+extern VALUE cArray;
+extern VALUE cBignum;
+extern VALUE cClass;
+extern VALUE cData;
+extern VALUE cFile;
+extern VALUE cFixnum;
+extern VALUE cFloat;
+extern VALUE cHash;
+extern VALUE cInteger;
+extern VALUE cIO;
+extern VALUE cModule;
+extern VALUE cNumeric;
+extern VALUE cProc;
+extern VALUE cRegexp;
+extern VALUE cString;
+extern VALUE cThread;
+extern VALUE cStruct;
+
+extern VALUE eException;
+extern VALUE eStandardError;
+extern VALUE eSystemExit, eInterrupt, eFatal;
+extern VALUE eArgError;
+extern VALUE eEOFError;
+extern VALUE eIndexError;
+extern VALUE eIOError;
+extern VALUE eLoadError;
+extern VALUE eNameError;
+extern VALUE eRuntimeError;
+extern VALUE eSecurityError;
+extern VALUE eSyntaxError;
+extern VALUE eSystemCallError;
+extern VALUE eTypeError;
+extern VALUE eZeroDiv;
+extern VALUE eNotImpError;
+
#include "intern.h"
#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
diff --git a/string.c b/string.c
index dd534321c8..5def049e35 100644
--- a/string.c
+++ b/string.c
@@ -2607,10 +2607,6 @@ str_center(str, w)
return res;
}
-extern VALUE mKernel;
-extern VALUE mComparable;
-extern VALUE mEnumerable;
-
void
Init_String()
{
diff --git a/struct.c b/struct.c
index 1bd964fda0..76187c09b4 100644
--- a/struct.c
+++ b/struct.c
@@ -15,7 +15,6 @@
#endif
VALUE cStruct;
-extern VALUE mEnumerable;
static VALUE
class_of(obj)
diff --git a/time.c b/time.c
index 6bd0443a86..00289b0553 100644
--- a/time.c
+++ b/time.c
@@ -39,7 +39,6 @@ static VALUE cTime;
#if defined(HAVE_TIMES) || defined(NT)
static VALUE S_Tms;
#endif
-extern VALUE mComparable;
struct time_object {
struct timeval tv;
diff --git a/variable.c b/variable.c
index c4f2d0d3c0..7269ee1d87 100644
--- a/variable.c
+++ b/variable.c
@@ -43,8 +43,6 @@ struct fc_result {
struct fc_result *prev;
};
-extern VALUE cModule;
-
static int
fc_i(key, value, res)
ID key;