summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eb28e1a)
raw | patch | inline | side by side (parent: eb28e1a)
author | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:13 +0000 (14:56 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:13 +0000 (14:56 +0200) |
Unclutter these functions by removing one indent level.
src/wreadln.c | patch | blob | history |
diff --git a/src/wreadln.c b/src/wreadln.c
index 6c66895f7611c6e43edbeeb418a0b5c753e2abd7..59026ed08d9c5fa9f6c3299d2784605affbc38bd 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
/* move the cursor one step to the right */
static inline void cursor_move_right(struct wreadln *wr)
{
- if (wr->cursor < strlen(wr->line)) {
- ++wr->cursor;
- if (wr->cursor >= (size_t)wr->width &&
- wr->start < wr->cursor - wr->width + 1)
- ++wr->start;
- }
+ if (wr->line[wr->cursor] == 0)
+ return;
+
+ ++wr->cursor;
+ if (wr->cursor >= (size_t)wr->width &&
+ wr->start < wr->cursor - wr->width + 1)
+ ++wr->start;
}
/* move the cursor one step to the left */
static inline void cursor_move_left(struct wreadln *wr)
{
- if (wr->cursor > 0) {
- if (wr->cursor == wr->start && wr->start > 0)
- --wr->start;
- --wr->cursor;
- }
+ if (wr->cursor == 0)
+ return;
+
+ if (wr->cursor == wr->start && wr->start > 0)
+ --wr->start;
+ --wr->cursor;
}
/* move the cursor to the end of the line */