On Friday, September 6, 2013 22:10 CEST, Brad Smith <[email protected]> wrote: 
 
> On 28/08/13 5:03 AM, Sebastian Reitenbach wrote:
> >
> > 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?
> 
> I would be if it didn't have #if defined(__OpenBSD__) and instead used a 
> proper CMake check.
> 

Here's an updated diff, now with proper cmake test for arc4random.
If that's OK now, I'll go bother upstream to include it.


cheers,
Sebastian


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    12 Sep 2013 11:20:07 -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    12 Sep 2013 11:20:07 -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     12 Sep 2013 11:20:07 -0000
@@ -0,0 +1,35 @@
+$OpenBSD$
+
+use arc4random
+
+--- 3rdparty/map2jnx/main.cpp.orig     Mon Jun 17 14:27:52 2013
++++ 3rdparty/map2jnx/main.cpp  Thu Sep 12 09:09:12 2013
+@@ -14,6 +14,7 @@
+ 
+ 
**********************************************************************************************/
+ 
++#include "config.h"
+ 
+ #ifdef _MSC_VER
+ #define fseeko _fseeki64
+@@ -419,14 +420,20 @@ static uint32_t scale2jnx(double scale)
+ static char randChar()
+ {
+     char buf[2];
++#if defined(HAVE_ARC4RANDOM)
++    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(HAVE_ARC4RANDOM)
+     srand((unsigned int)time(0));
++#endif
+ 
+     guid[0]     = randChar();
+     guid[1]     = randChar();
Index: patches/patch-ConfigureChecks_cmake
===================================================================
RCS file: patches/patch-ConfigureChecks_cmake
diff -N patches/patch-ConfigureChecks_cmake
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-ConfigureChecks_cmake 12 Sep 2013 11:20:07 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+use arc4random
+
+--- ConfigureChecks.cmake.orig Wed Sep 11 15:08:42 2013
++++ ConfigureChecks.cmake      Wed Sep 11 15:09:18 2013
+@@ -31,6 +31,8 @@ check_include_file(byteswap.h HAVE_BYTESWAP_H)
+ 
+ test_big_endian(HAVE_BIGENDIAN)
+ 
++check_function_exists(arc4random HAVE_ARC4RANDOM) 
++
+ # check if we're on a 64bit host
+ if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+   SET(HOST_IS_64_BIT 1)
Index: patches/patch-config_h_cmake
===================================================================
RCS file: patches/patch-config_h_cmake
diff -N patches/patch-config_h_cmake
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-config_h_cmake        12 Sep 2013 11:20:07 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+use arc4random
+
+--- config.h.cmake.orig        Thu Sep 12 08:36:49 2013
++++ config.h.cmake     Thu Sep 12 08:37:05 2013
+@@ -19,6 +19,8 @@
+ 
+ #cmakedefine HAVE_BIGENDIAN 1
+ 
++#cmakedefine HAVE_ARC4RANDOM 1
++
+ /* build with native file dialogs */
+ #define FILE_DIALOG_FLAGS ${FILEDIALOGFLAGS}
+ 
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      12 Sep 2013 11:20:07 -0000
@@ -0,0 +1,27 @@
+$OpenBSD$
+
+use arc4random
+
+--- src/CTrackDB.cpp.orig      Wed Aug 14 19:56:40 2013
++++ src/CTrackDB.cpp   Thu Sep 12 09:08:18 2013
+@@ -16,6 +16,8 @@
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ 
**********************************************************************************************/
++#include "config.h"
++
+ #include <stdio.h>
+ #include <limits>
+ 
+@@ -173,7 +175,11 @@ void CTrackDB::loadGPX(CGpx& gpx)
+         hasItems = true;
+         CTrack* track = new CTrack(this);
+                                  //preset a random color
++#if defined(HAVE_ARC4RANDOM)
++        track->setColor((arc4random() % 13)+1);
++#else
+         track->setColor((rand() % 13)+1);
++#endif
+ 
+         /*
+          *  Global track information

Reply via email to