Changeset: 69433fa7fefe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=69433fa7fefe
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures_nocfitsio.stable.out
clients/Tests/MAL-signatures_nogeom.stable.out
clients/Tests/MAL-signatures_sphinxclient.stable.out
clients/Tests/exports.stable.out
monetdb5/modules/atoms/uuid.c
monetdb5/modules/atoms/uuid.h
monetdb5/modules/atoms/uuid.mal
Branch: Jan2014
Log Message:
Implemented uuid.fromstr.
This fixes bug 3407.
diffs (183 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -43183,6 +43183,10 @@ command url.url(s:str):url
address URLnew;
comment Create an URL from a string literal
+command uuid.#fromstr():uuid
+address UUIDfromString;
+comment Convert string to uuid
+
command uuid.isaUUID(u:uuid):bit
address UUIDisaUUID;
comment Test a string for a UUID format
@@ -43195,7 +43199,7 @@ command uuid.str(u:uuid):str
address UUIDuuid2str;
comment Coerce a uuid to its string type
-command uuid.#tostr():void
+command uuid.#tostr():str
address UUIDtoString;
comment Convert uuid to string equivalent
diff --git a/clients/Tests/MAL-signatures_nocfitsio.stable.out
b/clients/Tests/MAL-signatures_nocfitsio.stable.out
--- a/clients/Tests/MAL-signatures_nocfitsio.stable.out
+++ b/clients/Tests/MAL-signatures_nocfitsio.stable.out
@@ -43159,6 +43159,10 @@ command url.url(s:str):url
address URLnew;
comment Create an URL from a string literal
+command uuid.#fromstr():uuid
+address UUIDfromString;
+comment Convert string to uuid
+
command uuid.isaUUID(u:uuid):bit
address UUIDisaUUID;
comment Test a string for a UUID format
@@ -43171,7 +43175,7 @@ command uuid.str(u:uuid):str
address UUIDuuid2str;
comment Coerce a uuid to its string type
-command uuid.#tostr():void
+command uuid.#tostr():str
address UUIDtoString;
comment Convert uuid to string equivalent
diff --git a/clients/Tests/MAL-signatures_nogeom.stable.out
b/clients/Tests/MAL-signatures_nogeom.stable.out
--- a/clients/Tests/MAL-signatures_nogeom.stable.out
+++ b/clients/Tests/MAL-signatures_nogeom.stable.out
@@ -42997,6 +42997,10 @@ command url.url(s:str):url
address URLnew;
comment Create an URL from a string literal
+command uuid.#fromstr():uuid
+address UUIDfromString;
+comment Convert string to uuid
+
command uuid.isaUUID(u:uuid):bit
address UUIDisaUUID;
comment Test a string for a UUID format
@@ -43009,7 +43013,7 @@ command uuid.str(u:uuid):str
address UUIDuuid2str;
comment Coerce a uuid to its string type
-command uuid.#tostr():void
+command uuid.#tostr():str
address UUIDtoString;
comment Convert uuid to string equivalent
diff --git a/clients/Tests/MAL-signatures_sphinxclient.stable.out
b/clients/Tests/MAL-signatures_sphinxclient.stable.out
--- a/clients/Tests/MAL-signatures_sphinxclient.stable.out
+++ b/clients/Tests/MAL-signatures_sphinxclient.stable.out
@@ -43192,6 +43192,10 @@ command url.url(s:str):url
address URLnew;
comment Create an URL from a string literal
+command uuid.#fromstr():uuid
+address UUIDfromString;
+comment Convert string to uuid
+
command uuid.isaUUID(u:uuid):bit
address UUIDisaUUID;
comment Test a string for a UUID format
@@ -43204,7 +43208,7 @@ command uuid.str(u:uuid):str
address UUIDuuid2str;
comment Coerce a uuid to its string type
-command uuid.#tostr():void
+command uuid.#tostr():str
address UUIDtoString;
comment Convert uuid to string equivalent
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2323,6 +2323,7 @@ str URLnew4(str *url, str *protocol, str
str URLnoop(str *url, str *val);
int URLtoString(str *s, int *len, str src);
str UUIDequal(bit *retval, str *l, str *r);
+int UUIDfromString(char *svalue, int *len, str *retval);
str UUIDgenerateUuid(str *retval);
str UUIDisaUUID(bit *retval, str *s);
str UUIDstr2uuid(str *retval, str *s);
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -39,19 +39,37 @@
int
UUIDtoString(str *retval, int *len, str value)
{
- if (*len < UUID_LEN) {
- if (*retval != NULL)
- GDKfree(*retval);
- *retval = GDKmalloc(sizeof(str) * (*len = UUID_LEN));
- }
- if (value == str_nil) {
- *len = snprintf(*retval, *len, "(nil)");
+ if (*len < UUID_LEN) {
+ if (*retval != NULL)
+ GDKfree(*retval);
+ *retval = GDKmalloc(sizeof(str) * (*len = UUID_LEN));
+ }
+ if (value == str_nil) {
+ *len = snprintf(*retval, *len, "(nil)");
} else {
strncpy(*retval, value, UUID_LEN);
(*retval)[UUID_LEN] = 0;
*len = UUID_LEN;
- }
- return(*len);
+ }
+ return(*len);
+}
+
+int
+UUIDfromString(char *svalue, int *len, str *retval)
+{
+ str msg;
+
+ if (*retval)
+ GDKfree(*retval);
+ *retval = NULL;
+ msg = UUIDstr2uuid(retval, &svalue);
+ if (msg != MAL_SUCCEED) {
+ GDKfree(msg);
+ *retval = GDKstrdup(str_nil);
+ return 0;
+ }
+ *len = UUID_LEN;
+ return UUID_LEN;
}
static str
diff --git a/monetdb5/modules/atoms/uuid.h b/monetdb5/modules/atoms/uuid.h
--- a/monetdb5/modules/atoms/uuid.h
+++ b/monetdb5/modules/atoms/uuid.h
@@ -39,6 +39,7 @@ typedef str uuid;
#endif
uuid_export int UUIDtoString(str *retval, int *len, str handle);
+uuid_export int UUIDfromString(char *svalue, int *len, str *retval);
uuid_export str UUIDgenerateUuid(str *retval);
uuid_export str UUIDstr2uuid(str *retval, str *s);
uuid_export str UUIDuuid2str(str *retval, str *s);
diff --git a/monetdb5/modules/atoms/uuid.mal b/monetdb5/modules/atoms/uuid.mal
--- a/monetdb5/modules/atoms/uuid.mal
+++ b/monetdb5/modules/atoms/uuid.mal
@@ -2,10 +2,14 @@ module uuid;
atom uuid:str;
-command tostr()
+command tostr() :str
address UUIDtoString
comment "Convert uuid to string equivalent";
+command fromstr() :uuid
+address UUIDfromString
+comment "Convert string to uuid";
+
command new() :uuid
address UUIDgenerateUuid
comment "Generate uuid";
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list