aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fontconfig/fonts.conf.in6
-rw-r--r--fontconfig/src/fcarch.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp4
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c4
-rw-r--r--xorg-server/include/Xprintf.h12
-rw-r--r--xorg-server/os/log.c105
-rw-r--r--xorg-server/os/xprintf.c44
7 files changed, 112 insertions, 65 deletions
diff --git a/fontconfig/fonts.conf.in b/fontconfig/fonts.conf.in
index 533381b9d..8f9fb8823 100644
--- a/fontconfig/fonts.conf.in
+++ b/fontconfig/fonts.conf.in
@@ -34,7 +34,7 @@
<test qual="any" name="family">
<string>mono</string>
</test>
- <edit name="family" mode="assign">
+ <edit name="family" mode="assign" binding="same">
<string>monospace</string>
</edit>
</match>
@@ -46,7 +46,7 @@
<test qual="any" name="family">
<string>sans serif</string>
</test>
- <edit name="family" mode="assign">
+ <edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
@@ -58,7 +58,7 @@
<test qual="any" name="family">
<string>sans</string>
</test>
- <edit name="family" mode="assign">
+ <edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
diff --git a/fontconfig/src/fcarch.c b/fontconfig/src/fcarch.c
index 5fe7d97d8..44548fc1b 100644
--- a/fontconfig/src/fcarch.c
+++ b/fontconfig/src/fcarch.c
@@ -56,8 +56,6 @@ FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcStrSet *));
FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcCharLeaf **));
FC_ASSERT_STATIC (SIZEOF_VOID_P == sizeof (FcChar16 *));
-#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
-
FC_ASSERT_STATIC (0x08 + 1*FC_MAX(4,ALIGNOF_DOUBLE) == sizeof (FcValue));
FC_ASSERT_STATIC (0x00 + 2*SIZEOF_VOID_P == sizeof (FcPatternElt));
FC_ASSERT_STATIC (0x08 + 2*SIZEOF_VOID_P == sizeof (FcPattern));
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9e68deb34..eecabb3e6 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1775,9 +1775,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
emit(ir, TGSI_OPCODE_TRUNC, result_dst, op[0]);
break;
case ir_unop_ceil:
- op[0].negate = ~op[0].negate;
- emit(ir, TGSI_OPCODE_FLR, result_dst, op[0]);
- result_src.negate = ~result_src.negate;
+ emit(ir, TGSI_OPCODE_CEIL, result_dst, op[0]);
break;
case ir_unop_floor:
emit(ir, TGSI_OPCODE_FLR, result_dst, op[0]);
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index a773c34c6..aca0734e0 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -1679,11 +1679,11 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size)
for (i = 0; i < size; i++) {
if (gamma == 1.0)
- ramp[i] = i << 8;
+ ramp[i] = i | i << 8;
else
ramp[i] =
(CARD16) (pow((double) i / (double) (size - 1), 1. / gamma)
- * (double) (size - 1) * 256);
+ * (double) (size - 1) * 257);
}
}
diff --git a/xorg-server/include/Xprintf.h b/xorg-server/include/Xprintf.h
index 414fd46fb..9e8cdc5dc 100644
--- a/xorg-server/include/Xprintf.h
+++ b/xorg-server/include/Xprintf.h
@@ -66,4 +66,16 @@ _X_ATTRIBUTE_PRINTF(2, 0);
#define vasprintf Xvasprintf
#endif
+/*
+ * These functions provide a portable implementation of the linux kernel
+ * scnprintf & vscnprintf routines that return the number of bytes actually
+ * copied during a snprintf, (excluding the final '\0').
+ */
+extern _X_EXPORT int
+Xscnprintf(char *s, int n, const char * _X_RESTRICT_KYWD fmt, ...)
+_X_ATTRIBUTE_PRINTF(3,4);
+extern _X_EXPORT int
+Xvscnprintf(char *s, int n, const char * _X_RESTRICT_KYWD fmt, va_list va)
+_X_ATTRIBUTE_PRINTF(3,0);
+
#endif /* XPRINTF_H */
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 061b3dd61..2c13c1a7d 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -168,7 +168,7 @@ asm(".desc ___crashreporter_info__, 0x10");
#define X_DEBUG_STRING "(DB)"
#endif
#ifndef X_NONE_STRING
-#define X_NONE_STRING ""
+#define X_NONE_STRING ""
#endif
/*
@@ -226,7 +226,7 @@ LogInit(const char *fname, const char *backup)
* needed.
*/
if (saveBuffer && bufferSize > 0) {
- free(saveBuffer); /* Must be free(), not free() */
+ free(saveBuffer);
saveBuffer = NULL;
bufferSize = 0;
}
@@ -268,36 +268,19 @@ LogSetParameter(LogParameter param, int value)
}
/* This function does the actual log message writes. */
-
-void
-LogVWrite(int verb, const char *f, va_list args)
+static void
+LogSWrite(int verb, const char *buf, size_t len, Bool end_line)
{
- static char tmpBuffer[1024];
- int len = 0;
static Bool newline = TRUE;
- if (newline) {
- sprintf(tmpBuffer, "[%10.3f] ", GetTimeInMillis() / 1000.0);
- len = strlen(tmpBuffer);
- if (logFile)
- fwrite(tmpBuffer, len, 1, logFile);
- }
-
- /*
- * Since a va_list can only be processed once, write the string to a
- * buffer, and then write the buffer out to the appropriate output
- * stream(s).
- */
- if (verb < 0 || logFileVerbosity >= verb || logVerbosity >= verb) {
- vsnprintf(tmpBuffer, sizeof(tmpBuffer), f, args);
- len = strlen(tmpBuffer);
- }
- newline = (tmpBuffer[len - 1] == '\n');
- if ((verb < 0 || logVerbosity >= verb) && len > 0)
- fwrite(tmpBuffer, len, 1, stderr);
- if ((verb < 0 || logFileVerbosity >= verb) && len > 0) {
+ if (verb < 0 || logVerbosity >= verb)
+ fwrite(buf, len, 1, stderr);
+ if (verb < 0 || logFileVerbosity >= verb) {
if (logFile) {
- fwrite(tmpBuffer, len, 1, logFile);
+ if (newline)
+ fprintf(logFile, "[%10.3f] ", GetTimeInMillis() / 1000.0);
+ newline = end_line;
+ fwrite(buf, len, 1, logFile);
if (logFlush) {
fflush(logFile);
#ifndef WIN32
@@ -315,13 +298,19 @@ LogVWrite(int verb, const char *f, va_list args)
FatalError("realloc() failed while saving log messages\n");
}
bufferUnused -= len;
- memcpy(saveBuffer + bufferPos, tmpBuffer, len);
+ memcpy(saveBuffer + bufferPos, buf, len);
bufferPos += len;
}
}
}
void
+LogVWrite(int verb, const char *f, va_list args)
+{
+ return LogVMessageVerb(X_NONE, verb, f, args);
+}
+
+void
LogWrite(int verb, const char *f, ...)
{
va_list args;
@@ -376,22 +365,28 @@ void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
const char *type_str;
- char tmpFormat[1024];
- const char *new_format;
+ char buf[1024];
+ const size_t size = sizeof(buf);
+ Bool newline;
+ size_t len = 0;
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
return;
- /* if type_str is not "", prepend it and ' ', to format */
- if (type_str[0] == '\0')
- new_format = format;
- else {
- new_format = tmpFormat;
- snprintf(tmpFormat, sizeof(tmpFormat), "%s %s", type_str, format);
- }
+ /* if type_str is not "", prepend it and ' ', to message */
+ if (type_str[0] != '\0')
+ len += Xscnprintf(&buf[len], size - len, "%s ", type_str);
+
+ if (size - len > 1)
+ len += Xvscnprintf(&buf[len], size - len, format, args);
+
+ /* Force '\n' at end of truncated line */
+ if (size - len == 1)
+ buf[len - 1] = '\n';
- LogVWrite(verb, new_format, args);
+ newline = (buf[len - 1] == '\n');
+ LogSWrite(verb, buf, len, newline);
}
/* Log message with verbosity level specified. */
@@ -421,31 +416,31 @@ LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
va_list msg_args, const char *hdr_format, va_list hdr_args)
{
const char *type_str;
- char tmpFormat[1024];
- char *tmpFormat_end = &tmpFormat[sizeof(tmpFormat)];
- char *p;
- int left;
+ char buf[1024];
+ const size_t size = sizeof(buf);
+ Bool newline;
+ size_t len = 0;
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
return;
- /* if type_str != "", copy it and ' ' to tmpFormat; set p after ' ' */
- p = tmpFormat;
+ /* if type_str is not "", prepend it and ' ', to message */
if (type_str[0] != '\0')
- p += snprintf(tmpFormat, sizeof(tmpFormat), "%s ", type_str);
+ len += Xscnprintf(&buf[len], size - len, "%s ", type_str);
+
+ if (hdr_format && size - len > 1)
+ len += Xvscnprintf(&buf[len], size - len, hdr_format, hdr_args);
- /* append as much of hdr as fits after type_str (if there was one) */
- left = tmpFormat_end - p;
- if (left > 1)
- p += vsnprintf(p, left, hdr_format, hdr_args);
+ if (msg_format && size - len > 1)
+ len += Xvscnprintf(&buf[len], size - len, msg_format, msg_args);
- /* append as much of msg_format as will fit after hdr */
- left = tmpFormat_end - p;
- if (left > 1)
- snprintf(p, left, "%s", msg_format);
+ /* Force '\n' at end of truncated line */
+ if (size - len == 1)
+ buf[len - 1] = '\n';
- LogVWrite(verb, tmpFormat, msg_args);
+ newline = (buf[len - 1] == '\n');
+ LogSWrite(verb, buf, len, newline);
}
void
diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c
index 17fea2ec7..80caa5790 100644
--- a/xorg-server/os/xprintf.c
+++ b/xorg-server/os/xprintf.c
@@ -186,6 +186,50 @@ XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
return size;
}
+/**
+ * Varargs snprintf that returns the actual number of bytes (excluding final
+ * '\0') that were copied into the buffer.
+ * This is opposed to the normal sprintf() usually returns the number of bytes
+ * that would have been written.
+ *
+ * @param s buffer to copy into
+ * @param n size of buffer s
+ * @param format printf style format string
+ * @param va variable argument list
+ * @return number of bytes actually copied, excluding final '\0'
+ */
+int
+Xvscnprintf(char *s, int n, const char *format, va_list args)
+{
+ int x;
+ if (n == 0)
+ return 0;
+ x = vsnprintf(s, n , format, args);
+ return (x >= n) ? (n - 1) : x;
+}
+
+/**
+ * snprintf that returns the actual number of bytes (excluding final '\0') that
+ * were copied into the buffer.
+ * This is opposed to the normal sprintf() usually returns the number of bytes
+ * that would have been written.
+ *
+ * @param s buffer to copy into
+ * @param n size of buffer s
+ * @param format printf style format string
+ * @param ... arguments for specified format
+ * @return number of bytes actually copied, excluding final '\0'
+ */
+int Xscnprintf(char *s, int n, const char *format, ...)
+{
+ int x;
+ va_list ap;
+ va_start(ap, format);
+ x = Xvscnprintf(s, n, format, ap);
+ va_end(ap);
+ return x;
+}
+
/* Old api, now deprecated, may be removed in the future */
char *
Xvprintf(const char *format, va_list va)