]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/c-typeprint.c
New common function "startswith"
[thirdparty/binutils-gdb.git] / gdb / c-typeprint.c
index 64279c86eb6c9d43b20beae69d2ccf291f6debc5..421b72014865e17521b142f907aeb12a88546a79 100644 (file)
@@ -544,7 +544,7 @@ is_type_conversion_operator (struct type *type, int i, int j)
      some other way, feel free to rewrite this function.  */
   const char *name = TYPE_FN_FIELDLIST_NAME (type, i);
 
-  if (strncmp (name, "operator", 8) != 0)
+  if (!startswith (name, "operator"))
     return 0;
 
   name += 8;
@@ -560,9 +560,9 @@ is_type_conversion_operator (struct type *type, int i, int j)
     /* If this doesn't look like the start of an identifier, then it
        isn't a type conversion operator.  */
     return 0;
-  else if (strncmp (name, "new", 3) == 0)
+  else if (startswith (name, "new"))
     name += 3;
-  else if (strncmp (name, "delete", 6) == 0)
+  else if (startswith (name, "delete"))
     name += 6;
   else
     /* If it doesn't look like new or delete, it's a type conversion
@@ -933,7 +933,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
           enum}" tag for unnamed struct/union/enum's, which we don't
           want to print.  */
        if (TYPE_TAG_NAME (type) != NULL
-           && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+           && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
          {
            /* When printing the tag name, we are still effectively
               printing in the outer context, hence the use of FLAGS
@@ -1345,7 +1345,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
          tag for unnamed struct/union/enum's, which we don't
          want to print.  */
       if (TYPE_TAG_NAME (type) != NULL
-         && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+         && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
        {
          print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
          if (show > 0)