This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfc] Replace STRCMP() with strcmp()
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [rfc] Replace STRCMP() with strcmp()
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 18 Jan 2001 12:56:13 +1100
Comments?
Unlike STREQ() and STREQN(), this is one is a text substitution so
should be ok :-)
Andrew
Thu Jan 18 12:48:04 2001 Andrew Cagney <cagney@b1.cygnus.com>
* defs.h (STRCMP): Delete macro.
* objfiles.c (objfile_relocate): Replace STRCMP with call to
strcmp.
* symtab.c (lookup_partial_symbol, lookup_block_symbol): Ditto.
* symfile.c (compare_symbols): Ditto.
* standalone.c (open): Ditto.
* remote-es.c (verify_break): Ditto.
* cli/cli-decode.c (add_cmd, add_show_from_set): Ditto.
* symfile.c (compare_psymbols): Delete comment refering to STRCMP.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.33
diff -p -r1.33 defs.h
*** defs.h 2000/12/15 01:01:46 1.33
--- defs.h 2001/01/18 01:54:18
*************** typedef bfd_vma CORE_ADDR;
*** 148,154 ****
issue is found that we spend the effort on algorithmic
optimizations than micro-optimizing.'' J.T. */
- #define STRCMP(a,b) (*(a) == *(b) ? strcmp ((a), (b)) : (int)*(a) - (int)*(b))
#define STREQ(a,b) (*(a) == *(b) ? !strcmp ((a), (b)) : 0)
#define STREQN(a,b,c) (*(a) == *(b) ? !strncmp ((a), (b), (c)) : 0)
--- 148,153 ----
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.12
diff -p -r1.12 objfiles.c
*** objfiles.c 2000/12/15 01:01:48 1.12
--- objfiles.c 2001/01/18 01:54:24
*************** objfile_relocate (struct objfile *objfil
*** 584,590 ****
else if (SYMBOL_CLASS (sym) == LOC_CONST
&& SYMBOL_NAMESPACE (sym) == LABEL_NAMESPACE
! && STRCMP (SYMBOL_NAME (sym), MIPS_EFI_SYMBOL_NAME) == 0)
ecoff_relocate_efi (sym, ANOFFSET (delta,
s->block_line_section));
#endif
--- 584,590 ----
else if (SYMBOL_CLASS (sym) == LOC_CONST
&& SYMBOL_NAMESPACE (sym) == LABEL_NAMESPACE
! && strcmp (SYMBOL_NAME (sym), MIPS_EFI_SYMBOL_NAME) == 0)
ecoff_relocate_efi (sym, ANOFFSET (delta,
s->block_line_section));
#endif
Index: remote-es.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-es.c,v
retrieving revision 1.7
diff -p -r1.7 remote-es.c
*** remote-es.c 2000/12/15 01:01:48 1.7
--- remote-es.c 2001/01/18 01:54:26
*************** verify_break (int vec)
*** 1151,1157 ****
{
memory_error (status, memaddress);
}
! return (STRCMP (instr, buf));
}
return (-1);
}
--- 1151,1157 ----
{
memory_error (status, memaddress);
}
! return (strcmp (instr, buf));
}
return (-1);
}
Index: standalone.c
===================================================================
RCS file: /cvs/src/src/gdb/standalone.c,v
retrieving revision 1.3
diff -p -r1.3 standalone.c
*** standalone.c 2000/07/30 01:48:27 1.3
--- standalone.c 2001/01/18 01:54:29
*************** open (char *filename, int modes)
*** 145,151 ****
for (next = files_start; *(int *) next; next += *(int *) next)
{
! if (!STRCMP (next + 4, filename))
{
sourcebeg = next + 4 + strlen (next + 4) + 1;
sourcebeg = (char *) (((int) sourcebeg + 3) & (-4));
--- 145,151 ----
for (next = files_start; *(int *) next; next += *(int *) next)
{
! if (!strcmp (next + 4, filename))
{
sourcebeg = next + 4 + strlen (next + 4) + 1;
sourcebeg = (char *) (((int) sourcebeg + 3) & (-4));
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.22
diff -p -r1.22 symfile.c
*** symfile.c 2000/12/15 01:01:50 1.22
--- symfile.c 2001/01/18 01:54:36
*************** compare_symbols (const PTR s1p, const PT
*** 213,219 ****
s1 = (struct symbol **) s1p;
s2 = (struct symbol **) s2p;
! return (STRCMP (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2)));
}
/*
--- 213,219 ----
s1 = (struct symbol **) s1p;
s2 = (struct symbol **) s2p;
! return (strcmp (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2)));
}
/*
*************** compare_psymbols (const PTR s1p, const P
*** 260,277 ****
}
else
{
- /* Note: I replaced the STRCMP line (commented out below)
- * with a simpler "strcmp()" which compares the 2 strings
- * from the beginning. (STRCMP is a macro which first compares
- * the initial characters, then falls back on strcmp).
- * The reason is that the STRCMP line was tickling a C compiler
- * bug on HP-UX 10.30, which is avoided with the simpler
- * code. The performance gain from the more complicated code
- * is negligible, given that we have already checked the
- * initial 2 characters above. I reported the compiler bug,
- * and once it is fixed the original line can be put back. RT
- */
- /* return ( STRCMP (st1 + 2, st2 + 2)); */
return (strcmp (st1, st2));
}
}
--- 260,265 ----
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.25
diff -p -r1.25 symtab.c
*** symtab.c 2000/12/15 01:01:50 1.25
--- symtab.c 2001/01/18 01:54:42
*************** lookup_partial_symbol (struct partial_sy
*** 1004,1010 ****
{
do_linear_search = 1;
}
! if (STRCMP (SYMBOL_SOURCE_NAME (*center), name) >= 0)
{
top = center;
}
--- 1004,1010 ----
{
do_linear_search = 1;
}
! if (strcmp (SYMBOL_SOURCE_NAME (*center), name) >= 0)
{
top = center;
}
*************** lookup_block_symbol (register const stru
*** 1237,1243 ****
{
top = inc;
}
! else if (STRCMP (SYMBOL_SOURCE_NAME (sym), name) < 0)
{
bot = inc;
}
--- 1237,1243 ----
{
top = inc;
}
! else if (strcmp (SYMBOL_SOURCE_NAME (sym), name) < 0)
{
bot = inc;
}
Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.5
diff -p -r1.5 cli-decode.c
*** cli-decode.c 2000/12/15 01:01:51 1.5
--- cli-decode.c 2001/01/18 01:54:47
*************** add_cmd (char *name, enum command_class
*** 67,73 ****
delete_cmd (name, list);
! if (*list == NULL || STRCMP ((*list)->name, name) >= 0)
{
c->next = *list;
*list = c;
--- 67,73 ----
delete_cmd (name, list);
! if (*list == NULL || strcmp ((*list)->name, name) >= 0)
{
c->next = *list;
*list = c;
*************** add_cmd (char *name, enum command_class
*** 75,81 ****
else
{
p = *list;
! while (p->next && STRCMP (p->next->name, name) <= 0)
{
p = p->next;
}
--- 75,81 ----
else
{
p = *list;
! while (p->next && strcmp (p->next->name, name) <= 0)
{
p = p->next;
}
*************** add_show_from_set (struct cmd_list_eleme
*** 312,318 ****
else
fprintf_unfiltered (gdb_stderr, "GDB internal error: Bad docstring for set command\n");
! if (*list == NULL || STRCMP ((*list)->name, showcmd->name) >= 0)
{
showcmd->next = *list;
*list = showcmd;
--- 312,318 ----
else
fprintf_unfiltered (gdb_stderr, "GDB internal error: Bad docstring for set command\n");
! if (*list == NULL || strcmp ((*list)->name, showcmd->name) >= 0)
{
showcmd->next = *list;
*list = showcmd;
*************** add_show_from_set (struct cmd_list_eleme
*** 320,326 ****
else
{
p = *list;
! while (p->next && STRCMP (p->next->name, showcmd->name) <= 0)
{
p = p->next;
}
--- 320,326 ----
else
{
p = *list;
! while (p->next && strcmp (p->next->name, showcmd->name) <= 0)
{
p = p->next;
}