This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH] Check for existence of asprintf and vasprintf
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: Mike Frysinger <vapier at gentoo dot org>, <elfutils-devel at sourceware dot org>
- Date: Fri, 24 Feb 2017 10:42:08 +0100
- Subject: Re: [PATCH] Check for existence of asprintf and vasprintf
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=ulf dot hermann at qt dot io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Wv4X9sqamHp8CDlGOJb6DNpOTy+f2gtoat9+0kJwy1A=; b=AE0nYywAOpWUcz9uX5lL9g+G5XIXyzk316OrCJA7bK5e6WbtwQqD9C8/CQN7qqte6dnrB8A2XrfJLVJFG6nepqgWXLfJijotCRxTcdPiXzYy/IHb1xmuMEraUFB3OSYoucR0YS1oPzEzkNY7R/yvds+FB+afnnMqEFY1pAp4zDk=
- References: <email@example.com> <20170222144004.GV28432@vapier> <firstname.lastname@example.org> <20170222163249.GW28432@vapier> <email@example.com> <20170222170356.GX28432@vapier> <firstname.lastname@example.org> <20170222185737.GE28432@vapier> <email@example.com> <20170223185129.GU28432@vapier>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
and the GNU variant is a whopping two lines of code:
char *base = strrchr(path, '/');
return base ? base + 1 : (char *)path;
and we get straight to an example of why your solutions don't scale.
your replacement is wrong. and ironically, it's wrong on Windows,
which is the whole point of your work. '/' is not the path sep used
on every system out there. it also does not properly handle systems
(such as Windows) that have filesystem prefixes like C:\.
Both basename variants' documentations only talk about '/'. This is not
the place where we should handle windows directory separators. We should
either already expect forward slashes as input (with drive names as
first path component, as e.g. msys does it), or convert them early on.
And the implementation I've given above is the same code as in glibc.
However, I will actually prepare some patches to replace missing
functions using gnulib rather than my own implementations.