Removed basename() calls.
Relying on glibc's version of basename() hurts portability, and the POSIX version has stupid behaviour (modifying the argument in certain situations). So don't use it at all anymore. We're also not defining _GNU_SOURCE anymore to try to prevent future use of glibc-specific features.
This commit is contained in:
parent
cdcb3a391d
commit
60927a881c
4
Makefile
4
Makefile
@ -23,7 +23,9 @@ CFLAGS ?= -O2
|
||||
CFLAGS += -std=c99 -fpic -Wall -Wwrite-strings -Wnonnull
|
||||
|
||||
CPPFLAGS += \
|
||||
-D_GNU_SOURCE \
|
||||
-D_ATFILE_SOURCE \
|
||||
-D_POSIX_C_SOURCE \
|
||||
-D_BSD_SOURCE \
|
||||
-DVERSION=\"$(VERSION)\" \
|
||||
-DPKG_API="__attribute__ ((visibility(\"default\")))"
|
||||
|
||||
|
@ -94,11 +94,13 @@ static PkgPackage *
|
||||
create_from_filename (const char *path)
|
||||
{
|
||||
PkgPackage *pkg;
|
||||
char buf[PATH_MAX], *hash, *dash, *suffix;
|
||||
char buf[PATH_MAX], *slash, *hash, *dash, *suffix;
|
||||
const char *file;
|
||||
size_t len, name_len, version_len, release_len;
|
||||
|
||||
file = basename (path);
|
||||
slash = strrchr (path, '/');
|
||||
file = slash ? slash + 1 : path;
|
||||
|
||||
len = strlen (file);
|
||||
|
||||
if (len < strlen (".pkg.tar.") || len >= sizeof (buf))
|
||||
|
@ -32,7 +32,10 @@ int pkgrm (int argc, char **argv);
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
progname = basename (argv[0]);
|
||||
char *slash;
|
||||
|
||||
slash = strrchr (argv[0], '/');
|
||||
progname = slash ? slash + 1 : argv[0];
|
||||
|
||||
if (!strcmp (progname, "pkginfo"))
|
||||
return pkginfo (argc, argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user