Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed whitespace

  • Loading branch information...
commit 98ceec20dfbf0e93a1241fc4b12c1d0c9e0c1bcc 1 parent c88de08
@skaes authored
Showing with 65 additions and 65 deletions.
  1. +65 −65 ext/uuid4r.c
View
130 ext/uuid4r.c
@@ -1,13 +1,13 @@
-/*
+/*
* COPYRIGHT AND LICENSE
- *
+ *
* Copyright (C) 2006 Daigo Moriwaki <daigo@debian.org>
- *
+ *
* Permission to use, copy, modify, and distribute this software for
* any purpose with or without fee is hereby granted, provided that
* the above copyright notice and this permission notice appear in all
* copies.
- *
+ *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -22,7 +22,7 @@
* SUCH DAMAGE.
*
*/
-
+
#include "ruby.h"
#include "uuid.h"
@@ -41,7 +41,7 @@ rb2uuid_fmt(symbol)
{
ID fmt;
uuid_fmt_t result;
-
+
fmt = rb_to_id(symbol);
if (fmt == id_fmt_bin)
result = UUID_FMT_BIN;
@@ -67,7 +67,7 @@ export(uuid, fmt)
str = NULL;
ptr = NULL;
-
+
/* dispatch into format-specific functions */
switch (fmt) {
case UUID_FMT_BIN:
@@ -75,7 +75,7 @@ export(uuid, fmt)
result = rb_str_new(ptr, UUID_LEN_BIN);
free(ptr);
break;
- case UUID_FMT_STR:
+ case UUID_FMT_STR:
rc = uuid_export(uuid, fmt, (void **)&str, NULL);
result = rb_str_new2(str);
free(str);
@@ -88,7 +88,7 @@ export(uuid, fmt)
default:
rb_raise(rb_eArgError, "wrong argument");
}
-
+
return result;
}
@@ -101,7 +101,7 @@ uuid4r_free(uuid)
{
uuid_destroy(uuid);
}
-
+
static VALUE
uuid4r_alloc(klass)
VALUE klass;
@@ -124,7 +124,7 @@ uuid4r_compare(lhs, rhs)
const uuid_t *uuid_lhs;
const uuid_t *uuid_rhs;
int value;
-
+
Data_Get_Struct(lhs, uuid_t, uuid_lhs);
Data_Get_Struct(rhs, uuid_t, uuid_rhs);
uuid_compare(uuid_lhs, uuid_rhs, &value);
@@ -141,15 +141,15 @@ uuid4r_export(argc, argv, self)
VALUE format;
uuid_fmt_t fmt;
uuid_t *uuid;
-
+
if ( rb_scan_args(argc, argv, "01", &format) == 1)
fmt = rb2uuid_fmt(format);
else
fmt = UUID_FMT_STR;
Data_Get_Struct(self, uuid_t, uuid);
-
- return export(uuid, fmt);
+
+ return export(uuid, fmt);
}
VALUE
@@ -158,12 +158,12 @@ uuid4r_import(self, format, str)
{
uuid_fmt_t fmt;
uuid_t *uuid;
-
+
uuid_create(&uuid);
fmt = rb2uuid_fmt(format);
StringValue(str);
uuid_import(uuid, fmt, RSTRING_PTR(str), RSTRING_LEN(str));
-
+
return Data_Wrap_Struct(rb_cUUID4RCommon, 0, uuid4r_free, uuid);
}
@@ -174,10 +174,10 @@ uuid4rv1_initialize(self)
VALUE self;
{
uuid_t *uuid;
-
+
Data_Get_Struct(self, uuid_t, uuid);
- uuid_make(uuid, UUID_MAKE_V1);
-
+ uuid_make(uuid, UUID_MAKE_V1);
+
return self;
}
@@ -192,16 +192,16 @@ uuid4rv3_initialize(self, namespace, namespace_str)
uuid_t *uuid;
uuid_t *uuid_ns;
char *uuid_ns_str;
-
+
uuid_ns = NULL;
uuid_ns_str = NULL;
uuid_create(&uuid_ns);
- uuid_load(uuid_ns, StringValueCStr(namespace));
+ uuid_load(uuid_ns, StringValueCStr(namespace));
uuid_ns_str = StringValueCStr(namespace_str);
-
+
Data_Get_Struct(self, uuid_t, uuid);
- uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
-
+ uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
+
return self;
}
@@ -212,10 +212,10 @@ uuid4rv4_initialize(self)
VALUE self;
{
uuid_t *uuid;
-
+
Data_Get_Struct(self, uuid_t, uuid);
- uuid_make(uuid, UUID_MAKE_V4);
-
+ uuid_make(uuid, UUID_MAKE_V4);
+
return self;
}
@@ -230,16 +230,16 @@ uuid4rv5_initialize(self, namespace, namespace_str)
uuid_t *uuid;
uuid_t *uuid_ns;
char *uuid_ns_str;
-
+
uuid_ns = NULL;
uuid_ns_str = NULL;
uuid_create(&uuid_ns);
- uuid_load(uuid_ns, StringValueCStr(namespace));
+ uuid_load(uuid_ns, StringValueCStr(namespace));
uuid_ns_str = StringValueCStr(namespace_str);
-
+
Data_Get_Struct(self, uuid_t, uuid);
- uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
-
+ uuid_make(uuid, UUID_MAKE_V5, uuid_ns, uuid_ns_str);
+
return self;
}
@@ -251,9 +251,9 @@ uuid4rv5_initialize(self, namespace, namespace_str)
* UUID4R::uuid(3, namespace, namespace_str, format = :str) => uuid
* UUID4R::uuid(4, format = :str) => uuid
* UUID4R::uuid(5, namespace, namespace_str, format = :str) => uuid
- *
+ *
* Generates a DCE 1.1 with a specified version: 1, 3, 4 or 5.
- * Returns an uuid as a specified format (:str, :bin, :txt).
+ * Returns an uuid as a specified format (:str, :bin, :txt).
*/
VALUE
uuid4r_uuid(argc, argv, self)
@@ -274,42 +274,42 @@ uuid4r_uuid(argc, argv, self)
uuid_ns = NULL;
uuid_ns_str = NULL;
-
+
switch (argc) {
case 1:
rb_scan_args(argc, argv, "11", &version, &format);
fmt = UUID_FMT_STR;
break;
case 2:
- rb_scan_args(argc, argv, "11", &version, &format);
- fmt = rb2uuid_fmt(format);
+ rb_scan_args(argc, argv, "11", &version, &format);
+ fmt = rb2uuid_fmt(format);
break;
case 3:
rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
fmt = UUID_FMT_STR;
break;
case 4:
- rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
- fmt = rb2uuid_fmt(format);
+ rb_scan_args(argc, argv, "31", &version, &namespace, &namespace_str, &format);
+ fmt = rb2uuid_fmt(format);
break;
default:
rb_raise(rb_eArgError, "wrong argument");
break;
}
-
+
switch (NUM2INT(version)) {
case 1: mode = UUID_MAKE_V1; break;
case 4: mode = UUID_MAKE_V4; break;
case 3:
mode = UUID_MAKE_V3;
uuid_create(&uuid_ns);
- uuid_load(uuid_ns, StringValueCStr(namespace));
+ uuid_load(uuid_ns, StringValueCStr(namespace));
uuid_ns_str = StringValueCStr(namespace_str);
break;
- case 5:
+ case 5:
mode = UUID_MAKE_V5;
uuid_create(&uuid_ns);
- uuid_load(uuid_ns, StringValueCStr(namespace));
+ uuid_load(uuid_ns, StringValueCStr(namespace));
uuid_ns_str = StringValueCStr(namespace_str);
break;
}
@@ -326,9 +326,9 @@ uuid4r_uuid(argc, argv, self)
/**
* call-seq:
* UUID4R::uuid_v1(format = :str) => uuid
- *
+ *
* Generates a DCE 1.1 v1 UUID from system environment.
- * Returns an uuid as a specified format (:str, :bin, :txt).
+ * Returns an uuid as a specified format (:str, :bin, :txt).
*/
VALUE
uuid4r_uuid_v1(argc, argv, self)
@@ -337,19 +337,19 @@ uuid4r_uuid_v1(argc, argv, self)
VALUE self;
{
VALUE rest;
-
+
if ( rb_scan_args(argc, argv, "01", &rest) == 1)
return rb_funcall(self, rb_intern("uuid"), 2, INT2NUM(1), rest);
else
- return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(1));
+ return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(1));
}
/**
* call-seq:
* UUID4R::uuid_v4(format = :str) => uuid
- *
+ *
* Generates a DCE 1.1 v4 UUID based a random number.
- * Returns an uuid as a specified format (:str, :bin, :txt).
+ * Returns an uuid as a specified format (:str, :bin, :txt).
*/
VALUE
uuid4r_uuid_v4(argc, argv, self)
@@ -358,19 +358,19 @@ uuid4r_uuid_v4(argc, argv, self)
VALUE self;
{
VALUE rest;
-
+
if ( rb_scan_args(argc, argv, "01", &rest) == 1)
return rb_funcall(self, rb_intern("uuid"), 2, INT2NUM(4), rest);
else
- return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(4));
+ return rb_funcall(self, rb_intern("uuid"), 1, INT2NUM(4));
}
/**
* call-seq:
* UUID4R::uuid_v3(namespace, namespace_str, format = :str) => uuid
- *
+ *
* Generates a DCE 1.1 v3 UUID with a name based with MD5.
- * Returns an uuid as a specified format (:str, :bin, :txt).
+ * Returns an uuid as a specified format (:str, :bin, :txt).
*/
VALUE
uuid4r_uuid_v3(argc, argv, self)
@@ -380,21 +380,21 @@ uuid4r_uuid_v3(argc, argv, self)
{
VALUE namespace, namespace_str;
VALUE rest;
-
+
if ( rb_scan_args(argc, argv, "21", &namespace, &namespace_str, &rest) == 3)
- return rb_funcall(self, rb_intern("uuid"), 4,
+ return rb_funcall(self, rb_intern("uuid"), 4,
INT2NUM(3), namespace, namespace_str, rest);
else
- return rb_funcall(self, rb_intern("uuid"), 3,
- INT2NUM(3), namespace, namespace_str);
+ return rb_funcall(self, rb_intern("uuid"), 3,
+ INT2NUM(3), namespace, namespace_str);
}
/**
* call-seq:
* UUID4R::uuid_v5(namespace, namespace_str, format = :str) => uuid
- *
+ *
* Generates a DCE 1.1 v5 UUID with a name based with SHA-1.
- * Returns an uuid as a specified format (:str, :bin, :txt).
+ * Returns an uuid as a specified format (:str, :bin, :txt).
*/
VALUE
uuid4r_uuid_v5(argc, argv, self)
@@ -404,13 +404,13 @@ uuid4r_uuid_v5(argc, argv, self)
{
VALUE namespace, namespace_str;
VALUE rest;
-
+
if ( rb_scan_args(argc, argv, "21", &namespace, &namespace_str, &rest) == 3)
- return rb_funcall(self, rb_intern("uuid"), 4,
+ return rb_funcall(self, rb_intern("uuid"), 4,
INT2NUM(5), namespace, namespace_str, rest);
else
- return rb_funcall(self, rb_intern("uuid"), 3,
- INT2NUM(5), namespace, namespace_str);
+ return rb_funcall(self, rb_intern("uuid"), 3,
+ INT2NUM(5), namespace, namespace_str);
}
@@ -429,14 +429,14 @@ void Init_uuid4r (void) {
rb_define_module_function(rb_cUUID4R, "uuid_v4", uuid4r_uuid_v4, -1);
rb_define_module_function(rb_cUUID4R, "uuid_v5", uuid4r_uuid_v5, -1);
rb_define_module_function(rb_cUUID4R, "import", uuid4r_import, 2);
-
+
/* ------ UUID4RCommon ------ */
rb_cUUID4RCommon = rb_define_class_under(rb_cUUID4R, "UUID4RCommon", rb_cObject);
rb_define_alloc_func(rb_cUUID4RCommon, uuid4r_alloc);
rb_define_method(rb_cUUID4RCommon, "export", uuid4r_export, -1);
rb_define_method(rb_cUUID4RCommon, "compare", uuid4r_compare, 1);
rb_define_alias(rb_cUUID4RCommon, "<=>", "compare");
-
+
/* ------ UUID4Rv1 ------ */
rb_cUUID4Rv1 = rb_define_class_under(rb_cUUID4R, "UUID4Rv1", rb_cUUID4RCommon);
rb_define_alloc_func(rb_cUUID4Rv1, uuid4r_alloc);
Please sign in to comment.
Something went wrong with that request. Please try again.