[LDTP-Dev] [PATCH] fix for bug #317594

J Premkumar jpremkumar at novell.com
Sat Oct 1 03:55:24 PDT 2005


Hi

I have attached patch for fixing bug #317594. The problem was due to
stripping white spaces while loading appmap values into hash table.
Furthermore, the patch also removes preprocessing of label/label_by
values during appmap generation as well as during object verification
while getting gui handle. Same change has been made in remap.c that
takes care of generating appmap at runtime. Please review the patch.

Thanks
Premkumar

Index: appmap.c
===================================================================
RCS file: /cvs/pyldtp/appmap.c,v
retrieving revision 1.12
diff -u -p -r1.12 appmap.c
--- appmap.c	23 Sep 2005 18:46:57 -0000	1.12
+++ appmap.c	1 Oct 2005 12:54:06 -0000
@@ -90,12 +90,7 @@ void add_child_attributes (char *cur_ent
 	  key = strtok (strdup (all_attributes), "=");
 	  while (key)
 	    {
-	      // Strip any white spaces
-	      key = g_strdup (g_strstrip (key));
 	      value = strtok (NULL, ",");
-	      if (value)
-		// Strip any white spaces
-		value = g_strdup (g_strstrip (value));
 	      g_print ("%s: %s\n", key, value);
 	      if (hash_attributes)
 		g_hash_table_insert (hash_attributes, key, value);


Index: gui.c
===================================================================
RCS file: /cvs/pyldtp/gui.c,v
retrieving revision 1.50
diff -u -p -r1.50 gui.c
--- gui.c	27 Sep 2005 11:20:26 -0000	1.50
+++ gui.c	1 Oct 2005 18:06:03 -0000
@@ -444,7 +444,8 @@ int is_object_matching (Accessible *obje
   char *accessible_label;
   char *hash_label;
   /*
-   * NOTE: Checking if the obtained object is the required one with
respect to label only
+   * NOTE: Checking if the obtained object is the required one with
respect to label
+   * or label_by only
    */
   hash_label = g_hash_table_lookup (comp_attributes, "label");
   if (hash_label)
@@ -468,26 +469,17 @@ int is_object_matching (Accessible *obje
       hash_label = g_hash_table_lookup (comp_attributes, "label_by");
       if (hash_label)
 	{
-	  char *tmp;
 	  accessible_label = get_relation_name (object);
 	  if (accessible_label)
 	    {
-	      if (strstr (accessible_label, ":"))
-		{
-		  tmp = strip_delim (accessible_label, ':');
-		  g_free (accessible_label);
-		  accessible_label = g_strdup (tmp);
-		  g_free (tmp);
-		  tmp = NULL;
-		}
 	      if (g_strcasecmp (accessible_label, hash_label) == 0)
 		{
-		  g_free (accessible_label);
+		  SPI_freeString (accessible_label);
 		  return 1;
 		}
 	      else
 		{
-		  g_free (accessible_label);
+		  SPI_freeString (accessible_label);
 		  return 0;
 		}
 	    }


Index: remap.c
===================================================================
RCS file: /cvs/pyldtp/remap.c,v
retrieving revision 1.2
diff -u -p -r1.2 remap.c
--- remap.c	1 Oct 2005 17:49:52 -0000	1.2
+++ remap.c	1 Oct 2005 18:03:43 -0000
@@ -116,8 +116,7 @@ char *strip_delim (char *data, char deli
  */
 int filter_appmap_data (Accessible *accessible, OBJECT_INFO *obj_info,
char *label)
 {
-  if (g_strcasecmp (obj_info->object_type, "label") == 0 ||
-      g_strcasecmp (obj_info->object_type, "separator") == 0 ||
+  if (g_strcasecmp (obj_info->object_type, "separator") == 0 ||
       g_strcasecmp (obj_info->object_type, "table_cell") == 0)
     return 0;
   if (g_strcasecmp (label, "ukngrip") == 0)
@@ -235,6 +234,21 @@ char *add_appmap_data (Accessible *acces
   g_free (label);
   label = g_strdup (accessible_name);
   SPI_freeString (accessible_name);
+  /*
+   * Following code is for limiting appmap from generating label
+   * with value as string made of only space characters
+   */
+  if (strstr (label, " "))
+    {
+      char *stripped_data = NULL;
+      stripped_data = strip_white_space (label);
+      if (g_ascii_strcasecmp (stripped_data, "") == 0)
+        {
+	  g_free (label);
+	  label = g_strdup (stripped_data);
+        }
+      g_free (stripped_data);
+    }
 
   if (filter_appmap_data (accessible, cur_obj_info, name))
     {
@@ -251,15 +265,6 @@ char *add_appmap_data (Accessible *acces
 	    {
 	      if (label_by)
 		{
-		  char *tmp;
-		  if (strstr (label_by, ":"))
-		    {
-		      tmp = strip_delim (label_by, ':');
-		      g_free (label_by);
-		      label_by = g_strdup (tmp);
-		      g_free (tmp);
-		      tmp = NULL;
-		    }
 		  g_hash_table_insert (hash_attributes, g_strdup
("label_by"), g_strdup (label_by));
 		  g_free (label_by);
 		}

Index: appmap-gen.c
===================================================================
RCS file: /cvs/appmap/appmap-gen.c,v
retrieving revision 1.14
diff -u -p -r1.14 appmap-gen.c
--- appmap-gen.c	1 Oct 2005 17:26:22 -0000	1.14
+++ appmap-gen.c	1 Oct 2005 17:39:28 -0000
@@ -362,6 +362,10 @@ char *add_appmap_data (FILE *fp, Accessi
   g_free (label);
   label = g_strdup (accessible_name);
   SPI_freeString (accessible_name);
+  /*
+   * Following code is for limiting appmap from generating label
+   * with value as string made of only space characters
+   */
   if (strstr (label, " "))
     {
       char *stripped_data = NULL;
@@ -370,10 +374,8 @@ char *add_appmap_data (FILE *fp, Accessi
 	{
 	  g_free (label);
 	  label = g_strdup (stripped_data);
-	  g_free (stripped_data);
 	}
-      else
-	g_free (stripped_data);
+      g_free (stripped_data);
     }
 
   if (filter_appmap_data (accessible, cur_obj_info, name))
@@ -385,15 +387,6 @@ char *add_appmap_data (FILE *fp, Accessi
 					     cur_obj_info->object_type,
parent_name, child_index);
 	  else
 	    {
-	      char *tmp;
-	      if (strstr (label_by, ":"))
-		{
-		  tmp = strip_delim (label_by, ':');
-		  g_free (label_by);
-		  label_by = g_strdup (tmp);
-		  g_free (tmp);
-		  value = NULL;
-		}
 	      object_record = g_strdup_printf
("%s={class=%s,parent=%s,child_index=%d,label_by=%s}\n", name, 
 					      
cur_obj_info->object_type, parent_name, child_index, label_by);
 	      g_free (label_by);



More information about the Ldtp-dev mailing list