myadm

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

commit c7f7504b5bab4b9ecc0cf6c07d88854ddc5f891e
parent 3afa246eb5346087b06b400e04014541f0c28526
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 14 May 2016 21:33:14 +0200

Inizialize len in mksql_update_record().

Diffstat:
Mmyadm.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/myadm.c b/myadm.c @@ -457,7 +457,7 @@ void mksql_update_record(char *sql, Item *item, Field *fields, char *tbl, char *pk) { Field *fld; char *pkv = NULL, sqlfds[MAXQUERYLEN+1], col[MAXQUERYLEN*2+1]; - int size = MAXQUERYLEN+1, len, i; + int size = MAXQUERYLEN+1, len = 0, i; for(i = 0, fld = fields; fld; fld = fld->next, ++i) { if(!pkv && !strncmp(pk, fld->name, fld->len)) @@ -600,16 +600,15 @@ ui_showfields(Field *fds, int *lens) { return; line[0] = '\0'; for(fld = fds, i = 0; fld; fld = fld->next, ++i) { - if(i) { + if(i) for(j = 0; j < fldseplen && li < COLS; ++j) line[li++] = FLDSEP[j]; - if(li == COLS) - break; - } - for(j = 0; j < fld->len && j < lens[i] && li < COLS; ++j) + for(j = 0; li < COLS && j < fld->len && j < lens[i]; ++j) line[li++] = fld->name[j]; - while(j++ < lens[i] && li < COLS) + while(li < COLS && j++ < lens[i]) line[li++] = ' '; + if(li == COLS) + break; } line[li] = '\0'; ui_set("subtle", "%s", line);