Juan Zacarias has proposed merging lp:~zorba-coders/zorba/xqxq-bug-1056704 into 
lp:zorba/xqxq-module with lp:~zorba-coders/zorba/bug-1056704 as a prerequisite.

Commit message:
Fix for bug-1056704:
Changed xqxq-module implementation to zorba's util/uuid.h

Requested reviews:
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1056704 in Zorba: "XQXQ generate UUID bug"
  https://bugs.launchpad.net/zorba/+bug/1056704

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/xqxq-bug-1056704/+merge/127374
-- 
https://code.launchpad.net/~zorba-coders/zorba/xqxq-bug-1056704/+merge/127374
Your team Zorba Coders is subscribed to branch lp:zorba/xqxq-module.
=== modified file 'src/xqxq.xq.src/xqxq.cpp'
--- src/xqxq.xq.src/xqxq.cpp	2011-11-30 21:57:52 +0000
+++ src/xqxq.xq.src/xqxq.cpp	2012-10-01 21:44:25 +0000
@@ -10,7 +10,7 @@
 #include <zorba/xquery.h>
 #include <time.h>
 #include <stdio.h>
-
+#include <zorba/util/uuid.h>
 #include <vector>
 
 #include "xqxq.h"
@@ -269,29 +269,18 @@
           e.diagnostic().qname().ns(), e.diagnostic().qname().localname());
       throw USER_EXCEPTION(errQName, err.str());
     }
-
-    String lUUID = getUUID();
-    
-    lQueryMap->storeQuery(lUUID, lQuery);
-
-    return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lUUID)));
-  }
-
-  String 
-    PrepareMainModuleFunction::S4 ()
-  {
-    unsigned long randNum = (1 + rand() * 0x10000)|0;
-    char* randBuff= new char[20];
-    sprintf(randBuff, "%lx", randNum);
-    String lString(randBuff);
-    delete[] randBuff;
-    return lString;
-  }
-
-  String 
-    PrepareMainModuleFunction::getUUID()
-  {
-    return (String("urn:uuid:") + S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4());
+    
+    uuid lUUID;
+    uuid::create(&lUUID);
+    
+    std::stringstream lStream;
+    lStream << lUUID;
+
+    String lStrUUID = lStream.str();
+    
+    lQueryMap->storeQuery(lStrUUID, lQuery);
+
+    return ItemSequence_t(new SingletonItemSequence(XQXQModule::getItemFactory()->createAnyURI(lStrUUID)));
   }
 
   /*******************************************************************************************

=== modified file 'src/xqxq.xq.src/xqxq.h'
--- src/xqxq.xq.src/xqxq.h	2011-11-28 23:55:59 +0000
+++ src/xqxq.xq.src/xqxq.h	2012-10-01 21:44:25 +0000
@@ -126,14 +126,6 @@
         evaluate(const Arguments_t&,
                  const zorba::StaticContext*,
                  const zorba::DynamicContext*) const;
-
-    protected:
-       static String
-         getUUID();
-
-       static String
-         S4();
-
   };
 
   class PrepareLibraryModuleFunction : public XQXQFunction{

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to