#include <stdlib.h> /* free() */
#include <string.h> /* memset(), strcmp(), strdup() */
#include "../common/parse_file.h" /* EDIT_STARTED, parse_file(), set_val(),
- * token_from_line(), err_line()
+ * token_from_line(), err_line(),
+ * finalize_by_readyflag()
*/
#include "../common/try_malloc.h" /* try_malloc() */
#include "array_append.h" /* array_append() */
static struct Command * cmd = NULL;
if (!token0 || !strcmp(token0, str_cmd))
{
- char * err_fin = "Last definition block not finished yet.";
- err_line((cmd_flags & READY_CMD) ^ READY_CMD, err_fin);
+ finalize_by_readyflag(&cmd_flags, READY_CMD);
if (cmd)
{
array_append(world.commandDB.n, sizeof(struct Command),
#include <string.h> /* memset(), strchr(), strcmp(), strdup(), strlen() */
#include <unistd.h> /* optarg, getopt() */
#include "../common/parse_file.h" /* EDIT_STARTED, parse_file(), set_val(),
- * token_from_line()
+ * token_from_line(), finalize_by_readyflag()
*/
#include "../common/readwrite.h" /* try_fopen(), try_fclose_unlink_rename(),
* try_fwrite()
if (!token0 || !strcmp(token0, str_win) || !strcmp(token0, str_ord)
|| !strcmp(token0, str_kbd))
{
- err_line( ((win_flags & READY_WIN) ^ READY_WIN)
- || ((ord_flags & READY_ORD) ^ READY_ORD)
- || ((kbd_flags & READY_KBD) ^ READY_KBD),
- "Last definition block not yet finished yet.");
+ finalize_by_readyflag(&win_flags, READY_WIN);
+ finalize_by_readyflag(&ord_flags, READY_ORD);
+ finalize_by_readyflag(&kbd_flags, READY_KBD);
write_if_win(&win);
- ord_flags = READY_ORD;
- win_flags = READY_WIN;
- kbd_flags = READY_KBD;
}
if (!token0)
{
}
return 0;
}
+
+
+
+extern void finalize_by_readyflag(uint8_t * flags, uint8_t ready_flag)
+{
+ char * err_fin = "Last definition block not finished yet.";
+ err_line((*flags & ready_flag) ^ ready_flag, err_fin);
+ *flags = ready_flag;
+}
uint8_t * flags, uint8_t set_flag, char type,
char * element);
+/* Check "ready_flag" is set in "flags", re-set "flags" to "ready_flag" only. */
+extern void finalize_by_readyflag(uint8_t * flags, uint8_t ready_flag);
+
#endif
#include <stdlib.h> /* atoi(), free() */
#include <string.h> /* strcmp() */
#include "../common/parse_file.h" /* EDIT_STARTED, set_val(), test_for_int(),
- * err_line(), parse_file(),token_from_line()
+ * err_line(), parse_file(),token_from_line(),
+ * finalize_by_readyflag()
*/
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
static struct EntryHead * mod = NULL;
if (!token0 || !strcmp(token0,str_act) || !strcmp(token0,str_obj))
{
- err_line( ((action_flags & READY_ACT) ^ READY_ACT)
- || ((object_flags & READY_OBJ) ^ READY_OBJ),
- "Last definitino block not finished yet.");
+ finalize_by_readyflag(&action_flags, READY_ACT);
+ finalize_by_readyflag(&object_flags, READY_OBJ);
write_if_entry(&moa, (struct EntryHead ***) &moa_p_p);
write_if_entry(&mod, (struct EntryHead ***) &mod_p_p);
- action_flags = READY_ACT;
- object_flags = READY_OBJ;
}
err_line(token0 && NULL != token_from_line(NULL), "Too many values.");
if ( token0