warning from dirname also valid for basename

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

warning from dirname also valid for basename

Han Boetes
Hi,

While porting mg I found out that the POSIX implementation of
basename which is provided with glibc also modifies the string
passed to basename; the trailing / is removed.

        http://www.opengroup.org/onlinepubs/007908799/xsh/basename.html

        The basename() function may modify the string pointed to
        by path, and may return a pointer to static storage that
        may then be overwritten by a subsequent call to
        basename().


       
Index: lib/libc/gen/basename.3
===================================================================
RCS file: /cvs/src/lib/libc/gen/basename.3,v
retrieving revision 1.18
diff -u -p -r1.18 basename.3
--- lib/libc/gen/basename.3 30 Jul 2003 22:29:32 -0000 1.18
+++ lib/libc/gen/basename.3 12 Nov 2005 10:39:48 -0000
@@ -67,6 +67,13 @@ The path component to be returned was la
 .Fn basename
 returns a pointer to internal static storage space that will be overwritten
 by subsequent calls.
+.Pp
+Other vendor implementations of
+.Fn basename
+may modify the contents of the string passed to
+.Fn basename ;
+this should be taken into account when writing code which calls this function
+if portability is desired.
 .Sh SEE ALSO
 .Xr basename 1 ,
 .Xr dirname 1 ,




# Han

Reply | Threaded
Open this post in threaded view
|

Re: warning from dirname also valid for basename

Jason McIntyre-2
On Sat, Nov 12, 2005 at 12:00:11PM +0100, Han Boetes wrote:

>
> Index: lib/libc/gen/basename.3
> ===================================================================
> RCS file: /cvs/src/lib/libc/gen/basename.3,v
> retrieving revision 1.18
> diff -u -p -r1.18 basename.3
> --- lib/libc/gen/basename.3 30 Jul 2003 22:29:32 -0000 1.18
> +++ lib/libc/gen/basename.3 12 Nov 2005 10:39:48 -0000
> @@ -67,6 +67,13 @@ The path component to be returned was la
>  .Fn basename
>  returns a pointer to internal static storage space that will be overwritten
>  by subsequent calls.
> +.Pp
> +Other vendor implementations of
> +.Fn basename
> +may modify the contents of the string passed to
> +.Fn basename ;
> +this should be taken into account when writing code which calls this function
> +if portability is desired.
>  .Sh SEE ALSO
>  .Xr basename 1 ,
>  .Xr dirname 1 ,
>

hi. fix taken - thanks!
jmc