iconv: add euro symbol to GBK as single byte 0x80
[musl.git] / src / string / stpcpy.c
blob4db46a9e50b2f53278a22b91bebea08fc7544f6b
1 #include <string.h>
2 #include <stdint.h>
3 #include <limits.h>
5 #define ALIGN (sizeof(size_t))
6 #define ONES ((size_t)-1/UCHAR_MAX)
7 #define HIGHS (ONES * (UCHAR_MAX/2+1))
8 #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
10 char *__stpcpy(char *restrict d, const char *restrict s)
12 #ifdef __GNUC__
13 typedef size_t __attribute__((__may_alias__)) word;
14 word *wd;
15 const word *ws;
16 if ((uintptr_t)s % ALIGN == (uintptr_t)d % ALIGN) {
17 for (; (uintptr_t)s % ALIGN; s++, d++)
18 if (!(*d=*s)) return d;
19 wd=(void *)d; ws=(const void *)s;
20 for (; !HASZERO(*ws); *wd++ = *ws++);
21 d=(void *)wd; s=(const void *)ws;
23 #endif
24 for (; (*d=*s); s++, d++);
26 return d;
29 weak_alias(__stpcpy, stpcpy);