[LDTP-Dev] [PATCH] fix for bug #317594
jpremkumar
jpremkumar at novell.com
Mon Oct 3 22:17:27 PDT 2005
Hi Nagappan,
I have attached the modified patch for bug #317594 based on your review
comments. Please review them.
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 4 Oct 2005 12:07:25 -0000
@@ -90,15 +90,14 @@ void add_child_attributes (char *cur_ent
key = strtok (strdup (all_attributes), "=");
while (key)
{
- // Strip any white spaces
- key = g_strdup (g_strstrip (key));
+ char *hash_key;
+ char *hash_value;
+ hash_key = g_strdup (key);
value = strtok (NULL, ",");
- if (value)
- // Strip any white spaces
- value = g_strdup (g_strstrip (value));
- g_print ("%s: %s\n", key, value);
+ hash_value = g_strdup (value);
+ g_print ("%s: %s\n", hash_key, hash_value);
if (hash_attributes)
- g_hash_table_insert (hash_attributes, key, value);
+ g_hash_table_insert (hash_attributes, hash_key, hash_value);
key = strtok (NULL, "=");
}
if (component)
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 4 Oct 2005 12:07:25 -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 (strchr (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: 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 4 Oct 2005 12:07:25 -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/label_by only
*/
hash_label = g_hash_table_lookup (comp_attributes, "label");
if (hash_label)
@@ -468,18 +469,9 @@ 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);
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 4 Oct 2005 12:06:34 -0000
@@ -362,7 +362,11 @@ char *add_appmap_data (FILE *fp, Accessi
g_free (label);
label = g_strdup (accessible_name);
SPI_freeString (accessible_name);
- if (strstr (label, " "))
+ /*
+ * Following code is for limiting appmap from generating
+ * label with value as string made of only space character
+ */
+ if (strchr (label, ' '))
{
char *stripped_data = NULL;
stripped_data = strip_white_space (label);
@@ -370,9 +374,7 @@ char *add_appmap_data (FILE *fp, Accessi
{
g_free (label);
label = g_strdup (stripped_data);
- g_free (stripped_data);
}
- else
g_free (stripped_data);
}
@@ -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);
On Sat, 2005-10-01 at 21:38 +0530, A Nagappan wrote:
> Hi Prem,
>
> 1. In appmap.c, we should not remove g_strdup, because this string we will be removing at later stage. Moreover, its not advisable, to store the data in a hash table, with the memory allocated by other function.
> 2. accessible_label value is a string in is_object_matching function, it should be freed using SPI_freeString, instead it has to be freed by g_free. Earlier implementation was the right one, any reason for changing this ?
> 3. In remap.c, add_appmap_data function whats the reson for strstr ? Why can't we use strchr, if we just finding only space ? moreover we can try implementing the new functions with localization in mind ?
> 4. Why this comparison is done 'g_ascii_strcasecmp (stripped_data, "")' in add_appmap_data function ?
>
> Don't check in this patch, until its further reviewed...
>
> Thanks
> Nagappan
>
> Nagappan A <anagappan at novell.com>
> Linux Desktop Testing Project - http://gnomebangalore.org/ldtp
> http://nagappanal.blogspot.com
>
More information about the Ldtp-dev
mailing list