mailing list of musl libc
 help / color / mirror / code / Atom feed
5c608957a40006d2bfa2cd74759ded5fa67dbe13 blob 800 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
#include <stdint.h>
#include <string.h>
#include "word.h"

/**
 * strncmp - Word sized c standard strncmp.
 * @c: Comparative
 * @s: Source
 * @n: Max size of @s
 */
int strncmp(const char *c, const char *s, size_t n)
{
	const size_t *wc, *ws;

	if ((uintptr_t)c % sizeof(size_t) != (uintptr_t)s % sizeof(size_t))
		goto misaligned;

	for (; (uintptr_t)c % sizeof(size_t); c++, s++, n--) {
		if (*c != *s || !*c || !*s || !n)
			return *(const unsigned char *)c
				- *(const unsigned char *)s;
	}

	for (wc = (const size_t *)c, ws = (const size_t *)s
	     ; !word_has_zero(*wc) || !word_has_zero(*ws)
	     ; wc++, ws++);

	c = (const char *)wc;
	s = (const char *)ws;

misaligned:
	for(; *c == *s && *c && *s && n; c++, s++, n--);

	return *(const unsigned char *)c - *(const unsigned char *)s;
}
debug log:

solving 5c60895 ...
found 5c60895 in https://inbox.vuxu.org/musl/1359936735-31915-4-git-send-email-nwmcsween@gmail.com/
found e228843 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 e228843f0bb394a209b764296e1df52fc8663344	src/string/strncmp.c

applying [1/1] https://inbox.vuxu.org/musl/1359936735-31915-4-git-send-email-nwmcsween@gmail.com/
diff --git a/src/string/strncmp.c b/src/string/strncmp.c
index e228843..5c60895 100644

Checking patch src/string/strncmp.c...
Applied patch src/string/strncmp.c cleanly.

index at:
100644 5c608957a40006d2bfa2cd74759ded5fa67dbe13	src/string/strncmp.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).