Skip to content
Snippets Groups Projects
  • Ray Strode's avatar
    03b48a39
    fdio: implement glnx_basename from scratch · 03b48a39
    Ray Strode authored
    At the top of glnx-fdio.h there's this comment:
    
    /* When we include libgen.h because we need
     * dirname() we immediately undefine
     * basename() since libgen.h defines it as
     * a macro to the XDG version which is really
     * broken. */
    
    and then it does #undef basename to try to
    gain access to non-default basename implementation.
    
    The problem is that this trick doesn't work on
    some systems:
    
    ./libglnx/glnx-fdio.h: In function 'glnx_basename':
    ./libglnx/glnx-fdio.h:46:11: error: 'basename'
    undeclared (first use in this function)
       return (basename) (path);
    
    Anyway, basename() is like 3 lines of code to
    implement, so this commit just does that instead
    of relying on glibc for it.
    03b48a39
    History
    fdio: implement glnx_basename from scratch
    Ray Strode authored
    At the top of glnx-fdio.h there's this comment:
    
    /* When we include libgen.h because we need
     * dirname() we immediately undefine
     * basename() since libgen.h defines it as
     * a macro to the XDG version which is really
     * broken. */
    
    and then it does #undef basename to try to
    gain access to non-default basename implementation.
    
    The problem is that this trick doesn't work on
    some systems:
    
    ./libglnx/glnx-fdio.h: In function 'glnx_basename':
    ./libglnx/glnx-fdio.h:46:11: error: 'basename'
    undeclared (first use in this function)
       return (basename) (path);
    
    Anyway, basename() is like 3 lines of code to
    implement, so this commit just does that instead
    of relying on glibc for it.