X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstring%2Fstpcpy.c;h=feb9eb8156bc16675df962edc47cd9ffdc36adfa;hb=f206fec1c8162ea93ece055f09a571acde69974a;hp=10ca4933d2bad8ac2c3320d6e0cd18f6e83a0e36;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/string/stpcpy.c b/src/string/stpcpy.c index 10ca4933..feb9eb81 100644 --- a/src/string/stpcpy.c +++ b/src/string/stpcpy.c @@ -4,19 +4,19 @@ #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;