* exception message clean-up by Ian Macdonald <ian@caliban.org>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-03-29 07:54:38 +00:00
parent 6a738f2265
commit 919f456de8
39 changed files with 127 additions and 124 deletions

View File

@ -1774,7 +1774,7 @@ rb_ary_select(argc, argv, ary)
long i; long i;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
result = rb_ary_new2(RARRAY(ary)->len); result = rb_ary_new2(RARRAY(ary)->len);
for (i = 0; i < RARRAY(ary)->len; i++) { for (i = 0; i < RARRAY(ary)->len; i++) {

View File

@ -1017,7 +1017,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
} }
if (argc > i) { if (argc > i) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", argc, i); rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, i);
} }
return argc; return argc;

20
eval.c
View File

@ -3639,7 +3639,7 @@ rb_eval(self, n)
case NODE_ATTRSET: case NODE_ATTRSET:
if (ruby_frame->argc != 1) if (ruby_frame->argc != 1)
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
ruby_frame->argc); ruby_frame->argc);
result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]); result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]);
break; break;
@ -4853,7 +4853,7 @@ massign(self, node, val, pcall)
} }
if (pcall && list) goto arg_error; if (pcall && list) goto arg_error;
if (node->nd_args) { if (node->nd_args) {
if (node->nd_args == (NODE*)-1) { if ((long)(node->nd_args) == -1) {
/* no check for mere `*' */ /* no check for mere `*' */
} }
else if (!list && i<len) { else if (!list && i<len) {
@ -5333,7 +5333,7 @@ call_cfunc(func, recv, len, argc, argv)
VALUE *argv; VALUE *argv;
{ {
if (len >= 0 && argc != len) { if (len >= 0 && argc != len) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, len); argc, len);
} }
@ -5484,7 +5484,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
/* for attr get/set */ /* for attr get/set */
case NODE_IVAR: case NODE_IVAR:
if (argc != 0) { if (argc != 0) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
result = rb_attr_get(recv, body->nd_vid); result = rb_attr_get(recv, body->nd_vid);
break; break;
@ -5547,10 +5547,10 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
i = node->nd_cnt; i = node->nd_cnt;
if (i > argc) { if (i > argc) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, i); argc, i);
} }
if ((int)node->nd_rest == -1) { if ((long)node->nd_rest == -1) {
int opt = i; int opt = i;
NODE *optnode = node->nd_opt; NODE *optnode = node->nd_opt;
@ -5559,7 +5559,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
optnode = optnode->nd_next; optnode = optnode->nd_next;
} }
if (opt < argc) { if (opt < argc) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, opt); argc, opt);
} }
ruby_frame->argc = opt; ruby_frame->argc = opt;
@ -5585,7 +5585,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
} }
} }
local_vars = ruby_scope->local_vars; local_vars = ruby_scope->local_vars;
if ((int)node->nd_rest >= 0) { if ((long)node->nd_rest >= 0) {
VALUE v; VALUE v;
if (argc > 0) if (argc > 0)
@ -7196,7 +7196,7 @@ rb_obj_extend(argc, argv, obj)
int i; int i;
if (argc == 0) { if (argc == 0) {
rb_raise(rb_eArgError, "wrong number of arguments(0 for 1)"); rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
} }
for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE); for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
while (argc--) { while (argc--) {
@ -9096,7 +9096,7 @@ rb_mod_define_method(argc, argv, mod)
} }
} }
else { else {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
} }
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) { if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
struct METHOD *method = (struct METHOD *)DATA_PTR(body); struct METHOD *method = (struct METHOD *)DATA_PTR(body);

View File

@ -601,7 +601,7 @@ iconv_s_iconv
struct iconv_env_t arg; struct iconv_env_t arg;
if (argc < 2) /* needs `to' and `from' arguments at least */ if (argc < 2) /* needs `to' and `from' arguments at least */
rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", argc, 2); rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, 2);
arg.argc = argc -= 2; arg.argc = argc -= 2;
arg.argv = argv + 2; arg.argv = argv + 2;

View File

@ -63,7 +63,7 @@ ossl_x509_ary2sk0(VALUE ary)
val = rb_ary_entry(ary, i); val = rb_ary_entry(ary, i);
if (!rb_obj_is_kind_of(val, cX509Cert)) { if (!rb_obj_is_kind_of(val, cX509Cert)) {
sk_X509_pop_free(sk, X509_free); sk_X509_pop_free(sk, X509_free);
ossl_raise(eOSSLError, "object except X509 cert is in array"); ossl_raise(eOSSLError, "object not X509 cert in array");
} }
x509 = DupX509CertPtr(val); /* NEED TO DUP */ x509 = DupX509CertPtr(val); /* NEED TO DUP */
sk_X509_push(sk, x509); sk_X509_push(sk, x509);

View File

@ -567,7 +567,7 @@ ossl_asn1_default_tag(VALUE obj)
return i; return i;
} }
} }
ossl_raise(eASN1Error, "not found universal tag for %s", ossl_raise(eASN1Error, "universal tag for %s not found",
rb_class2name(CLASS_OF(obj))); rb_class2name(CLASS_OF(obj)));
return -1; /* dummy */ return -1; /* dummy */
@ -650,7 +650,7 @@ ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
if(!SYMBOL_P(tag_class)) if(!SYMBOL_P(tag_class))
ossl_raise(eASN1Error, "invalid tag class"); ossl_raise(eASN1Error, "invalid tag class");
if((SYM2ID(tag_class) == sUNIVERSAL) && NUM2INT(tag) > 31) if((SYM2ID(tag_class) == sUNIVERSAL) && NUM2INT(tag) > 31)
ossl_raise(eASN1Error, "too large tag number for Universal"); ossl_raise(eASN1Error, "tag number for Universal too large");
ossl_asn1_set_tag(self, tag); ossl_asn1_set_tag(self, tag);
ossl_asn1_set_value(self, value); ossl_asn1_set_value(self, value);
ossl_asn1_set_tag_class(self, tag_class); ossl_asn1_set_tag_class(self, tag_class);
@ -865,13 +865,13 @@ ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
if(NIL_P(tagging)) if(NIL_P(tagging))
tagging = ID2SYM(sEXPLICIT); tagging = ID2SYM(sEXPLICIT);
if(!SYMBOL_P(tagging)) if(!SYMBOL_P(tagging))
ossl_raise(eASN1Error, "invelid tag default"); ossl_raise(eASN1Error, "invalid tag default");
if(NIL_P(tag_class)) if(NIL_P(tag_class))
tag_class = ID2SYM(sCONTEXT_SPECIFIC); tag_class = ID2SYM(sCONTEXT_SPECIFIC);
if(!SYMBOL_P(tag_class)) if(!SYMBOL_P(tag_class))
ossl_raise(eASN1Error, "invelid tag class"); ossl_raise(eASN1Error, "invalid tag class");
if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31) if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
ossl_raise(eASN1Error, "too large tag number for Universal"); ossl_raise(eASN1Error, "tag number for Universal too large");
} }
else{ else{
tag = INT2NUM(ossl_asn1_default_tag(self)); tag = INT2NUM(ossl_asn1_default_tag(self));

View File

@ -147,7 +147,7 @@ ossl_config_initialize(int argc, VALUE *argv, VALUE self)
} }
} }
#ifdef OSSL_NO_CONF_API #ifdef OSSL_NO_CONF_API
else rb_raise(rb_eArgError, "wrong number of arguments(0 for 1)"); else rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
#else #else
else _CONF_new_data(conf); else _CONF_new_data(conf);
#endif #endif

View File

@ -358,7 +358,7 @@ ossl_pkcs7_set_detached(VALUE self, VALUE flag)
GetPKCS7(self, p7); GetPKCS7(self, p7);
if(flag != Qtrue && flag != Qfalse) if(flag != Qtrue && flag != Qfalse)
ossl_raise(ePKCS7Error, "must secify a boolean"); ossl_raise(ePKCS7Error, "must specify a boolean");
if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0)) if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0))
ossl_raise(ePKCS7Error, NULL); ossl_raise(ePKCS7Error, NULL);

View File

@ -733,7 +733,7 @@ reduce0(val, data, self)
/* calculate transition state */ /* calculate transition state */
if (RARRAY(v->state)->len == 0) if (RARRAY(v->state)->len == 0)
rb_raise(RaccBug, "state stack unexpected empty"); rb_raise(RaccBug, "state stack unexpectedly empty");
k2 = num_to_long(LAST_I(v->state)); k2 = num_to_long(LAST_I(v->state));
k1 = num_to_long(reduce_to) - v->nt_base; k1 = num_to_long(reduce_to) - v->nt_base;
D_printf("(goto) k1=%ld\n", k1); D_printf("(goto) k1=%ld\n", k1);

View File

@ -83,7 +83,7 @@ readline_s_set_completion_proc(self, proc)
VALUE proc; VALUE proc;
{ {
if (!rb_respond_to(proc, rb_intern("call"))) if (!rb_respond_to(proc, rb_intern("call")))
rb_raise(rb_eArgError, "argument have to respond to `call'"); rb_raise(rb_eArgError, "argument must respond to `call'");
return rb_iv_set(mReadline, COMPLETION_PROC, proc); return rb_iv_set(mReadline, COMPLETION_PROC, proc);
} }

View File

@ -227,7 +227,7 @@ fsdbm_select(argc, argv, obj)
struct dbmdata *dbmp; struct dbmdata *dbmp;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
GetDBM(obj, dbmp); GetDBM(obj, dbmp);
dbm = dbmp->di_dbm; dbm = dbmp->di_dbm;

View File

@ -879,7 +879,7 @@ strio_read(argc, argv, self)
} }
break; break;
default: default:
rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
if (NIL_P(str)) { if (NIL_P(str)) {
str = rb_str_substr(ptr->string, ptr->pos, len); str = rb_str_substr(ptr->string, ptr->pos, len);

View File

@ -146,7 +146,7 @@ static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
VALUE pri; VALUE pri;
if (argc < 2) { if (argc < 2) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2+)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
} }
argc--; argc--;

View File

@ -811,7 +811,7 @@ ip_ruby(clientData, interp, argc, argv)
/* ruby command has 1 arg. */ /* ruby command has 1 arg. */
if (argc != 2) { if (argc != 2) {
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
} }
/* get C string from Tcl object */ /* get C string from Tcl object */

View File

@ -73,7 +73,7 @@
#define OLEData_Get_Struct(obj, pole) {\ #define OLEData_Get_Struct(obj, pole) {\
Data_Get_Struct(obj, struct oledata, pole);\ Data_Get_Struct(obj, struct oledata, pole);\
if(!pole->pDispatch) {\ if(!pole->pDispatch) {\
rb_raise(rb_eRuntimeError, "Fail to get Dispatch Interface");\ rb_raise(rb_eRuntimeError, "failed to get Dispatch Interface");\
}\ }\
} }
@ -769,7 +769,7 @@ ole_val2variant(val, var)
if(pub) free(pub); if(pub) free(pub);
if(psab) free(psab); if(psab) free(psab);
if(pid) free(pid); if(pid) free(pid);
rb_raise(rb_eRuntimeError, "memory allocate error"); rb_raise(rb_eRuntimeError, "memory allocation error");
} }
val1 = val; val1 = val;
i = 0; i = 0;
@ -907,7 +907,7 @@ ole_variant2val(pvar)
if(pID) free(pID); if(pID) free(pID);
if(pLB) free(pLB); if(pLB) free(pLB);
if(pUB) free(pUB); if(pUB) free(pUB);
rb_raise(rb_eRuntimeError, "memory allocate error"); rb_raise(rb_eRuntimeError, "memory allocation error");
} }
obj = Qnil; obj = Qnil;
@ -1361,7 +1361,7 @@ ole_create_dcom(argc, argv, self)
if (!gole32) if (!gole32)
gole32 = LoadLibrary("OLE32"); gole32 = LoadLibrary("OLE32");
if (!gole32) if (!gole32)
rb_raise(rb_eRuntimeError, "Fail to load OLE32."); rb_raise(rb_eRuntimeError, "failed to load OLE32.");
if (!gCoCreateInstanceEx) if (!gCoCreateInstanceEx)
gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*) gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*)
GetProcAddress(gole32, "CoCreateInstanceEx"); GetProcAddress(gole32, "CoCreateInstanceEx");
@ -1388,7 +1388,7 @@ ole_create_dcom(argc, argv, self)
SysFreeString(serverinfo.pwszName); SysFreeString(serverinfo.pwszName);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"Fail to create DCOM server : `%s' in `%s'", "failed to create DCOM server : `%s' in `%s'",
StringValuePtr(ole), StringValuePtr(ole),
StringValuePtr(host)); StringValuePtr(host));
@ -1415,7 +1415,7 @@ ole_bind_obj(moniker, argc, argv, self)
hr = CreateBindCtx(0, &pBindCtx); hr = CreateBindCtx(0, &pBindCtx);
if(FAILED(hr)) { if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"Fail to create bind context"); "failed to create bind context");
} }
pbuf = ole_mb2wc(StringValuePtr(moniker), -1); pbuf = ole_mb2wc(StringValuePtr(moniker), -1);
@ -1492,7 +1492,7 @@ fole_s_connect(argc, argv, self)
if(FAILED(hr)) { if(FAILED(hr)) {
OLE_RELEASE(pUnknown); OLE_RELEASE(pUnknown);
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"Fail to create WIN32OLE server : `%s'", "failed to create WIN32OLE server : `%s'",
StringValuePtr(svr_name)); StringValuePtr(svr_name));
} }
@ -1536,12 +1536,12 @@ fole_s_const_load(argc, argv, self)
hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo); 0, lcid, &pTypeInfo);
if(FAILED(hr)) { if(FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
} }
hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index); hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
if(FAILED(hr)) { if(FAILED(hr)) {
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError, "fail to GetContainingTypeLib"); ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
} }
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
if(TYPE(klass) != T_NIL) { if(TYPE(klass) != T_NIL) {
@ -1561,7 +1561,7 @@ fole_s_const_load(argc, argv, self)
hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib); hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
SysFreeString(pBuf); SysFreeString(pBuf);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
if(TYPE(klass) != T_NIL) { if(TYPE(klass) != T_NIL) {
ole_const_load(pTypeLib, klass, self); ole_const_load(pTypeLib, klass, self);
} }
@ -1717,11 +1717,11 @@ fole_s_show_help(argc, argv, self)
helpfile = target; helpfile = target;
} }
if (TYPE(helpfile) != T_STRING) { if (TYPE(helpfile) != T_STRING) {
rb_raise(rb_eTypeError, "1st parametor must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)."); rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD).");
} }
hwnd = ole_show_help(helpfile, helpcontext); hwnd = ole_show_help(helpfile, helpcontext);
if(hwnd == 0) { if(hwnd == 0) {
rb_raise(rb_eRuntimeError, "fail to open help file:%s", rb_raise(rb_eRuntimeError, "failed to open help file:%s",
StringValuePtr(helpfile)); StringValuePtr(helpfile));
} }
return Qnil; return Qnil;
@ -1775,7 +1775,7 @@ fole_initialize(argc, argv, self)
&IID_IDispatch, (void**)&pDispatch); &IID_IDispatch, (void**)&pDispatch);
if(FAILED(hr)) { if(FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
"Fail to create WIN32OLE object from `%s'", "failed to create WIN32OLE object from `%s'",
StringValuePtr(svr_name)); StringValuePtr(svr_name));
} }
@ -1876,7 +1876,7 @@ ole_invoke(argc, argv, self, wFlags)
rb_scan_args(argc, argv, "1*", &cmd, &paramS); rb_scan_args(argc, argv, "1*", &cmd, &paramS);
OLEData_Get_Struct(self, pole); OLEData_Get_Struct(self, pole);
if(!pole->pDispatch) { if(!pole->pDispatch) {
rb_raise(rb_eRuntimeError, "Fail to get dispatch interface."); rb_raise(rb_eRuntimeError, "failed to get dispatch interface.");
} }
wcmdname = ole_mb2wc(StringValuePtr(cmd), -1); wcmdname = ole_mb2wc(StringValuePtr(cmd), -1);
hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL, hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
@ -2431,7 +2431,7 @@ fole_each(self)
if (FAILED(hr)) { if (FAILED(hr)) {
VariantClear(&result); VariantClear(&result);
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to get IEnum Interface"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to get IEnum Interface");
} }
if (V_VT(&result) == VT_UNKNOWN) if (V_VT(&result) == VT_UNKNOWN)
@ -2444,7 +2444,7 @@ fole_each(self)
(void**)&pEnum); (void**)&pEnum);
if (FAILED(hr) || !pEnum) { if (FAILED(hr) || !pEnum) {
VariantClear(&result); VariantClear(&result);
ole_raise(hr, rb_eRuntimeError, "Fail to get IEnum Interface"); ole_raise(hr, rb_eRuntimeError, "failed to get IEnum Interface");
} }
VariantClear(&result); VariantClear(&result);
@ -2499,7 +2499,7 @@ ole_method_sub(self, pOwnerTypeInfo, pTypeInfo, name)
VALUE method = Qnil; VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
} }
for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) { for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc); hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
@ -2538,7 +2538,7 @@ olemethod_from_typeinfo(self, pTypeInfo, name)
VALUE method = Qnil; VALUE method = Qnil;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
} }
method = ole_method_sub(self, 0, pTypeInfo, name); method = ole_method_sub(self, 0, pTypeInfo, name);
if (method != Qnil) { if (method != Qnil) {
@ -2574,7 +2574,7 @@ ole_methods_sub(pOwnerTypeInfo, pTypeInfo, methods, mask)
WORD i; WORD i;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
} }
for(i = 0; i < pTypeAttr->cFuncs; i++) { for(i = 0; i < pTypeAttr->cFuncs; i++) {
pstr = NULL; pstr = NULL;
@ -2615,7 +2615,7 @@ ole_methods_from_typeinfo(pTypeInfo, mask)
VALUE methods = rb_ary_new(); VALUE methods = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
} }
ole_methods_sub(0, pTypeInfo, methods, mask); ole_methods_sub(0, pTypeInfo, methods, mask);
@ -2648,7 +2648,7 @@ typeinfo_from_ole(pole, ppti)
HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch, HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
0, lcid, &pTypeInfo); 0, lcid, &pTypeInfo);
if(FAILED(hr)) { if(FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
} }
hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo,
-1, -1,
@ -2658,7 +2658,7 @@ typeinfo_from_ole(pole, ppti)
hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i); hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "fail to GetContainingTypeLib"); ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
} }
count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib); count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@ -2773,12 +2773,12 @@ fole_obj_help( self )
hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo ); hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo );
if(FAILED(hr)) { if(FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "fail to GetTypeInfo"); ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
} }
hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index ); hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
if(FAILED(hr)) { if(FAILED(hr)) {
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError, "fail to GetContainingTypeLib"); ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
} }
hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index, hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
&bstr, NULL, NULL, NULL); &bstr, NULL, NULL, NULL);
@ -3011,7 +3011,7 @@ fole_method_help( self, cmdname )
OLEData_Get_Struct(self, pole); OLEData_Get_Struct(self, pole);
hr = typeinfo_from_ole(pole, &pTypeInfo); hr = typeinfo_from_ole(pole, &pTypeInfo);
if(FAILED(hr)) if(FAILED(hr))
ole_raise(hr, rb_eRuntimeError, "fail to get ITypeInfo"); ole_raise(hr, rb_eRuntimeError, "failed to get ITypeInfo");
method = folemethod_s_allocate(cWIN32OLE_METHOD); method = folemethod_s_allocate(cWIN32OLE_METHOD);
obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname); obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname);
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
@ -3046,7 +3046,7 @@ foletype_s_ole_classes(self, typelib)
pbuf = ole_mb2wc(StringValuePtr(file), -1); pbuf = ole_mb2wc(StringValuePtr(file), -1);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
SysFreeString(pbuf); SysFreeString(pbuf);
ole_classes_from_typelib(pTypeLib, classes); ole_classes_from_typelib(pTypeLib, classes);
OLE_RELEASE(pTypeLib); OLE_RELEASE(pTypeLib);
@ -3221,7 +3221,7 @@ foletype_initialize(self, typelib, oleclass)
pbuf = ole_mb2wc(StringValuePtr(file), -1); pbuf = ole_mb2wc(StringValuePtr(file), -1);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib); hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to LoadTypeLibEx"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to LoadTypeLibEx");
SysFreeString(pbuf); SysFreeString(pbuf);
if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) { if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
OLE_RELEASE(pTypeLib); OLE_RELEASE(pTypeLib);
@ -3414,7 +3414,7 @@ ole_type_major_version(pTypeInfo)
HRESULT hr; HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMajorVerNum); ver = INT2FIX(pTypeAttr->wMajorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver; return ver;
@ -3443,7 +3443,7 @@ ole_type_minor_version(pTypeInfo)
HRESULT hr; HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
ver = INT2FIX(pTypeAttr->wMinorVerNum); ver = INT2FIX(pTypeAttr->wMinorVerNum);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return ver; return ver;
@ -3472,7 +3472,7 @@ ole_type_typekind(pTypeInfo)
HRESULT hr; HRESULT hr;
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
typekind = INT2FIX(pTypeAttr->typekind); typekind = INT2FIX(pTypeAttr->typekind);
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr); OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return typekind; return typekind;
@ -3622,7 +3622,7 @@ ole_variables(pTypeInfo)
VALUE variables = rb_ary_new(); VALUE variables = rb_ary_new();
hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr); hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetTypeAttr"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetTypeAttr");
} }
for(i = 0; i < pTypeAttr->cVars; i++) { for(i = 0; i < pTypeAttr->cVars; i++) {
@ -3702,7 +3702,7 @@ static ole_variable_ole_type(pTypeInfo, var_index)
VALUE type; VALUE type;
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetVarDesc"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil); type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type; return type;
@ -3731,7 +3731,7 @@ static ole_variable_ole_type_detail(pTypeInfo, var_index)
VALUE type = rb_ary_new(); VALUE type = rb_ary_new();
hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc); hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetVarDesc"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetVarDesc");
ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type); ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc); pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
return type; return type;
@ -3970,7 +3970,7 @@ ole_method_return_type(pTypeInfo, method_index)
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil); type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
@ -4002,7 +4002,7 @@ ole_method_return_vtype(pTypeInfo, method_index)
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if (FAILED(hr)) if (FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt); vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
@ -4066,7 +4066,7 @@ ole_method_invkind(pTypeInfo, method_index)
VALUE invkind; VALUE invkind;
hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc); hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
if(FAILED(hr)) if(FAILED(hr))
ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Fail to GetFuncDesc"); ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "failed to GetFuncDesc");
invkind = INT2FIX(pFuncDesc->invkind); invkind = INT2FIX(pFuncDesc->invkind);
pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc); pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
return invkind; return invkind;
@ -5269,7 +5269,7 @@ fev_initialize(argc, argv, self)
rb_scan_args(argc, argv, "11", &ole, &itf); rb_scan_args(argc, argv, "11", &ole, &itf);
if (!rb_obj_is_kind_of(ole, cWIN32OLE)) { if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
rb_raise(rb_eTypeError, "1st parametor must be WIN32OLE object."); rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object.");
} }
if(TYPE(itf) != T_NIL) { if(TYPE(itf) != T_NIL) {
@ -5285,7 +5285,7 @@ fev_initialize(argc, argv, self)
hr = find_default_source(ole, &iid, &pTypeInfo); hr = find_default_source(ole, &iid, &pTypeInfo);
} }
if (FAILED(hr)) { if (FAILED(hr)) {
ole_raise(hr, rb_eRuntimeError, "not found interface"); ole_raise(hr, rb_eRuntimeError, "interface not found");
} }
OLEData_Get_Struct(ole, pole); OLEData_Get_Struct(ole, pole);
@ -5296,7 +5296,7 @@ fev_initialize(argc, argv, self)
if (FAILED(hr)) { if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError, ole_raise(hr, rb_eRuntimeError,
"fail to query IConnectionPointContainer"); "failed to query IConnectionPointContainer");
} }
hr = pContainer->lpVtbl->FindConnectionPoint(pContainer, hr = pContainer->lpVtbl->FindConnectionPoint(pContainer,
@ -5305,7 +5305,7 @@ fev_initialize(argc, argv, self)
OLE_RELEASE(pContainer); OLE_RELEASE(pContainer);
if (FAILED(hr)) { if (FAILED(hr)) {
OLE_RELEASE(pTypeInfo); OLE_RELEASE(pTypeInfo);
ole_raise(hr, rb_eRuntimeError, "fail to query IConnectionPoint"); ole_raise(hr, rb_eRuntimeError, "failed to query IConnectionPoint");
} }
pIEV = EVENTSINK_Constructor(); pIEV = EVENTSINK_Constructor();
pIEV->m_iid = iid; pIEV->m_iid = iid;

4
file.c
View File

@ -2116,7 +2116,7 @@ rb_file_s_umask(argc, argv)
omask = umask(NUM2INT(argv[0])); omask = umask(NUM2INT(argv[0]));
} }
else { else {
rb_raise(rb_eArgError, "wrong number of argument"); rb_raise(rb_eArgError, "wrong number of arguments");
} }
return INT2FIX(omask); return INT2FIX(omask);
} }
@ -2996,7 +2996,7 @@ test_check(n, argc, argv)
int i; int i;
n+=1; n+=1;
if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments(%d for %d)", argc, n); if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
for (i=1; i<n; i++) { for (i=1; i<n; i++) {
switch (TYPE(argv[i])) { switch (TYPE(argv[i])) {
case T_STRING: case T_STRING:

6
hash.c
View File

@ -286,7 +286,7 @@ rb_hash_s_create(argc, argv, klass)
} }
if (argc % 2 != 0) { if (argc % 2 != 0) {
rb_raise(rb_eArgError, "odd number args for Hash"); rb_raise(rb_eArgError, "odd number of arguments for Hash");
} }
hash = hash_alloc(klass); hash = hash_alloc(klass);
@ -803,7 +803,7 @@ rb_hash_select(argc, argv, hash)
VALUE result; VALUE result;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
result = rb_ary_new(); result = rb_ary_new();
rb_hash_foreach(hash, select_i, result); rb_hash_foreach(hash, select_i, result);
@ -2019,7 +2019,7 @@ env_select(argc, argv)
char **env; char **env;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
result = rb_ary_new(); result = rb_ary_new();
env = GET_ENVIRON(environ); env = GET_ENVIRON(environ);

View File

@ -30,7 +30,7 @@
# See http://www.w3.org/CGI/ for more information on the CGI # See http://www.w3.org/CGI/ for more information on the CGI
# protocol. # protocol.
raise "Please, use ruby1.5.4 or later." if RUBY_VERSION < "1.5.4" raise "Please, use ruby 1.5.4 or later." if RUBY_VERSION < "1.5.4"
require 'English' require 'English'

View File

@ -557,7 +557,7 @@ class CSV
private private
def initialize(dev) def initialize(dev)
raise RuntimeError.new('do not instanciate this class directly') raise RuntimeError.new('do not instantiate this class directly')
end end
def get_row(row) def get_row(row)
@ -709,7 +709,7 @@ class CSV
private private
def initialize(dev) def initialize(dev)
raise RuntimeError.new('do not instanciate this class directly') raise RuntimeError.new('do not instantiate this class directly')
end end
def terminate def terminate
@ -801,7 +801,7 @@ class CSV
# end # end
# end # end
# #
class StreamBuf # pure virtual. (do not instanciate it directly) class StreamBuf # pure virtual. (do not instantiate it directly)
# get a char or a partial string from the stream. # get a char or a partial string from the stream.
# idx: index of a string to specify a start point of a string to get. # idx: index of a string to specify a start point of a string to get.
@ -893,7 +893,7 @@ class CSV
return idx_is_eos?(0) return idx_is_eos?(0)
end end
# WARN: Do not instanciate this class directly. Define your own class # WARN: Do not instantiate this class directly. Define your own class
# which derives this class and define 'read' instance method. # which derives this class and define 'read' instance method.
def initialize def initialize
@buf_list = [] @buf_list = []

View File

@ -111,6 +111,9 @@ def DelegateClass(superclass)
def __getobj__ def __getobj__
@_dc_obj @_dc_obj
end end
def __setobj__(obj)
@_dc_obj = obj
end
return klass; return klass;
end end

View File

@ -125,7 +125,7 @@ class Generator
# Returns the element at the current position and moves forward. # Returns the element at the current position and moves forward.
def next() def next()
if end? if end?
raise EOFError, "no more element is supplied" raise EOFError, "no more elements available"
end end
if @cont_next = callcc { |c| c } if @cont_next = callcc { |c| c }
@ -140,7 +140,7 @@ class Generator
# Returns the element at the current position. # Returns the element at the current position.
def current() def current()
if @queue.empty? if @queue.empty?
raise EOFError, "no more element is supplied" raise EOFError, "no more elements available"
end end
@queue.first @queue.first

View File

@ -121,7 +121,7 @@ module Net # :nodoc:
# #
# def fetch( uri_str, limit = 10 ) # def fetch( uri_str, limit = 10 )
# # You should choose better exception. # # You should choose better exception.
# raise ArgumentError, 'http redirect too deep' if limit == 0 # raise ArgumentError, 'HTTP redirect too deep' if limit == 0
# #
# response = Net::HTTP.get_response(URI.parse(uri_str)) # response = Net::HTTP.get_response(URI.parse(uri_str))
# case response # case response
@ -480,7 +480,7 @@ module Net # :nodoc:
# Finishes HTTP session and closes TCP connection. # Finishes HTTP session and closes TCP connection.
# Raises IOError if not started. # Raises IOError if not started.
def finish def finish
raise IOError, 'HTTP session not started yet' unless started? raise IOError, 'HTTP session not yet started' unless started?
do_finish do_finish
end end
@ -2058,11 +2058,11 @@ e @header.each_key(&block)
end end
def stream_check def stream_check
raise IOError, 'try to read body out of block' if @socket.closed? raise IOError, 'attempt to read body out of block' if @socket.closed?
end end
def procdest(dest, block) def procdest(dest, block)
raise ArgumentError, 'both of arg and block are given for HTTP method' \ raise ArgumentError, 'both arg and block given for HTTP method' \
if dest and block if dest and block
if block if block
ReadAdapter.new(block) ReadAdapter.new(block)

View File

@ -123,7 +123,7 @@ module Net
# a Net::HTTP object raises IOError. # a Net::HTTP object raises IOError.
def use_ssl=(flag) def use_ssl=(flag)
flag = (flag ? true : false) flag = (flag ? true : false)
raise IOError, "use_ssl value changed but session already started" \ raise IOError, "use_ssl value changed, but session already started" \
if started? and @use_ssl != flag if started? and @use_ssl != flag
if flag and not @ssl_context if flag and not @ssl_context
@ssl_context = OpenSSL::SSL::SSLContext.new @ssl_context = OpenSSL::SSL::SSLContext.new

View File

@ -859,7 +859,7 @@ module Net # :nodoc:
# firewall. # firewall.
# Errno::ETIMEDOUT:: connection timed out (possibly due to packets # Errno::ETIMEDOUT:: connection timed out (possibly due to packets
# being dropped by an intervening firewall). # being dropped by an intervening firewall).
# Errno::NETUNREACH:: there is no route to that network. # Errno::ENETUNREACH:: there is no route to that network.
# SocketError:: hostname not known or other socket error. # SocketError:: hostname not known or other socket error.
# Net::IMAP::ByeResponseError:: we connected to the host, but they # Net::IMAP::ByeResponseError:: we connected to the host, but they
# immediately said goodbye to us. # immediately said goodbye to us.

View File

@ -293,7 +293,7 @@ module Net
# This method must not be called while POP3 session is opened. # This method must not be called while POP3 session is opened.
# This method raises POPAuthenticationError if authentication fails. # This method raises POPAuthenticationError if authentication fails.
def auth_only(account, password) def auth_only(account, password)
raise IOError, 'opening already opened POP session' if started? raise IOError, 'opening previously opened POP session' if started?
start(account, password) { start(account, password) {
; ;
} }
@ -449,7 +449,7 @@ module Net
# Finishes a POP3 session and closes TCP connection. # Finishes a POP3 session and closes TCP connection.
def finish def finish
raise IOError, 'POP session not started yet' unless started? raise IOError, 'POP session not yet started' unless started?
do_finish do_finish
end end

View File

@ -373,7 +373,7 @@ module Net # :nodoc:
# Finishes the SMTP session and closes TCP connection. # Finishes the SMTP session and closes TCP connection.
# Raises IOError if not started. # Raises IOError if not started.
def finish def finish
raise IOError, 'not started yet' unless started? raise IOError, 'not yet started' unless started?
do_finish do_finish
end end
@ -474,7 +474,7 @@ module Net # :nodoc:
def send0( from_addr, to_addrs ) def send0( from_addr, to_addrs )
raise IOError, 'closed session' unless @socket raise IOError, 'closed session' unless @socket
raise ArgumentError, 'mail destination does not given' if to_addrs.empty? raise ArgumentError, 'mail destination not given' if to_addrs.empty?
if $SAFE > 0 if $SAFE > 0
raise SecurityError, 'tainted from_addr' if from_addr.tainted? raise SecurityError, 'tainted from_addr' if from_addr.tainted?
to_addrs.each do |to| to_addrs.each do |to|
@ -501,7 +501,7 @@ module Net # :nodoc:
private private
def check_auth_args( user, secret, authtype ) def check_auth_args( user, secret, authtype )
raise ArgumentError, 'both of user and secret are required'\ raise ArgumentError, 'both user and secret are required'\
unless user and secret unless user and secret
auth_method = "auth_#{authtype || 'cram_md5'}" auth_method = "auth_#{authtype || 'cram_md5'}"
raise ArgumentError, "wrong auth type #{authtype}"\ raise ArgumentError, "wrong auth type #{authtype}"\

View File

@ -501,7 +501,7 @@ module URI
if proxy_uri if proxy_uri
proxy_uri = URI.parse(proxy_uri) proxy_uri = URI.parse(proxy_uri)
unless URI::HTTP === proxy_uri unless URI::HTTP === proxy_uri
raise "Non-http proxy URI: #{proxy_uri}" raise "Non-HTTP proxy URI: #{proxy_uri}"
end end
name = 'no_proxy' name = 'no_proxy'
if no_proxy = ENV[name] || ENV[name.upcase] if no_proxy = ENV[name] || ENV[name.upcase]

View File

@ -63,7 +63,7 @@ class OpenStruct
len = args.length len = args.length
if mname =~ /=$/ if mname =~ /=$/
if len != 1 if len != 1
raise ArgumentError, "wrong # of arguments (#{len} for 1)", caller(1) raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
end end
if self.frozen? if self.frozen?
raise TypeError, "can't modify frozen #{self.class}", caller(1) raise TypeError, "can't modify frozen #{self.class}", caller(1)

View File

@ -48,7 +48,7 @@ class Rational < Numeric
@RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-' @RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-'
def Rational.reduce(num, den = 1) def Rational.reduce(num, den = 1)
raise ZeroDivisionError, "denominator is 0" if den == 0 raise ZeroDivisionError, "denominator is zero" if den == 0
if den < 0 if den < 0
num = -num num = -num
@ -135,7 +135,7 @@ class Rational < Numeric
den = @denominator * a.numerator den = @denominator * a.numerator
Rational(num, den) Rational(num, den)
elsif a.kind_of?(Integer) elsif a.kind_of?(Integer)
raise ZeroDivisionError, "divided by 0" if a == 0 raise ZeroDivisionError, "division by zero" if a == 0
self / Rational.new!(a, 1) self / Rational.new!(a, 1)
elsif a.kind_of?(Float) elsif a.kind_of?(Float)
Float(self) / a Float(self) / a

View File

@ -1157,9 +1157,9 @@ class Resolv
@limit = @index + len @limit = @index + len
d = yield(len) d = yield(len)
if @index < @limit if @index < @limit
raise DecodeError.new("junk exist") raise DecodeError.new("junk exists")
elsif @limit < @index elsif @limit < @index
raise DecodeError.new("limit exceed") raise DecodeError.new("limit exceeded")
end end
@limit = save_limit @limit = save_limit
return d return d
@ -1185,7 +1185,7 @@ class Resolv
raise StandardError.new("unsupported template: '#{byte.chr}' in '#{template}'") raise StandardError.new("unsupported template: '#{byte.chr}' in '#{template}'")
end end
} }
raise DecodeError.new("limit exceed") if @limit < @index + len raise DecodeError.new("limit exceeded") if @limit < @index + len
arr = @data.unpack("@#{@index}#{template}") arr = @data.unpack("@#{@index}#{template}")
@index += len @index += len
return arr return arr
@ -1193,7 +1193,7 @@ class Resolv
def get_string def get_string
len = @data[@index] len = @data[@index]
raise DecodeError.new("limit exceed") if @limit < @index + 1 + len raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len
d = @data[@index + 1, len] d = @data[@index + 1, len]
@index += 1 + len @index += 1 + len
return d return d
@ -1554,7 +1554,7 @@ class Resolv
raise ArgumentError.new("IPv4 address with invalid value: " + arg) raise ArgumentError.new("IPv4 address with invalid value: " + arg)
end end
else else
raise ArgumentError.new("cannot interprete as IPv4 address: #{arg.inspect}") raise ArgumentError.new("cannot interpret as IPv4 address: #{arg.inspect}")
end end
end end
@ -1662,7 +1662,7 @@ class Resolv
end end
return IPv6.new(address) return IPv6.new(address)
else else
raise ArgumentError.new("cannot interprete as IPv6 address: #{arg.inspect}") raise ArgumentError.new("cannot interpret as IPv6 address: #{arg.inspect}")
end end
end end

View File

@ -13,7 +13,7 @@
# a == b # => true # a == b # => true
# a.new # NoMethodError - new is private ... # a.new # NoMethodError - new is private ...
# #
# * ``The instance'' is created at instanciation time, in other # * ``The instance'' is created at instantiation time, in other
# words the first call of Klass.instance(), thus # words the first call of Klass.instance(), thus
# #
# class OtherKlass # class OtherKlass
@ -44,11 +44,11 @@
# #
# * Klass._load(str) - calling Klass.instance() # * Klass._load(str) - calling Klass.instance()
# #
# * Klass._instanciate?() - returning ``the instance'' or # * Klass._instantiate?() - returning ``the instance'' or
# nil. This hook method puts a second (or nth) thread calling # nil. This hook method puts a second (or nth) thread calling
# Klass.instance() on a waiting loop. The return value # Klass.instance() on a waiting loop. The return value
# signifies the successful completion or premature termination # signifies the successful completion or premature termination
# of the first, or more generally, current "instanciation thread". # of the first, or more generally, current "instantiation thread".
# #
# #
# The instance method of Singleton are # The instance method of Singleton are
@ -103,7 +103,7 @@ class << Singleton
@__instance__ = nil # failed instance creation @__instance__ = nil # failed instance creation
end end
end end
elsif _instanciate?() elsif _instantiate?()
Thread.critical = false Thread.critical = false
else else
@__instance__ = false @__instance__ = false
@ -144,7 +144,7 @@ class << Singleton
end end
# waiting-loop hook # waiting-loop hook
def _instanciate?() def _instantiate?()
while false.equal?(@__instance__) while false.equal?(@__instance__)
Thread.critical = false Thread.critical = false
sleep(0.08) # timeout sleep(0.08) # timeout
@ -209,7 +209,7 @@ end
puts "\nThreaded example with exception and customized #_instanciate?() hook"; p puts "\nThreaded example with exception and customized #_instantiate?() hook"; p
Thread.abort_on_exception = false Thread.abort_on_exception = false
class Ups < SomeSingletonClass class Ups < SomeSingletonClass
@ -220,7 +220,7 @@ class Ups < SomeSingletonClass
end end
class << Ups class << Ups
def _instanciate? def _instantiate?
@enter.push Thread.current[:i] @enter.push Thread.current[:i]
while false.equal?(@__instance__) while false.equal?(@__instance__)
Thread.critical = false Thread.critical = false
@ -247,7 +247,7 @@ class << Ups
end end
end end
def instanciate_all def instantiate_all
@enter = [] @enter = []
@leave = [] @leave = []
1.upto(9) {|i| 1.upto(9) {|i|
@ -270,7 +270,7 @@ class << Ups
end end
Ups.instanciate_all Ups.instantiate_all
# results in message like # results in message like
# Before there were 0 Ups instance(s) # Before there were 0 Ups instance(s)
# boom - thread #6 failed to create instance # boom - thread #6 failed to create instance
@ -293,7 +293,7 @@ def Yup.new
end end
end end
end end
Yup.instanciate_all Yup.instantiate_all
puts "\n\n","Customized marshalling" puts "\n\n","Customized marshalling"

View File

@ -9,7 +9,7 @@ require 'tmpdir'
# A class for managing temporary files. This library is written to be # A class for managing temporary files. This library is written to be
# thread safe. # thread safe.
class Tempfile < SimpleDelegator class Tempfile < DelegateClass(File)
MAX_TRY = 10 MAX_TRY = 10
@@cleanlist = [] @@cleanlist = []

View File

@ -119,7 +119,7 @@ private
return parts.dup return parts.dup
end end
if parts.length != result.length if parts.length != result.length
raise RuntimeError.new("Incomplete prarmeterOrder list.") raise RuntimeError.new("Incomplete parameter order list.")
end end
result result
end end

View File

@ -467,7 +467,7 @@ module XMLRPC
else else
# is a normal return value # is a normal return value
raise "Missing return value!" if parser.params.size == 0 raise "Missing return value!" if parser.params.size == 0
raise "To many return values. Only one allowed!" if parser.params.size > 1 raise "Too many return values. Only one allowed!" if parser.params.size > 1
[true, parser.params[0]] [true, parser.params[0]]
end end
end end

4
re.c
View File

@ -1256,7 +1256,7 @@ match_select(argc, argv, match)
VALUE match; VALUE match;
{ {
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
else { else {
struct re_registers *regs = RMATCH(match)->regs; struct re_registers *regs = RMATCH(match)->regs;
@ -1657,7 +1657,7 @@ rb_reg_initialize_m(argc, argv, self)
rb_check_frozen(self); rb_check_frozen(self);
if (argc == 0 || argc > 3) { if (argc == 0 || argc > 3) {
rb_raise(rb_eArgError, "wrong number of argument"); rb_raise(rb_eArgError, "wrong number of arguments");
} }
if (TYPE(argv[0]) == T_REGEXP) { if (TYPE(argv[0]) == T_REGEXP) {
if (argc > 1) { if (argc > 1) {

View File

@ -108,7 +108,7 @@ sign_bits(base, p)
(posarg = -1, GETNTHARG(n)))) (posarg = -1, GETNTHARG(n))))
#define GETNTHARG(nth) \ #define GETNTHARG(nth) \
((nth >= argc) ? (rb_raise(rb_eArgError, "too few argument."), 0) : argv[nth]) ((nth >= argc) ? (rb_raise(rb_eArgError, "too few arguments."), 0) : argv[nth])
#define GETASTER(val) do { \ #define GETASTER(val) do { \
t = p++; \ t = p++; \
@ -716,7 +716,7 @@ rb_f_sprintf(argc, argv)
* the format string may contain `n$'-style argument selector. * the format string may contain `n$'-style argument selector.
*/ */
if (RTEST(ruby_verbose) && nextarg < argc) { if (RTEST(ruby_verbose) && nextarg < argc) {
rb_raise(rb_eArgError, "too many argument for format string"); rb_raise(rb_eArgError, "too many arguments for format string");
} }
#endif #endif
rb_str_resize(result, blen); rb_str_resize(result, blen);

View File

@ -1566,7 +1566,7 @@ rb_str_aref_m(argc, argv, str)
return rb_str_substr(str, NUM2LONG(argv[0]), NUM2LONG(argv[1])); return rb_str_substr(str, NUM2LONG(argv[0]), NUM2LONG(argv[1]));
} }
if (argc != 1) { if (argc != 1) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
} }
return rb_str_aref(str, argv[0]); return rb_str_aref(str, argv[0]);
} }
@ -1760,7 +1760,7 @@ rb_str_aset_m(argc, argv, str)
return argv[2]; return argv[2];
} }
if (argc != 2) { if (argc != 2) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
} }
return rb_str_aset(str, argv[0], argv[1]); return rb_str_aset(str, argv[0], argv[1]);
} }
@ -1833,7 +1833,7 @@ rb_str_slice_bang(argc, argv, str)
int i; int i;
if (argc < 1 || 2 < argc) { if (argc < 1 || 2 < argc) {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 1)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
} }
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
buf[i] = argv[i]; buf[i] = argv[i];
@ -1907,7 +1907,7 @@ rb_str_sub_bang(argc, argv, str)
if (OBJ_TAINTED(repl)) tainted = 1; if (OBJ_TAINTED(repl)) tainted = 1;
} }
else { else {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
} }
pat = get_pat(argv[0], 1); pat = get_pat(argv[0], 1);
@ -2011,7 +2011,7 @@ str_gsub(argc, argv, str, bang)
if (OBJ_TAINTED(repl)) tainted = 1; if (OBJ_TAINTED(repl)) tainted = 1;
} }
else { else {
rb_raise(rb_eArgError, "wrong number of arguments(%d for 2)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
} }
pat = get_pat(argv[0], 1); pat = get_pat(argv[0], 1);

View File

@ -734,7 +734,7 @@ rb_struct_select(argc, argv, s)
long i; long i;
if (argc > 0) { if (argc > 0) {
rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
result = rb_ary_new(); result = rb_ary_new();
for (i = 0; i < RSTRUCT(s)->len; i++) { for (i = 0; i < RSTRUCT(s)->len; i++) {

2
time.c
View File

@ -1816,7 +1816,7 @@ time_mdump(time)
tm = gmtime(&t); tm = gmtime(&t);
if ((tm->tm_year & 0x1ffff) != tm->tm_year) if ((tm->tm_year & 0x1ffff) != tm->tm_year)
rb_raise(rb_eArgError, "too big year to marshal"); rb_raise(rb_eArgError, "year too big to marshal");
p = 0x1 << 31 | /* 1 */ p = 0x1 << 31 | /* 1 */
tm->tm_year << 14 | /* 17 */ tm->tm_year << 14 | /* 17 */