Fix some warnings from clang-check.

This commit is contained in:
Dave Davenport 2015-02-13 15:37:55 +01:00
parent 7e1063803a
commit 8347963ed8
2 changed files with 12 additions and 2 deletions

View File

@ -44,7 +44,7 @@
char* fgets_s ( char* s, int n, FILE *iop, char sep )
{
// Map these to registers.
register int c;
register int c = EOF;
register char* cs;
cs = s;
// read until EOF or buffer is full.

View File

@ -312,7 +312,8 @@ void textbox_draw ( textbox *tb )
// cursor handling for edit mode
void textbox_cursor ( textbox *tb, int pos )
{
tb->cursor = MAX ( 0, MIN ( ( int ) strlen ( tb->text ), pos ) );
int length = (tb->text == NULL)? 0: strlen(tb->text);
tb->cursor = MAX ( 0, MIN ( length, pos ) );
}
// move right
@ -332,6 +333,9 @@ void textbox_cursor_dec ( textbox *tb )
// Move word right
void textbox_cursor_inc_word ( textbox *tb )
{
if(tb->text == NULL) {
return;
}
// Find word boundaries, with pango_Break?
gchar *c = &( tb->text[tb->cursor] );
while ( ( c = g_utf8_next_char ( c ) ) ) {
@ -347,6 +351,9 @@ void textbox_cursor_inc_word ( textbox *tb )
break;
}
}
if(c == NULL) {
return;
}
while ( ( c = g_utf8_next_char ( c ) ) ) {
gunichar uc = g_utf8_get_char ( c );
GUnicodeBreakType bt = g_unichar_break_type ( uc );
@ -445,6 +452,9 @@ void textbox_delete ( textbox *tb, int pos, int dlen )
// delete on character
void textbox_cursor_del ( textbox *tb )
{
if(tb->text == NULL) {
return;
}
int index = g_utf8_next_char ( &( tb->text[tb->cursor] ) ) - tb->text;
textbox_delete ( tb, tb->cursor, index - tb->cursor );
}