Index: gdb/cli/cli-utils.c |
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c |
index a7b27187ec84f389fb2446fddb4a76e355f03682..81a4acc3d803ab30a4b2e890fc494747263b41f4 100644 |
--- a/gdb/cli/cli-utils.c |
+++ b/gdb/cli/cli-utils.c |
@@ -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 * |
@@ -245,3 +257,46 @@ remove_trailing_whitespace (const char *start, char *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; |
+} |