OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxb/] [cxb30131.c] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.