xfree86: allow to check for options without warnings in the log
This allows set_percent_option in synaptics to work as described, and should generally enable to check option syntax without log spam. Signed-off-by: Simon Thum <simon.thum@gmx.de> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
2fbccc881b
commit
38ffeec0c8
|
@ -496,27 +496,33 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
switch (p->type) {
|
switch (p->type) {
|
||||||
case OPTV_INTEGER:
|
case OPTV_INTEGER:
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires an integer value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires an integer value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
} else {
|
} else {
|
||||||
p->value.num = strtoul(s, &end, 0);
|
p->value.num = strtoul(s, &end, 0);
|
||||||
if (*end == '\0') {
|
if (*end == '\0') {
|
||||||
p->found = TRUE;
|
p->found = TRUE;
|
||||||
} else {
|
} else {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires an integer value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires an integer value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPTV_STRING:
|
case OPTV_STRING:
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires an string value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires an string value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
} else {
|
} else {
|
||||||
p->value.str = s;
|
p->value.str = s;
|
||||||
|
@ -529,18 +535,22 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
break;
|
break;
|
||||||
case OPTV_REAL:
|
case OPTV_REAL:
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a floating point value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires a floating point "
|
||||||
|
"value\n", p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
} else {
|
} else {
|
||||||
p->value.realnum = strtod(s, &end);
|
p->value.realnum = strtod(s, &end);
|
||||||
if (*end == '\0') {
|
if (*end == '\0') {
|
||||||
p->found = TRUE;
|
p->found = TRUE;
|
||||||
} else {
|
} else {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a floating point value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires a floating point "
|
||||||
|
"value\n", p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,8 +559,11 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
if (GetBoolValue(p, s)) {
|
if (GetBoolValue(p, s)) {
|
||||||
p->found = TRUE;
|
p->found = TRUE;
|
||||||
} else {
|
} else {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a boolean value\n", p->name);
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
|
"Option \"%s\" requires a boolean value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -561,8 +574,10 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
* hence 100 looks the same as 100% to the caller of sccanf
|
* hence 100 looks the same as 100% to the caller of sccanf
|
||||||
*/
|
*/
|
||||||
if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
|
if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
"Option \"%s\" requires a percent value\n", p->name);
|
"Option \"%s\" requires a percent value\n", p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
} else {
|
} else {
|
||||||
p->found = TRUE;
|
p->found = TRUE;
|
||||||
|
@ -571,9 +586,11 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
break;
|
break;
|
||||||
case OPTV_FREQ:
|
case OPTV_FREQ:
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a frequency value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires a frequency value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
} else {
|
} else {
|
||||||
double freq = strtod(s, &end);
|
double freq = strtod(s, &end);
|
||||||
|
@ -590,17 +607,21 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
|
||||||
!xf86NameCmp(end, "M"))
|
!xf86NameCmp(end, "M"))
|
||||||
units = 1000000;
|
units = 1000000;
|
||||||
else {
|
else {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a frequency value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires a frequency value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
}
|
}
|
||||||
if (p->found)
|
if (p->found)
|
||||||
freq *= (double)units;
|
freq *= (double)units;
|
||||||
} else {
|
} else {
|
||||||
xf86DrvMsg(scrnIndex, X_WARNING,
|
if (markUsed) {
|
||||||
"Option \"%s\" requires a frequency value\n",
|
xf86DrvMsg(scrnIndex, X_WARNING,
|
||||||
p->name);
|
"Option \"%s\" requires a frequency value\n",
|
||||||
|
p->name);
|
||||||
|
}
|
||||||
p->found = FALSE;
|
p->found = FALSE;
|
||||||
}
|
}
|
||||||
if (p->found) {
|
if (p->found) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user