summaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-09 13:48:05 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-09 13:48:05 +0000
commit2838513a2cbe3dabed7f5e5e229099de9618833d (patch)
treec6c4257bc6daf8e297d1d5763c98b90120605f30 /gcc/opts-common.c
parent39b6232eee3cf86162d5a58982017499e0f815eb (diff)
downloadgcc-2838513a2cbe3dabed7f5e5e229099de9618833d.tar.gz
2013-03-09 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 196572 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@196574 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 95ca5841acc..9d186a759cb 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -692,6 +692,40 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
return result;
}
+/* Obstack for option strings. */
+
+struct obstack opts_obstack;
+
+/* Like libiberty concat, but allocate using opts_obstack. */
+
+char *
+opts_concat (const char *first, ...)
+{
+ char *newstr, *end;
+ size_t length = 0;
+ const char *arg;
+ va_list ap;
+
+ /* First compute the size of the result and get sufficient memory. */
+ va_start (ap, first);
+ for (arg = first; arg; arg = va_arg (ap, const char *))
+ length += strlen (arg);
+ newstr = XOBNEWVEC (&opts_obstack, char, length + 1);
+ va_end (ap);
+
+ /* Now copy the individual pieces to the result string. */
+ va_start (ap, first);
+ for (arg = first, end = newstr; arg; arg = va_arg (ap, const char *))
+ {
+ length = strlen (arg);
+ memcpy (end, arg, length);
+ end += length;
+ }
+ *end = '\0';
+ va_end (ap);
+ return newstr;
+}
+
/* Decode command-line options (ARGC and ARGV being the arguments of
main) into an array, setting *DECODED_OPTIONS to a pointer to that
array and *DECODED_OPTIONS_COUNT to the number of entries in the