summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-02-10 20:16:07 +0000
committermidipix <writeonce@midipix.org>2024-02-10 20:18:34 +0000
commitd4e0f6ee0cf86349c5b7420e50c1f2063ae9545b (patch)
tree7d0bcac80d56a63d68bdc7738cd198e40c1b1638 /src
parente035ec7d042843bd0af392660a77b091cb80cc7c (diff)
downloadslibtool-d4e0f6ee0cf86349c5b7420e50c1f2063ae9545b.tar.bz2
slibtool-d4e0f6ee0cf86349c5b7420e50c1f2063ae9545b.tar.xz
compile mode: argument vector: de-duplicate header search directory arguments.
Diffstat (limited to 'src')
-rw-r--r--src/logic/slbt_exec_compile.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c
index e619c0e..522d1fe 100644
--- a/src/logic/slbt_exec_compile.c
+++ b/src/logic/slbt_exec_compile.c
@@ -48,6 +48,7 @@ static int slbt_exec_compile_finalize_argument_vector(
char ** cap;
char ** src;
char ** dst;
+ char ** cmp;
char * ccwrap;
/* vector size */
@@ -102,13 +103,38 @@ static int slbt_exec_compile_finalize_argument_vector(
base++;
}
- /* join all other args */
+ /* join all other args, starting with de-duplicated -I arguments */
src = aargv;
cap = aarg;
dst = &base[1];
- for (; src<cap; )
- *dst++ = *src++;
+ for (; src<cap; ) {
+ if (((*src)[0] == '-') && ((*src)[1] == 'I')) {
+ cmp = &base[1];
+
+ for (; cmp && cmp<dst; ) {
+ if (!strcmp(*src,*cmp)) {
+ cmp = 0;
+ } else {
+ cmp++;
+ }
+ }
+
+ if (cmp)
+ *dst++ = *src;
+ }
+
+ src++;
+ }
+
+ src = aargv;
+
+ for (; src<cap; ) {
+ if (((*src)[0] != '-') || ((*src)[1] != 'I'))
+ *dst++ = *src;
+
+ src++;
+ }
/* properly null-terminate argv, accounting for redundant arguments */
*dst = 0;