aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-03-17 23:58:36 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-03-17 23:58:36 -0500
commit89a05b6b885e4137f3d77dd006a31df81182587c (patch)
tree4f335515c629aa2dc297b67ca3b6073088a64abc
parent44a801ac9d018484e1092106dbcd76bea2ead3b5 (diff)
downloadluancurses-89a05b6b885e4137f3d77dd006a31df81182587c.tar.gz
luancurses-89a05b6b885e4137f3d77dd006a31df81182587c.zip
add error checking for character modes
-rw-r--r--src/curses.c3
-rw-r--r--src/strings.c6
2 files changed, 4 insertions, 5 deletions
diff --git a/src/curses.c b/src/curses.c
index 9fcfa09..34809f9 100644
--- a/src/curses.c
+++ b/src/curses.c
@@ -125,6 +125,9 @@ static int get_char_attr(lua_State* L, int stack_pos)
int cur_mode;
cur_mode = get_mode_enum(str);
+ if (cur_mode == -1) {
+ return luaL_error(L, "Unknown attribute %s", str);
+ }
lua_toboolean(L, -1) ? (mode |= cur_mode) : (mode &= ~cur_mode);
}
diff --git a/src/strings.c b/src/strings.c
index 0eca298..1a211a2 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -142,11 +142,7 @@ int get_color_enum(const char* str)
int get_mode_enum(const char* str)
{
- int ret;
-
- ret = str2enum(modes, lengthof(modes), str);
-
- return ret == -1 ? A_NORMAL : ret;
+ return str2enum(modes, lengthof(modes), str);
}
int get_key_enum(const char* str)