Index: gdb/cli/cli-utils.c |
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c |
index 81a4acc3d803ab30a4b2e890fc494747263b41f4..80df4abdcc3be49514073dbe8802f2f2ea2627ee 100644 |
--- a/gdb/cli/cli-utils.c |
+++ b/gdb/cli/cli-utils.c |
@@ -1,6 +1,6 @@ |
/* CLI utilities. |
- Copyright (c) 2011-2012 Free Software Foundation, Inc. |
+ Copyright (C) 2011-2013 Free Software Foundation, Inc. |
This file is part of GDB. |
@@ -19,7 +19,7 @@ |
#include "defs.h" |
#include "cli/cli-utils.h" |
-#include "gdb_string.h" |
+#include <string.h> |
#include "value.h" |
#include "gdb_assert.h" |
@@ -237,8 +237,8 @@ skip_spaces_const (const char *chp) |
/* See documentation in cli-utils.h. */ |
-char * |
-skip_to_space (char *chp) |
+const char * |
+skip_to_space_const (const char *chp) |
{ |
if (chp == NULL) |
return NULL; |
@@ -261,30 +261,39 @@ remove_trailing_whitespace (const char *start, char *s) |
/* See documentation in cli-utils.h. */ |
char * |
-extract_arg (char **arg) |
+extract_arg_const (const char **arg) |
{ |
- char *result, *copy; |
+ const char *result; |
if (!*arg) |
return NULL; |
/* Find the start of the argument. */ |
- *arg = skip_spaces (*arg); |
+ *arg = skip_spaces_const (*arg); |
if (!**arg) |
return NULL; |
result = *arg; |
/* Find the end of the argument. */ |
- *arg = skip_to_space (*arg + 1); |
+ *arg = skip_to_space_const (*arg + 1); |
if (result == *arg) |
return NULL; |
- copy = xmalloc (*arg - result + 1); |
- memcpy (copy, result, *arg - result); |
- copy[*arg - result] = '\0'; |
+ return savestring (result, *arg - result); |
+} |
+ |
+/* See documentation in cli-utils.h. */ |
+ |
+char * |
+extract_arg (char **arg) |
+{ |
+ const char *arg_const = *arg; |
+ char *result; |
- return copy; |
+ result = extract_arg_const (&arg_const); |
+ *arg += arg_const - *arg; |
+ return result; |
} |
/* See documentation in cli-utils.h. */ |