Add a new basename_of() function.

This commit is contained in:
jkh 1994-11-17 10:51:51 +00:00
parent 197446d284
commit bedd10c589
2 changed files with 15 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* $Id: lib.h,v 1.9 1994/09/29 13:19:42 jkh Exp $ */
/* $Id: lib.h,v 1.10 1994/10/04 16:07:50 jkh Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@ -109,6 +109,7 @@ char *copy_string(char *);
Boolean suffix(char *, char *);
void nuke_suffix(char *);
void str_lowercase(char *);
char *basename_of(char *);
/* File */
Boolean fexists(char *);

View File

@ -24,6 +24,18 @@ static const char *rcsid = "$Id";
#include "lib.h"
/* Return the filename portion of a path */
char *
basename_of(char *str)
{
char *basename = str + strlen(str) - 1;
while (basename != str && basename[-1] != '/')
--basename;
return basename;
}
/* Get a string parameter as a file spec or as a "contents follow -" spec */
char *
get_dash_string(char **str)
{
@ -36,6 +48,7 @@ get_dash_string(char **str)
return *str;
}
/* Rather Obvious */
char *
copy_string(char *str)
{