diff options
-rw-r--r-- | hw/xfree86/common/xf86Option.c | 25 | ||||
-rw-r--r-- | hw/xfree86/parser/Configint.h | 2 | ||||
-rw-r--r-- | hw/xfree86/parser/scan.c | 30 | ||||
-rw-r--r-- | hw/xfree86/parser/xf86Parser.h | 9 |
4 files changed, 43 insertions, 23 deletions
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index ad8d1c426..a2868bf21 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -42,6 +42,7 @@ #include "xf86.h" #include "xf86Xinput.h" #include "xf86Optrec.h" +#include "xf86Parser.h" static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p, Bool markUsed); @@ -456,29 +457,7 @@ xf86ShowUnusedOptions(int scrnIndex, pointer options) static Bool GetBoolValue(OptionInfoPtr p, const char *s) { - if (*s == '\0') { - p->value.bool = TRUE; - } else { - if (xf86NameCmp(s, "1") == 0) - p->value.bool = TRUE; - else if (xf86NameCmp(s, "on") == 0) - p->value.bool = TRUE; - else if (xf86NameCmp(s, "true") == 0) - p->value.bool = TRUE; - else if (xf86NameCmp(s, "yes") == 0) - p->value.bool = TRUE; - else if (xf86NameCmp(s, "0") == 0) - p->value.bool = FALSE; - else if (xf86NameCmp(s, "off") == 0) - p->value.bool = FALSE; - else if (xf86NameCmp(s, "false") == 0) - p->value.bool = FALSE; - else if (xf86NameCmp(s, "no") == 0) - p->value.bool = FALSE; - else - return FALSE; - } - return TRUE; + return xf86getBoolValue(&p->value.bool, s); } static Bool diff --git a/hw/xfree86/parser/Configint.h b/hw/xfree86/parser/Configint.h index cdc7be806..03509b397 100644 --- a/hw/xfree86/parser/Configint.h +++ b/hw/xfree86/parser/Configint.h @@ -148,6 +148,8 @@ else\ "The %s keyword requires a number to follow it." #define POSITIVE_INT_MSG \ "The %s keyword requires a positive integer to follow it." +#define BOOL_MSG \ +"The %s keyword requires a boolean to follow it." #define ZAXISMAPPING_MSG \ "The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." #define AUTOREPEAT_MSG \ diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c index d2e8b6d2b..270dbd5bb 100644 --- a/hw/xfree86/parser/scan.c +++ b/hw/xfree86/parser/scan.c @@ -1028,3 +1028,33 @@ xf86addComment(char *cur, char *add) return (cur); } + +Bool +xf86getBoolValue(Bool *val, const char *str) +{ + if (!val || !str) + return FALSE; + if (*str == '\0') { + *val = TRUE; + } else { + if (strcmp(str, "1") == 0) + *val = TRUE; + else if (strcmp(str, "on") == 0) + *val = TRUE; + else if (strcmp(str, "true") == 0) + *val = TRUE; + else if (strcmp(str, "yes") == 0) + *val = TRUE; + else if (strcmp(str, "0") == 0) + *val = FALSE; + else if (strcmp(str, "off") == 0) + *val = FALSE; + else if (strcmp(str, "false") == 0) + *val = FALSE; + else if (strcmp(str, "no") == 0) + *val = FALSE; + else + return FALSE; + } + return TRUE; +} diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h index 603080066..72beb5fa0 100644 --- a/hw/xfree86/parser/xf86Parser.h +++ b/hw/xfree86/parser/xf86Parser.h @@ -64,6 +64,7 @@ #ifndef _xf86Parser_h_ #define _xf86Parser_h_ +#include <X11/Xdefs.h> #include "xf86Optrec.h" #define HAVE_PARSER_DECLS @@ -330,6 +331,13 @@ typedef struct } XF86ConfInputrefRec, *XF86ConfInputrefPtr; +typedef struct +{ + Bool set; + Bool val; +} +xf86TriState; + /* Values for adj_where */ #define CONF_ADJ_OBSOLETE -1 #define CONF_ADJ_ABSOLUTE 0 @@ -480,5 +488,6 @@ extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr li extern _X_EXPORT int xf86pathIsAbsolute(const char *path); extern _X_EXPORT int xf86pathIsSafe(const char *path); extern _X_EXPORT char *xf86addComment(char *cur, char *add); +extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str); #endif /* _xf86Parser_h_ */ |