Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > 03bdd856d84db3146de6a56ce373d107 > files > 19

dietlibc-0.32-4.20090113.6.mga1.src.rpm

diff -Naurp dietlibc-0.32-20080509/lib/strncmp.c dietlibc-0.32-20080509.oden/lib/strncmp.c
--- dietlibc-0.32-20080509/lib/strncmp.c	2005-04-10 09:59:32.000000000 -0400
+++ dietlibc-0.32-20080509.oden/lib/strncmp.c	2008-06-08 12:49:28.000000000 -0400
@@ -6,12 +6,12 @@
 int strncmp(const char *s1, const char *s2, size_t n) {
   register const unsigned char* a=(const unsigned char*)s1;
   register const unsigned char* b=(const unsigned char*)s2;
-  register const unsigned char* fini=a+n;
-  while (a<fini) {
+  while (n>0) {
     register int res=*a-*b;
     if (res) return res;
     if (!*a) return 0;
     ++a; ++b;
+    --n;
   }
   return 0;
 }
diff -Naurp dietlibc-0.32-20080509/test/Makefile dietlibc-0.32-20080509.oden/test/Makefile
--- dietlibc-0.32-20080509/test/Makefile	2008-06-08 12:50:43.000000000 -0400
+++ dietlibc-0.32-20080509.oden/test/Makefile	2008-06-08 12:50:25.000000000 -0400
@@ -14,7 +14,7 @@ glob grent hasmntopt hello iconv if_name
 memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest \
 protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \
 speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
-strstr strtol sysenter ungetc waitpid
+strstr strtol strncmp sysenter ungetc waitpid
 
 test: $(TESTPROGRAMS)
 
@@ -49,6 +49,10 @@ timetests:
 	$(MAKE) -C time CC="$(CC)" CFLAGS="$(CFLAGS)" DIET=$(DIET) LCOMPAT=$(LCOMPAT)
 	
 	
+str%: str%.c
+	$(DIET) $(CC) $(CFLAGS) -fno-builtin $^ -o $@
+mem%: mem%.c
+	$(DIET) $(CC) $(CFLAGS) -fno-builtin $^ -o $@
 %: %.c
 	$(DIET) $(CC) $(CFLAGS) $^ -o $@
 
diff -Naurp dietlibc-0.32-20080509/test/strncmp.c dietlibc-0.32-20080509.oden/test/strncmp.c
--- dietlibc-0.32-20080509/test/strncmp.c	1969-12-31 19:00:00.000000000 -0500
+++ dietlibc-0.32-20080509.oden/test/strncmp.c	2008-06-08 12:49:28.000000000 -0400
@@ -0,0 +1,27 @@
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+int main(void)
+{
+  const char foo[] = "foo";
+
+  if (strncmp(foo, "bar", 3) == 0)
+    abort();
+  if (strncmp(foo, "foo", 3) != 0)
+    abort();
+  if (strncmp(foo, "", (size_t)-1) == 0)
+    abort();
+  if (strncmp(foo, "fo", 3) == 0)
+    abort();
+  if (strncmp(foo, "fo", 2) != 0)
+    abort();
+  if (strncmp(foo, "fo", 10) <= 0)
+    abort();
+  if (strncmp(foo, "fo", ULONG_MAX) <= 0)
+    abort();
+  if (strncmp(foo, "fo", (size_t)-1) <= 0)
+    abort();
+
+  return 0;
+}