forked from github/server
ignore lines that contain only whitespace.
This commit is contained in:
parent
573077987c
commit
d35181b5d6
|
@ -95,15 +95,18 @@ static void handle_unit(void *userData, int no) {
|
||||||
|
|
||||||
static void handle_order(void *userData, const char *str) {
|
static void handle_order(void *userData, const char *str) {
|
||||||
parser_state *state = (parser_state *)userData;
|
parser_state *state = (parser_state *)userData;
|
||||||
const char * tok, *input = str;
|
const char * tok, *input;
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
const struct locale *lang;
|
const struct locale *lang;
|
||||||
param_t p;
|
|
||||||
faction * f = state->f;
|
faction * f = state->f;
|
||||||
|
|
||||||
lang = f ? f->locale : default_locale;
|
lang = f ? f->locale : default_locale;
|
||||||
|
ltrim(&str);
|
||||||
|
if (*str == 0) return;
|
||||||
|
input = str;
|
||||||
tok = parse_token(&input, buffer, sizeof(buffer));
|
tok = parse_token(&input, buffer, sizeof(buffer));
|
||||||
p = findparam(tok, lang);
|
if (tok) {
|
||||||
|
param_t p = findparam(tok, lang);
|
||||||
if (p == P_FACTION || p == P_GAMENAME) {
|
if (p == P_FACTION || p == P_GAMENAME) {
|
||||||
tok = parse_token(&input, buffer, sizeof(buffer));
|
tok = parse_token(&input, buffer, sizeof(buffer));
|
||||||
if (tok) {
|
if (tok) {
|
||||||
|
@ -132,8 +135,8 @@ static void handle_order(void *userData, const char *str) {
|
||||||
state->next_order = NULL;
|
state->next_order = NULL;
|
||||||
}
|
}
|
||||||
else if (state->u) {
|
else if (state->u) {
|
||||||
unit * u = state->u;
|
unit *u = state->u;
|
||||||
order * ord = parse_order(str, lang);
|
order *ord = parse_order(str, lang);
|
||||||
if (ord) {
|
if (ord) {
|
||||||
*state->next_order = ord;
|
*state->next_order = ord;
|
||||||
state->next_order = &ord->next;
|
state->next_order = &ord->next;
|
||||||
|
@ -142,6 +145,7 @@ static void handle_order(void *userData, const char *str) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("parse_error", "unit command", u, str));
|
ADDMSG(&u->faction->msgs, msg_message("parse_error", "unit command", u, str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseorders(FILE *F)
|
int parseorders(FILE *F)
|
||||||
|
|
|
@ -26,7 +26,7 @@ static parse_state *states;
|
||||||
|
|
||||||
#define TRIMMED(wc) (iswspace(wc) || iswcntrl(wc) || (wc) == 160 || (wc) == 8199 || (wc) == 8239)
|
#define TRIMMED(wc) (iswspace(wc) || iswcntrl(wc) || (wc) == 160 || (wc) == 8199 || (wc) == 8239)
|
||||||
|
|
||||||
static int ltrim(const char **str_p)
|
int ltrim(const char **str_p)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
wint_t wc;
|
wint_t wc;
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern "C" {
|
||||||
int getint(void);
|
int getint(void);
|
||||||
int getid(void);
|
int getid(void);
|
||||||
unsigned int atoip(const char *s);
|
unsigned int atoip(const char *s);
|
||||||
|
int ltrim(const char **str_p);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue