From: Jim Meyering Date: Sun, 23 Jul 2000 09:25:14 +0000 (+0000) Subject: (base_name): Add an assertion. X-Git-Tag: FILEUTILS-4_0x~20 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=2546495dab90deab019c7f91e89355ebef777ca3;p=thirdparty%2Fcoreutils.git (base_name): Add an assertion. --- diff --git a/lib/basename.c b/lib/basename.c index be03e609b4..5237b11b72 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -19,6 +19,8 @@ # include #endif +#include + #ifndef FILESYSTEM_PREFIX_LEN # define FILESYSTEM_PREFIX_LEN(Filename) 0 #endif @@ -61,5 +63,8 @@ base_name (char const *name) if (*base == '\0' && ISSLASH (*name) && all_slashes) --base; + /* Make sure the last byte is not a slash. */ + assert (all_slashes || *(p - 1) != '/'); + return (char *) base; }