cmdparse: correctly parse con_id/id (fixes warning)
This commit is contained in:
parent
b21137b2c0
commit
7100d32971
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
|
||||||
|
@ -259,17 +260,33 @@ criteria:
|
||||||
| TOK_CON_ID '=' STR
|
| TOK_CON_ID '=' STR
|
||||||
{
|
{
|
||||||
printf("criteria: id = %s\n", $<string>3);
|
printf("criteria: id = %s\n", $<string>3);
|
||||||
/* TODO: correctly parse number */
|
char *end;
|
||||||
current_match.con_id = (Con*)atoi($<string>3);
|
long parsed = strtol($<string>3, &end, 10);
|
||||||
|
if (parsed == LONG_MIN ||
|
||||||
|
parsed == LONG_MAX ||
|
||||||
|
parsed < 0 ||
|
||||||
|
(end && *end != '\0')) {
|
||||||
|
ELOG("Could not parse con id \"%s\"\n", $<string>3);
|
||||||
|
} else {
|
||||||
|
current_match.con_id = (Con*)parsed;
|
||||||
printf("id as int = %p\n", current_match.con_id);
|
printf("id as int = %p\n", current_match.con_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
| TOK_ID '=' STR
|
| TOK_ID '=' STR
|
||||||
{
|
{
|
||||||
printf("criteria: window id = %s\n", $<string>3);
|
printf("criteria: window id = %s\n", $<string>3);
|
||||||
/* TODO: correctly parse number */
|
char *end;
|
||||||
current_match.id = atoi($<string>3);
|
long parsed = strtol($<string>3, &end, 10);
|
||||||
|
if (parsed == LONG_MIN ||
|
||||||
|
parsed == LONG_MAX ||
|
||||||
|
parsed < 0 ||
|
||||||
|
(end && *end != '\0')) {
|
||||||
|
ELOG("Could not parse window id \"%s\"\n", $<string>3);
|
||||||
|
} else {
|
||||||
|
current_match.id = parsed;
|
||||||
printf("window id as int = %d\n", current_match.id);
|
printf("window id as int = %d\n", current_match.id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
| TOK_MARK '=' STR
|
| TOK_MARK '=' STR
|
||||||
{
|
{
|
||||||
printf("criteria: mark = %s\n", $<string>3);
|
printf("criteria: mark = %s\n", $<string>3);
|
||||||
|
|
Loading…
Reference in New Issue