xref: /netbsd-src/tests/lib/libc/ssp/h_stpcpy.c (revision 658a209ca64dbe8bbb113381c99d4ab8c96b2be9)
1*658a209cSchristos /* $NetBSD: h_stpcpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $ */
2*658a209cSchristos 
3*658a209cSchristos /*
4*658a209cSchristos  * Copyright (c) 2014 The NetBSD Foundation, Inc.
5*658a209cSchristos  * All rights reserved.
6*658a209cSchristos  *
7*658a209cSchristos  * Redistribution and use in source and binary forms, with or without
8*658a209cSchristos  * modification, are permitted provided that the following conditions
9*658a209cSchristos  * are met:
10*658a209cSchristos  * 1. Redistributions of source code must retain the above copyright
11*658a209cSchristos  *    notice, this list of conditions and the following disclaimer.
12*658a209cSchristos  * 2. Redistributions in binary form must reproduce the above copyright
13*658a209cSchristos  *    notice, this list of conditions and the following disclaimer in the
14*658a209cSchristos  *    documentation and/or other materials provided with the distribution.
15*658a209cSchristos  *
16*658a209cSchristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17*658a209cSchristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18*658a209cSchristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*658a209cSchristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20*658a209cSchristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*658a209cSchristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*658a209cSchristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*658a209cSchristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*658a209cSchristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*658a209cSchristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*658a209cSchristos  * POSSIBILITY OF SUCH DAMAGE.
27*658a209cSchristos  */
28*658a209cSchristos 
29*658a209cSchristos #include <sys/cdefs.h>
30*658a209cSchristos __COPYRIGHT("@(#) Copyright (c) 2008\
31*658a209cSchristos  The NetBSD Foundation, inc. All rights reserved.");
32*658a209cSchristos __RCSID("$NetBSD: h_stpcpy.c,v 1.1 2014/04/06 19:28:59 christos Exp $");
33*658a209cSchristos 
34*658a209cSchristos #include <stdio.h>
35*658a209cSchristos #include <stdlib.h>
36*658a209cSchristos #include <string.h>
37*658a209cSchristos 
38*658a209cSchristos int
main(int argc,char * argv[])39*658a209cSchristos main(int argc, char *argv[])
40*658a209cSchristos {
41*658a209cSchristos 	char b[10];
42*658a209cSchristos 	char *q = stpcpy(b, argv[1]);
43*658a209cSchristos 
44*658a209cSchristos 	if ((size_t)(q - b) != strlen(argv[1]))
45*658a209cSchristos 		abort();
46*658a209cSchristos 
47*658a209cSchristos 	(void)printf("%s\n", b);
48*658a209cSchristos 	return 0;
49*658a209cSchristos }
50