Browse Source

- macro, punctuation, and rewording tweaks

- avoid first person.
ok jmc
OPENBSD_3_8
jaredy 19 years ago
parent
commit
1f6f803468
4 changed files with 21 additions and 18 deletions
  1. +7
    -5
      src/lib/libc/string/strcat.3
  2. +4
    -3
      src/lib/libc/string/strcpy.3
  3. +6
    -6
      src/lib/libc/string/strlcpy.3
  4. +4
    -4
      src/lib/libc/string/wcstok.3

+ 7
- 5
src/lib/libc/string/strcat.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strcat.3,v 1.10 2005/02/25 03:12:44 cloder Exp $
.\" $OpenBSD: strcat.3,v 1.11 2005/08/06 03:21:36 jaredy Exp $
.\" .\"
.Dd July 8, 1997 .Dd July 8, 1997
.Dt STRCAT 3 .Dt STRCAT 3
@ -78,7 +78,7 @@ functions return the pointer
The following appends The following appends
.Dq Li abc .Dq Li abc
to to
.Dq Li chararray :
.Va chararray :
.Bd -literal -offset indent .Bd -literal -offset indent
char *letters = "abcdefghi"; char *letters = "abcdefghi";
@ -99,11 +99,13 @@ buf[sizeof(buf) - 1] = '\e0';
.Ed .Ed
.Pp .Pp
The above will copy as many characters from The above will copy as many characters from
.Dq Li input
.Va input
to to
.Dq Li buf
.Va buf
as will fit. as will fit.
It then appends as many characters from suffix as will fit (or none
It then appends as many characters from
.Va suffix
as will fit (or none
if there is no space). if there is no space).
For operations like this, the For operations like this, the
.Xr strlcpy 3 .Xr strlcpy 3


+ 4
- 3
src/lib/libc/string/strcpy.3 View File

@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: strcpy.3,v 1.13 2005/02/25 03:12:44 cloder Exp $
.\" $OpenBSD: strcpy.3,v 1.14 2005/08/06 03:21:36 jaredy Exp $
.\" .\"
.Dd June 29, 1991 .Dd June 29, 1991
.Dt STRCPY 3 .Dt STRCPY 3
@ -100,7 +100,8 @@ and does
.Em not .Em not
NUL terminate NUL terminate
.Va chararray .Va chararray
because the source string is >= the length parameter.
because the length of the source string is greater than or equal to the
length parameter.
.Fn strncpy .Fn strncpy
.Em only .Em only
NUL terminates the destination string when the length of the source NUL terminates the destination string when the length of the source
@ -118,7 +119,7 @@ Because
.Fn strncpy .Fn strncpy
does does
.Em not .Em not
guarantee to NUL terminate the string itself, we must do this by hand.
guarantee to NUL terminate the string itself, it must be done by hand.
.Bd -literal -offset indent .Bd -literal -offset indent
char buf[BUFSIZ]; char buf[BUFSIZ];


+ 6
- 6
src/lib/libc/string/strlcpy.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: strlcpy.3,v 1.16 2003/06/17 21:56:24 millert Exp $
.\" $OpenBSD: strlcpy.3,v 1.17 2005/08/06 03:21:36 jaredy Exp $
.\" .\"
.\" Copyright (c) 1998, 2000 Todd C. Miller <Todd.Miller@courtesan.com> .\" Copyright (c) 1998, 2000 Todd C. Miller <Todd.Miller@courtesan.com>
.\" .\"
@ -49,7 +49,7 @@ is larger than 0 or, in the case of
.Fn strlcat , .Fn strlcat ,
as long as there is at least one byte free in as long as there is at least one byte free in
.Fa dst ) . .Fa dst ) .
Note that you should include a byte for the NUL in
Note that a byte for the NUL should be included in
.Fa size . .Fa size .
Also note that Also note that
.Fn strlcpy .Fn strlcpy
@ -105,10 +105,10 @@ that means the initial length of
plus plus
the length of the length of
.Fa src . .Fa src .
While this may seem somewhat confusing it was done to make
While this may seem somewhat confusing, it was done to make
truncation detection simple. truncation detection simple.
.Pp .Pp
Note however, that if
Note, however, that if
.Fn strlcat .Fn strlcat
traverses traverses
.Fa size .Fa size
@ -152,8 +152,8 @@ if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname))
goto toolong; goto toolong;
.Ed .Ed
.Pp .Pp
Since we know how many characters we copied the first time, we can
speed things up a bit by using a copy instead of an append:
Since it is known how many characters were copied the first time, things
can be sped up a bit by using a copy instead of an append:
.Bd -literal -offset indent .Bd -literal -offset indent
char *dir, *file, pname[MAXPATHLEN]; char *dir, *file, pname[MAXPATHLEN];
size_t n; size_t n;


+ 4
- 4
src/lib/libc/string/wcstok.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: wcstok.3,v 1.2 2005/04/13 20:42:48 jmc Exp $
.\" $OpenBSD: wcstok.3,v 1.3 2005/08/06 03:21:36 jaredy Exp $
.\" .\"
.\" $NetBSD: wcstok.3,v 1.3 2003/09/08 17:54:33 wiz Exp $ .\" $NetBSD: wcstok.3,v 1.3 2003/09/08 17:54:33 wiz Exp $
.\" .\"
@ -68,7 +68,7 @@
The The
.Fn wcstok .Fn wcstok
function function
is used to isolate sequential tokens in a null-terminated wide character
is used to isolate sequential tokens in a NUL-terminated wide character
string, string,
.Fa str . .Fa str .
These tokens are separated in the string by at least one of the These tokens are separated in the string by at least one of the
@ -97,12 +97,12 @@ The
.Fn wcstok .Fn wcstok
function function
returns a pointer to the beginning of each subsequent token in the string, returns a pointer to the beginning of each subsequent token in the string,
after replacing the token itself with a null wide character (L'\e0').
after replacing the token itself with a NUL wide character (L'\e0').
When no more tokens remain, a null pointer is returned. When no more tokens remain, a null pointer is returned.
.Sh EXAMPLES .Sh EXAMPLES
The following code fragment splits a wide character string on The following code fragment splits a wide character string on
.Tn ASCII .Tn ASCII
space, tab and newline characters and writes the tokens to
space, tab, and newline characters and writes the tokens to
standard output: standard output:
.Bd -literal -offset indent .Bd -literal -offset indent
const wchar_t *seps = L" \et\en"; const wchar_t *seps = L" \et\en";


Loading…
Cancel
Save