* configure.tgt (powerpc-*-elf, et al): Define targ_extra_libpath.
[deliverable/binutils-gdb.git] / gdb / cli / cli-utils.c
index 2cce06897a10f6a1a3bcc5579501fdd4e221c8e6..81a4acc3d803ab30a4b2e890fc494747263b41f4 100644 (file)
@@ -1,6 +1,6 @@
 /* CLI utilities.
 
-   Copyright (c) 2011 Free Software Foundation, Inc.
+   Copyright (c) 2011-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -223,6 +223,18 @@ skip_spaces (char *chp)
   return chp;
 }
 
+/* A const-correct version of the above.  */
+
+const char *
+skip_spaces_const (const char *chp)
+{
+  if (chp == NULL)
+    return NULL;
+  while (*chp && isspace (*chp))
+    chp++;
+  return chp;
+}
+
 /* See documentation in cli-utils.h.  */
 
 char *
@@ -234,3 +246,57 @@ skip_to_space (char *chp)
     chp++;
   return chp;
 }
+
+/* See documentation in cli-utils.h.  */
+
+char *
+remove_trailing_whitespace (const char *start, char *s)
+{
+  while (s > start && isspace (*(s - 1)))
+    --s;
+
+  return s;
+}
+
+/* See documentation in cli-utils.h.  */
+
+char *
+extract_arg (char **arg)
+{
+  char *result, *copy;
+
+  if (!*arg)
+    return NULL;
+
+  /* Find the start of the argument.  */
+  *arg = skip_spaces (*arg);
+  if (!**arg)
+    return NULL;
+  result = *arg;
+
+  /* Find the end of the argument.  */
+  *arg = skip_to_space (*arg + 1);
+
+  if (result == *arg)
+    return NULL;
+
+  copy = xmalloc (*arg - result + 1);
+  memcpy (copy, result, *arg - result);
+  copy[*arg - result] = '\0';
+
+  return copy;
+}
+
+/* See documentation in cli-utils.h.  */
+
+int
+check_for_argument (char **str, char *arg, int arg_len)
+{
+  if (strncmp (*str, arg, arg_len) == 0
+      && ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len])))
+    {
+      *str += arg_len;
+      return 1;
+    }
+  return 0;
+}
This page took 0.023871 seconds and 4 git commands to generate.