commit 035c384a7fdefaabf6ec3431e0e03b988c50476b
parent 60198586f36999de08b461f915890ca9ff87d0fc
Author: Claudio Alessi <smoppy@gmail.com>
Date: Wed, 2 Mar 2016 18:24:17 +0100
Simplify stfl_putitem().
Lots of work to do.
Diffstat:
M | core.c | | | 22 | ++++++++-------------- |
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/core.c b/core.c
@@ -280,27 +280,22 @@ mysql_items(MYSQL_RES *res, Item **items) {
return nrows;
}
-/* XXX this function is a disaster */
void
stfl_putitem(Item *item) {
char t[32];
char txt[256];
char itm[128];
+ int i;
- if(item->nfields == 1) {
- snprintf(txt, sizeof txt, "listitem text:\"%s\"", QUOTE(item->fields[0]));
+ itm[0] = '\0';
+ for(i = 0; i < item->nfields; ++i) {
+ snprintf(t, sizeof t, "%-8.16s", item->fields[i]);
+ if(i)
+ strncat(itm, " | ", sizeof itm);
+ strncat(itm, t, sizeof itm);
}
- else {
- itm[0] = '\0';
- for(int i = 0; i < item->nfields; ++i) {
- snprintf(t, sizeof t, "%-8.16s", item->fields[i]);
- if(i)
- strncat(itm, " | ", sizeof itm);
- strncat(itm, t, sizeof itm);
- }
- snprintf(txt, sizeof txt, "listitem text:%s", QUOTE(itm));
- }
+ snprintf(txt, sizeof txt, "listitem text:%s", QUOTE(itm));
stfl_modify(selview->form, L"items", L"append", stfl_ipool_towc(ipool, txt));
}
@@ -316,7 +311,6 @@ mysql_listview(MYSQL_RES *res) {
/* XXX columns row */
stfl_modify(selview->form, L"items", L"replace_inner", L"vbox"); /* clear */
- /* XXX actually in reverse order */
if(selview->items)
selview->form = stfl_create(L"<items.stfl>");