Use StringValue() instead of Check_Type(blah, T_STRING).
authorTilman Sauerbeck <tilman@code-monkey.de>
Mon, 11 Apr 2005 20:58:23 +0000 (20:58 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Mon, 11 Apr 2005 20:58:23 +0000 (20:58 +0000)
ChangeLog
ext/ext.c

index f9d6069a66a244de440245d8259d42cc12f24e11..4bcd38873b8b6e3cd780786d78c9de0709989b4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,11 @@
 --
-$Id: ChangeLog 26 2005-04-09 17:50:00Z tilman $
+$Id: ChangeLog 28 2005-04-11 20:58:23Z tilman $
 ++
 
+2005-04-11 Tilman Sauerbeck (tilman at code-monkey de)
+        * ext/ext.c: Use StringValue() instead of
+          Check_Type(blah, T_STRING)
+
 2005-04-09 Tilman Sauerbeck (tilman at code-monkey de)
         * Released version 0.1.2
 
index 236df7c0450359299852bdd27fa93ebdc6685221..94df85d4e8ff2d601c580ca91531228201331326 100644 (file)
--- a/ext/ext.c
+++ b/ext/ext.c
@@ -1,5 +1,5 @@
 /*
- * $Id: ext.c 13 2005-03-27 18:35:51Z tilman $
+ * $Id: ext.c 28 2005-04-11 20:58:23Z tilman $
  *
  * Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
  *
 #include <ruby.h>
 
 #define CHECK_KEY(key) \
-       Check_Type ((key), T_STRING); \
-       if (rb_funcall ((key), rb_intern ("include?"), \
-                           1, INT2FIX (0)) == Qtrue) \
+       StringValue((key)); \
+\
+       if (rb_funcall (key, rb_intern ("include?"), \
+                       1, INT2FIX (0)) == Qtrue) \
                rb_raise (rb_eArgError, "key must not contain binary zeroes");
 
 static VALUE c_close (VALUE self);
@@ -100,10 +101,10 @@ c_init (int argc, VALUE *argv, VALUE self)
 
        rb_scan_args (argc, argv, "11", &file, &mode);
 
-       Check_Type (file, T_STRING);
+       StringValue (file);
 
        if (!NIL_P (mode)) {
-               Check_Type (mode, T_STRING);
+               StringValue (mode);
 
                tmp = StringValuePtr (mode);
                if (!strcmp (tmp, "r+"))
@@ -194,10 +195,8 @@ c_list (int argc, VALUE *argv, VALUE self)
 
        rb_scan_args (argc, argv, "01", &glob);
 
-       if (!NIL_P (glob)) {
-               Check_Type (glob, T_STRING);
+       if (!NIL_P (glob))
                tmp = StringValuePtr (glob);
-       }
 
        ret = rb_ary_new ();
 
@@ -302,7 +301,7 @@ c_write (int argc, VALUE *argv, VALUE self)
                comp = Qtrue;
 
        CHECK_KEY (key);
-       Check_Type (buf, T_STRING);
+       StringValue (buf);
 
        n = eet_write (*ef, StringValuePtr (key),
                       StringValuePtr (buf), RSTRING (buf)->len,
@@ -395,7 +394,7 @@ c_write_image (int argc, VALUE *argv, VALUE self)
                has_alpha = Qfalse;
 
        CHECK_KEY (key);
-       Check_Type (buf, T_STRING);
+       StringValue (buf);
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);