genericopenlibs/cstdlib/LCHAR/STRCAT.C
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * FUNCTION
       
    16 * <<strcat>>---concatenate strings
       
    17 * INDEX
       
    18 * strcat
       
    19 * ANSI_SYNOPSIS
       
    20 * #include <string.h>
       
    21 * char *strcat(char *<[dst]>, const char *<[src]>);
       
    22 * TRAD_SYNOPSIS
       
    23 * #include <string.h>
       
    24 * char *strcat(<[dst]>, <[src]>)
       
    25 * char *<[dst]>;
       
    26 * char *<[src]>;
       
    27 * <<strcat>> appends a copy of the string pointed to by <[src]>
       
    28 * (including the terminating null character) to the end of the
       
    29 * string pointed to by <[dst]>.  The initial character of
       
    30 * <[src]> overwrites the null character at the end of <[dst]>.
       
    31 * RETURNS
       
    32 * This function returns the initial value of <[dst]>
       
    33 * PORTABILITY
       
    34 * <<strcat>> is ANSI C.
       
    35 * <<strcat>> requires no supporting OS subroutines.
       
    36 * QUICKREF
       
    37 * strcat ansi pure
       
    38 * 
       
    39 *
       
    40 */
       
    41 
       
    42 
       
    43 
       
    44 #include <string.h>
       
    45 
       
    46 /*SUPPRESS 560*/
       
    47 /*SUPPRESS 530*/
       
    48 
       
    49 /**
       
    50 Append string.
       
    51 Appends s2 string to s1 string. 
       
    52 The terminating null character in s1 is overwritten by the first character of s2.
       
    53 The resulting string includes a null-character at end.
       
    54 @return s1.
       
    55 @param s1 Pointer to a null-terminated string with enough space allocated to 
       
    56 contain both s2 and s1. 
       
    57 @param s2 Null-terminated string to append.
       
    58 */
       
    59 EXPORT_C char * strcat (char *s1, const char *s2)
       
    60 {
       
    61   char *s = s1;
       
    62 
       
    63   while (*s1)
       
    64     s1++;
       
    65 
       
    66   while ((*s1++ = *s2++)!=0)
       
    67     ;
       
    68   return s;
       
    69 }
       
    70 
       
    71 /**
       
    72 Append a copy of the wide-character string pointed to by s2
       
    73 @return s1
       
    74 @param s1 wide-character
       
    75 @param s2 wide-character
       
    76 */
       
    77 EXPORT_C wchar_t * wcscat (wchar_t *s1, const wchar_t *s2)
       
    78 {
       
    79   wchar_t *s = s1;
       
    80 
       
    81   while (*s1)
       
    82     s1++;
       
    83 
       
    84   while ((*s1++ = *s2++)!=L'\0')
       
    85     ;
       
    86   return s;
       
    87 }