changeset 703:caa09587c3fb

Fix compat basename() to handle paths with no slashes. Thanks to Frank Teo
author Matt Johnston <matt@ucc.asn.au>
date Tue, 19 Mar 2013 20:04:55 +0800
parents 48e173a0c52b
children 523be406edc4
files compat.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Tue Mar 19 19:47:29 2013 +0800
+++ b/compat.c	Tue Mar 19 20:04:55 2013 +0800
@@ -193,6 +193,10 @@
 char *basename(const char *path) {
 
 	char *foo = strrchr(path, '/');
+	if (!foo)
+	{
+		return path;
+	}
 	return ++foo;
 }