X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=inline;f=src%2Fstring%2Fstpcpy.c;h=06623c4491c4f6ebb26d7a7c664c06a4a3f54f9f;hb=a7dbcf5c8ca7edb7a46eb276031ad1df4131135b;hp=10ca4933d2bad8ac2c3320d6e0cd18f6e83a0e36;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/string/stpcpy.c b/src/string/stpcpy.c index 10ca4933..06623c44 100644 --- a/src/string/stpcpy.c +++ b/src/string/stpcpy.c @@ -1,22 +1,21 @@ #include -#include #include #include #include "libc.h" -#define ALIGN (sizeof(size_t)-1) +#define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) -char *__stpcpy(char *d, const char *s) +char *__stpcpy(char *restrict d, const char *restrict s) { size_t *wd; const size_t *ws; - if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) { - for (; (*d=*s) && ((uintptr_t)s & ALIGN); s++, d++); - if (!*s) return d; + if ((uintptr_t)s % ALIGN == (uintptr_t)d % ALIGN) { + for (; (uintptr_t)s % ALIGN; s++, d++) + if (!(*d=*s)) return d; wd=(void *)d; ws=(const void *)s; for (; !HASZERO(*ws); *wd++ = *ws++); d=(void *)wd; s=(const void *)ws;