Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156905590
D26353.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D26353.diff
View Options
Index: lib/libc/string/strchr.c
===================================================================
--- lib/libc/string/strchr.c
+++ lib/libc/string/strchr.c
@@ -29,7 +29,8 @@
char *__strchrnul(const char *, int);
-char *strchr(const char *s, int c)
+char *
+strchr(const char *s, int c)
{
char *r = __strchrnul(s, c);
return *(unsigned char *)r == (unsigned char)c ? r : 0;
Index: lib/libc/string/strchrnul.c
===================================================================
--- lib/libc/string/strchrnul.c
+++ lib/libc/string/strchrnul.c
@@ -25,29 +25,34 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <string.h>
-#include <stdint.h>
#include <limits.h>
+#include <stdint.h>
+#include <string.h>
#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)
+#define ONES ((size_t)-1 / UCHAR_MAX)
+#define HIGHS (ONES * (UCHAR_MAX / 2 + 1))
+#define HASZERO(x) (((x)-ONES) & ~(x)&HIGHS)
char *__strchrnul(const char *, int);
-char *__strchrnul(const char *s, int c)
+char *
+__strchrnul(const char *s, int c)
{
size_t *w, k;
c = (unsigned char)c;
- if (!c) return (char *)s + strlen(s);
+ if (!c)
+ return (char *)s + strlen(s);
for (; (uintptr_t)s % ALIGN; s++)
- if (!*s || *(unsigned char *)s == c) return (char *)s;
+ if (!*s || *(unsigned char *)s == c)
+ return (char *)s;
k = ONES * c;
- for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++);
- for (s = (void *)w; *s && *(unsigned char *)s != c; s++);
+ for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w ^ k); w++)
+ ;
+ for (s = (void *)w; *s && *(unsigned char *)s != c; s++)
+ ;
return (char *)s;
}
Index: lib/libc/string/strcspn.c
===================================================================
--- lib/libc/string/strcspn.c
+++ lib/libc/string/strcspn.c
@@ -27,20 +27,25 @@
#include <string.h>
-#define BITOP(a,b,op) \
- ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
+#define BITOP(a, b, op) \
+ ((a)[(size_t)(b) / (8 * sizeof *(a))] op(size_t) 1 \
+ << ((size_t)(b) % (8 * sizeof *(a))))
char *__strchrnul(const char *, int);
-size_t strcspn(const char *s, const char *c)
+size_t
+strcspn(const char *s, const char *c)
{
const char *a = s;
- size_t byteset[32/sizeof(size_t)];
+ size_t byteset[32 / sizeof(size_t)];
- if (!c[0] || !c[1]) return __strchrnul(s, *c)-a;
+ if (!c[0] || !c[1])
+ return __strchrnul(s, *c) - a;
memset(byteset, 0, sizeof byteset);
- for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++);
- for (; *s && !BITOP(byteset, *(unsigned char *)s, &); s++);
- return s-a;
+ for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++)
+ ;
+ for (; *s && !BITOP(byteset, *(unsigned char *)s, &); s++)
+ ;
+ return s - a;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 18, 6:14 AM (7 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33235766
Default Alt Text
D26353.diff (2 KB)
Attached To
Mode
D26353: clang-format libc string functions imported from musl
Attached
Detach File
Event Timeline
Log In to Comment