summaryrefslogtreecommitdiffhomepage
path: root/compat.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2013-03-19 20:04:55 +0800
committerMatt Johnston <matt@ucc.asn.au>2013-03-19 20:04:55 +0800
commit6270ed2f8a0b6ce13bb244766e4fd9e46ae5002b (patch)
treed04e6447d7139f83c4c89280e748fca31a8e86e9 /compat.c
parent80e77b5e6d1ca8487baa1d80068b654b73443cd8 (diff)
Fix compat basename() to handle paths with no slashes. Thanks to Frank Teo
Diffstat (limited to 'compat.c')
-rw-r--r--compat.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compat.c b/compat.c
index 7e0c1ac..a689a14 100644
--- a/compat.c
+++ b/compat.c
@@ -193,6 +193,10 @@ int daemon(int nochdir, int noclose) {
char *basename(const char *path) {
char *foo = strrchr(path, '/');
+ if (!foo)
+ {
+ return path;
+ }
return ++foo;
}