[Mesa-dev] [PATCH v2 1/5] util: manually extract the program name from program_invocation_name

Eric Engestrom eric.engestrom at intel.com
Mon Jun 18 11:40:02 UTC 2018


On Monday, 2018-06-18 12:37:59 +0100, Eric Engestrom wrote:
> On Friday, 2018-06-15 12:56:04 +1000, Timothy Arceri wrote:
> > On 14/06/18 19:40, Eric Engestrom wrote:
> > 
> > > On Thursday, 2018-06-14 11:00:21 +1000, Timothy Arceri wrote:
> > > > Glibc has the same code to get program_invocation_short_name. However
> > > > for some reason the short name gets mangled for some wine apps.
> > > > 
> > > > For example with Google Earth VR I get:
> > > > 
> > > > program_invocation_name:
> > > > "/home/tarceri/.local/share/Steam/steamapps/common/EarthVR/Earth.exe"
> > > > 
> > > > program_invocation_short_name:
> > > > "e"
> > > > ---
> > > >   src/util/xmlconfig.c | 11 ++++++++++-
> > > >   1 file changed, 10 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
> > > > index 60a6331c86c..ad943e2ce48 100644
> > > > --- a/src/util/xmlconfig.c
> > > > +++ b/src/util/xmlconfig.c
> > > > @@ -45,7 +45,16 @@
> > > >   /* These aren't declared in any libc5 header */
> > > >   extern char *program_invocation_name, *program_invocation_short_name;
> > > >   #    endif
> > > > -#    define GET_PROGRAM_NAME() program_invocation_short_name
> > > > +static const char *
> > > > +__getProgramName()
> > > > +{
> > > > +    char * arg = strrchr(program_invocation_name, '/');
> > > > +    if (arg)
> > > > +        return arg+1;
> > > > +    else
> > > > +        return program_invocation_name;
> > > > +}
> > > > +#    define GET_PROGRAM_NAME() __getProgramName()
> > > How about:
> > > 
> > >    #include <libgen.h>
> > >    #define GET_PROGRAM_NAME() basename(program_invocation_name)
> > 
> > I'm happy to change, but I was simply staying consistent with how it is
> > defined in other places in this file.
> 
> Either is fine, I just thought as I saw this "that's basename() !", but
> I guess it doesn't really matter.
> 
> For either solution:
> Acked-by: Eric Engestrom <eric.engestrom at intel.com>

To be clear, this is just for patch 1, the rest of the series changes
stuff I don't know if it's ok to change, I'll let others decide :)


More information about the mesa-dev mailing list