diff options
author | DJ Delorie <dj@redhat.com> | 2001-07-05 16:09:34 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2001-07-05 16:09:34 -0400 |
commit | 0259b07a28f451df6f509ac9d0be1cfef134487f (patch) | |
tree | 9448fd5a37ea4742eed3de53532273939ceb2e89 /gcc/gcc.c | |
parent | 081ca317a420381a89a6d502990389df1c56cb16 (diff) | |
download | gcc-0259b07a28f451df6f509ac9d0be1cfef134487f.zip gcc-0259b07a28f451df6f509ac9d0be1cfef134487f.tar.gz gcc-0259b07a28f451df6f509ac9d0be1cfef134487f.tar.bz2 |
gcc.c (TARGET_OPTION_TRANSLATE_TABLE): New.
* gcc.c (TARGET_OPTION_TRANSLATE_TABLE): New.
(translate_options): If the above is defined, use it to map
given options to new options.
* doc/tm.texi: Document it.
From-SVN: r43787
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 65 |
1 files changed, 64 insertions, 1 deletions
@@ -952,6 +952,18 @@ struct option_map option_map[] = {"--", "-f", "*j"} }; + +#ifdef TARGET_OPTION_TRANSLATE_TABLE +static struct { + const char *option_found; + const char *replacements; +} target_option_translations[] = +{ + TARGET_OPTION_TRANSLATE_TABLE, + { 0, 0 } +}; +#endif + /* Translate the options described by *ARGCP and *ARGVP. Make a new vector and store it back in *ARGVP, and store its length in *ARGVC. */ @@ -964,8 +976,9 @@ translate_options (argcp, argvp) int i; int argc = *argcp; const char *const *argv = *argvp; + int newvsize = (argc + 2) * 2 * sizeof (const char *); const char **newv = - (const char **) xmalloc ((argc + 2) * 2 * sizeof (const char *)); + (const char **) xmalloc (newvsize); int newindex = 0; i = 0; @@ -973,6 +986,56 @@ translate_options (argcp, argvp) while (i < argc) { +#ifdef TARGET_OPTION_TRANSLATE_TABLE + int tott_idx; + + for (tott_idx = 0; + target_option_translations[tott_idx].option_found; + tott_idx++) + { + if (strcmp (target_option_translations[tott_idx].option_found, + argv[i]) == 0) + { + int spaces = 1; + const char *sp; + char *np; + + for (sp = target_option_translations[tott_idx].replacements; + *sp; sp++) + { + if (*sp == ' ') + spaces ++; + } + + newvsize += spaces * sizeof (const char *); + newv = (const char **) xrealloc (newv, newvsize); + + sp = target_option_translations[tott_idx].replacements; + np = (char *) xmalloc (strlen (sp) + 1); + strcpy (np, sp); + + while (1) + { + while (*np == ' ') + np++; + if (*np == 0) + break; + newv[newindex++] = np; + while (*np != ' ' && *np) + np++; + if (*np == 0) + break; + *np++ = 0; + } + + i ++; + break; + } + } + if (target_option_translations[tott_idx].option_found) + continue; +#endif + /* Translate -- options. */ if (argv[i][0] == '-' && argv[i][1] == '-') { |