summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>1999-06-04 19:14:57 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>1999-06-04 19:14:57 +0000
commitea3aa758f0613eb4538aa90000b1fefafcdc6976 (patch)
tree6c58fae8633b1642bfe1f4b5f0ea28f071694465
parente288cb3c3b2f3f37b0ec44648cf15b3ce1fa3299 (diff)
some repairs, add example to strdup(3) page
-rw-r--r--lib/libc/string/strcat.35
-rw-r--r--lib/libc/string/strcmp.38
-rw-r--r--lib/libc/string/strcpy.314
-rw-r--r--lib/libc/string/strdup.320
-rw-r--r--lib/libc/string/strlen.37
-rw-r--r--lib/libc/string/strsep.312
-rw-r--r--lib/libc/string/strtok.39
7 files changed, 44 insertions, 31 deletions
diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3
index 7591423f96e..8b81e082f20 100644
--- a/lib/libc/string/strcat.3
+++ b/lib/libc/string/strcat.3
@@ -33,13 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strcat.3,v 1.5 1999/03/06 23:41:13 millert Exp $
+.\" $OpenBSD: strcat.3,v 1.6 1999/06/04 19:14:55 aaron Exp $
.\"
.Dd July 8, 1997
.Dt STRCAT 3
.Os
.Sh NAME
-.Nm strcat
+.Nm strcat,
+.Nm strncat
.Nd concatenate strings
.Sh SYNOPSIS
.Fd #include <string.h>
diff --git a/lib/libc/string/strcmp.3 b/lib/libc/string/strcmp.3
index 91e51d68fc7..b8dc8ac4ff9 100644
--- a/lib/libc/string/strcmp.3
+++ b/lib/libc/string/strcmp.3
@@ -33,13 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strcmp.3,v 1.2 1996/08/19 08:34:11 tholo Exp $
+.\" $OpenBSD: strcmp.3,v 1.3 1999/06/04 19:14:56 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRCMP 3
.Os
.Sh NAME
-.Nm strcmp
+.Nm strcmp,
+.Nm strncmp
.Nd compare strings
.Sh SYNOPSIS
.Fd #include <string.h>
@@ -72,9 +73,8 @@ The comparison is done using unsigned characters, so that
is greater than
.Ql \e0 .
.Pp
-The
.Fn strncmp
-compares not more than
+compares at most
.Fa len
characters.
.Sh SEE ALSO
diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3
index 80d528caefc..75727223ff0 100644
--- a/lib/libc/string/strcpy.3
+++ b/lib/libc/string/strcpy.3
@@ -33,13 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strcpy.3,v 1.6 1999/05/23 14:11:03 aaron Exp $
+.\" $OpenBSD: strcpy.3,v 1.7 1999/06/04 19:14:56 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRCPY 3
.Os
.Sh NAME
-.Nm strcpy
+.Nm strcpy,
+.Nm strncpy
.Nd copy strings
.Sh SYNOPSIS
.Fd #include <string.h>
@@ -61,7 +62,6 @@ to
.Ql \e0
character).
.Pp
-The
.Fn strncpy
copies not more than
.Fa len
@@ -105,10 +105,10 @@ to
.Dq Li abcdef
and does
.Em not
-NUL-terminate chararray because the source string is >= the length parameter.
+null terminate chararray because the source string is >= the length parameter.
.Fn strncpy
.Em only
-NUL-terminates the destination string when then length of the source
+null terminates the destination string when then length of the source
string is less than the length parameter.
.Bd -literal -offset indent
(void)strncpy(chararray, "abcdefgh", 6);
@@ -118,11 +118,11 @@ The following copies as many characters from
.Dq Li input
to
.Dq Li buf
-as will fit and NUL-terminates the result. Because
+as will fit and null terminates the result. Because
.Fn strncpy
does
.Em not
-guarantee to NUL-terminate the string itself, we must do this by hand.
+guarantee to null terminate the string itself, we must do this by hand.
.Bd -literal -offset indent
char buf[BUFSIZ];
diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3
index 6abbba57cb7..73c144d6e4c 100644
--- a/lib/libc/string/strdup.3
+++ b/lib/libc/string/strdup.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: strdup.3,v 1.6 1998/08/19 05:51:14 pjanzen Exp $
+.\" $OpenBSD: strdup.3,v 1.7 1999/06/04 19:14:56 aaron Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -42,20 +42,32 @@
.Sh SYNOPSIS
.Fd #include <string.h>
.Ft char *
-.Fn strdup "const char *str"
+.Fn strdup "const char *s"
.Sh DESCRIPTION
The
.Fn strdup
function
allocates sufficient memory for a copy
of the string
-.Fa str ,
+.Fa s ,
does the copy, and returns a pointer to it.
The pointer may subsequently be used as an
argument to the function
.Xr free 3 .
.Pp
-If insufficient memory is available, NULL is returned.
+If insufficient memory is available,
+.Dv NULL
+is returned.
+.Sh EXAMPLES
+The following will point
+.Va p
+to an allocated area of memory containing the null-terminated string
+.Qq foobar :
+.Bd -literal -offset indent
+char *p;
+
+p = strdup("foobar");
+.Ed
.Sh SEE ALSO
.Xr free 3 ,
.Xr malloc 3 ,
diff --git a/lib/libc/string/strlen.3 b/lib/libc/string/strlen.3
index 99e7dd19c34..9db28cd1842 100644
--- a/lib/libc/string/strlen.3
+++ b/lib/libc/string/strlen.3
@@ -33,14 +33,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strlen.3,v 1.2 1996/08/19 08:34:19 tholo Exp $
+.\" $OpenBSD: strlen.3,v 1.3 1999/06/04 19:14:56 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRLEN 3
.Os
.Sh NAME
.Nm strlen
-.Nd find length of string
+.Nd find length of a string
.Sh SYNOPSIS
.Fd #include <string.h>
.Ft size_t
@@ -57,8 +57,7 @@ The
function
returns
the number of characters that precede the
-terminating
-.Dv NUL
+terminating NUL
character.
.Sh SEE ALSO
.Xr string 3
diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3
index 5af262a074e..dfd835bce89 100644
--- a/lib/libc/string/strsep.3
+++ b/lib/libc/string/strsep.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: strsep.3,v 1.4 1998/06/15 17:55:14 mickey Exp $
+.\" $OpenBSD: strsep.3,v 1.5 1999/06/04 19:14:56 aaron Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -58,13 +58,17 @@ the first occurrence of any character in the string
character) and replaces it with a
.Ql \e0 .
The location of the next character after the delimiter character
-(or NULL, if the end of the string was reached) is stored in
+(or
+.Dv NULL ,
+if the end of the string was reached) is stored in
.Fa *stringp .
The original value of
.Fa *stringp
is returned.
.Pp
-An ``empty'' field, i.e. one caused by two adjacent delimiter characters,
+An
+.Dq empty
+field, i.e., one caused by two adjacent delimiter characters,
can be detected by comparing the location referenced by the pointer returned
in
.Fa *stringp
@@ -101,7 +105,7 @@ While the
.Fn strtok
function should be preferred for portability reasons (it conforms to
.St -ansiC )
-it is unable to handle empty fields, i.e. detect fields delimited by
+it is unable to handle empty fields, i.e., detect fields delimited by
two adjacent delimiter characters, or to be used for more than a single
string at a time.
The
diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3
index 6abcfc67241..62f0d7a5010 100644
--- a/lib/libc/string/strtok.3
+++ b/lib/libc/string/strtok.3
@@ -33,14 +33,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: strtok.3,v 1.4 1999/05/23 14:11:03 aaron Exp $
+.\" $OpenBSD: strtok.3,v 1.5 1999/06/04 19:14:56 aaron Exp $
.\"
.Dd June 29, 1991
.Dt STRTOK 3
.Os
.Sh NAME
-.Nm strtok ,
-.Nm strsep
+.Nm strtok
.Nd string token operations
.Sh SYNOPSIS
.Fd #include <string.h>
@@ -104,9 +103,7 @@ if handed a string containing only delimiter characters,
will not alter the next starting point, so that a call to
.Fn strtok
with a different (or empty) delimiter string
-may return a
-.Pf non- Dv NULL
-value.
+may return a non-null value.
Since this implementation always alters the next starting point,
such a sequence of calls would always return
.Dv NULL .