From d19184d67aa96de07e25e8f8f6adb4f33042caa6 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Tue, 29 Jun 1993 04:37:51 +0000 Subject: [PATCH] (main): For -iwithprefix, if no include_prefix, make a default from GCC_INCLUDE_DIR. Support -iwithprefixbefore. From-SVN: r4793 --- gcc/cccp.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/gcc/cccp.c b/gcc/cccp.c index bddb9e1..259494a 100644 --- a/gcc/cccp.c +++ b/gcc/cccp.c @@ -1101,6 +1101,16 @@ main (argc, argv) with the default prefix at the front of its name. */ if (!strcmp (argv[i], "-iwithprefix")) { struct file_name_list *dirtmp; + char *prefix; + + if (include_prefix != 0) + prefix = include_prefix; + else { + prefix = savestring (GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp (prefix + strlen (prefix) - 8, "/include")) + prefix[strlen (prefix) - 7] = 0; + } dirtmp = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); @@ -1110,8 +1120,8 @@ main (argc, argv) fatal ("Directory name missing after `-iwithprefix' option"); dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) - + strlen (include_prefix) + 1); - strcpy (dirtmp->fname, include_prefix); + + strlen (prefix) + 1); + strcpy (dirtmp->fname, prefix); strcat (dirtmp->fname, argv[++i]); if (after_include == 0) @@ -1120,6 +1130,35 @@ main (argc, argv) last_after_include->next = dirtmp; last_after_include = dirtmp; /* Tail follows the last one */ } + /* Add directory to main path for includes, + with the default prefix at the front of its name. */ + if (!strcmp (argv[i], "-iwithprefixbefore")) { + struct file_name_list *dirtmp; + char *prefix; + + if (include_prefix != 0) + prefix = include_prefix; + else { + prefix = savestring (GCC_INCLUDE_DIR); + /* Remove the `include' from /usr/local/lib/gcc.../include. */ + if (!strcmp (prefix + strlen (prefix) - 8, "/include")) + prefix[strlen (prefix) - 7] = 0; + } + + dirtmp = (struct file_name_list *) + xmalloc (sizeof (struct file_name_list)); + dirtmp->next = 0; /* New one goes on the end */ + dirtmp->control_macro = 0; + if (i + 1 == argc) + fatal ("Directory name missing after `-iwithprefixbefore' option"); + + dirtmp->fname = (char *) xmalloc (strlen (argv[i+1]) + + strlen (prefix) + 1); + strcpy (dirtmp->fname, prefix); + strcat (dirtmp->fname, argv[++i]); + + append_include_chain (dirtmp, dirtmp); + } /* Add directory to end of path for includes. */ if (!strcmp (argv[i], "-idirafter")) { struct file_name_list *dirtmp; -- 2.7.4