Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmbsncat.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS system libraries 00004 * FILE: lib/msvcrt/mbstring/mbsncat.c 00005 * PURPOSE: Concatenate two multi byte string to maximum of n characters or bytes 00006 * PROGRAMER: Ariadne 00007 * UPDATE HISTORY: 00008 * 12/04/99: Created 00009 */ 00010 00011 #include <precomp.h> 00012 #include <mbstring.h> 00013 #include <string.h> 00014 00015 size_t _mbclen2(const unsigned int s); 00016 unsigned char *_mbset (unsigned char *string, int c); 00017 00018 /* 00019 * @implemented 00020 */ 00021 unsigned char *_mbsncat (unsigned char *dst, const unsigned char *src, size_t n) 00022 { 00023 int c; 00024 unsigned char *save = dst; 00025 00026 while ((c = _mbsnextc (dst))) 00027 dst = _mbsinc (dst); 00028 00029 while (n-- > 0 && (c = _mbsnextc (src))) { 00030 00031 _mbset (dst, c); 00032 00033 dst = _mbsinc (dst); 00034 00035 src = _mbsinc ((unsigned char *) src); 00036 00037 } 00038 00039 *dst = '\0'; 00040 00041 return save; 00042 } 00043 00044 /* 00045 * @implemented 00046 */ 00047 unsigned char * _mbsnbcat(unsigned char *dst, const unsigned char *src, size_t n) 00048 { 00049 unsigned char *d; 00050 const unsigned char *s = src; 00051 if (n != 0) { 00052 d = dst + _mbslen(dst); // get the end of string 00053 d += _mbclen2(*d); // move 1 or 2 up 00054 00055 do { 00056 if ((*d++ = *s++) == 0) 00057 { 00058 while (--n != 0) 00059 *d++ = 0; 00060 break; 00061 } 00062 if ( !(n==1 && _ismbblead(*s)) ) 00063 n--; 00064 } while (n > 0); 00065 } 00066 return dst; 00067 } Generated on Thu May 24 2012 04:36:57 for ReactOS by
1.7.6.1
|