commit:     1e8c1aa5752b38209bb521578377cd2025773e62
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  6 14:34:38 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr  6 14:34:38 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=1e8c1aa5

sys-devel/binutils-config: fix -rpath and -L <arg> handling

A thinko broke skipping of arguments consisting of two entries,
resulting in very weird command lines.  Not noticed on Darwin because
for some odd reason.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 ...1-r11.ebuild => binutils-config-5.1-r12.ebuild} |  0
 sys-devel/binutils-config/files/ldwrapper.c        | 22 +++++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/sys-devel/binutils-config/binutils-config-5.1-r11.ebuild 
b/sys-devel/binutils-config/binutils-config-5.1-r12.ebuild
similarity index 100%
rename from sys-devel/binutils-config/binutils-config-5.1-r11.ebuild
rename to sys-devel/binutils-config/binutils-config-5.1-r12.ebuild

diff --git a/sys-devel/binutils-config/files/ldwrapper.c 
b/sys-devel/binutils-config/files/ldwrapper.c
index 22fbf9aba8..1aa96537d0 100644
--- a/sys-devel/binutils-config/files/ldwrapper.c
+++ b/sys-devel/binutils-config/files/ldwrapper.c
@@ -530,7 +530,7 @@ main(int argc, char *argv[])
                        char *path;
                        int pth;
                        char duplicate;
-                       int before = j - 1;
+                       int nexti = i;
 
                        /* arguments can be in many ways here:
                         * -L<path>
@@ -541,10 +541,11 @@ main(int argc, char *argv[])
                        while (*path != '\0' && isspace(*path))
                                path++;
                        if (*path == '\0') {
+                               nexti++;
                                /* no more arguments?!? skip */
-                               if (i + 1 >= argc)
+                               if (nexti >= argc)
                                        continue;
-                               path = argv[i + 1];
+                               path = argv[nexti];
                                while (*path != '\0' && isspace(*path))
                                        path++;
                        }
@@ -570,7 +571,8 @@ main(int argc, char *argv[])
                                        }
                                }
                                if (duplicate) {
-                                       j = before;
+                                       i = nexti;
+                                       j--;
                                        continue;
                                }
                                /* record path */
@@ -584,7 +586,8 @@ main(int argc, char *argv[])
                                        }
                                }
                                if (duplicate) {
-                                       j = before;
+                                       i = nexti;
+                                       j--;
                                        continue;
                                }
                                /* record path */
@@ -597,8 +600,12 @@ main(int argc, char *argv[])
                        char *path;
                        int pth;
                        char duplicate;
+                       int nexti = i + 1;
 
-                       path = argv[i + 1];
+                       /* no more arguments?!? skip */
+                       if (nexti >= argc)
+                               continue;
+                       path = argv[nexti];
                        while (*path != '\0' && isspace(*path))
                                path++;
                        /* not absolute (or empty)?!? skip */
@@ -617,7 +624,8 @@ main(int argc, char *argv[])
                                }
                        }
                        if (duplicate) {
-                               j -= 2;
+                               j--;
+                               i = nexti;
                                continue;
                        }
                        /* record path */

Reply via email to