This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[obish] Eliminate some of those STREQNs


Hello,

The attached eliminates some of the remaining STREQN references. Note that it only eliminates those that gcov (run over the testsuite) identified as being executed. That way I figure I'm on safe ground :-)

I've also attached a grep over the GCOV files that lists the STREQNs that didn't get converted. If anyone is interested in improving GDB's test coverage ... :-)

committed,
Andrew
2003-11-06  Andrew Cagney  <cagney@redhat.com>

	* valops.c (destructor_name_p): Replace STREQN with strncmp.
	* top.c (command_line_input): Ditto.
	* objc-exp.y (yylex): Ditto.
	* minsyms.c (prim_record_minimal_symbol_and_info): Ditto.
	* jv-exp.y (yylex): Ditto.
	* f-exp.y (yylex): Ditto.
	* event-top.c (command_line_handler): Ditto.
	* environ.c (get_in_environ): Ditto.
	(set_in_environ): Ditto.
	* dwarfread.c (handle_producer): Ditto.
	* dbxread.c (process_one_symbol): Ditto.
	* c-typeprint.c (c_type_print_base): Ditto.
	* c-exp.y (yylex): Ditto.

Index: mi/ChangeLog
2003-11-06  Andrew Cagney  <cagney@redhat.com>

	* mi-cmd-var.c (mi_cmd_var_set_format): 

Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.23
diff -u -r1.23 c-exp.y
--- c-exp.y	25 Sep 2003 16:50:38 -0000	1.23
+++ c-exp.y	6 Nov 2003 21:23:30 -0000
@@ -1340,7 +1340,7 @@
   tokstart = lexptr;
   /* See if it is a special token of length 3.  */
   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
-    if (STREQN (tokstart, tokentab3[i].operator, 3))
+    if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
       {
 	lexptr += 3;
 	yylval.opcode = tokentab3[i].opcode;
@@ -1349,7 +1349,7 @@
 
   /* See if it is a special token of length 2.  */
   for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
-    if (STREQN (tokstart, tokentab2[i].operator, 2))
+    if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
       {
 	lexptr += 2;
 	yylval.opcode = tokentab2[i].opcode;
@@ -1645,52 +1645,52 @@
   switch (namelen)
     {
     case 8:
-      if (STREQN (tokstart, "unsigned", 8))
+      if (strncmp (tokstart, "unsigned", 8) == 0)
 	return UNSIGNED;
       if (current_language->la_language == language_cplus
-	  && STREQN (tokstart, "template", 8))
+	  && strncmp (tokstart, "template", 8) == 0)
 	return TEMPLATE;
-      if (STREQN (tokstart, "volatile", 8))
+      if (strncmp (tokstart, "volatile", 8) == 0)
 	return VOLATILE_KEYWORD;
       break;
     case 6:
-      if (STREQN (tokstart, "struct", 6))
+      if (strncmp (tokstart, "struct", 6) == 0)
 	return STRUCT;
-      if (STREQN (tokstart, "signed", 6))
+      if (strncmp (tokstart, "signed", 6) == 0)
 	return SIGNED_KEYWORD;
-      if (STREQN (tokstart, "sizeof", 6))      
+      if (strncmp (tokstart, "sizeof", 6) == 0)
 	return SIZEOF;
-      if (STREQN (tokstart, "double", 6))      
+      if (strncmp (tokstart, "double", 6) == 0)
 	return DOUBLE_KEYWORD;
       break;
     case 5:
       if (current_language->la_language == language_cplus)
         {
-          if (STREQN (tokstart, "false", 5))
+          if (strncmp (tokstart, "false", 5) == 0)
             return FALSEKEYWORD;
-          if (STREQN (tokstart, "class", 5))
+          if (strncmp (tokstart, "class", 5) == 0)
             return CLASS;
         }
-      if (STREQN (tokstart, "union", 5))
+      if (strncmp (tokstart, "union", 5) == 0)
 	return UNION;
-      if (STREQN (tokstart, "short", 5))
+      if (strncmp (tokstart, "short", 5) == 0)
 	return SHORT;
-      if (STREQN (tokstart, "const", 5))
+      if (strncmp (tokstart, "const", 5) == 0)
 	return CONST_KEYWORD;
       break;
     case 4:
-      if (STREQN (tokstart, "enum", 4))
+      if (strncmp (tokstart, "enum", 4) == 0)
 	return ENUM;
-      if (STREQN (tokstart, "long", 4))
+      if (strncmp (tokstart, "long", 4) == 0)
 	return LONG;
       if (current_language->la_language == language_cplus)
           {
-            if (STREQN (tokstart, "true", 4))
+            if (strncmp (tokstart, "true", 4) == 0)
               return TRUEKEYWORD;
           }
       break;
     case 3:
-      if (STREQN (tokstart, "int", 3))
+      if (strncmp (tokstart, "int", 3) == 0)
 	return INT_KEYWORD;
       break;
     default:
Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.28
diff -u -r1.28 c-typeprint.c
--- c-typeprint.c	14 Sep 2003 16:32:12 -0000	1.28
+++ c-typeprint.c	6 Nov 2003 21:23:30 -0000
@@ -859,10 +859,11 @@
 	      QUIT;
 	      /* Don't print out virtual function table.  */
 	      /* HP ANSI C++ case */
-	      if (TYPE_HAS_VTABLE (type) && (STREQN (TYPE_FIELD_NAME (type, i), "__vfp", 5)))
+	      if (TYPE_HAS_VTABLE (type)
+		  && (strncmp (TYPE_FIELD_NAME (type, i), "__vfp", 5) == 0))
 		continue;
 	      /* Other compilers */
-	      if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
+	      if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
 		  && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
 		continue;
 
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.57
diff -u -r1.57 dbxread.c
--- dbxread.c	6 Oct 2003 19:27:12 -0000	1.57
+++ dbxread.c	6 Nov 2003 21:23:31 -0000
@@ -3169,12 +3169,12 @@
 		  int l = colon_pos - name;
 
 		  m = lookup_minimal_symbol_by_pc (last_pc_address);
-		  if (m && STREQN (DEPRECATED_SYMBOL_NAME (m), name, l)
+		  if (m && strncmp (DEPRECATED_SYMBOL_NAME (m), name, l) == 0
 		      && DEPRECATED_SYMBOL_NAME (m)[l] == '\0')
 		    /* last_pc_address was in this function */
 		    valu = SYMBOL_VALUE (m);
 		  else if (m && DEPRECATED_SYMBOL_NAME (m + 1)
-			   && STREQN (DEPRECATED_SYMBOL_NAME (m + 1), name, l)
+			   && strncmp (DEPRECATED_SYMBOL_NAME (m + 1), name, l) == 0
 			   && DEPRECATED_SYMBOL_NAME (m + 1)[l] == '\0')
 		    /* last_pc_address was in last function */
 		    valu = SYMBOL_VALUE (m + 1);
Index: dwarfread.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarfread.c,v
retrieving revision 1.30
diff -u -r1.30 dwarfread.c
--- dwarfread.c	12 Sep 2003 18:40:16 -0000	1.30
+++ dwarfread.c	6 Nov 2003 21:23:32 -0000
@@ -1810,7 +1810,7 @@
   else
     {
       processing_gcc_compilation =
-	STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER));
+	strncmp (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)) == 0;
     }
 
   /* Select a demangling style if we can identify the producer and if
Index: environ.c
===================================================================
RCS file: /cvs/src/src/gdb/environ.c,v
retrieving revision 1.8
diff -u -r1.8 environ.c
--- environ.c	16 Sep 2003 18:56:35 -0000	1.8
+++ environ.c	6 Nov 2003 21:23:32 -0000
@@ -106,7 +106,7 @@
   char *s;
 
   for (; (s = *vector) != NULL; vector++)
-    if (STREQN (s, var, len) && s[len] == '=')
+    if (strncmp (s, var, len) == 0 && s[len] == '=')
       return &s[len + 1];
 
   return 0;
@@ -123,7 +123,7 @@
   char *s;
 
   for (i = 0; (s = vector[i]) != NULL; i++)
-    if (STREQN (s, var, len) && s[len] == '=')
+    if (strncmp (s, var, len) == 0 && s[len] == '=')
       break;
 
   if (s == 0)
Index: event-top.c
===================================================================
RCS file: /cvs/src/src/gdb/event-top.c,v
retrieving revision 1.30
diff -u -r1.30 event-top.c
--- event-top.c	21 Sep 2003 01:26:44 -0000	1.30
+++ event-top.c	6 Nov 2003 21:23:32 -0000
@@ -702,7 +702,7 @@
 #define SERVER_COMMAND_LENGTH 7
   server_command =
     (p - linebuffer > SERVER_COMMAND_LENGTH)
-    && STREQN (linebuffer, "server ", SERVER_COMMAND_LENGTH);
+    && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
   if (server_command)
     {
       /* Note that we don't set `line'.  Between this and the check in
Index: f-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/f-exp.y,v
retrieving revision 1.13
diff -u -r1.13 f-exp.y
--- f-exp.y	25 Sep 2003 16:50:38 -0000	1.13
+++ f-exp.y	6 Nov 2003 21:23:32 -0000
@@ -944,8 +944,8 @@
     { 
       for (i = 0; boolean_values[i].name != NULL; i++)
 	{
-	  if STREQN (tokstart, boolean_values[i].name,
-		    strlen (boolean_values[i].name))
+	  if (strncmp (tokstart, boolean_values[i].name,
+		       strlen (boolean_values[i].name)) == 0)
 	    {
 	      lexptr += strlen (boolean_values[i].name); 
 	      yylval.lval = boolean_values[i].value; 
@@ -957,7 +957,7 @@
   /* See if it is a special .foo. operator */
   
   for (i = 0; dot_ops[i].operator != NULL; i++)
-    if (STREQN (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)))
+    if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0)
       {
 	lexptr += strlen (dot_ops[i].operator);
 	yylval.opcode = dot_ops[i].opcode;
@@ -1114,8 +1114,8 @@
   /* Catch specific keywords.  */
   
   for (i = 0; f77_keywords[i].operator != NULL; i++)
-    if (STREQN(tokstart, f77_keywords[i].operator,
-               strlen(f77_keywords[i].operator)))
+    if (strncmp (tokstart, f77_keywords[i].operator,
+		 strlen(f77_keywords[i].operator)) == 0)
       {
 	/* 	lexptr += strlen(f77_keywords[i].operator); */ 
 	yylval.opcode = f77_keywords[i].opcode;
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.16
diff -u -r1.16 jv-exp.y
--- jv-exp.y	25 Sep 2003 16:50:38 -0000	1.16
+++ jv-exp.y	6 Nov 2003 21:23:33 -0000
@@ -872,7 +872,7 @@
   tokstart = lexptr;
   /* See if it is a special token of length 3.  */
   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
-    if (STREQN (tokstart, tokentab3[i].operator, 3))
+    if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
       {
 	lexptr += 3;
 	yylval.opcode = tokentab3[i].opcode;
@@ -881,7 +881,7 @@
 
   /* See if it is a special token of length 2.  */
   for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
-    if (STREQN (tokstart, tokentab2[i].operator, 2))
+    if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
       {
 	lexptr += 2;
 	yylval.opcode = tokentab2[i].opcode;
@@ -1167,9 +1167,9 @@
 	}
       break;
     case 3:
-      if (STREQN (tokstart, "int", 3))
+      if (strncmp (tokstart, "int", 3) == 0)
 	return INT;
-      if (STREQN (tokstart, "new", 3))
+      if (strncmp (tokstart, "new", 3) == 0)
 	return NEW;
       break;
     default:
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.36
diff -u -r1.36 minsyms.c
--- minsyms.c	21 Oct 2003 22:56:38 -0000	1.36
+++ minsyms.c	6 Nov 2003 21:23:33 -0000
@@ -586,7 +586,7 @@
 	const char *tempstring = name;
 	if (tempstring[0] == get_symbol_leading_char (objfile->obfd))
 	  ++tempstring;
-	if (STREQN (tempstring, "__gnu_compiled", 14))
+	if (strncmp (tempstring, "__gnu_compiled", 14) == 0)
 	  return (NULL);
       }
     }
Index: objc-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/objc-exp.y,v
retrieving revision 1.14
diff -u -r1.14 objc-exp.y
--- objc-exp.y	25 Sep 2003 16:50:38 -0000	1.14
+++ objc-exp.y	6 Nov 2003 21:23:33 -0000
@@ -1592,7 +1592,7 @@
       if (STREQN (tokstart, "unsigned", 8))
 	return UNSIGNED;
       if (current_language->la_language == language_cplus
-	  && STREQN (tokstart, "template", 8))
+	  && strncmp (tokstart, "template", 8) == 0)
 	return TEMPLATE;
       if (STREQN (tokstart, "volatile", 8))
 	return VOLATILE_KEYWORD;
@@ -1609,7 +1609,7 @@
       break;
     case 5:
       if ((current_language->la_language == language_cplus)
-	  && STREQN (tokstart, "class", 5))
+	  && strncmp (tokstart, "class", 5) == 0)
 	return CLASS;
       if (STREQN (tokstart, "union", 5))
 	return UNION;
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.83
diff -u -r1.83 top.c
--- top.c	5 Nov 2003 23:50:12 -0000	1.83
+++ top.c	6 Nov 2003 21:23:34 -0000
@@ -1266,7 +1266,7 @@
 #define SERVER_COMMAND_LENGTH 7
   server_command =
     (p - linebuffer > SERVER_COMMAND_LENGTH)
-    && STREQN (linebuffer, "server ", SERVER_COMMAND_LENGTH);
+    && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
   if (server_command)
     {
       /* Note that we don't set `line'.  Between this and the check in
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.117
diff -u -r1.117 valops.c
--- valops.c	2 Oct 2003 20:28:30 -0000	1.117
+++ valops.c	6 Nov 2003 21:23:34 -0000
@@ -2137,7 +2137,7 @@
 	len = strlen (dname);
       else
 	len = cp - dname;
-      if (strlen (name + 1) != len || !STREQN (dname, name + 1, len))
+      if (strlen (name + 1) != len || strncmp (dname, name + 1, len) != 0)
 	error ("name of destructor must equal name of class");
       else
 	return 1;
Index: mi/mi-cmd-var.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-var.c,v
retrieving revision 1.16
diff -u -r1.16 mi-cmd-var.c
--- mi/mi-cmd-var.c	2 Feb 2003 06:24:04 -0000	1.16
+++ mi/mi-cmd-var.c	6 Nov 2003 21:23:35 -0000
@@ -189,15 +189,15 @@
 
   len = strlen (formspec);
 
-  if (STREQN (formspec, "natural", len))
+  if (strncmp (formspec, "natural", len) == 0)
     format = FORMAT_NATURAL;
-  else if (STREQN (formspec, "binary", len))
+  else if (strncmp (formspec, "binary", len) == 0)
     format = FORMAT_BINARY;
-  else if (STREQN (formspec, "decimal", len))
+  else if (strncmp (formspec, "decimal", len) == 0)
     format = FORMAT_DECIMAL;
-  else if (STREQN (formspec, "hexadecimal", len))
+  else if (strncmp (formspec, "hexadecimal", len) == 0)
     format = FORMAT_HEXADECIMAL;
-  else if (STREQN (formspec, "octal", len))
+  else if (strncmp (formspec, "octal", len) == 0)
     format = FORMAT_OCTAL;
   else
     error ("mi_cmd_var_set_format: Unknown display format: must be: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"");
dbxread.c.gcov:2528:      ######    	  if (STREQN (tempstring, "__gnu_compiled", 14))
dwarf2read.c.gcov:3026:      ######    		      if (STREQN (fieldname, vptr_name, strlen (vptr_name) - 1)
dwarfread.c.gcov:1805:      ######      if (STREQN (producer, GCC_PRODUCER, strlen (GCC_PRODUCER)))
dwarfread.c.gcov:1823:      ######          if (STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)))
dwarfread.c.gcov:1831:      ######          else if (STREQN (producer, LCC_PRODUCER, strlen (LCC_PRODUCER)))
environ.c.gcov:173:      ######          if (STREQN (s, var, len) && s[len] == '=')
jv-exp.y.gcov:1136:      ######          if (STREQN (tokstart, "boolean", 7))
jv-exp.y.gcov:1140:      ######          if (STREQN (tokstart, "double", 6))      
jv-exp.y.gcov:1144:      ######          if (STREQN (tokstart, "short", 5))
jv-exp.y.gcov:1146:      ######          if (STREQN (tokstart, "false", 5))
jv-exp.y.gcov:1151:      ######          if (STREQN (tokstart, "super", 5))
jv-exp.y.gcov:1153:      ######          if (STREQN (tokstart, "float", 5))
jv-exp.y.gcov:1157:      ######          if (STREQN (tokstart, "long", 4))
jv-exp.y.gcov:1159:      ######          if (STREQN (tokstart, "byte", 4))
jv-exp.y.gcov:1161:      ######          if (STREQN (tokstart, "char", 4))
jv-exp.y.gcov:1163:      ######          if (STREQN (tokstart, "true", 4))
m2-exp.y.gcov:838:      ######         if(STREQN(tokentab2[i].name, tokstart, 2))
m2-exp.y.gcov:995:      ######         if(namelen == strlen(keytab[i].keyw) && STREQN(tokstart,keytab[i].keyw,namelen))
m2-exp.y.gcov:1069:      ######           if(STREQN(tokstart,"TRUE",4))
m2-exp.y.gcov:1074:      ######           else if(STREQN(tokstart,"FALSE",5))
objc-exp.y.gcov:1268:      ######        if (STREQN (tokstart, tokentab3[i].operator, 3))
objc-exp.y.gcov:1277:      ######        if (STREQN (tokstart, tokentab2[i].operator, 2))
objc-exp.y.gcov:1592:      ######          if (STREQN (tokstart, "unsigned", 8))
objc-exp.y.gcov:1597:      ######          if (STREQN (tokstart, "volatile", 8))
objc-exp.y.gcov:1601:      ######          if (STREQN (tokstart, "struct", 6))
objc-exp.y.gcov:1603:      ######          if (STREQN (tokstart, "signed", 6))
objc-exp.y.gcov:1605:      ######          if (STREQN (tokstart, "sizeof", 6))      
objc-exp.y.gcov:1607:      ######          if (STREQN (tokstart, "double", 6))      
objc-exp.y.gcov:1614:      ######          if (STREQN (tokstart, "union", 5))
objc-exp.y.gcov:1616:      ######          if (STREQN (tokstart, "short", 5))
objc-exp.y.gcov:1618:      ######          if (STREQN (tokstart, "const", 5))
objc-exp.y.gcov:1622:      ######          if (STREQN (tokstart, "enum", 4))
objc-exp.y.gcov:1624:      ######          if (STREQN (tokstart, "long", 4))
objc-exp.y.gcov:1628:      ######          if (STREQN (tokstart, "int", 3))
p-typeprint.c.gcov:142:      ######      int is_constructor = STREQN (physname, "__ct__", 6);
p-typeprint.c.gcov:143:      ######      int is_destructor = STREQN (physname, "__dt__", 6);
p-typeprint.c.gcov:562:      ######    	      if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
p-typeprint.c.gcov:640:      ######    		  int is_constructor = STREQN (physname, "__ct__", 6);
p-typeprint.c.gcov:641:      ######    		  int is_destructor = STREQN (physname, "__dt__", 6);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]