ignore lines that contain only whitespace.

This commit is contained in:
Enno Rehling 2021-06-01 20:35:40 +02:00
parent 573077987c
commit d35181b5d6
3 changed files with 40 additions and 35 deletions

View File

@ -95,15 +95,18 @@ static void handle_unit(void *userData, int no) {
static void handle_order(void *userData, const char *str) {
parser_state *state = (parser_state *)userData;
const char * tok, *input = str;
const char * tok, *input;
char buffer[64];
const struct locale *lang;
param_t p;
faction * f = state->f;
lang = f ? f->locale : default_locale;
ltrim(&str);
if (*str == 0) return;
input = str;
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) {
tok = parse_token(&input, buffer, sizeof(buffer));
if (tok) {
@ -132,8 +135,8 @@ static void handle_order(void *userData, const char *str) {
state->next_order = NULL;
}
else if (state->u) {
unit * u = state->u;
order * ord = parse_order(str, lang);
unit *u = state->u;
order *ord = parse_order(str, lang);
if (ord) {
*state->next_order = ord;
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));
}
}
}
}
int parseorders(FILE *F)

View File

@ -26,7 +26,7 @@ static parse_state *states;
#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;
wint_t wc;

View File

@ -22,6 +22,7 @@ extern "C" {
int getint(void);
int getid(void);
unsigned int atoip(const char *s);
int ltrim(const char **str_p);
#ifdef __cplusplus
}