summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-10-21 21:14:45 -0400
committermidipix <writeonce@midipix.org>2018-10-21 21:49:54 -0400
commit8902815c5f5a9f16224140245c0b800d12455735 (patch)
treee1e80429161ff5d8b01c0a515c10e904a014e200 /src
parent19ea755e63f55baeaea746573df75373736a0033 (diff)
downloadslibtool-8902815c5f5a9f16224140245c0b800d12455735.tar.bz2
slibtool-8902815c5f5a9f16224140245c0b800d12455735.tar.xz
slbt_exec_link_finalize_argument_vector(): refactor argument removal logic.
Diffstat (limited to 'src')
-rw-r--r--src/logic/slbt_exec_link.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index 25a9412..ed45d67 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -634,9 +634,11 @@ static int slbt_exec_link_finalize_argument_vector(
arg = *parg;
dot = strrchr(arg,'.');
+ /* object input argument? */
if (dot && (!strcmp(dot,".o") || !strcmp(dot,".lo"))) {
*oarg++ = *parg++;
+ /* --whole-archive input argument? */
} else if ((arg[0] == '-')
&& (arg[1] == 'W')
&& (arg[2] == 'l')
@@ -650,52 +652,54 @@ static int slbt_exec_link_finalize_argument_vector(
*oarg++ = *parg++;
*oarg++ = *parg++;
+ /* local archive input argument? */
} else if (dot && !strcmp(dot,arsuffix)) {
*oarg++ = *parg++;
- } else {
- /* not a -l argument? */
- if ((parg[0][0] != '-') || (parg[0][1] != 'l')) {
- if (!strncmp(*parg,"-USLIBTOOL_PLACEHOLDER_",23))
- parg++;
- else
- *aarg++ = *parg++;
-
- } else {
- /* find the previus occurence of this -l argument */
- for (rarg=0, larg=&aarg[-1]; !rarg && (larg>=aargv); larg--)
- if (!strcmp(*larg,*parg))
- rarg = larg;
+ /* -l argument? */
+ } else if ((parg[0][0] == '-') && (parg[0][1] == 'l')) {
+ /* find the previous occurence of this -l argument */
+ for (rarg=0, larg=&aarg[-1]; !rarg && (larg>=aargv); larg--)
+ if (!strcmp(*larg,*parg))
+ rarg = larg;
- /* first occurence of this specific -l argument? */
- if (!rarg) {
- *aarg++ = *parg++;
+ /* first occurence of this specific -l argument? */
+ if (!rarg) {
+ *aarg++ = *parg++;
- } else {
- larg = rarg;
-
- /* if all -l arguments following the previous */
- /* occurence had already appeared before the */
- /* previous argument, then the current */
- /* occurence is redundant. */
-
- for (darg=&larg[1]; rarg && darg<aarg; darg++) {
- /* only test -l arguments */
- if ((darg[0][0] == '-') && (darg[0][1] == 'l')) {
- for (rarg=0, earg=aargv; !rarg && earg<larg; earg++)
- if (!strcmp(*earg,*darg))
- rarg = darg;
- }
+ } else {
+ larg = rarg;
+
+ /* if all -l arguments following the previous */
+ /* occurence had already appeared before the */
+ /* previous argument, then the current */
+ /* occurence is redundant. */
+
+ for (darg=&larg[1]; rarg && darg<aarg; darg++) {
+ /* only test -l arguments */
+ if ((darg[0][0] == '-') && (darg[0][1] == 'l')) {
+ for (rarg=0, earg=aargv; !rarg && earg<larg; earg++)
+ if (!strcmp(*earg,*darg))
+ rarg = darg;
}
+ }
- /* final verdict: repeated -l argument? */
- if (rarg)
- parg++;
+ /* final verdict: repeated -l argument? */
+ if (rarg) {
+ parg++;
- else
- *aarg++ = *parg++;
+ } else {
+ *aarg++ = *parg++;
}
}
+
+ /* placeholder argument? */
+ } else if (!strncmp(*parg,"-USLIBTOOL_PLACEHOLDER_",23)) {
+ parg++;
+
+ /* all other arguments */
+ } else {
+ *aarg++ = *parg++;
}
}