On Fri, 18 Sept 2026 at 22:22, Dmitry Goncharov <[email protected]>
wrote:

> On Fri, Sep 18, 2026 at 4:34 PM Tim Murphy <[email protected]> wrote:
> >
> > Re build problem with discarding const in tilde_expand():
> >
> > I worked out that removing const upwards is not needed - the behaviour
> can be amended.  Perhaps alloca would be offer more performance than this
> but I'm really just trying to move on.  This just uses xstrdup to copy the
> string that is being modified for the sake of it being convenient for
> parsing;
> ...
> alloca would make the diff smaller and it is used everywhere in make.
>
> regards, Dmitry
>

Hi, you're right it's shorter - here it is:

diff --git a/src/read.c b/src/read.c
index 75e37743..81c941a6 100644
--- a/src/read.c
+++ b/src/read.c
@@ -3065,10 +3065,15 @@ tilde_expand (const char *name)
   else
     {
       struct passwd *pwent;
-      char *userend = strchr (name + 1, '/');
+      char *userend;
+      char *username = alloca(strlen(name));
+
+      strcpy(username, name+1);
+
+      userend = strchr (username, '/');
       if (userend != 0)
         *userend = '\0';
-      pwent = getpwnam (name + 1);
+      pwent = getpwnam (username);
       if (pwent != 0)
         {
           if (userend == 0)

Reply via email to