1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

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 ) char* fgets_s ( char* s, int n, FILE *iop, char sep )
{ {
// Map these to registers. // Map these to registers.
register int c; register int c = EOF;
register char* cs; register char* cs;
cs = s; cs = s;
// read until EOF or buffer is full. // read until EOF or buffer is full.

View file

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