[tag] Check that tag has not been added before.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-25 17:43:09 +02:00
parent d9dd1fba8e
commit 971d51918b
1 changed files with 9 additions and 3 deletions

12
tag.c
View File

@ -254,10 +254,16 @@ luaA_tag_tostring(lua_State *L)
static int
luaA_tag_add(lua_State *L)
{
tag_t **tag = luaL_checkudata(L, 1, "tag");
int screen = luaL_checknumber(L, 2) - 1;
tag_t *t, **tag = luaL_checkudata(L, 1, "tag");
int i, screen = luaL_checknumber(L, 2) - 1;
luaA_checkscreen(screen);
/* \todo check tag is not already in another screen */
for(i = 0; i < globalconf.screens_info->nscreen; i++)
for(t = globalconf.screens[screen].tags; t; t = t->next)
if(*tag == t)
luaL_error(L, "tag already on screen %d", i);
(*tag)->screen = screen;
tag_append_to_screen(*tag, screen);
return 0;
}