diff options
| author | Rui Paulo <rpaulo@FreeBSD.org> | 2010-09-26 12:52:23 +0000 |
|---|---|---|
| committer | Rui Paulo <rpaulo@FreeBSD.org> | 2010-09-26 12:52:23 +0000 |
| commit | 08a11c1f7c3a4bac9113a410c8bb1eddcc85d210 (patch) | |
| tree | 95305ac33ce84dd76b708da7d5bca07d2739cef2 /lib | |
| parent | 0adc931073ec55b34f7b24eb167075e3919e2ac6 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/gen/Makefile.inc | 1 | ||||
| -rw-r--r-- | lib/libc/gen/Symbol.map | 1 | ||||
| -rw-r--r-- | lib/libc/gen/basename.3 | 20 | ||||
| -rw-r--r-- | lib/libc/gen/basename.c | 24 |
4 files changed, 13 insertions, 33 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index d6b403ef375f..d04dd7502057 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -77,7 +77,6 @@ MAN+= alarm.3 arc4random.3 \ MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 \ arc4random.3 arc4random_buf.3 arc4random.3 arc4random_uniform.3 -MLINKS+=basename.3 basename_r.3 MLINKS+=ctermid.3 ctermid_r.3 MLINKS+=devname.3 devname_r.3 MLINKS+=devname.3 fdevname.3 diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index a3ea75b0b018..4c19a3de26a5 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -366,7 +366,6 @@ FBSD_1.1 { }; FBSD_1.2 { - basename_r; getpagesizes; }; diff --git a/lib/libc/gen/basename.3 b/lib/libc/gen/basename.3 index 4a3743a8634a..33a0a717d910 100644 --- a/lib/libc/gen/basename.3 +++ b/lib/libc/gen/basename.3 @@ -27,7 +27,7 @@ .\" $OpenBSD: basename.3,v 1.12 2000/04/18 03:01:25 aaron Exp $ .\" $FreeBSD$ .\" -.Dd October 6, 2009 +.Dd October 12, 2006 .Dt BASENAME 3 .Os .Sh NAME @@ -37,8 +37,6 @@ .In libgen.h .Ft char * .Fn basename "const char *path" -.Ft char * -.Fn basename_r "const char *path" "char *bname" .Sh DESCRIPTION The .Fn basename @@ -60,12 +58,6 @@ If is a null pointer or the empty string, a pointer to the string .Qq \&. is returned. -.Pp -The -.Fn basename_r -variation accepts a buffer of at least -.Dv MAXPATHLEN -bytes in which to store the resulting component. .Sh IMPLEMENTATION NOTES The .Fn basename @@ -73,17 +65,15 @@ function returns a pointer to internal storage space allocated on the first call that will be overwritten by subsequent calls. -.Fn basename_r -is therefore preferred for threaded applications. .Sh RETURN VALUES On successful completion, .Fn basename -and -.Fn basename_r -return pointers to the last component of +returns a pointer to the last component of .Fa path . .Pp -If they fail, a null pointer is returned and the global variable +If +.Fn basename +fails, a null pointer is returned and the global variable .Va errno is set to indicate the error. .Sh ERRORS diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c index 9588c282bcf7..9552ab348666 100644 --- a/lib/libc/gen/basename.c +++ b/lib/libc/gen/basename.c @@ -40,12 +40,18 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> char * -basename_r(path, bname) +basename(path) const char *path; - char *bname; { + static char *bname = NULL; const char *endp, *startp; + if (bname == NULL) { + bname = (char *)malloc(MAXPATHLEN); + if (bname == NULL) + return(NULL); + } + /* Empty or NULL string gets treated as "." */ if (path == NULL || *path == '\0') { (void)strcpy(bname, "."); @@ -76,17 +82,3 @@ basename_r(path, bname) bname[endp - startp + 1] = '\0'; return(bname); } - -char * -basename(path) - const char *path; -{ - static char *bname = NULL; - - if (bname == NULL) { - bname = (char *)malloc(MAXPATHLEN); - if (bname == NULL) - return (NULL); - } - return (basename_r(path, bname)); -} |
