1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
--- platform.cpp.orig 2004-08-20 18:26:58 UTC
+++ platform.cpp
@@ -434,55 +434,4 @@ bool atob(const char *str)
return !stricmp(str, "true") || atof(str);
}
-S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
-{
- va_list args;
- va_start(args, format);
-#ifdef TNL_COMPILER_VISUALC
- S32 len = _vsnprintf(buffer, bufferSize, format, args);
-#else
- S32 len = vsnprintf(buffer, bufferSize, format, args);
-#endif
- return (len);
-}
-
-
-S32 dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist)
-{
-#ifdef TNL_COMPILER_VISUALC
- S32 len = _vsnprintf(buffer, bufferSize, format, (va_list) arglist);
-#else
- S32 len = vsnprintf(buffer, bufferSize, format, (char *) arglist);
-#endif
- return len;
-}
-
};
-
-
-#if defined (__GNUC__)
-
-int stricmp(const char *str1, const char *str2)
-{
- while(toupper(*str1) == toupper(*str2) && *str1)
- {
- str1++;
- str2++;
- }
- return (toupper(*str1) > toupper(*str2)) ? 1 : ((toupper(*str1) < toupper(*str2)) ? -1 : 0);
-}
-
-int strnicmp(const char *str1, const char *str2, unsigned int len)
-{
- for(unsigned int i = 0; i < len; i++)
- {
- if(toupper(str1[i]) == toupper(str2[i]))
- continue;
- return (toupper(str1[i]) > toupper(str2[i])) ? 1 : ((toupper(str1[i]) < toupper(str2[i])) ? -1 : 0);
- }
- return 0;
-}
-
-#endif
-
-
Use defines instead of (partially incorrect) function-wrappers for
standard functions.
-mi
--- tnlPlatform.h.orig 2004-09-28 18:45:25 UTC
+++ tnlPlatform.h
@@ -30,6 +30,7 @@
#ifndef _TNL_TYPES_H_
#include "tnlTypes.h"
#endif
+#include <stdio.h>
namespace TNL {
@@ -100,13 +101,14 @@ extern bool atob(const char *str); ///< String
/// Printf into string with a buffer size.
///
/// This will print into the specified string until the buffer size is reached.
-extern int dSprintf(char *buffer, U32 bufferSize, const char *format, ...);
+#ifdef TNL_COMPILER_VISUALC
+# define dSprintf _snprintf
+# define dVsprintf _vsnprintf
+#else
+# define dSprintf snprintf
+# define dVsprintf vsnprintf
+#endif
-/// Vsprintf with buffer size argument.
-///
-/// This will print into the specified string until the buffer size is reached.
-extern int dVsprintf(char *buffer, U32 bufferSize, const char *format, void *arglist); ///< compiler independent
-
inline char dToupper(const char c) { if (c >= char('a') && c <= char('z')) return char(c + 'A' - 'a'); else return c; } ///< Converts an ASCII character to upper case.
inline char dTolower(const char c) { if (c >= char('A') && c <= char('Z')) return char(c - 'A' + 'a'); else return c; } ///< Converts an ASCII character to lower case.
@@ -119,8 +121,8 @@ inline char dTolower(const char c) { if (c >= char('A'
#if defined (__GNUC__)
-int stricmp(const char *str1, const char *str2);
-int strnicmp(const char *str1, const char *str2, unsigned int len);
+#define stricmp(str1, str2) strcasecmp(str1, str2)
+#define strnicmp(str1, str2, size) strncasecmp(str1, str2, size)
#endif
|