annotate gcc/testsuite/ada/acats/tests/cxb/cxb30131.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /*
kono
parents:
diff changeset
2 -- CXB30131.C
kono
parents:
diff changeset
3 --
kono
parents:
diff changeset
4 -- Grant of Unlimited Rights
kono
parents:
diff changeset
5 --
kono
parents:
diff changeset
6 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
kono
parents:
diff changeset
7 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
kono
parents:
diff changeset
8 -- unlimited rights in the software and documentation contained herein.
kono
parents:
diff changeset
9 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
kono
parents:
diff changeset
10 -- this public release, the Government intends to confer upon all
kono
parents:
diff changeset
11 -- recipients unlimited rights equal to those held by the Government.
kono
parents:
diff changeset
12 -- These rights include rights to use, duplicate, release or disclose the
kono
parents:
diff changeset
13 -- released technical data and computer software in whole or in part, in
kono
parents:
diff changeset
14 -- any manner and for any purpose whatsoever, and to have or permit others
kono
parents:
diff changeset
15 -- to do so.
kono
parents:
diff changeset
16 --
kono
parents:
diff changeset
17 -- DISCLAIMER
kono
parents:
diff changeset
18 --
kono
parents:
diff changeset
19 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
kono
parents:
diff changeset
20 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
kono
parents:
diff changeset
21 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
kono
parents:
diff changeset
22 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
kono
parents:
diff changeset
23 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
kono
parents:
diff changeset
24 -- PARTICULAR PURPOSE OF SAID MATERIAL.
kono
parents:
diff changeset
25 --*
kono
parents:
diff changeset
26 --
kono
parents:
diff changeset
27 -- FUNCTION NAME: CXB30131 ("combine_two_strings")
kono
parents:
diff changeset
28 --
kono
parents:
diff changeset
29 -- FUNCTION DESCRIPTION:
kono
parents:
diff changeset
30 -- This C function returns a pointer to the combination of two
kono
parents:
diff changeset
31 -- input strings.
kono
parents:
diff changeset
32 --
kono
parents:
diff changeset
33 -- INPUTS:
kono
parents:
diff changeset
34 -- This function requires that two parameters be passed to it.
kono
parents:
diff changeset
35 -- The type of both of these parameters are pointer to char (which
kono
parents:
diff changeset
36 -- is used to reference an array of chars).
kono
parents:
diff changeset
37 --
kono
parents:
diff changeset
38 -- PROCESSING:
kono
parents:
diff changeset
39 -- The function will create a char array that is equal to the combined
kono
parents:
diff changeset
40 -- length of the char arrays referenced by the two input parameters.
kono
parents:
diff changeset
41 -- The char elements contained in the char arrays specified by the
kono
parents:
diff changeset
42 -- parameters will be combined (in order) into this new char array.
kono
parents:
diff changeset
43 --
kono
parents:
diff changeset
44 -- OUTPUTS:
kono
parents:
diff changeset
45 -- The newly created char array will be returned as the function
kono
parents:
diff changeset
46 -- result through the function name. The char arrays referenced by the
kono
parents:
diff changeset
47 -- two parameters will be unaffected.
kono
parents:
diff changeset
48 --
kono
parents:
diff changeset
49 -- CHANGE HISTORY:
kono
parents:
diff changeset
50 -- 12 Oct 95 SAIC Initial prerelease version.
kono
parents:
diff changeset
51 -- 26 Oct 96 SAIC Modified temp array initialization.
kono
parents:
diff changeset
52 -- 15 Feb 99 RLB Repaired to remove non-standard function strdup.
kono
parents:
diff changeset
53 --!
kono
parents:
diff changeset
54 */
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 #include <string.h>
kono
parents:
diff changeset
57 #include <stdlib.h>
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 char *stringdup (char *s)
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 char *result = malloc(sizeof(char)*(strlen(s)+1));
kono
parents:
diff changeset
62 return strcpy(result,s);
kono
parents:
diff changeset
63 }
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 char *CXB30131 (char *string1, char *string2)
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* NOTE: The above function definition should be accepted by an ANSI-C */
kono
parents:
diff changeset
68 /* compiler. Older C compilers may reject it; they may, however */
kono
parents:
diff changeset
69 /* accept the following three lines. An implementation may comment */
kono
parents:
diff changeset
70 /* out the above function definition and uncomment the following */
kono
parents:
diff changeset
71 /* one. Otherwise, an implementation must provide the necessary */
kono
parents:
diff changeset
72 /* modifications to this C code to satisfy the function */
kono
parents:
diff changeset
73 /* requirements (see Function Description). */
kono
parents:
diff changeset
74 /* */
kono
parents:
diff changeset
75 /* char *CXB30131 (string1, string2) */
kono
parents:
diff changeset
76 /* char *string1; */
kono
parents:
diff changeset
77 /* char *string2; */
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 {
kono
parents:
diff changeset
80 char temp[100]; /* Local array that holds the combined strings */
kono
parents:
diff changeset
81 int index; /* Loop counter */
kono
parents:
diff changeset
82 int length = 0; /* Variable that holds the length of the strings */
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 /* Initialize the local array */
kono
parents:
diff changeset
85 for (index = 0; index < 100; index++)
kono
parents:
diff changeset
86 { temp[index] = 0; }
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 /* Use the library function strcpy to copy the contents of string1
kono
parents:
diff changeset
89 into temp. */
kono
parents:
diff changeset
90 strcpy (temp, string1);
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 /* Use the library function strlen to determine the number of
kono
parents:
diff changeset
93 characters in the temp array (without the trailing nul). */
kono
parents:
diff changeset
94 length = strlen (temp);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 /* Add each character in string2 into the temp array, add nul
kono
parents:
diff changeset
97 to the end of the array. */
kono
parents:
diff changeset
98 for (index = length; *string2 != '\0'; index++)
kono
parents:
diff changeset
99 { temp[index] = *string2++; }
kono
parents:
diff changeset
100 temp[index] = '\0';
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Use the library function strdup to return a pointer to temp. */
kono
parents:
diff changeset
103 return (stringdup(temp));
kono
parents:
diff changeset
104 }