genericopenlibs/openenvcore/libc/src/string/wcpncpy.c
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 2005-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 * Name        : wcpncpy.c
       
    16 * Part of     : MRT
       
    17 * Implementation for wcpncpy API
       
    18 * Version     : 1.0
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 #include <wchar.h>
       
    25 
       
    26 //copies a fixed length string of wide characters and
       
    27 //returns a pointer to its end
       
    28 
       
    29 EXPORT_C wchar_t *wcpncpy(wchar_t * dst, const wchar_t * src, size_t n)
       
    30 {
       
    31         wchar_t *dptr;
       
    32         const wchar_t *sptr;
       
    33         size_t count;
       
    34 
       
    35         dptr = dst;
       
    36         sptr = src;
       
    37         count = n;
       
    38         while (count > 0)
       
    39         {
       
    40                 --count;
       
    41                 if ((*dptr++ = *sptr++) == L'\0')
       
    42                         break;
       
    43         }
       
    44         while (count > 0)
       
    45         {
       
    46                 count--;
       
    47                 *dptr++ = L'\0';
       
    48         }
       
    49 
       
    50         return (dptr - 1);
       
    51 }
       
    52