[PATCH] DDX/libxf86config: Fix missing server internal symbols

Egbert Eich eich at freedesktop.org
Thu Aug 15 03:20:47 PDT 2013


With the option --enable-install-libxf86config the config file parser
can be installed independently. This however makes sense only if this
lib doesn't use any symbols from the Xserver.

Fix a.) by including os/utils.o and os/strlcpy.c
    b.) by implementing simple replacements for VErrorF(), ErrorF
    	and xstrtokenize()
    c.) by replacing xf86CheckBoolOption() with  xf86findOptionValue()
    	which requires a sligtly more complicated sematics.

Signed-off-by: Egbert Eich <eich at freedesktop.org>
---
Please note:
This fix has been taken from an enterprise product at SUSE. It has been 
ported to the current HEAD and tested minimally. 
Going forward we won't need this feature any more.
However a broken feature should either be removed or fixed (if a fix is
available).

 hw/xfree86/parser/Layout.c     | 11 +++---
 hw/xfree86/parser/Makefile.am  |  2 +
 hw/xfree86/parser/standalone.c | 88 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 5 deletions(-)
 create mode 100644 hw/xfree86/parser/standalone.c

diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index cbd8d24..1d9c1ad 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -62,9 +62,6 @@
 #include <string.h>
 #include "optionstr.h"
 
-/* Needed for auto server layout */
-extern int xf86CheckBoolOption(void *optlist, const char *name, int deflt);
-
 extern LexRec val;
 
 static xf86ConfigSymTabRec LayoutTab[] = {
@@ -431,8 +428,12 @@ xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
 
     /* add all AutoServerLayout devices to the server layout */
     while (input) {
-        if (xf86CheckBoolOption
-            (input->inp_option_lst, "AutoServerLayout", FALSE)) {
+	Bool asl_value = FALSE;
+	char *s = xf86findOptionValue(input->inp_option_lst ,
+				      "AutoServerLayout");
+	Bool asl_found = xf86getBoolValue(&asl_value, s);
+	if (asl_found == TRUE && asl_value == TRUE) {
+
             XF86ConfInputrefPtr iref = layout->lay_input_lst;
 
             /* avoid duplicates if referenced but lists AutoServerLayout too */
diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
index 002cfbf..654daed 100644
--- a/hw/xfree86/parser/Makefile.am
+++ b/hw/xfree86/parser/Makefile.am
@@ -32,6 +32,8 @@ libxf86config_internal_la_SOURCES = \
 
 libxf86config_la_SOURCES = \
 	$(top_srcdir)/os/xprintf.c \
+	$(top_srcdir)/os/strlcpy.c \
+	standalone.c \
 	$(INTERNAL_SOURCES)
 libxf86config_la_CFLAGS = $(AM_CFLAGS)
 libxf86config_la_LDFLAGS = -static
diff --git a/hw/xfree86/parser/standalone.c b/hw/xfree86/parser/standalone.c
new file mode 100644
index 0000000..dfd36da
--- /dev/null
+++ b/hw/xfree86/parser/standalone.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013 Egbert Eich
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdarg.h>
+#include <string.h>
+#include "os.h"
+
+/*
+ * Tokenize a string into a NULL terminated array of strings. Always returns
+ * an allocated array unless an error occurs.
+ */
+char**
+xstrtokenize(const char *str, const char *separators)
+{
+    char **list, **nlist;
+    char *tok, *tmp;
+    unsigned num = 0, n;
+
+    if (!str)
+        return NULL;
+    list = calloc(1, sizeof(*list));
+    if (!list)
+        return NULL;
+    tmp = strdup(str);
+    if (!tmp)
+        goto error;
+    for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
+        nlist = realloc(list, (num + 2) * sizeof(*list));
+        if (!nlist)
+            goto error;
+        list = nlist;
+        list[num] = strdup(tok);
+        if (!list[num])
+            goto error;
+        list[++num] = NULL;
+    }
+    free(tmp);
+    return list;
+
+error:
+    free(tmp);
+    for (n = 0; n < num; n++)
+        free(list[n]);
+    free(list);
+    return NULL;
+}
+
+VErrorF(const char *f, va_list args)
+{
+    vfprintf(stderr, f, args);
+}
+
+void
+ErrorF(const char *f, ...)
+{
+    va_list args;
+
+    va_start(args, f);
+    VErrorF(f, args);
+    va_end(args);
+}
-- 
1.8.1.4



More information about the xorg-devel mailing list