Message ID | CAHjoi4eR+n=qQ8vZAKwwgLiPSFfrBWHRHwYNvfJn4y0F9EqO7g@mail.gmail.com |
---|---|
State | Changes Requested |
Headers | show |
On Tuesday 28 February 2012 10:36:22 Keith Mok wrote: > There is no GNU basename support in MacOS. > Use generic POSIX basename defined in libgen.h instead. alternative: define a non-braindead version in compiler.h: static const char *_basename(const char *filename) { const char *p = strrchr(filename, '/'); return p ? p + 1 : filename; } /* Avoid issues with clobbering C library def */ #undef basename #define basename(x) _basename(x) -mike
Dear Keith Mok, In message <CAHjoi4eR+n=qQ8vZAKwwgLiPSFfrBWHRHwYNvfJn4y0F9EqO7g@mail.gmail.com> you wrote: > There is no GNU basename support in MacOS. > Use generic POSIX basename defined in libgen.h instead. ... > int fp, ep; > const char *prg; > + char *prog_pathname; > > - prg = basename(argv[0]); > + prog_pathname = strdup(argv[0]); > + prg = basename(prog_pathname); free() missing. Actually the strdup should not be needed at all, as we don't use argv[0] after that - at least we shouldn't. The remaining "usage(argv[0]);" should be fixed instead. Besides - I agree with Mike's comment how your MacOS issue should be fixed. Best regards, Wolfgang Denk
Hi Wolfgang, > Besides - I agree with Mike's comment how your MacOS issue should be > fixed. But will Mike's fix break Windows user which cross-compile u-boot ? The path separator is '\' instead of '/' Regards, Keith
Dear Keith Mok, In message <CAHjoi4dV3gP1XqoH5vUy_NJAFouAx3HbTt-bHqfP2nrt-2o39w@mail.gmail.com> you wrote: > > > Besides - I agree with Mike's comment how your MacOS issue should be > > fixed. > But will Mike's fix break Windows user which cross-compile u-boot ? > The path separator is '\' instead of '/' I'm not a windows expert (actually I'm proud of never having worked with Windows in my whole life), but I think it is only the command line interface that insists of using '\\' (because DOS used '/' as option switch). Best regards, Wolfgang Denk
Dear Keith, please keep the mailing list on Cc: In message <CAHjoi4eRTxXJKwg_XsEvtELNQmDzfqHzZiRO=MY-jfVYvDUrgA@mail.gmail.com> you wrote: > > > I'm not a windows expert (actually I'm proud of never having worked > > with Windows in my whole life), but I think it is only the command > > line interface that insists of using '\\' (because DOS used '/' as > > option switch). > So should we stick on using libgen provided basename to maximize the > compatibility of different platforms ? I don't think so. As the comment in "/usr/include/libgen.h" suggests, we should use "the weird XPG version of this function" only when really needed. And we definitely don;t need to do that on GNU/Linux systems. Best regards, Wolfgang Denk
diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index f781731..8b49723 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -25,9 +25,6 @@ * MA 02111-1307 USA */ -/* We want the GNU version of basename() */ -#define _GNU_SOURCE - #include <errno.h> #include <fcntl.h> #include <stdio.h> @@ -35,6 +32,7 @@ #include <string.h> #include <unistd.h> #include <compiler.h> +#include <libgen.h> #include <sys/types.h> #include <sys/stat.h> @@ -85,8 +83,10 @@ int main(int argc, char **argv) int fp, ep; const char *prg; + char *prog_pathname; - prg = basename(argv[0]); + prog_pathname = strdup(argv[0]); + prg = basename(prog_pathname); /* Turn off getopt()'s internal error message */ opterr = 0;
There is no GNU basename support in MacOS. Use generic POSIX basename defined in libgen.h instead. Signed-off-by: Keith Mok <ek9852@gmail.com> --- tools/mkenvimage.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)