Mesa (master): util: drop strncat(), strcmp(), strncmp(), snprintf() & vsnprintf() MSVC fallbacks
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jul 19 21:48:52 UTC 2019
Module: Mesa
Branch: master
Commit: 6f8b5872ab9238a3b3965c43edb6a5c9192d470d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f8b5872ab9238a3b3965c43edb6a5c9192d470d
Author: Eric Engestrom <eric.engestrom at intel.com>
Date: Thu Jul 4 16:13:34 2019 +0100
util: drop strncat(), strcmp(), strncmp(), snprintf() & vsnprintf() MSVC fallbacks
It would seem MSVC>=2015 is now C99-compliant wrt these functions:
strncat: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strncat-strncat-l-wcsncat-wcsncat-l-mbsncat-mbsncat-l?view=vs-2017
strcmp: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strcmp-wcscmp-mbscmp?view=vs-2017
strncmp: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strncmp-wcsncmp-mbsncmp-mbsncmp-l?view=vs-2017
snprintf: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=vs-2017
vsnprintf: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l?view=vs-2017
Suggested-by: Emil Velikov <emil.velikov at collabora.com>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/util/u_string.h | 81 -----------------------------------------------------
1 file changed, 81 deletions(-)
diff --git a/src/util/u_string.h b/src/util/u_string.h
index 055d769fe13..499894b9f94 100644
--- a/src/util/u_string.h
+++ b/src/util/u_string.h
@@ -65,37 +65,6 @@ util_strchrnul(const char *s, char c)
#ifdef _WIN32
-#define vsnprintf util_vsnprintf
-static inline int
-util_vsnprintf(char *str, size_t size, const char *format, va_list ap)
-{
- /* We need to use _vscprintf to calculate the length as vsnprintf returns -1
- * if the number of characters to write is greater than count.
- */
- va_list ap_copy;
- int ret;
- va_copy(ap_copy, ap);
- ret = _vsnprintf(str, size, format, ap);
- if (ret < 0) {
- ret = _vscprintf(format, ap_copy);
- }
- va_end(ap_copy);
- return ret;
-}
-
-#define snprintf util_snprintf
-static inline int
- PRINTFLIKE(3, 4)
-util_snprintf(char *str, size_t size, const char *format, ...)
-{
- va_list ap;
- int ret;
- va_start(ap, format);
- ret = vsnprintf(str, size, format, ap);
- va_end(ap);
- return ret;
-}
-
#define sprintf util_sprintf
static inline void
PRINTFLIKE(2, 3)
@@ -129,56 +98,6 @@ util_vasprintf(char **ret, const char *format, va_list ap)
return vsnprintf(*ret, r + 1, format, ap);
}
-#define strncat util_strncat
-static inline char*
-util_strncat(char *dst, const char *src, size_t n)
-{
- char *p = dst + strlen(dst);
- const char *q = src;
- size_t i;
-
- for (i = 0; i < n && *q != '\0'; ++i)
- *p++ = *q++;
- *p = '\0';
-
- return dst;
-}
-
-#define strcmp util_strcmp
-static inline int
-util_strcmp(const char *s1, const char *s2)
-{
- unsigned char u1, u2;
-
- while (1) {
- u1 = (unsigned char) *s1++;
- u2 = (unsigned char) *s2++;
- if (u1 != u2)
- return u1 - u2;
- if (u1 == '\0')
- return 0;
- }
- return 0;
-}
-
-#define strncmp util_strncmp
-static inline int
-util_strncmp(const char *s1, const char *s2, size_t n)
-{
- unsigned char u1, u2;
-
- while (n-- > 0) {
- u1 = (unsigned char) *s1++;
- u2 = (unsigned char) *s2++;
- if (u1 != u2)
- return u1 - u2;
- if (u1 == '\0')
- return 0;
- }
- return 0;
-}
-
-
#define strcasecmp stricmp
#define strdup _strdup
More information about the mesa-commit
mailing list