aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/drivers/dri/common/xmlconfig.c')
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index ce376475c..d11ba4e4b 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -101,7 +101,11 @@ static const char *__getProgramName () {
# define GET_PROGRAM_NAME() __getProgramName()
# else
# define GET_PROGRAM_NAME() ""
+# ifdef _MSC_VER
+# pragma message("Per application configuration won't work with your OS version.")
+# else
# warning "Per application configuration won't work with your OS version."
+# endif
# endif
#endif
@@ -286,6 +290,29 @@ static float strToF (const XML_Char *string, const XML_Char **tail) {
return result;
}
+#if !defined(HAVE_STRNDUP)
+
+/* Emulates glibc's strndup() */
+char *
+strndup(const char *str, size_t size)
+{
+ size_t len;
+ char *result = (char *)NULL;
+
+ if ((char *)NULL == str) return (char *)NULL;
+
+ len = strlen(str);
+ if (!len) return strdup("");
+ if (size > len) size = len;
+
+ result = (char *)malloc((size + 1) * sizeof (char));
+ memcpy(result, str, size);
+ result[size] = 0x0;
+ return result;
+}
+
+#endif /* _WIN32 should be !HAVE_STRNDUP */
+
/** \brief Parse a value of a given type. */
static unsigned char parseValue (driOptionValue *v, driOptionType type,
const XML_Char *string) {
@@ -445,11 +472,11 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0)
-#define XML_WARNING(msg,args...) do { \
+#define XML_WARNING(msg, ...) do { \
__driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
} while (0)
/** \brief Output an error message. */
#define XML_ERROR1(msg) do { \
@@ -457,11 +484,11 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser)); \
} while (0)
-#define XML_ERROR(msg,args...) do { \
+#define XML_ERROR(msg, ...) do { \
__driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
} while (0)
/** \brief Output a fatal error message and abort. */
#define XML_FATAL1(msg) do { \
@@ -471,12 +498,12 @@ __driUtilMessage(const char *f, ...)
(int) XML_GetCurrentColumnNumber(data->parser)); \
abort();\
} while (0)
-#define XML_FATAL(msg,args...) do { \
+#define XML_FATAL(msg, ...) do { \
fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
data->name, \
(int) XML_GetCurrentLineNumber(data->parser), \
(int) XML_GetCurrentColumnNumber(data->parser), \
- args); \
+ __VA_ARGS__); \
abort();\
} while (0)