aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2012-07-05 01:00:43 +0000
committerHui Zhu <teawater@gmail.com>2012-07-05 01:00:43 +0000
commite6f0bce70d56cee13a0bf5ca4f72687b3203e6c9 (patch)
treedccf8f6903d9ed86ce0dd6e0edb41fcb08d9de3d /gdb/cli
parent38401e4002fa0741e2933f84e260f2a35cac533e (diff)
downloadgdb-e6f0bce70d56cee13a0bf5ca4f72687b3203e6c9.zip
gdb-e6f0bce70d56cee13a0bf5ca4f72687b3203e6c9.tar.gz
gdb-e6f0bce70d56cee13a0bf5ca4f72687b3203e6c9.tar.bz2
2012-07-05 Hui Zhu <hui_zhu@mentor.com>
* breakpoint.c (check_for_argument): Move to file cli/cli-utils.c. * cli/cli-utils.c (check_for_argument): New function. * cli/cli-utils.h (check_for_argument): Ditto.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-utils.c14
-rw-r--r--gdb/cli/cli-utils.h6
2 files changed, 20 insertions, 0 deletions
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 3239a46..81a4acc 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -286,3 +286,17 @@ extract_arg (char **arg)
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;
+}
diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h
index 5f8a91d..9fb12ba 100644
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -114,4 +114,10 @@ extern char *remove_trailing_whitespace (const char *start, char *s);
extern char *extract_arg (char **arg);
+/* A helper function that looks for an argument at the start of a
+ string. The argument must also either be at the end of the string,
+ or be followed by whitespace. Returns 1 if it finds the argument,
+ 0 otherwise. If the argument is found, it updates *STR. */
+extern int check_for_argument (char **str, char *arg, int arg_len);
+
#endif /* CLI_UTILS_H */