myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit 304c23a27eba30f682134de1ae9fc57e3ebdac57
parent 3ecf95b35b6cf537d04562a3dce4402410172355
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sun, 15 May 2016 17:09:38 +0200

Cleanup some loop.

Diffstat:
Mmyadm.c | 11+++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/myadm.c b/myadm.c @@ -599,7 +599,7 @@ ui_showfields(Field *fds, int *lens) { if(!(fds && lens)) return; line[0] = '\0'; - for(fld = fds, i = 0; fld; fld = fld->next, ++i) { + for(fld = fds, i = 0; fld && li < COLS; fld = fld->next, ++i) { if(i) for(j = 0; j < fldseplen && li < COLS; ++j) line[li++] = FLDSEP[j]; @@ -607,8 +607,6 @@ ui_showfields(Field *fds, int *lens) { line[li++] = fld->name[j]; while(li < COLS && j++ < lens[i]) line[li++] = ' '; - if(li == COLS) - break; } line[li] = '\0'; ui_set("subtle", "%s", line); @@ -803,13 +801,10 @@ ui_putitem(Item *item, int *lens, int id) { if(!(item && lens)) return; line[0] = '\0'; - for(i = 0; i < item->ncols; ++i) { - if(i) { + for(i = 0; i < item->ncols && li < COLS; ++i) { + if(i) for(j = 0; j < fldseplen && li < COLS; ++j) line[li++] = FLDSEP[j]; - if(li == COLS) - break; - } pad = li; for(j = 0; j < item->lens[i] && j < lens[i] && li < COLS; ++j) line[li++] = (isprint(item->cols[i][j])