diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-02 10:05:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-02 10:05:37 +0000 |
commit | 46c4975d9c25f7f336a23bde080420c5ed29ab0e (patch) | |
tree | ebd8f7cd175a477da19c8871a44adab3e933077e | |
parent | e6ab550ac5504c4e5f3b2946749f8381513448ff (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-- | ChangeLog | 7 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | bignum.c | 1 | ||||
-rw-r--r-- | class.c | 5 | ||||
-rw-r--r-- | error.c | 1 | ||||
-rw-r--r-- | eval.c | 10 | ||||
-rw-r--r-- | ext/socket/socket.c | 89 | ||||
-rw-r--r-- | file.c | 3 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | io.c | 5 | ||||
-rw-r--r-- | marshal.c | 6 | ||||
-rw-r--r-- | numeric.c | 3 | ||||
-rw-r--r-- | object.c | 1 | ||||
-rw-r--r-- | pack.c | 2 | ||||
-rw-r--r-- | range.c | 4 | ||||
-rw-r--r-- | re.c | 4 | ||||
-rw-r--r-- | ruby.h | 55 | ||||
-rw-r--r-- | string.c | 4 | ||||
-rw-r--r-- | struct.c | 1 | ||||
-rw-r--r-- | time.c | 1 | ||||
-rw-r--r-- | variable.c | 2 |
21 files changed, 106 insertions, 102 deletions
@@ -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 @@ -1294,8 +1294,6 @@ ary_flatten(ary) return v; } -extern VALUE mEnumerable; - void Init_Array() { @@ -12,7 +12,6 @@ #include <math.h> #include <ctype.h> -extern VALUE cInteger; VALUE cBignum; typedef unsigned short USHORT; @@ -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; @@ -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; @@ -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); } @@ -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() { @@ -1047,8 +1047,6 @@ id2ref(obj, id) return (VALUE)ptr; } -extern VALUE cModule; - void Init_GC() { @@ -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() { @@ -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) @@ -1303,9 +1303,6 @@ fix_zero_p(num) return FALSE; } -extern VALUE mComparable; -extern VALUE eStandardError; - void Init_Numeric() { @@ -22,7 +22,6 @@ VALUE cObject; #endif VALUE cModule; VALUE cClass; -extern VALUE cFixnum; VALUE cData; static VALUE cNilClass; @@ -74,8 +74,6 @@ endian() #endif #endif -extern VALUE cString, cArray; - static char *toofew = "too few arguments"; static void encodes _((VALUE,char*,int,int)); @@ -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() { @@ -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() { @@ -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) @@ -2607,10 +2607,6 @@ str_center(str, w) return res; } -extern VALUE mKernel; -extern VALUE mComparable; -extern VALUE mEnumerable; - void Init_String() { @@ -15,7 +15,6 @@ #endif VALUE cStruct; -extern VALUE mEnumerable; static VALUE class_of(obj) @@ -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; |