X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=winsup%2Fmingw%2Fmingwex%2Fwmemmove.c;fp=winsup%2Fmingw%2Fmingwex%2Fwmemmove.c;h=3c545ac3206604d6d6dab8f45e0d66aab292c2f8;hb=ae4bf010374a9320497af260fa90af3fe8e2c5a5;hp=0000000000000000000000000000000000000000;hpb=3cc729069938336ea54d399c4bbbe7d197295f9a;p=pf3gnuchains%2Fpf3gnuchains3x.git diff --git a/winsup/mingw/mingwex/wmemmove.c b/winsup/mingw/mingwex/wmemmove.c new file mode 100644 index 0000000000..3c545ac320 --- /dev/null +++ b/winsup/mingw/mingwex/wmemmove.c @@ -0,0 +1,43 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include +#include +#include +#include + +wchar_t * +wmemmove(s1, s2, n) + register wchar_t *s1; + register const wchar_t *s2; + register size_t n; + { + wchar_t *orig_s1 = s1; + + if ( s1 == NULL || s2 == NULL || n == 0 ) + return orig_s1; /* robust */ + + /* XXX -- The following test works only within a flat address space! */ + if ( s2 >= s1 ) + for ( ; n > 0; --n ) + *s1++ = *s2++; + else { + s1 += n; + s2 += n; + + for ( ; n > 0; --n ) + *--s1 = *--s2; + } + + return orig_s1; + } +