Subject: CVS commit: basesrc/lib/libc/gen
To: None <source-changes@netbsd.org>
From: Jason R Thorpe <thorpej@netbsd.org>
List: source-changes
Date: 10/17/2002 05:06:05
Module Name:	basesrc
Committed By:	thorpej
Date:		Thu Oct 17 02:06:04 UTC 2002

Modified Files:
	basesrc/lib/libc/gen: basename.3 basename.c dirname.3 dirname.c

Log Message:
Change basename(3) and dirname(3) to return a pointer to static
storage, rather than modifying their input arguments.  While not
reentrant, this is explcitly allowed by IEEE Std 1003.1-2001 (which
allows either behavior, stating that it is implementation-dependent).

The new semantics are considered less hostile/more useful by most programs
which use basename(3) and/or dirname(3) (several programs in the NetBSD
tree reimplement basename()/dirname() themselves to avoid modification
of the input argument).

This new implementation truncates results to PATH_MAX.  The Std does
not address this in the static storage case.  However since PATH_MAX
is the maximum pathname length in the Std, this should not be a problem
in practice.  Nontheless, it is noted in the BUGS section.

See the basename(3)/dirname(3) regression tests in src/regress/lib/libc.

Inspired by discussion with Niels Provos, related to PR 18647.


To generate a diff of this commit:
cvs rdiff -r1.7 -r1.8 basesrc/lib/libc/gen/basename.3 \
    basesrc/lib/libc/gen/dirname.3
cvs rdiff -r1.4 -r1.5 basesrc/lib/libc/gen/basename.c
cvs rdiff -r1.5 -r1.6 basesrc/lib/libc/gen/dirname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.