Fix printf positional parameters syntax - sacc - sacc(omys), simple console gopher client
git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/
Log
Files
Refs
Tags
LICENSE
---
commit 23234609e4029833cd123921a50d8067d3308b11
parent d733c513f8f4e7318c0a9578335f9cfb2bf63211
Author: Quentin Rameau 
Date:   Sun, 10 Dec 2017 23:02:57 +0100

Fix printf positional parameters syntax

I forgot that *all* placeholders must specify a positional parameters
when one is used.

Diffstat:
  M ui_ti.c                             |       7 ++++---
  M ui_txt.c                            |       5 +++--

2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/ui_ti.c b/ui_ti.c
@@ -162,7 +162,7 @@ displaystatus(Item *item)
         putp(tparm(cursor_address, lines-1, 0));
         putp(tparm(enter_standout_mode));
         fmt = (strcmp(item->port, "70") && strcmp(item->port, "gopher")) ?
-              "%3lld%%| %s:%5$s/%c%s" : "%3lld%%| %s/%c%s";
+              "%1$3lld%%| %2$s:%5$s/%3$c%4$s" : "%3lld%%| %s/%c%s";
         n = printf(fmt,
                    (printoff + lines-1 >= nitems) ? 100 :
                    (printoff + lines-1) * 100 / nitems,
@@ -192,8 +192,9 @@ displayuri(Item *item)
                 n = printf("%s: %s", item->username, item->selector);
                 break;
         default:
-                fmt = strcmp(item->port, "70") ? "%s: gopher://%s:%5$s/%c%s" :
-                                                 "%s: gopher://%s/%c%s";
+                fmt = strcmp(item->port, "70") ?
+                      "%1$s: gopher://%2$s:%5$s/%3$c%4$s" :
+                      "%s: gopher://%s/%c%s";
                 n = printf(fmt, item->username,
                            item->host, item->type, item->selector, item->port);
                 break;
diff --git a/ui_txt.c b/ui_txt.c
@@ -84,7 +84,8 @@ printstatus(Item *item, char c)
         unsigned long long printoff = dir ? dir->printoff : 0;
 
         fmt = (strcmp(item->port, "70") && strcmp(item->port, "gopher")) ?
-              "%3lld%%%*c %s:%8$s/%c%s [%c]: " : "%3lld%%%*c %s/%c%s [%c]: ";
+              "%1$3lld%%%*2$3$c %4$s:%8$s/%5$c%6$s [%7$c]: " :
+              "%3lld%%%*c %s/%c%s [%c]: ";
         printf(fmt, (printoff + lines-1 >= nitems) ? 100 :
                (printoff + lines) * 100 / nitems, ndigits(nitems)+2, '|',
                item->host, item->type, item->selector, c, item->port);
@@ -160,7 +161,7 @@ printuri(Item *item, size_t i)
                 break;
         default:
                 fmt = strcmp(item->port, "70") ?
-                      "%zu: %s: gopher://%s:%6$s/%c%s\n" :
+                      "%1$zu: %2$s: gopher://%3$s:%6$s/%4$c%5$s\n" :
                       "%zu: %s: gopher://%s/%c%s\n";
                 printf(fmt, i, item->username,
                        item->host, item->type, item->selector, item->port);