# Install manpages.
#
-install-man install-manpages: install-mingwrt-manpages
-format_manpage = sed "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $2/"
-
vpath %.man ${mingwrt_srcdir}/man
-basename.$(man3ext) dirname.$(man3ext): %.$(man3ext): dirname.man
- $(call format_manpage,$*,$(man3ext)) $< > $@
-
-mingwrt-man$(man3ext): basename.$(man3ext) dirname.$(man3ext)
-
+install-man install-manpages: install-mingwrt-manpages
+mingwrt-man$(man3ext): $(addsuffix .$(man3ext),basename dirname)
install-mingwrt-manpages: mandir mingwrt-man3
+
mingwrt-man%:
$(call mkinstalldirs,,${man$*dir})
$(call INSTALL_DATA,$^,${man$*dir})
$(RM) $^
+%: %.man
+ $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $@
+
+format_manpage = sed \
+ -e "s/%PAGEREF%/`echo $1 | tr a-z A-Z` $(2:.%=%) `date -r $3 +%d-%b-%Y`/"
+
+basename.$(man3ext): export reference_manpage = dirname.$(man3ext).man
+basename.$(man3ext): %: %.mancopy-recursive
+
+%.mancopy-recursive:
+ $(MAKE) --no-print-directory $*.mancopy
+
+%.mancopy: $(reference_manpage)
+ $(call format_manpage,$(basename $*),$(suffix $*),$<) $< > $*
+
# Undo Installation
# -----------------
-.\" t
-.TH DIRNAME 3 04-Jan-2007 MinGW "Programmer's Reference Manual"
+'\" t
+.\" vim: ft=nroff
+.TH %PAGEREF% MinGW "Programmer's Reference Manual"
.
.SH NAME
.
-.BR dirname ,\0 basename
+.BR \%dirname ,\0 \%basename
\- parse path name components
.
.
.SH DESCRIPTION
.
The
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions parse a null\-terminated path name string,
and split it into its
.B directory name
.B directory separator
characters,
which,
-for this MS\-Windows(\(tm) implementation,
+for this MS\-Windows implementation,
are the characters
.RB \(dq / \(dq
and
.RB (\(dq : \(dq),
the first two characters of
.I path
-are interpreted as an MS\-Windows(\(tm) drive designator,
+are interpreted as an MS\-Windows drive designator,
which will be included in the
.B directory name
component of
.
.PP
In normal usage,
-.B dirname
+.BR \%dirname ()
returns a pointer to a string representing the path name component of
.IR path ,
up to but not including the rightmost directory separator,
while
-.B basename
+.BR \%basename ()
returns a pointer to the component following this separator.
Any trailing directory separators present in
.I path
are disregarded,
when determining the rightmost separator,
and, in the case of the return value from
-.BR dirname ,
+.BR \%dirname (),
any internal sequences of recurring separator characters
are each reduced to a single such character.
.
.PP
If
.I path
-contains no MS\-Windows(\(tm) drive designator,
+contains no MS\-Windows drive designator,
and no directory separator character,
then
-.B dirname
+.BR \%dirname ()
returns the string
.RB \(dq . \(dq,
and
-.B basename
+.BR \%basename ()
returns a copy of
.IR path.
If
.I path
-does commence with an MS\-Windows(\(tm) drive designator,
+does commence with an MS\-Windows drive designator,
but contains no directory separators,
then
-.B dirname
+.BR \%dirname ()
returns the string
.RB \(dq d:. \(dq,
where
.RB \(dq d: \(dq
represents the drive designator,
while
-.B basename
+.BR \%basename ()
returns a copy of
.IR path ,
with its initial two characters,
is a NULL pointer,
or is a pointer to an empty string,
then both
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
return the string
.RB \(dq . \(dq.
.
or the string
.RB \(dq \e \(dq,
both
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
return the string
.RB \(dq / \(dq,
or the string
two directory separator characters,
which must be similar,
then
-.B dirname
+.BR \%dirname ()
will preserve these two characters in the returned path name.
This construct does not affect the string returned by
-.BR basename ,
+.BR \%basename (),
neither is this behaviour replicated by
-.BR dirname ,
+.BR \%dirname (),
if
.I path
-includes an MS\-Windows(\(tm) drive designator.
+includes an MS\-Windows drive designator.
.
.PP
In the special case,
is specified as
.I exactly
two identical directory separator characters,
-with no MS\-Windows(\(tm) drive designator,
+with no MS\-Windows drive designator,
and no following path name,
-.B dirname
+.BR \%dirname ()
returns
.I path
unchanged;
-.B basename
+.BR \%basename ()
normalises the return string to only a single character,
either
.RB \(dq / \(dq
.
.PP
Concatenating the string returned by
-.BR dirname ,
+.BR \%dirname (),
a
.RB \(dq / \(dq
or a
.RB \(dq \e \(dq,
and the string returned by
-.B basename
+.BR \%basename ()
yields a complete path name.
.
.PP
The
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions conform generally to SUSv3,
extended to accommodate the handling of
.RB \(dq / \(dq
and
.RB \(dq \e \(dq
as alternative directory separator characters,
-and also to accommodate the likelihood of MS\-Windows(\(tm)
+and also to accommodate the likelihood of MS\-Windows
drive designators appearing in any path name specification.
The example,
which follows,
.SH EXAMPLE
.
To verify the behaviour of the
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions,
the test program defines the following function:\(em
.
.RE
.PP
This illustrates the correct use of the
-.B dirname
+.BR \%dirname ()
and the
-.B basename
+.BR \%basename ()
functions,
with copies of the original
.I path
string being passed in the function calls.
Note that the return values from each function are used immediately,
in the
-.B printf
+.BR printf ()
call,
and the temporary copies of
.I path
.
.PP
Calling this example function illustrates the effect of each of the
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions,
for various values of
.IR path .
.
.PP
Similarly,
-for the case where path names are expressed using the MS\-Windows(\(tm)
+for the case where path names are expressed using the MS\-Windows
.RB \(dq \e \(dq
directory separator notation,
calling the example function displays:\(em
.
.PP
and,
-when an MS\-Windows(\(tm) drive designator is also specified,
+when an MS\-Windows drive designator is also specified,
this becomes:\(em
.RS
.TS
two directory separator characters,
and also that this special handling is suppressed
when these two characters are dissimilar,
-or when an MS\-Windows(\(tm) drive designator is specified:\(em
+or when an MS\-Windows drive designator is specified:\(em
.RS
.TS
tab(!);
.SH RETURN VALUE
.
The
-.B dirname
+.BR \%dirname ()
function returns a pointer to a null terminated string,
which represents the directory path component of the passed
.I path
.
.PP
The
-.B basename
+.BR \%basename ()
function
returns a pointer to a null terminated string,
which represents the rightmost element of the passed
with all trailing directory separator characters removed.
.
.PP
-If any MS\-Windows(\(tm) drive designator is specified in the input
+If any MS\-Windows drive designator is specified in the input
.I path
string,
it is included in the return value of the
-.B dirname
+.BR \%dirname ()
function,
but not in that of the
-.B basename
+.BR \%basename ()
function.
.
.
.SH CAVEATS AND BUGS
.
The
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions may modify the
.I path
string passed to them.
since the
.I path
argument may be modified by the
-.B dirname
+.BR \%dirname ()
or the
-.B basename
+.BR \%basename ()
function call,
if you wish to preserve the original content of
.IR path ,
which may be overwritten on a subsequent function call.
.PP
Although the
-.B dirname
+.BR \%dirname ()
and
-.B basename
+.BR \%basename ()
functions parse path name strings,
they are basically just
.I string
functions.
-The presence of an MS\-Windows(\(tm) drive designator is determined
+The presence of an MS\-Windows drive designator is determined
by the appearance of a colon
.RB (\(dq : \(dq)
as the second character of the
.
.SH AUTHOR
.
-This manpage was written for the MinGW implementation of the
-.B dirname
+This manpage was written by \%Keith\ Marshall,
+\%<keithmarshall@users.sourceforge.net>, to document the
+.BR \%basename ()
and
-.B basename
-functions by Keith\ Marshall,
-<keithmarshall@users.sourceforge.net>.
-It may copied, modified and redistributed,
+.BR \%dirname ()
+functions as they have been implemented for the MinGW.org Project.
+It may be copied, modified and redistributed,
without restriction of copyright,
provided this acknowledgement of contribution by
the original author remains unchanged.