On Tuesday, August 27, 2013 19:08 CEST, Otto Moerbeek <[email protected]> wrote: 
 
> On Tue, Aug 27, 2013 at 06:54:46PM +0200, Sebastian Reitenbach wrote:
> 
> > The patch below updates geo/qlandkartegt from 1.7.0 to 1.7.3
> > The license changed to GPLv3 with update to 1.7.1
> > 
> > While there, exchange usage of rand with arc4random.
> > As far as I can see, it only selects some colors randomly.
> > The usage of arc4random is done the hard way, my cmake
> > skills are not as good as I'd like them to be to add a
> > configure test and use something better ;)
> > 
> > tested on amd64.
> > 
> 
> RAND_MAX does not apply to arc4random(), it has a different range. Use
> UINT_MAX. 
> 
>       -Otto
> 

here is an updated diff, also removing the superfluous include <stdlib.h>
from the patch.

OK?


Index: Makefile
===================================================================
RCS file: /cvs/ports/geo/qlandkartegt/Makefile,v
retrieving revision 1.12
diff -u -p -u -r1.12 Makefile
--- Makefile    2 Jul 2013 04:30:20 -0000       1.12
+++ Makefile    28 Aug 2013 09:00:03 -0000
@@ -3,14 +3,14 @@
 VMEM_WARNING = yes
 COMMENT =      garmin gps map management tool
 
-DISTNAME =     qlandkartegt-1.7.0
+DISTNAME =     qlandkartegt-1.7.3
 CATEGORIES =   geo x11
 
 HOMEPAGE =     http://www.qlandkarte.org/
 MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=qlandkartegt/}
 MAINTAINER =   Sebastian Reitenbach <[email protected]>
 
-# GPLv2
+# GPLv3
 PERMIT_PACKAGE_CDROM =         Yes
 
 MODULES =      devel/cmake x11/qt4
Index: distinfo
===================================================================
RCS file: /cvs/ports/geo/qlandkartegt/distinfo,v
retrieving revision 1.10
diff -u -p -u -r1.10 distinfo
--- distinfo    2 Jul 2013 04:30:20 -0000       1.10
+++ distinfo    28 Aug 2013 09:00:03 -0000
@@ -1,2 +1,2 @@
-SHA256 (qlandkartegt-1.7.0.tar.gz) = 
Tbq57QCCRkepr9MVYZ55dOF2o7R+UPN1REHmnx2+5y0=
-SIZE (qlandkartegt-1.7.0.tar.gz) = 8136806
+SHA256 (qlandkartegt-1.7.3.tar.gz) = 
2/yWNvSozIhzff+MvTtBHksawXxVJRY5a1XR5oCtlTw=
+SIZE (qlandkartegt-1.7.3.tar.gz) = 8334026
Index: patches/patch-3rdparty_map2jnx_main_cpp
===================================================================
RCS file: patches/patch-3rdparty_map2jnx_main_cpp
diff -N patches/patch-3rdparty_map2jnx_main_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-3rdparty_map2jnx_main_cpp     28 Aug 2013 09:00:03 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+
+use arc4random
+
+--- 3rdparty/map2jnx/main.cpp.orig     Tue Aug 27 09:44:48 2013
++++ 3rdparty/map2jnx/main.cpp  Tue Aug 27 09:46:40 2013
+@@ -419,14 +419,20 @@ static uint32_t scale2jnx(double scale)
+ static char randChar()
+ {
+     char buf[2];
++#if defined(__OpenBSD__)
++    int r = (int)((arc4random() * 16.0) / UINT_MAX);
++#else
+     int r = (int)((rand() * 16.0) / RAND_MAX);
++#endif
+     sprintf(buf,"%X", r & 0x0F);
+     return buf[0];
+ }
+ 
+ static void createGUID(char * guid)
+ {
++#if !defined(__OpenBSD__)
+     srand((unsigned int)time(0));
++#endif
+ 
+     guid[0]     = randChar();
+     guid[1]     = randChar();
Index: patches/patch-src_CTrackDB_cpp
===================================================================
RCS file: patches/patch-src_CTrackDB_cpp
diff -N patches/patch-src_CTrackDB_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_CTrackDB_cpp      28 Aug 2013 09:00:03 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+use arc4random
+
+--- src/CTrackDB.cpp.orig      Wed Aug 14 19:56:40 2013
++++ src/CTrackDB.cpp   Wed Aug 28 09:04:34 2013
+@@ -173,7 +173,11 @@ void CTrackDB::loadGPX(CGpx& gpx)
+         hasItems = true;
+         CTrack* track = new CTrack(this);
+                                  //preset a random color
++#if defined(__OpenBSD__)
++        track->setColor((arc4random() % 13)+1);
++#else
+         track->setColor((rand() % 13)+1);
++#endif
+ 
+         /*
+          *  Global track information

 
 
 

Reply via email to