Usermode/GUI Terminal - Fixed some characters not triggering end of normal text
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / string.c
index e9e1574..2ab271f 100644 (file)
@@ -100,6 +100,18 @@ EXPORT char *strcat(char *dst, const char *src)
        return dst;
 }
 
+EXPORT char *strncat(char *dst, const char *src, size_t n)
+{
+       char    *to = dst;
+       // Find the end
+       while(*to)      to++;
+       // Copy
+       while(*src && n--)      *to++ = *src++;
+       // End string
+       *to = '\0';
+       return dst;
+}
+
 /**
  * \brief Get the length of a string
  */
@@ -188,13 +200,13 @@ EXPORT char *strrchr(const char *str, int character)
  * \fn EXPORT char *strstr(char *str1, const char *str2)
  * \brief Search a \a str1 for the first occurance of \a str2
  */
-EXPORT char *strstr(char *str1, const char *str2)
+EXPORT char *strstr(const char *str1, const char *str2)
 {
        const char      *test = str2;
        
        for(;*str1;str1++)
        {
-               if(*test == '\0')       return str1;
+               if(*test == '\0')       return (char*)str1;
                if(*str1 == *test)      test++;
                else    test = str2;
        }
@@ -273,10 +285,11 @@ EXPORT void *memmove(void *dest, const void *src, size_t count)
        char *sp = (char *)src;
        char *dp = (char *)dest;
        // Check if the areas overlap
-       if( (intptr_t)dest > (intptr_t)src && (intptr_t)dest < (intptr_t)src+count )
-               for(;count--;) dp[count] = sp[count];
+       if( (uintptr_t)src < (uintptr_t)dest && (uintptr_t)dest < (uintptr_t)src+count )
+               for(;count--;)
+                       dp[count] = sp[count];
        else
-               for(;count--;) *dp++ = *sp++;
+               memcpy(dest, src, count);
        return dest;
 }
 

UCC git Repository :: git.ucc.asn.au