Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] ARI fixes fro objc-lang.[ch]
@ 2002-10-02 19:42 Adam Fedor
  2002-10-03 16:50 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Fedor @ 2002-10-02 19:42 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 622 bytes --]

This is an obvious fix, but I guess I need to post it to this list first?

2002-10-02  Adam Fedor  <fedor@gnu.org>

         * objc-lang.c: ARI fixes. Change string.h to gdb_string.h
         (objc_demangle): Remove assignment in if statements, free->xfree
         (add_msglist): Likewise.
         (end_msglist): Likewise.
         (complare_selectors): Likewise.
         (selectors_info): Likewise.
         (compare_classes): Likewise.
         (classes_info): Likewise.
         (print_object_command): Likewise.
         (find_objc_msgcall_submethod): PTR->void *
         * objc-lang.h: Remove check for __STDC__


[-- Attachment #2: gdb1.patch --]
[-- Type: text/plain, Size: 6800 bytes --]

? gdb1.patch
Index: gdb/objc-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.c,v
retrieving revision 1.3
diff -u -p -r1.3 objc-lang.c
--- gdb/objc-lang.c	19 Sep 2002 04:12:10 -0000	1.3
+++ gdb/objc-lang.c	3 Oct 2002 02:19:44 -0000
@@ -34,7 +34,7 @@
 #include "value.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include "string.h"		/* for strchr */
+#include "gdb_string.h"		/* for strchr */
 #include "target.h"		/* for target_has_execution */
 #include "gdbcore.h"
 #include "gdbcmd.h"
@@ -266,9 +266,10 @@ objc_demangle (const char *mangled)
       while (*cp && *cp == '_')
 	cp++;			/* skip any initial underbars in class name */
 
-      if (!(cp = strchr(cp, '_')))	/* find first non-initial underbar */
+      cp = strchr(cp, '_');
+      if (!cp)	                /* find first non-initial underbar */
 	{
-	  free(demangled);	/* not mangled name */
+	  xfree(demangled);	/* not mangled name */
 	  return NULL;
 	}
       if (cp[1] == '_') {	/* easy case: no category name     */
@@ -277,9 +278,10 @@ objc_demangle (const char *mangled)
       }
       else {
 	*cp++ = '(';		/* less easy case: category name */
-	if (!(cp = strchr(cp, '_')))
+	cp = strchr(cp, '_');
+	if (!cp)
 	  {
-	    free(demangled);	/* not mangled name */
+	    xfree(demangled);	/* not mangled name */
 	    return NULL;
 	  }
 	*cp++ = ')';
@@ -739,7 +741,7 @@ add_msglist(struct stoken *str, int addc
   s = (char *)xmalloc(len);
   strcpy(s, msglist_sel);
   strncat(s, p, plen);
-  free(msglist_sel);
+  xfree(msglist_sel);
   msglist_sel = s;
   if (addcolon) {
     s[len-2] = ':';
@@ -764,9 +766,9 @@ end_msglist(void)
   if (!selid)
     error("Can't find selector \"%s\"", p);
   write_exp_elt_longcst (selid);
-  free(p);
+  xfree(p);
   write_exp_elt_longcst (val);	/* Number of args */
-  free(sel);
+  xfree(sel);
 
   return val;
 }
@@ -805,12 +807,14 @@ compare_selectors (void *a, void *b)
 {
   char *aname, *bname;
 
-  if ((aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a)) == NULL ||
-      (bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b)) == NULL)
+  aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a);
+  bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b);
+  if (aname == NULL || bname == NULL)
     error ("internal: compare_selectors(1)");
 
-  if ((aname = strchr(aname, ' ')) == NULL ||
-      (bname = strchr(bname, ' ')) == NULL)
+  aname = strchr(aname, ' ');
+  bname = strchr(bname, ' ');
+  if (aname == NULL || bname == NULL)
     error ("internal: compare_selectors(2)");
 
   return specialcmp (aname+1, bname+1);
@@ -870,7 +874,8 @@ selectors_info (char *regexp, int from_t
   ALL_MSYMBOLS (objfile, msymbol)
     {
       QUIT;
-      if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
+      name = SYMBOL_DEMANGLED_NAME (msymbol);
+      if (name == NULL)
 	name = SYMBOL_NAME (msymbol);
       if (name &&
 	 (name[0] == '-' || name[0] == '+') &&
@@ -902,7 +907,8 @@ selectors_info (char *regexp, int from_t
       ALL_MSYMBOLS (objfile, msymbol)
 	{
 	  QUIT;
-	  if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
+	  name = SYMBOL_DEMANGLED_NAME (msymbol);
+	  if (name == NULL)
 	    name = SYMBOL_NAME (msymbol);
 	  if (name &&
 	     (name[0] == '-' || name[0] == '+') &&
@@ -927,7 +933,8 @@ selectors_info (char *regexp, int from_t
 	  char *p = asel;
 
 	  QUIT;
-	  if ((name = SYMBOL_DEMANGLED_NAME (sym_arr[ix])) == NULL)
+	  name = SYMBOL_DEMANGLED_NAME (sym_arr[ix]);
+	  if (name == NULL)
 	    name = SYMBOL_NAME (sym_arr[ix]);
 	  name = strchr (name, ' ') + 1;
 	  if (p[0] && specialcmp(name, p) == 0)
@@ -958,8 +965,9 @@ compare_classes (void *a, void *b)
 {
   char *aname, *bname;
 
-  if ((aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a)) == NULL ||
-      (bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b)) == NULL)
+  aname = SYMBOL_SOURCE_NAME (*(struct symbol **) a);
+  bname = SYMBOL_SOURCE_NAME (*(struct symbol **) b);
+  if (aname == NULL || bname == NULL)
     error ("internal: compare_classes(1)");
 
   return specialcmp (aname+1, bname+1);
@@ -1009,7 +1017,8 @@ classes_info (char *regexp, int from_tty
   ALL_MSYMBOLS (objfile, msymbol)
     {
       QUIT;
-      if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
+      name = SYMBOL_DEMANGLED_NAME (msymbol);
+      if (name == NULL)
 	name = SYMBOL_NAME (msymbol);
       if (name &&
 	 (name[0] == '-' || name[0] == '+') &&
@@ -1034,7 +1043,8 @@ classes_info (char *regexp, int from_tty
       ALL_MSYMBOLS (objfile, msymbol)
 	{
 	  QUIT;
-	  if ((name = SYMBOL_DEMANGLED_NAME (msymbol)) == NULL)
+	  name = SYMBOL_DEMANGLED_NAME (msymbol);
+	  if (name == NULL)
 	    name = SYMBOL_NAME (msymbol);
 	  if (name &&
 	     (name[0] == '-' || name[0] == '+') &&
@@ -1052,7 +1062,8 @@ classes_info (char *regexp, int from_tty
 	  char *p = aclass;
 
 	  QUIT;
-	  if ((name = SYMBOL_DEMANGLED_NAME (sym_arr[ix])) == NULL)
+	  name = SYMBOL_DEMANGLED_NAME (sym_arr[ix]);
+	  if (name == NULL)
 	    name = SYMBOL_NAME (sym_arr[ix]);
 	  name += 2;
 	  if (p[0] && specialcmp(name, p) == 0)
@@ -1551,12 +1562,14 @@ print_object_command (char *args, int fr
     do_cleanups (old_chain);
   }
 
-  if (!(function = find_function_in_inferior ("_NSPrintForDebugger")))
+  function = find_function_in_inferior ("_NSPrintForDebugger");
+  if (!function)
     error ("Unable to locate _NSPrintForDebugger in child process");
 
   description = call_function_by_hand (function, 1, &object);
 
-  if ((string_addr = value_as_long (description)) == 0)
+  string_addr = value_as_long (description);
+  if (string_addr == 0)
     error ("object returns null description");
 
   read_memory (string_addr + i++, &c, 1);
@@ -1658,7 +1671,7 @@ struct objc_submethod_helper_data {
 };
 
 int 
-find_objc_msgcall_submethod_helper (PTR arg)
+find_objc_msgcall_submethod_helper (void * arg)
 {
   struct objc_submethod_helper_data *s = 
     (struct objc_submethod_helper_data *) arg;
@@ -1681,7 +1694,7 @@ find_objc_msgcall_submethod (CORE_ADDR (
   s.new_pc = new_pc;
 
   if (catch_errors (find_objc_msgcall_submethod_helper,
-		    (PTR) &s,
+		    (void *) &s,
 		    "Unable to determine target of Objective-C method call (ignoring):\n",
 		    RETURN_MASK_ALL) == 0) 
     return 1;
Index: gdb/objc-lang.h
===================================================================
RCS file: /cvs/src/src/gdb/objc-lang.h,v
retrieving revision 1.3
diff -u -p -r1.3 objc-lang.h
--- gdb/objc-lang.h	19 Sep 2002 04:12:10 -0000	1.3
+++ gdb/objc-lang.h	3 Oct 2002 02:19:44 -0000
@@ -19,9 +19,7 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#ifdef __STDC__		/* Forward decls for prototypes.  */
 struct value;
-#endif
 
 extern int objc_parse (void);		/* Defined in c-exp.y */
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARI fixes fro objc-lang.[ch]
  2002-10-02 19:42 [PATCH] ARI fixes fro objc-lang.[ch] Adam Fedor
@ 2002-10-03 16:50 ` Kevin Buettner
  2002-10-08 16:24   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2002-10-03 16:50 UTC (permalink / raw)
  To: Adam Fedor, gdb-patches

On Oct 2,  8:42pm, Adam Fedor wrote:

> 2002-10-02  Adam Fedor  <fedor@gnu.org>
> 
>          * objc-lang.c: ARI fixes. Change string.h to gdb_string.h
>          (objc_demangle): Remove assignment in if statements, free->xfree
>          (add_msglist): Likewise.
>          (end_msglist): Likewise.
>          (complare_selectors): Likewise.
>          (selectors_info): Likewise.
>          (compare_classes): Likewise.
>          (classes_info): Likewise.
>          (print_object_command): Likewise.
>          (find_objc_msgcall_submethod): PTR->void *
>          * objc-lang.h: Remove check for __STDC__

The patch looks good to me.  I think it's okay to check it in.

Regarding the format of your ChangeLog entries though...

  1) Check your ChangeLog entry indentation.  It looks to me like
     you're indenting by nine spaces.  (A single tab is usually
     used, though there are a few entries scattered about which
     use eight spaces instead.)
  2) Make sure that each sentence ends with a period.
  3) If a period does not end the line, make sure that there are
     two spaces between it and the next non-blank character.
  4) [Now I'm really picking at nits...] I'd rather see:

	(find_objc_msgcall_submethod): Replace ``PTR'' with ``void *''.

     instead of:

	(find_objc_msgcall_submethod): PTR->void *.

Kevin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARI fixes fro objc-lang.[ch]
  2002-10-03 16:50 ` Kevin Buettner
@ 2002-10-08 16:24   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2002-10-08 16:24 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: Adam Fedor, gdb-patches

Kevin Buettner wrote:
> 
> On Oct 2,  8:42pm, Adam Fedor wrote:
> 
> > 2002-10-02  Adam Fedor  <fedor@gnu.org>
> >
> >          * objc-lang.c: ARI fixes. Change string.h to gdb_string.h
> >          (objc_demangle): Remove assignment in if statements, free->xfree
> >          (add_msglist): Likewise.
> >          (end_msglist): Likewise.
> >          (complare_selectors): Likewise.
> >          (selectors_info): Likewise.
> >          (compare_classes): Likewise.
> >          (classes_info): Likewise.
> >          (print_object_command): Likewise.
> >          (find_objc_msgcall_submethod): PTR->void *
> >          * objc-lang.h: Remove check for __STDC__
> 
> The patch looks good to me.  I think it's okay to check it in.
> 
> Regarding the format of your ChangeLog entries though...
> 
>   1) Check your ChangeLog entry indentation.  It looks to me like
>      you're indenting by nine spaces.  (A single tab is usually
>      used, though there are a few entries scattered about which
>      use eight spaces instead.)
>   2) Make sure that each sentence ends with a period.
>   3) If a period does not end the line, make sure that there are
>      two spaces between it and the next non-blank character.
>   4) [Now I'm really picking at nits...] I'd rather see:
> 
>         (find_objc_msgcall_submethod): Replace ``PTR'' with ``void *''.
> 
>      instead of:
> 
>         (find_objc_msgcall_submethod): PTR->void *.

Ditto what Kevin said.  Otherwise second his approval.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-08 23:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-02 19:42 [PATCH] ARI fixes fro objc-lang.[ch] Adam Fedor
2002-10-03 16:50 ` Kevin Buettner
2002-10-08 16:24   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox