summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strcat.3
diff options
context:
space:
mode:
authormillert <>2013-12-19 20:52:37 +0000
committermillert <>2013-12-19 20:52:37 +0000
commit062d999e00c36692605b1ac394ffcfbb340e1771 (patch)
treeef71f36904bc7ca141dbe9cf9a9504e688b183c3 /src/lib/libc/string/strcat.3
parent3c960933763956e6ab55d204e71d003e258f726a (diff)
downloadopenbsd-062d999e00c36692605b1ac394ffcfbb340e1771.tar.gz
openbsd-062d999e00c36692605b1ac394ffcfbb340e1771.tar.bz2
openbsd-062d999e00c36692605b1ac394ffcfbb340e1771.zip
Split out strncpy and strncat from strcpy and strcat manuals.
Requested by deraadt@
Diffstat (limited to 'src/lib/libc/string/strcat.3')
-rw-r--r--src/lib/libc/string/strcat.380
1 files changed, 9 insertions, 71 deletions
diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3
index 6b5e4003b6..fba992edd9 100644
--- a/src/lib/libc/string/strcat.3
+++ b/src/lib/libc/string/strcat.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: strcat.3,v 1.15 2013/07/17 05:42:11 schwarze Exp $ 1.\" $OpenBSD: strcat.3,v 1.16 2013/12/19 20:52:37 millert Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1991 The Regents of the University of California. 3.\" Copyright (c) 1990, 1991 The Regents of the University of California.
4.\" All rights reserved. 4.\" All rights reserved.
@@ -31,91 +31,33 @@
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE. 32.\" SUCH DAMAGE.
33.\" 33.\"
34.Dd $Mdocdate: July 17 2013 $ 34.Dd $Mdocdate: December 19 2013 $
35.Dt STRCAT 3 35.Dt STRCAT 3
36.Os 36.Os
37.Sh NAME 37.Sh NAME
38.Nm strcat , 38.Nm strcat
39.Nm strncat 39.Nd concatenate two strings
40.Nd concatenate strings
41.Sh SYNOPSIS 40.Sh SYNOPSIS
42.In string.h 41.In string.h
43.Ft char * 42.Ft char *
44.Fn strcat "char *s" "const char *append" 43.Fn strcat "char *s" "const char *append"
45.Ft char *
46.Fn strncat "char *s" "const char *append" "size_t count"
47.Sh DESCRIPTION 44.Sh DESCRIPTION
48The 45The
49.Fn strcat 46.Fn strcat
50and 47function appends a copy of the NUL-terminated string
51.Fn strncat
52functions append a copy of the NUL-terminated string
53.Fa append 48.Fa append
54to the end of the NUL-terminated string 49to the end of the NUL-terminated string
55.Fa s , 50.Fa s ,
56then add a terminating 51then adds a terminating
57.Ql \e0 . 52.Ql \e0 .
58The string 53The string
59.Fa s 54.Fa s
60must have sufficient space to hold the result. 55must have sufficient space to hold the result.
61.Pp
62The
63.Fn strncat
64function appends not more than
65.Fa count
66characters where space for the terminating
67.Ql \e0
68should not be included in
69.Fa count .
70.Sh RETURN VALUES 56.Sh RETURN VALUES
71The 57The
72.Fn strcat 58.Fn strcat
73and 59function return the pointer
74.Fn strncat
75functions return the pointer
76.Fa s . 60.Fa s .
77.Sh EXAMPLES
78The following appends
79.Dq Li abc
80to
81.Va chararray :
82.Bd -literal -offset indent
83char *letters = "abcdefghi";
84
85(void)strncat(chararray, letters, 3);
86.Ed
87.Pp
88The following example shows how to use
89.Fn strncat
90safely in conjunction with
91.Xr strncpy 3 .
92.Bd -literal -offset indent
93char buf[BUFSIZ];
94char *input, *suffix;
95
96(void)strncpy(buf, input, sizeof(buf) - 1);
97buf[sizeof(buf) - 1] = '\e0';
98(void)strncat(buf, suffix, sizeof(buf) - 1 - strlen(buf));
99.Ed
100.Pp
101The above will copy as many characters from
102.Va input
103to
104.Va buf
105as will fit.
106It then appends as many characters from
107.Va suffix
108as will fit (or none
109if there is no space).
110For operations like this, the
111.Xr strlcpy 3
112and
113.Xr strlcat 3
114functions are a better choice, as shown below.
115.Bd -literal -offset indent
116(void)strlcpy(buf, input, sizeof(buf));
117(void)strlcat(buf, suffix, sizeof(buf));
118.Ed
119.Sh SEE ALSO 61.Sh SEE ALSO
120.Xr bcopy 3 , 62.Xr bcopy 3 ,
121.Xr memccpy 3 , 63.Xr memccpy 3 ,
@@ -123,21 +65,17 @@ functions are a better choice, as shown below.
123.Xr memmove 3 , 65.Xr memmove 3 ,
124.Xr strcpy 3 , 66.Xr strcpy 3 ,
125.Xr strlcpy 3 , 67.Xr strlcpy 3 ,
68.Xr strncat 3 ,
126.Xr wcscat 3 , 69.Xr wcscat 3 ,
127.Xr wcslcpy 3 70.Xr wcslcpy 3
128.Sh STANDARDS 71.Sh STANDARDS
129The 72The
130.Fn strcat 73.Fn strcat
131and 74function conforms to
132.Fn strncat
133functions conform to
134.St -ansiC . 75.St -ansiC .
135.Sh HISTORY 76.Sh HISTORY
136The 77The
137.Fn strcat 78.Fn strcat
138function first appeared in the Programmer's Workbench (PWB/UNIX) 79function first appeared in the Programmer's Workbench (PWB/UNIX)
139and was ported to 80and was ported to
140.At v7 ;
141.Fn strncat
142first appeared in
143.At v7 . 81.At v7 .