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

Unified Diff: gdb/macroexp.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 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/macroexp.h ('k') | gdb/macrotab.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/macroexp.c
diff --git a/gdb/macroexp.c b/gdb/macroexp.c
index d5e4e40326301b36fb1d4cfd2cc602c08d0933f5..fa3431169ea3845832017b52b39b81a78e416047 100644
--- a/gdb/macroexp.c
+++ b/gdb/macroexp.c
@@ -113,6 +113,17 @@ free_buffer (struct macro_buffer *b)
xfree (b->text);
}
+/* Like free_buffer, but return the text as an xstrdup()d string.
+ This only exists to try to make the API relatively clean. */
+
+static char *
+free_buffer_return_text (struct macro_buffer *b)
+{
+ gdb_assert (! b->shared);
+ gdb_assert (b->size);
+ /* Nothing to do. */
+ return b->text;
+}
/* A cleanup function for macro buffers. */
static void
@@ -639,7 +650,7 @@ append_tokens_without_splicing (struct macro_buffer *dest,
stringify; it is LEN bytes long. */
static void
-stringify (struct macro_buffer *dest, char *arg, int len)
+stringify (struct macro_buffer *dest, const char *arg, int len)
{
/* Trim initial whitespace from ARG. */
while (len > 0 && macro_is_whitespace (*arg))
@@ -682,6 +693,22 @@ stringify (struct macro_buffer *dest, char *arg, int len)
dest->last_token = dest->len;
}
+/* See macroexp.h. */
+
+char *
+macro_stringify (const char *str)
+{
+ struct macro_buffer buffer;
+ int len = strlen (str);
+ char *result;
+
+ init_buffer (&buffer, len);
+ stringify (&buffer, str, len);
+ appendc (&buffer, '\0');
+
+ return free_buffer_return_text (&buffer);
+}
+
/* Expanding macros! */
« no previous file with comments | « gdb/macroexp.h ('k') | gdb/macrotab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698