]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOStringFuncs.c
xnu-4903.221.2.tar.gz
[apple/xnu.git] / iokit / Kernel / IOStringFuncs.c
index c4f9458feab9f32386c485cf486fa08e4c317570..6890305d67e15fa4680b36fea3fa78ced4268a6c 100644 (file)
@@ -475,17 +475,18 @@ strtouq(const char *nptr,
 char *
 strncat(char *s1, const char *s2, unsigned long n)
 {
-       char *os1;
-       int i = n;
+       if (n != 0) {
+               char *d = s1;
+               const char *s = s2;
 
-       os1 = s1;
-       while (*s1++)
-               ;
-       --s1;
-       while ((*s1++ = *s2++))
-               if (--i < 0) {
-                       *--s1 = '\0';
-                       break;
-               }
-       return(os1);
+               while (*d != 0)
+                       d++;
+               do {
+                       if ((*d = *s++) == '\0')
+                               break;
+                       d++;
+               } while (--n != 0);
+               *d = '\0';
+       }
+       return (s1);
 }