MISC(3X) MISC(3X)
NAME
make_string, make_pathname, argv_copy_and_clear, basename(1,3,3 File::Basename), dirname -
miscellaneous functions
SYNOPSIS
#include "misc.h"
char *make_string( count, ... )
unsigned count ;
char *make_pathname( count, ... )
unsigned count ;
char **argv_copy_and_clear( argv, start, count )
char **argv ;
int start, count ;
char *dirname( path )
char *path ;
char *basename(1,3,3 File::Basename)( path )
char *path ;
DESCRIPTION
This library contain miscellaneous functions, hence the name.
make_string() creates a string(3,n) by catenating the list of strings passed
as arguments. count indicates how many strings there are. Strings
that are NULL pointers are ignored. make_string() returns malloc'ed
memory.
make_pathname() creates a pathname by catenating the list of pathname
components passed as arguments and inserting slashes between them.
count indicates how many components there are. make_pathname() returns
malloc'ed memory.
argv_copy_and_clear() creates a new argv array of size count, and fills
it with the contents of argv from start up to start+count-1. The orig-
inal argv entries in(1,8) that range are cleared by filling them with SPA-
CEs.
dirname() returns in(1,8) a malloced string(3,n) containing all but the last of
component of path. There are 2 special cases: first when the path is
"/", dirname() will return "/", and second, when the path does not con-
tain any '/', dirname() will return ".".
basename(1,3,3 File::Basename)() returns a pointer to the last component of path.
RETURN VALUES
make_string() returns a pointer to the new string. It returns NULL if(3,n)
count is 0.
make_pathname() returns a pointer to the new pathname. It returns NULL
if(3,n) count is 0.
argv_copy_and_clear() returns the new argv array. It returns NULL if(3,n)
malloc fails to allocate more memory.
dirname() returns a new string(3,n) or NULL if(3,n) malloc fails to allocate more
memory.
basename(1,3,3 File::Basename)() returns a pointer to the last component of path.
BUGS
The behavior of dirname() and basename(1,3,3 File::Basename)() is undefined if(3,n) they are given
a zero-length string.
25 January 1992 MISC(3X)