Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: gdb/cli/cli-utils.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/cli/cli-utils.h ('k') | gdb/coff-pe-read.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. */
« no previous file with comments | « gdb/cli/cli-utils.h ('k') | gdb/coff-pe-read.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698