]> Zhao Yanbai Git Server - kernel.git/commitdiff
authorzhaoyanbai <zhaoyanbai@126.com>
Sat, 15 Aug 2026 00:42:14 +0000 (08:42 +0800)
committerzhaoyanbai <zhaoyanbai@126.com>
Sat, 15 Aug 2026 00:42:14 +0000 (08:42 +0800)
lib/string.c
lib/vsprintf.c

index c7ca91c..d1cc161 100644 (file)
@@ -88,11 +88,12 @@ char* strcat(char* dest, const char* src) {
     //     ;
     while (1) {
         *dest = *src;
-        dest++;
-        src++;
         if (*dest == 0) {
             break;
         }
+
+        dest++;
+        src++;
     }
     return tmp;
 }
index 1129c0a..2150486 100644 (file)
@@ -169,17 +169,19 @@ char* i64tou(char* s, uint64_t n) {
 
 char* itou(char* s, unsigned int n) {
     char* p = s;
+    char* h = s;
 
     do {
         *p++ = (n % 10) + '0';
         n /= 10;
     } while (n);
 
-    *p-- = 0;
+    *p = 0;
+    p--;
 
-    while (s < p) {
-        swap_char(s, p);
-        s++;
+    while (h < p) {
+        swap_char(h, p);
+        h++;
         p--;
     }
     return s;