]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Remove Str_Mbscpy and Str_Mbscat
authorOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:18 +0000 (14:21 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:18 +0000 (14:21 -0700)
Since we assume that all non-wide-char strings are UTF-8, the
implementations of Str_Mbscpy and Str_Mbscat are basically
identical to those of Str_Strcpy and Str_Strcat.  We thus do
not need the Str_Mbs versions.

open-vm-tools/lib/include/str.h
open-vm-tools/lib/string/str.c

index 2234a26110fd9fe9c9d89e0e6a3ab85b5236d389..89889406f7c49b60c7c67258c724c663e602cf4a 100644 (file)
@@ -197,20 +197,9 @@ wchar_t *Str_SafeVaswprintf(size_t *length,         // OUT/OPT:
                             const wchar_t *format,  // IN:
                             va_list arguments);     // IN:
 
-unsigned char *Str_Mbscpy(char *buf,        // OUT:
-                          const char *src,  // IN:
-                          size_t maxSize);  // IN:
-unsigned char *Str_Mbscat(char *buf,        // IN/OUT:
-                          const char *src,  // IN:
-                          size_t maxSize);  // IN:
-
 /*
  * These are handly for Windows programmers.  They are like
  * the _tcs functions, but with Str_Strcpy-style bounds checking.
- *
- * We don't have Str_Mbsncat() because it has some odd semantic
- * ambiguity (whether to truncate in the middle of a multibyte
- * sequence) that I want to stay away from.  -- edward
  */
 
 #ifdef _WIN32
@@ -218,8 +207,8 @@ unsigned char *Str_Mbscat(char *buf,        // IN/OUT:
    #define Str_Tcscpy(s1, s2, n) Str_Wcscpy(s1, s2, n)
    #define Str_Tcscat(s1, s2, n) Str_Wcscat(s1, s2, n)
 #else
-   #define Str_Tcscpy(s1, s2, n) Str_Mbscpy(s1, s2, n)
-   #define Str_Tcscat(s1, s2, n) Str_Mbscat(s1, s2, n)
+   #define Str_Tcscpy(s1, s2, n) Str_Strcpy(s1, s2, n)
+   #define Str_Tcscat(s1, s2, n) Str_Strcat(s1, s2, n)
 #endif
 #endif
 
index b18ffbe75a65916b78db2e845ecf27221cba6480..a295ea2c2ba32ba27c93b4fa36f9551774a62612 100644 (file)
@@ -954,78 +954,6 @@ Str_Wcsncat(wchar_t *buf,       // IN/OUT
 }
 
 
-/*
- *----------------------------------------------------------------------
- *
- * Str_Mbscpy --
- *
- *    Wrapper for _mbscpy that checks for buffer overruns.
- *
- * Results:
- *    Same as strcpy.
- *
- * Side effects:
- *    None.
- *
- *----------------------------------------------------------------------
- */
-
-unsigned char *
-Str_Mbscpy(char *buf,        // OUT
-           const char *src,  // IN
-           size_t maxSize)   // IN
-{
-   size_t len;
-
-   len = strlen(src);
-   if (len >= maxSize) {
-      Panic("%s:%d Buffer too small\n", __FILE__, __LINE__);
-   }
-   return memcpy(buf, src, len + 1);
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * Str_Mbscat --
- *
- *    Wrapper for _mbscat that checks for buffer overruns.
- *
- *    The Microsoft _mbscat may or may not deal with tailing
- *    partial multibyte sequence in buf.  We don't.
- *
- * Results:
- *    Same as strcat.
- *
- * Side effects:
- *    None.
- *
- *----------------------------------------------------------------------
- */
-
-unsigned char *
-Str_Mbscat(char *buf,        // IN/OUT
-           const char *src,  // IN
-           size_t maxSize)   // IN
-{
-   size_t bufLen;
-   size_t srcLen;
-
-   bufLen = strlen(buf);
-   srcLen = strlen(src);
-
-   /* The first comparison checks for numeric overflow */
-   if (bufLen + srcLen < srcLen || bufLen + srcLen >= maxSize) {
-      Panic("%s:%d Buffer too small\n", __FILE__, __LINE__);
-   }
-
-   memcpy(buf + bufLen, src, srcLen + 1);
-
-   return (unsigned char *)buf;
-}
-
-
 /*
  *-----------------------------------------------------------------------------
  *