Skip to content

Commit

Permalink
hash.c: refine error messages
Browse files Browse the repository at this point in the history
* hash.c (rb_hash_s_create): refine error messages.
* error.c (rb_builtin_class_name): share for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Nov 11, 2012
1 parent 10ba3bd commit 5a5a86c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
Sun Nov 11 15:38:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>

* hash.c (rb_hash_s_create): refine error messages.

* error.c (rb_builtin_class_name): share for above.

Sun Nov 11 15:12:18 2012 Shugo Maeda <shugo@ruby-lang.org>

* eval.c (top_using): remove Kernel#using, and add main.using instead.
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Expand Up @@ -662,7 +662,7 @@ gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
{$(VPATH)}thread.h
hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
$(ENCODING_H_INCLUDES)
$(ENCODING_H_INCLUDES) {$(VPATH)}internal.h
inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES) \
{$(VPATH)}internal.h
io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
Expand Down
5 changes: 3 additions & 2 deletions error.c
Expand Up @@ -432,8 +432,9 @@ rb_builtin_type_name(int t)
return 0;
}

static const char *
builtin_class_name(VALUE x)
#define builtin_class_name rb_builtin_class_name
const char *
rb_builtin_class_name(VALUE x)
{
const char *etype;

Expand Down
8 changes: 6 additions & 2 deletions hash.c
Expand Up @@ -15,6 +15,7 @@
#include "ruby/st.h"
#include "ruby/util.h"
#include "ruby/encoding.h"
#include "internal.h"
#include <errno.h>

#ifdef __APPLE__
Expand Down Expand Up @@ -392,11 +393,14 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)

hash = hash_alloc(klass);
for (i = 0; i < RARRAY_LEN(tmp); ++i) {
VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]);
VALUE e = RARRAY_PTR(tmp)[i];
VALUE v = rb_check_array_type(e);
VALUE key, val = Qnil;

if (NIL_P(v)) {
rb_raise(rb_eArgError, "wrong element type (expected array)");
rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)",
rb_builtin_class_name(e), i);

}
switch (RARRAY_LEN(v)) {
default:
Expand Down
1 change: 1 addition & 0 deletions internal.h
Expand Up @@ -95,6 +95,7 @@ NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3,
VALUE rb_check_backtrace(VALUE);
NORETURN(void rb_async_bug_errno(const char *,int));
const char *rb_builtin_type_name(int t);
const char *rb_builtin_class_name(VALUE x);

/* eval_error.c */
void ruby_error_print(void);
Expand Down

0 comments on commit 5a5a86c

Please sign in to comment.