diff options
| author | aaron <> | 1999-06-04 19:14:56 +0000 |
|---|---|---|
| committer | aaron <> | 1999-06-04 19:14:56 +0000 |
| commit | 569578dc356ba2402bc9d1b54016c009127366cb (patch) | |
| tree | a66749999785172106ab5135b5e7840c8e7b9541 | |
| parent | b54ee9c910d2afd114c02825c362ba253d8bf917 (diff) | |
| download | openbsd-569578dc356ba2402bc9d1b54016c009127366cb.tar.gz openbsd-569578dc356ba2402bc9d1b54016c009127366cb.tar.bz2 openbsd-569578dc356ba2402bc9d1b54016c009127366cb.zip | |
some repairs, add example to strdup(3) page
| -rw-r--r-- | src/lib/libc/string/strcat.3 | 5 | ||||
| -rw-r--r-- | src/lib/libc/string/strcmp.3 | 8 | ||||
| -rw-r--r-- | src/lib/libc/string/strcpy.3 | 14 | ||||
| -rw-r--r-- | src/lib/libc/string/strdup.3 | 20 | ||||
| -rw-r--r-- | src/lib/libc/string/strlen.3 | 7 | ||||
| -rw-r--r-- | src/lib/libc/string/strsep.3 | 12 | ||||
| -rw-r--r-- | src/lib/libc/string/strtok.3 | 9 |
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 | |||
| 72 | is greater than | 73 | is greater than |
| 73 | .Ql \e0 . | 74 | .Ql \e0 . |
| 74 | .Pp | 75 | .Pp |
| 75 | The | ||
| 76 | .Fn strncmp | 76 | .Fn strncmp |
| 77 | compares not more than | 77 | compares at most |
| 78 | .Fa len | 78 | .Fa len |
| 79 | characters. | 79 | characters. |
| 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 |
| 62 | character). | 63 | character). |
| 63 | .Pp | 64 | .Pp |
| 64 | The | ||
| 65 | .Fn strncpy | 65 | .Fn strncpy |
| 66 | copies not more than | 66 | copies not more than |
| 67 | .Fa len | 67 | .Fa len |
| @@ -105,10 +105,10 @@ to | |||
| 105 | .Dq Li abcdef | 105 | .Dq Li abcdef |
| 106 | and does | 106 | and does |
| 107 | .Em not | 107 | .Em not |
| 108 | NUL-terminate chararray because the source string is >= the length parameter. | 108 | null terminate chararray because the source string is >= the length parameter. |
| 109 | .Fn strncpy | 109 | .Fn strncpy |
| 110 | .Em only | 110 | .Em only |
| 111 | NUL-terminates the destination string when then length of the source | 111 | null terminates the destination string when then length of the source |
| 112 | string is less than the length parameter. | 112 | string 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 |
| 119 | to | 119 | to |
| 120 | .Dq Li buf | 120 | .Dq Li buf |
| 121 | as will fit and NUL-terminates the result. Because | 121 | as will fit and null terminates the result. Because |
| 122 | .Fn strncpy | 122 | .Fn strncpy |
| 123 | does | 123 | does |
| 124 | .Em not | 124 | .Em not |
| 125 | guarantee to NUL-terminate the string itself, we must do this by hand. | 125 | guarantee to null terminate the string itself, we must do this by hand. |
| 126 | .Bd -literal -offset indent | 126 | .Bd -literal -offset indent |
| 127 | char buf[BUFSIZ]; | 127 | char 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 |
| 47 | The | 47 | The |
| 48 | .Fn strdup | 48 | .Fn strdup |
| 49 | function | 49 | function |
| 50 | allocates sufficient memory for a copy | 50 | allocates sufficient memory for a copy |
| 51 | of the string | 51 | of the string |
| 52 | .Fa str , | 52 | .Fa s , |
| 53 | does the copy, and returns a pointer to it. | 53 | does the copy, and returns a pointer to it. |
| 54 | The pointer may subsequently be used as an | 54 | The pointer may subsequently be used as an |
| 55 | argument to the function | 55 | argument to the function |
| 56 | .Xr free 3 . | 56 | .Xr free 3 . |
| 57 | .Pp | 57 | .Pp |
| 58 | If insufficient memory is available, NULL is returned. | 58 | If insufficient memory is available, |
| 59 | .Dv NULL | ||
| 60 | is returned. | ||
| 61 | .Sh EXAMPLES | ||
| 62 | The following will point | ||
| 63 | .Va p | ||
| 64 | to an allocated area of memory containing the null-terminated string | ||
| 65 | .Qq foobar : | ||
| 66 | .Bd -literal -offset indent | ||
| 67 | char *p; | ||
| 68 | |||
| 69 | p = 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 | |||
| 57 | function | 57 | function |
| 58 | returns | 58 | returns |
| 59 | the number of characters that precede the | 59 | the number of characters that precede the |
| 60 | terminating | 60 | terminating NUL |
| 61 | .Dv NUL | ||
| 62 | character. | 61 | character. |
| 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 | |||
| 58 | character) and replaces it with a | 58 | character) and replaces it with a |
| 59 | .Ql \e0 . | 59 | .Ql \e0 . |
| 60 | The location of the next character after the delimiter character | 60 | The 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 , | ||
| 63 | if the end of the string was reached) is stored in | ||
| 62 | .Fa *stringp . | 64 | .Fa *stringp . |
| 63 | The original value of | 65 | The original value of |
| 64 | .Fa *stringp | 66 | .Fa *stringp |
| 65 | is returned. | 67 | is returned. |
| 66 | .Pp | 68 | .Pp |
| 67 | An ``empty'' field, i.e. one caused by two adjacent delimiter characters, | 69 | An |
| 70 | .Dq empty | ||
| 71 | field, i.e., one caused by two adjacent delimiter characters, | ||
| 68 | can be detected by comparing the location referenced by the pointer returned | 72 | can be detected by comparing the location referenced by the pointer returned |
| 69 | in | 73 | in |
| 70 | .Fa *stringp | 74 | .Fa *stringp |
| @@ -101,7 +105,7 @@ While the | |||
| 101 | .Fn strtok | 105 | .Fn strtok |
| 102 | function should be preferred for portability reasons (it conforms to | 106 | function should be preferred for portability reasons (it conforms to |
| 103 | .St -ansiC ) | 107 | .St -ansiC ) |
| 104 | it is unable to handle empty fields, i.e. detect fields delimited by | 108 | it is unable to handle empty fields, i.e., detect fields delimited by |
| 105 | two adjacent delimiter characters, or to be used for more than a single | 109 | two adjacent delimiter characters, or to be used for more than a single |
| 106 | string at a time. | 110 | string at a time. |
| 107 | The | 111 | The |
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, | |||
| 104 | will not alter the next starting point, so that a call to | 103 | will not alter the next starting point, so that a call to |
| 105 | .Fn strtok | 104 | .Fn strtok |
| 106 | with a different (or empty) delimiter string | 105 | with a different (or empty) delimiter string |
| 107 | may return a | 106 | may return a non-null value. |
| 108 | .Pf non- Dv NULL | ||
| 109 | value. | ||
| 110 | Since this implementation always alters the next starting point, | 107 | Since this implementation always alters the next starting point, |
| 111 | such a sequence of calls would always return | 108 | such a sequence of calls would always return |
| 112 | .Dv NULL . | 109 | .Dv NULL . |
