SF.net SVN: geany: [2608] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed May 21 17:41:40 UTC 2008


Revision: 2608
          http://geany.svn.sourceforge.net/geany/?rev=2608&view=rev
Author:   eht16
Date:     2008-05-21 10:41:11 -0700 (Wed, 21 May 2008)

Log Message:
-----------
Fix some quotations to not screw up the bash lexer.
Don't use /dev/random or /dev/urandom in gb.c, instead of GLib's random functions.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/configure.in
    trunk/src/gb.c
    trunk/win32-config.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-05-21 16:53:40 UTC (rev 2607)
+++ trunk/ChangeLog	2008-05-21 17:41:11 UTC (rev 2608)
@@ -2,6 +2,10 @@
 
  * plugins/Makefile.am:
    Specify the necessary libraries of each plugin to link against.
+ * configure.in, win32-config.h, src/gb.c:
+   Fix some quotations to not screw up the bash lexer.
+   Don't use /dev/random or /dev/urandom in gb.c, instead of GLib's
+   random functions.
 
 
 2008-05-21  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2008-05-21 16:53:40 UTC (rev 2607)
+++ trunk/configure.in	2008-05-21 17:41:11 UTC (rev 2608)
@@ -139,22 +139,16 @@
 
 if test "x$enable_gnu_regex" = "xyes" ; then
 	AC_DEFINE(USE_INCLUDED_REGEX, 1, [Define if included GNU regex code should be used.])
-	AC_DEFINE(HAVE_REGCOMP, 1, [Define if you have the `regcomp' function.])
+	AC_DEFINE(HAVE_REGCOMP, 1, [Define if you have the 'regcomp' function.])
 	AM_CONDITIONAL(USE_INCLUDED_REGEX, true)
 else
 	AM_CONDITIONAL(USE_INCLUDED_REGEX, false)
 fi
 
-# Check for random number paths (skip when cross compiling)
-if test "x$build" = "x$host"; then
-	AC_CHECK_FILE([/dev/urandom], AC_DEFINE([HAVE_DEVURANDOM], [1], [Define that you found /dev/urandom]))
-	AC_CHECK_FILE([/dev/random], AC_DEFINE([HAVE_DEVRANDOM], [1], [Define that you found /dev/random]))
-fi
-
 case "${host}" in
     *mingw*)
 	AC_CHECK_LIB(iberty, fnmatch, [], [
-		AC_MSG_ERROR([fnmatch dosn't present in libiberty. You need to update it, read http://geany.uvena.de/Support/CrossCompile for details.])
+		AC_MSG_ERROR([fnmatch does not present in libiberty. You need to update it, read http://geany.uvena.de/Support/CrossCompile for details.])
 		])
 	AC_DEFINE_UNQUOTED([WIN32], 1, [we are cross compiling for WIN32])
 	want_vte="no"

Modified: trunk/src/gb.c
===================================================================
--- trunk/src/gb.c	2008-05-21 16:53:40 UTC (rev 2607)
+++ trunk/src/gb.c	2008-05-21 17:41:11 UTC (rev 2608)
@@ -49,7 +49,6 @@
 GtkWidget *image1, *image2, *image3, *image4, *label1, *label2, *label3, *okbutton1, *textview1;
 gchar info_texts[4][50];
 gchar *help_text;
-gint random_fd;
 gboolean is_running;
 static GdkPixbuf **icons;
 
@@ -208,39 +207,6 @@
 }
 
 
-static void initialise_random_numbers(void)
-{
-#if defined(HAVE_FCNTL_H) && (defined(HAVE_DEVURANDOM) || defined(HAVE_DEVRANDOM))
-# ifdef HAVE_DEVURANDOM
-	random_fd = open("/dev/urandom", O_NONBLOCK | O_RDONLY);
-# elif HAVE_DEVRANDOM
-	random_fd = open("/dev/random", O_NONBLOCK | O_RDONLY);
-# endif
-#else
-    srand(time(NULL) * getpid());
-#endif
-}
-
-
-static gint random_number(gint max)
-{
-#if defined(HAVE_FCNTL_H) && (defined(HAVE_DEVURANDOM) || defined(HAVE_DEVRANDOM))
-    if (max <= 255)
-	{
-		unsigned char byte;
-		while (read(random_fd, &byte, 1) == 1)
-		{
-	    	if (byte < max)
-				return (byte % max);
-		}
-    }
-    return 0;
-#else
-	return (((unsigned short) rand()) % max);
-#endif
-}
-
-
 static void on_button5_clicked(GtkButton *button, gpointer user_data)
 {
     gb_destroyapp(GTK_WIDGET(button), user_data);
@@ -279,12 +245,12 @@
 	lap++;
 	update_labels(gb_window, FALSE, 3);
 
-	l = random_number(MAX_PICS);
-	m = random_number(MAX_PICS);
-	n = random_number(MAX_PICS);
-	erg_a = random_number(MAX_PICS);
-	erg_b = random_number(MAX_PICS);
-	erg_c = random_number(MAX_PICS);
+	l = g_random_int_range(0, MAX_PICS);
+	m = g_random_int_range(0, MAX_PICS);
+	n = g_random_int_range(0, MAX_PICS);
+	erg_a = g_random_int_range(0, MAX_PICS);
+	erg_b = g_random_int_range(0, MAX_PICS);
+	erg_c = g_random_int_range(0, MAX_PICS);
 
 	/* assign icons */
 	loops = 30;
@@ -1250,14 +1216,12 @@
 {
 	gint i;
 
-	initialise_random_numbers();
-
 	/* define start images */
-	i = random_number(MAX_PICS) + 1;
+	i = g_random_int_range(0, MAX_PICS);
 	gtk_image_set_from_pixbuf(GTK_IMAGE(image1), icons[i]);
-	i = random_number(MAX_PICS) + 1;
+	i = g_random_int_range(0, MAX_PICS);
 	gtk_image_set_from_pixbuf(GTK_IMAGE(image2), icons[i]);
-	i = random_number(MAX_PICS) + 1;
+	i = g_random_int_range(0, MAX_PICS);
 	gtk_image_set_from_pixbuf(GTK_IMAGE(image3), icons[i]);
 }
 
@@ -1267,7 +1231,6 @@
 {
 	if (is_running) return TRUE;
 	if (GTK_IS_WINDOW(gb_window)) gtk_widget_destroy(gb_window);
-	if (random_fd != -1) close(random_fd);
 	gb_window = NULL;
 	return FALSE;
 }
@@ -1275,7 +1238,6 @@
 
 void gb_start_easteregg(void)
 {
-	random_fd = -1;
 	load_images();
 	create_window();
 	g_signal_connect(G_OBJECT(gb_window), "delete_event", G_CALLBACK(gb_destroyapp), NULL);

Modified: trunk/win32-config.h
===================================================================
--- trunk/win32-config.h	2008-05-21 16:53:40 UTC (rev 2607)
+++ trunk/win32-config.h	2008-05-21 17:41:11 UTC (rev 2608)
@@ -38,12 +38,6 @@
    */
 /* #undef HAVE_DECL_GETENV */
 
-/* Define that you found /dev/random */
-//#define HAVE_DEVRANDOM 1
-
-/* Define that you found /dev/urandom */
-//#define HAVE_DEVURANDOM 1
-
 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
    */
 #define HAVE_DIRENT_H 1


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list