Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/v1_1r@232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jun 2, 1998
1 parent a99b711 commit a89790c
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 102 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,8 +1294,6 @@ ary_flatten(ary)
return v;
}

extern VALUE mEnumerable;

void
Init_Array()
{
Expand Down
1 change: 0 additions & 1 deletion bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <math.h>
#include <ctype.h>

extern VALUE cInteger;
VALUE cBignum;
typedef unsigned short USHORT;

Expand Down
5 changes: 0 additions & 5 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

extern st_table *rb_class_tbl;

extern VALUE cClass;
extern VALUE cModule;

VALUE
class_new(super)
VALUE super;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
89 changes: 49 additions & 40 deletions ext/socket/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -229,31 +227,32 @@ 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);
retry:
#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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -845,25 +845,26 @@ 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));
}
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);
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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),
Expand All @@ -1364,20 +1366,20 @@ 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);
}
else {
type = AF_INET;
}

h = gethostbyaddr(RSTRING(addr)->ptr, RSTRING(addr)->len, type);
h = gethostbyaddr(addr, alen, type);

return mkhostent(h);
}
Expand All @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ char *strrchr _((char*,char));
extern int utimes();
#endif

extern VALUE cIO;
VALUE cFile;
VALUE mFileTest;
static VALUE sStat;
Expand Down Expand Up @@ -1574,8 +1573,6 @@ f_test(argc, argv)
return Qnil; /* not reached */
}

extern VALUE mKernel;

void
Init_File()
{
Expand Down
2 changes: 0 additions & 2 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,6 @@ id2ref(obj, id)
return (VALUE)ptr;
}

extern VALUE cModule;

void
Init_GC()
{
Expand Down
5 changes: 0 additions & 5 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct timeval {
#endif

VALUE cIO;
extern VALUE cFile;
VALUE eEOFError;
VALUE eIOError;

Expand Down Expand Up @@ -2559,10 +2558,6 @@ opt_i_set(val)
inplace = RSTRING(val)->ptr;
}

extern VALUE mKernel;
extern VALUE mEnumerable;
extern VALUE eStandardError;

void
Init_IO()
{
Expand Down
6 changes: 0 additions & 6 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,6 @@ fix_zero_p(num)
return FALSE;
}

extern VALUE mComparable;
extern VALUE eStandardError;

void
Init_Numeric()
{
Expand Down
1 change: 0 additions & 1 deletion object.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ VALUE cObject;
#endif
VALUE cModule;
VALUE cClass;
extern VALUE cFixnum;
VALUE cData;

static VALUE cNilClass;
Expand Down
2 changes: 0 additions & 2 deletions pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ endian()
#endif
#endif

extern VALUE cString, cArray;

static char *toofew = "too few arguments";

static void encodes _((VALUE,char*,int,int));
Expand Down
4 changes: 0 additions & 4 deletions range.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "ruby.h"

static VALUE cRange;
extern VALUE cNumeric;

static ID upto;

static VALUE
Expand Down Expand Up @@ -203,8 +201,6 @@ range_length(rng)
return size;
}

extern VALUE mEnumerable;

void
Init_Range()
{
Expand Down
Loading

0 comments on commit a89790c

Please sign in to comment.