summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraaron <>1999-06-04 19:14:56 +0000
committeraaron <>1999-06-04 19:14:56 +0000
commit569578dc356ba2402bc9d1b54016c009127366cb (patch)
treea66749999785172106ab5135b5e7840c8e7b9541 /src
parentb54ee9c910d2afd114c02825c362ba253d8bf917 (diff)
downloadopenbsd-569578dc356ba2402bc9d1b54016c009127366cb.tar.gz
openbsd-569578dc356ba2402bc9d1b54016c009127366cb.tar.bz2
openbsd-569578dc356ba2402bc9d1b54016c009127366cb.zip
some repairs, add example to strdup(3) page
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/string/strcat.35
-rw-r--r--src/lib/libc/string/strcmp.38
-rw-r--r--src/lib/libc/string/strcpy.314
-rw-r--r--src/lib/libc/string/strdup.320
-rw-r--r--src/lib/libc/string/strlen.37
-rw-r--r--src/lib/libc/string/strsep.312
-rw-r--r--src/lib/libc/string/strtok.39
7 files changed, 44 insertions, 31 deletions
diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3
index 7591423f96..8b81e082f2 100644
--- a/src/lib/libc/string/strcat.3
+++ b/src/lib/libc/string/strcat.3
@@ -33,13 +33,14 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strcat.3,v 1.5 1999/03/06 23:41:13 millert Exp $ 36.\" $OpenBSD: strcat.3,v 1.6 1999/06/04 19:14:55 aaron Exp $
37.\" 37.\"
38.Dd July 8, 1997 38.Dd July 8, 1997
39.Dt STRCAT 3 39.Dt STRCAT 3
40.Os 40.Os
41.Sh NAME 41.Sh NAME
42.Nm strcat 42.Nm strcat,
43.Nm strncat
43.Nd concatenate strings 44.Nd concatenate strings
44.Sh SYNOPSIS 45.Sh SYNOPSIS
45.Fd #include <string.h> 46.Fd #include <string.h>
diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3
index 91e51d68fc..b8dc8ac4ff 100644
--- a/src/lib/libc/string/strcmp.3
+++ b/src/lib/libc/string/strcmp.3
@@ -33,13 +33,14 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strcmp.3,v 1.2 1996/08/19 08:34:11 tholo Exp $ 36.\" $OpenBSD: strcmp.3,v 1.3 1999/06/04 19:14:56 aaron Exp $
37.\" 37.\"
38.Dd June 29, 1991 38.Dd June 29, 1991
39.Dt STRCMP 3 39.Dt STRCMP 3
40.Os 40.Os
41.Sh NAME 41.Sh NAME
42.Nm strcmp 42.Nm strcmp,
43.Nm strncmp
43.Nd compare strings 44.Nd compare strings
44.Sh SYNOPSIS 45.Sh SYNOPSIS
45.Fd #include <string.h> 46.Fd #include <string.h>
@@ -72,9 +73,8 @@ The comparison is done using unsigned characters, so that
72is greater than 73is greater than
73.Ql \e0 . 74.Ql \e0 .
74.Pp 75.Pp
75The
76.Fn strncmp 76.Fn strncmp
77compares not more than 77compares at most
78.Fa len 78.Fa len
79characters. 79characters.
80.Sh SEE ALSO 80.Sh SEE ALSO
diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3
index 80d528caef..75727223ff 100644
--- a/src/lib/libc/string/strcpy.3
+++ b/src/lib/libc/string/strcpy.3
@@ -33,13 +33,14 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strcpy.3,v 1.6 1999/05/23 14:11:03 aaron Exp $ 36.\" $OpenBSD: strcpy.3,v 1.7 1999/06/04 19:14:56 aaron Exp $
37.\" 37.\"
38.Dd June 29, 1991 38.Dd June 29, 1991
39.Dt STRCPY 3 39.Dt STRCPY 3
40.Os 40.Os
41.Sh NAME 41.Sh NAME
42.Nm strcpy 42.Nm strcpy,
43.Nm strncpy
43.Nd copy strings 44.Nd copy strings
44.Sh SYNOPSIS 45.Sh SYNOPSIS
45.Fd #include <string.h> 46.Fd #include <string.h>
@@ -61,7 +62,6 @@ to
61.Ql \e0 62.Ql \e0
62character). 63character).
63.Pp 64.Pp
64The
65.Fn strncpy 65.Fn strncpy
66copies not more than 66copies not more than
67.Fa len 67.Fa len
@@ -105,10 +105,10 @@ to
105.Dq Li abcdef 105.Dq Li abcdef
106and does 106and does
107.Em not 107.Em not
108NUL-terminate chararray because the source string is >= the length parameter. 108null terminate chararray because the source string is >= the length parameter.
109.Fn strncpy 109.Fn strncpy
110.Em only 110.Em only
111NUL-terminates the destination string when then length of the source 111null terminates the destination string when then length of the source
112string is less than the length parameter. 112string is less than the length parameter.
113.Bd -literal -offset indent 113.Bd -literal -offset indent
114(void)strncpy(chararray, "abcdefgh", 6); 114(void)strncpy(chararray, "abcdefgh", 6);
@@ -118,11 +118,11 @@ The following copies as many characters from
118.Dq Li input 118.Dq Li input
119to 119to
120.Dq Li buf 120.Dq Li buf
121as will fit and NUL-terminates the result. Because 121as will fit and null terminates the result. Because
122.Fn strncpy 122.Fn strncpy
123does 123does
124.Em not 124.Em not
125guarantee to NUL-terminate the string itself, we must do this by hand. 125guarantee to null terminate the string itself, we must do this by hand.
126.Bd -literal -offset indent 126.Bd -literal -offset indent
127char buf[BUFSIZ]; 127char buf[BUFSIZ];
128 128
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3
index 6abbba57cb..73c144d6e4 100644
--- a/src/lib/libc/string/strdup.3
+++ b/src/lib/libc/string/strdup.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: strdup.3,v 1.6 1998/08/19 05:51:14 pjanzen Exp $ 1.\" $OpenBSD: strdup.3,v 1.7 1999/06/04 19:14:56 aaron Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1991, 1993 3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -42,20 +42,32 @@
42.Sh SYNOPSIS 42.Sh SYNOPSIS
43.Fd #include <string.h> 43.Fd #include <string.h>
44.Ft char * 44.Ft char *
45.Fn strdup "const char *str" 45.Fn strdup "const char *s"
46.Sh DESCRIPTION 46.Sh DESCRIPTION
47The 47The
48.Fn strdup 48.Fn strdup
49function 49function
50allocates sufficient memory for a copy 50allocates sufficient memory for a copy
51of the string 51of the string
52.Fa str , 52.Fa s ,
53does the copy, and returns a pointer to it. 53does the copy, and returns a pointer to it.
54The pointer may subsequently be used as an 54The pointer may subsequently be used as an
55argument to the function 55argument to the function
56.Xr free 3 . 56.Xr free 3 .
57.Pp 57.Pp
58If insufficient memory is available, NULL is returned. 58If insufficient memory is available,
59.Dv NULL
60is returned.
61.Sh EXAMPLES
62The following will point
63.Va p
64to an allocated area of memory containing the null-terminated string
65.Qq foobar :
66.Bd -literal -offset indent
67char *p;
68
69p = strdup("foobar");
70.Ed
59.Sh SEE ALSO 71.Sh SEE ALSO
60.Xr free 3 , 72.Xr free 3 ,
61.Xr malloc 3 , 73.Xr malloc 3 ,
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3
index 99e7dd19c3..9db28cd184 100644
--- a/src/lib/libc/string/strlen.3
+++ b/src/lib/libc/string/strlen.3
@@ -33,14 +33,14 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strlen.3,v 1.2 1996/08/19 08:34:19 tholo Exp $ 36.\" $OpenBSD: strlen.3,v 1.3 1999/06/04 19:14:56 aaron Exp $
37.\" 37.\"
38.Dd June 29, 1991 38.Dd June 29, 1991
39.Dt STRLEN 3 39.Dt STRLEN 3
40.Os 40.Os
41.Sh NAME 41.Sh NAME
42.Nm strlen 42.Nm strlen
43.Nd find length of string 43.Nd find length of a string
44.Sh SYNOPSIS 44.Sh SYNOPSIS
45.Fd #include <string.h> 45.Fd #include <string.h>
46.Ft size_t 46.Ft size_t
@@ -57,8 +57,7 @@ The
57function 57function
58returns 58returns
59the number of characters that precede the 59the number of characters that precede the
60terminating 60terminating NUL
61.Dv NUL
62character. 61character.
63.Sh SEE ALSO 62.Sh SEE ALSO
64.Xr string 3 63.Xr string 3
diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3
index 5af262a074..dfd835bce8 100644
--- a/src/lib/libc/string/strsep.3
+++ b/src/lib/libc/string/strsep.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: strsep.3,v 1.4 1998/06/15 17:55:14 mickey Exp $ 1.\" $OpenBSD: strsep.3,v 1.5 1999/06/04 19:14:56 aaron Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1991, 1993 3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
@@ -58,13 +58,17 @@ the first occurrence of any character in the string
58character) and replaces it with a 58character) and replaces it with a
59.Ql \e0 . 59.Ql \e0 .
60The location of the next character after the delimiter character 60The location of the next character after the delimiter character
61(or NULL, if the end of the string was reached) is stored in 61(or
62.Dv NULL ,
63if the end of the string was reached) is stored in
62.Fa *stringp . 64.Fa *stringp .
63The original value of 65The original value of
64.Fa *stringp 66.Fa *stringp
65is returned. 67is returned.
66.Pp 68.Pp
67An ``empty'' field, i.e. one caused by two adjacent delimiter characters, 69An
70.Dq empty
71field, i.e., one caused by two adjacent delimiter characters,
68can be detected by comparing the location referenced by the pointer returned 72can be detected by comparing the location referenced by the pointer returned
69in 73in
70.Fa *stringp 74.Fa *stringp
@@ -101,7 +105,7 @@ While the
101.Fn strtok 105.Fn strtok
102function should be preferred for portability reasons (it conforms to 106function should be preferred for portability reasons (it conforms to
103.St -ansiC ) 107.St -ansiC )
104it is unable to handle empty fields, i.e. detect fields delimited by 108it is unable to handle empty fields, i.e., detect fields delimited by
105two adjacent delimiter characters, or to be used for more than a single 109two adjacent delimiter characters, or to be used for more than a single
106string at a time. 110string at a time.
107The 111The
diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3
index 6abcfc6724..62f0d7a501 100644
--- a/src/lib/libc/string/strtok.3
+++ b/src/lib/libc/string/strtok.3
@@ -33,14 +33,13 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strtok.3,v 1.4 1999/05/23 14:11:03 aaron Exp $ 36.\" $OpenBSD: strtok.3,v 1.5 1999/06/04 19:14:56 aaron Exp $
37.\" 37.\"
38.Dd June 29, 1991 38.Dd June 29, 1991
39.Dt STRTOK 3 39.Dt STRTOK 3
40.Os 40.Os
41.Sh NAME 41.Sh NAME
42.Nm strtok , 42.Nm strtok
43.Nm strsep
44.Nd string token operations 43.Nd string token operations
45.Sh SYNOPSIS 44.Sh SYNOPSIS
46.Fd #include <string.h> 45.Fd #include <string.h>
@@ -104,9 +103,7 @@ if handed a string containing only delimiter characters,
104will not alter the next starting point, so that a call to 103will not alter the next starting point, so that a call to
105.Fn strtok 104.Fn strtok
106with a different (or empty) delimiter string 105with a different (or empty) delimiter string
107may return a 106may return a non-null value.
108.Pf non- Dv NULL
109value.
110Since this implementation always alters the next starting point, 107Since this implementation always alters the next starting point,
111such a sequence of calls would always return 108such a sequence of calls would always return
112.Dv NULL . 109.Dv NULL .