Skip to content

Commit

Permalink
Irssi coding style.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahf committed Apr 28, 2009
1 parent ec0e318 commit 74b8d2f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 192 deletions.
12 changes: 4 additions & 8 deletions lua_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ static const luaL_Reg irssi_lua_functions[] = {
{ NULL, NULL }
};

void arity_mismatch(const char *function_name)
{
void arity_mismatch(const char *function_name) {
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Arity mismatch for function \"%s\"", function_name);
}

void register_lua_api(lua_State *interpreter, const char *script_name)
{
void register_lua_api(lua_State *interpreter, const char *script_name) {
luaL_openlib(interpreter, "Irssi", irssi_lua_functions, 0);

lua_newtable(interpreter);
Expand All @@ -81,8 +79,7 @@ void register_lua_api(lua_State *interpreter, const char *script_name)
register_lua_output_api(interpreter);
}

char *get_caller_name(lua_State *interpreter)
{
char *get_caller_name(lua_State *interpreter) {
char *script_name;

lua_getglobal(interpreter, "__irssi_script_information__");
Expand All @@ -94,8 +91,7 @@ char *get_caller_name(lua_State *interpreter)
return script_name;
}

void lua_api_init()
{
void lua_api_init() {
lua_api_settings_init();
lua_api_commands_init();
lua_api_signals_init();
Expand Down
6 changes: 2 additions & 4 deletions lua_api_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

#include <lua_api_commands.h>

void lua_api_commands_init()
{
void lua_api_commands_init() {
}

void lua_api_commands_deinit()
{
void lua_api_commands_deinit() {
}
40 changes: 13 additions & 27 deletions lua_api_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,22 @@
lua_pushnumber(interpreter, value); \
lua_rawset(interpreter, -3);

int lua_api_print(lua_State *interpreter)
{
int lua_api_print(lua_State *interpreter) {
const char *message;
int n;
int msglevel;

n = lua_gettop(interpreter);

if (2 < n || 0 >= n)
{
if (2 < n || 0 >= n) {
arity_mismatch("print");
return LUA_FAILURE;
}

if (2 != n)
{
if (2 != n) {
msglevel = MSGLEVEL_CLIENTCRAP;
message = lua_tostring(interpreter, -1);
}
else
{
} else {
msglevel = lua_tonumber(interpreter, -1);
message = lua_tostring(interpreter, -2);
}
Expand All @@ -56,13 +51,11 @@ int lua_api_print(lua_State *interpreter)
return LUA_SUCCESS;
}

int lua_api_level2bits(lua_State *interpreter)
{
int lua_api_level2bits(lua_State *interpreter) {
const char *level;
int number;

if (1 != lua_gettop(interpreter))
{
if (1 != lua_gettop(interpreter)) {
arity_mismatch("level2bits");
return LUA_FAILURE;
}
Expand All @@ -76,12 +69,10 @@ int lua_api_level2bits(lua_State *interpreter)
return LUA_SUCCESS;
}

int lua_api_bits2level(lua_State *interpreter)
{
int lua_api_bits2level(lua_State *interpreter) {
int level_number;

if (1 != lua_gettop(interpreter))
{
if (1 != lua_gettop(interpreter)) {
arity_mismatch("bits2level");
return LUA_FAILURE;
}
Expand All @@ -93,13 +84,11 @@ int lua_api_bits2level(lua_State *interpreter)
return LUA_SUCCESS;
}

int lua_api_combine_level(lua_State *interpreter)
{
int lua_api_combine_level(lua_State *interpreter) {
int level;
const char *str;

if (2 != lua_gettop(interpreter))
{
if (2 != lua_gettop(interpreter)) {
arity_mismatch("combine_level");
return LUA_FAILURE;
}
Expand All @@ -112,8 +101,7 @@ int lua_api_combine_level(lua_State *interpreter)
return LUA_SUCCESS;
}

void register_lua_output_api(lua_State *interpreter)
{
void register_lua_output_api(lua_State *interpreter) {
lua_newtable(interpreter);

ADD_KV_PAIR(interpreter, "crap", MSGLEVEL_CRAP);
Expand Down Expand Up @@ -147,10 +135,8 @@ void register_lua_output_api(lua_State *interpreter)
lua_setglobal(interpreter, "msglevel");
}

void lua_api_output_init()
{
void lua_api_output_init() {
}

void lua_api_output_deinit()
{
void lua_api_output_deinit() {
}
Loading

0 comments on commit 74b8d2f

Please sign in to comment.