New common function "startswith"
[deliverable/binutils-gdb.git] / gdb / guile / scm-type.c
index 4f46139241f8483dc509ebac533c7db0246a3045..d21a7aec8c1eaa4d5705a2be32286ccbe8a25358 100644 (file)
@@ -713,7 +713,7 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector,
       n1 = 0;
     }
 
-  if (n2 < n1 - 1)
+  if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1.  */
     {
       gdbscm_out_of_range_error (func_name, SCM_ARG3,
                                 scm_cons (scm_from_long (n1),
@@ -1216,11 +1216,11 @@ tyscm_lookup_typename (const char *type_name, const struct block *block)
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      if (!strncmp (type_name, "struct ", 7))
+      if (startswith (type_name, "struct "))
        type = lookup_struct (type_name + 7, NULL);
-      else if (!strncmp (type_name, "union ", 6))
+      else if (startswith (type_name, "union "))
        type = lookup_union (type_name + 6, NULL);
-      else if (!strncmp (type_name, "enum ", 5))
+      else if (startswith (type_name, "enum "))
        type = lookup_enum (type_name + 5, NULL);
       else
        type = lookup_typename (current_language, get_current_arch (),
This page took 0.026575 seconds and 4 git commands to generate.