gscanner + gtk examples patch



Hi,

gscanner initialize only four bytes of the GTokenValue union. Either
initilize ->value.v_double to 0 or use memset like my small patch below.
Memory detection tools like bitwagon's chaperon reports this type of
things...

The gtk+/examples/Makefile hasn't got that many examples as it wants
too...

The examples/setselection/setselection.c won't compile since the
gtkselection api changed some between 2.0 and 2.2... The patch below makes
the thing compile. _but_ the example should be removed since it ain't
working properly or replaced by gtk/testselection.c which is way better.
(btw, do a "grep -n "gtk_selection_add_handler" docs/*" A document there
still refers to the old behavior)


Please let me know if I'm missing something in this untested patch.

/perraw


--- glib-1.2.4/gscanner.c	Mon Aug 30 23:01:47 1999
+++ glib-1.2.4/gscanner.c.new	Mon Aug 30 23:01:36 1999
@@ -214,12 +214,14 @@
   scanner->config->scope_0_fallback	= config_templ->scope_0_fallback;
   
   scanner->token = G_TOKEN_NONE;
-  scanner->value.v_int = 0;
+
+  memset (&scanner->value, 0, sizeof(GTokenValue));
   scanner->line = 1;
   scanner->position = 0;
   
   scanner->next_token = G_TOKEN_NONE;
-  scanner->next_value.v_int = 0;
+
+  memset (&scanner->next_value, 0, sizeof(GTokenValue));
   scanner->next_line = 1;
   scanner->next_position = 0;
   
@@ -632,7 +634,7 @@
 {
   GTokenValue v;
   
-  v.v_int = 0;
+  memset (&v, 0, sizeof(GTokenValue));
   
   g_return_val_if_fail (scanner != NULL, v);
 
@@ -678,7 +680,7 @@
     g_scanner_sync_file_offset (scanner);
 
   scanner->token = G_TOKEN_NONE;
-  scanner->value.v_int = 0;
+  memset (&scanner->value, 0, sizeof(GTokenValue));
   scanner->line = 1;
   scanner->position = 0;
   scanner->next_token = G_TOKEN_NONE;
@@ -706,7 +708,7 @@
     g_scanner_sync_file_offset (scanner);
 
   scanner->token = G_TOKEN_NONE;
-  scanner->value.v_int = 0;
+  memset (&scanner->value, 0, sizeof(GTokenValue));
   scanner->line = 1;
   scanner->position = 0;
   scanner->next_token = G_TOKEN_NONE;
@@ -1219,7 +1221,7 @@
   guchar	   ch;
   
   config = scanner->config;
-  (*value_p).v_int = 0;
+  memset (value_p, 0, sizeof(GTokenValue));
   
   if ((scanner->text >= scanner->text_end && scanner->input_fd < 0) ||
       scanner->token == G_TOKEN_EOF)
@@ -1241,6 +1243,7 @@
       ch = g_scanner_get_char (scanner, line_p, position_p);
       
       value.v_int = 0;
+      memset (&value, 0, sizeof(GTokenValue));
       token = G_TOKEN_NONE;
       
       /* this is *evil*, but needed ;(


--- gtk+-1.2.4/examples/Makefile	Mon Aug 30 21:14:29 1999
+++ gtk+-1.2.4/examples/Makefile.new	Mon Aug 30 21:19:14 1999
@@ -1,8 +1,6 @@
 
-SUBDIRS = 	arrow \
-		aspectframe \
+SUBDIRS = 	aspectframe \
 		base \
-		buttonbox \
 		buttons \
 		calendar \
 		clist \
@@ -14,7 +12,6 @@
 		gtkdial \
 		helloworld \
 		helloworld2 \
-		label \
 		list \
 		menu \
 		notebook \


--- gtk+-1.2.4/examples/selection/setselection.c	Mon Aug 30 22:57:57 1999
+++ gtk+-1.2.4/examples/selection/setselection.c.new	Mon Aug 30 23:00:29 1999
@@ -91,10 +91,10 @@
   gtk_signal_connect (GTK_OBJECT(selection_button), "selection_clear_event",
 		      GTK_SIGNAL_FUNC (selection_clear), &have_selection);
 
-  gtk_selection_add_handler (selection_button, GDK_SELECTION_PRIMARY,
-			     GDK_SELECTION_TYPE_STRING,
-			     selection_handle, NULL);
 
+  gtk_selection_add_target (selection_button, GDK_SELECTION_PRIMARY,
+                            GDK_SELECTION_TYPE_STRING, 0);
+  
   gtk_widget_show (selection_button);
   gtk_widget_show (window);
   






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]