From 74e84919d7dee9ed660c18ec4863c2f9f77be162 Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Sat, 24 Mar 2012 19:37:37 +0000 Subject: [PATCH] Modified the WMUD_COMMAND macro The WMUD_COMMAND macro now automatically prefixes command handlers with gcmd_. It is convenient. --- src/interpreter.c | 6 ++---- src/interpreter.h | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/interpreter.c b/src/interpreter.c index 4e13692..6fd49b5 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -24,9 +24,7 @@ #include "networking.h" #include "main.h" -#define IS_SPACE(c) (g_ascii_isspace((c)) || (!(c))) - -WMUD_COMMAND(gcmd_quit); +WMUD_COMMAND(quit); static wmudCommand command_list[] = { { "quit", gcmd_quit }, @@ -87,7 +85,7 @@ wmud_interpret_game_command(wmudClient *client) start++; break; } - else if (!IS_SPACE(*start)) + else if (g_ascii_isspace(*start) || (!*start)) { break; } diff --git a/src/interpreter.h b/src/interpreter.h index 8f42b57..e96147a 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -30,7 +30,13 @@ * Command handler function type */ typedef void (*wmudCommandFunc)(wmudClient *client, gchar *command, GSList *token_list); -#define WMUD_COMMAND(name) void name(wmudClient *client, gchar *command, GSList *token_list) +/** + * WMUD_COMMAND: + * @name: the name of the command. Should be in lowercase + * + * Shorthand to create the function header for command handlers + */ +#define WMUD_COMMAND(name) void gcmd_ ## name(wmudClient *client, gchar *command, GSList *token_list) /** * wmudCommand: