diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-21 15:54:00 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-21 16:52:40 -0800 |
commit | f59d8f32c755b8747acf71aa3ab4c4809bff4ebf (patch) | |
tree | d21dee6e3310d043bc23033019d195196dc7f4be /greeter | |
parent | 3297eb892017c850f25d3dc4a37095612a20a381 (diff) |
greeter: Make sure text input areas stay inside the lines
Regression introduced by f8585c60831a8e5ddebce18bdd7e78d217a822c5
broke bounds checking for text displayed in input fields.
Since this makes each TEXT_WIDTH value only be used once, just use
them directly instead of storing the result in a variable.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'greeter')
-rw-r--r-- | greeter/Login.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/greeter/Login.c b/greeter/Login.c index 9fd07c4..f448991 100644 --- a/greeter/Login.c +++ b/greeter/Login.c @@ -404,24 +404,21 @@ realizeValue (LoginWidget w, int cursor, int promptNum, GC gc) } else if ((state == LOGIN_PROMPT_ECHO_ON) || (state == LOGIN_TEXT_INFO) || ((state == LOGIN_PROMPT_ECHO_OFF) && (w->login.echo_passwd == True))) { - int textwidth; int offset = max(cursor, VALUE_SHOW_START(w, promptNum)); int textlen = strlen (text + offset); - textwidth = TEXT_WIDTH (text, text + offset, textlen); - - if (textwidth > (width - curoff)) { + if (TEXT_WIDTH (text, text + offset, textlen) > (width - curoff)) { /* Recalculate amount of text that can fit in field */ offset = VALUE_SHOW_START(w, promptNum); textlen = strlen (text + offset); - while ((textlen > 0) && (textwidth > width)) + while ((textlen > 0) && + (TEXT_WIDTH (text, text + offset, textlen) > width)) { if (offset < PROMPT_CURSOR(w, promptNum)) { offset++; } textlen--; - textwidth = TEXT_WIDTH (text, text + offset, textlen); } VALUE_SHOW_START(w, promptNum) = offset; |