uncommitted - sacc

Ready changes

Summary

Import uploads missing from VCS:

Diff

diff --git a/LICENSE b/LICENSE
index da0c220..6bf2c2e 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,6 +8,7 @@ Copyright (c) 2018 Ivan J. <parazyd@dyne.org>
 Copyright (c) 2018 Leonardo Taccari <iamleot@gmail.com>
 Copyright (c) 2018 Stefan Hagen <sh+git@codevoid.de>
 Copyright (c) 2021 escapeinsert <ben@0x1bi.net>
+Copyright (c) 2021 Anders Damsgaard <anders@adamsgaard.dk>
 
 Permission to use, copy, modify, and distribute this software for any
 purpose with or without fee is hereby granted, provided that the above
diff --git a/Makefile b/Makefile
index f988ebd..ce66b1b 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ install: $(BIN)
 	cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin/
 	chmod 555 $(DESTDIR)$(PREFIX)/bin/$(BIN)
 	mkdir -p $(DESTDIR)$(MANDIR)
-	cp -f $(MAN) $(DESTDIR)$(MANDIR)
+	sed -e "s/%VERSION%/$(GETVER)/" $(MAN) > $(DESTDIR)$(MANDIR)/$(MAN)
 
 uninstall:
 	rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN) $(DESTDIR)$(MANDIR)/$(MAN)
diff --git a/common.h b/common.h
index 7a9e866..622067f 100644
--- a/common.h
+++ b/common.h
@@ -44,17 +44,20 @@ struct dir {
 	size_t curline;
 };
 
-extern void (*diag)(char *fmt, ...);
-void die(const char *fmt, ...);
-size_t mbsprint(const char *s, size_t len);
+extern void (*diag)(char *, ...);
+
+extern void die(const char *, ...);
+extern size_t mbsprint(const char *, size_t);
 #ifdef NEED_STRCASESTR
-char *strcasestr(const char *h, const char *n);
+extern char *strcasestr(const char *, const char *);
 #endif /* NEED_STRCASESTR */
-const char *typedisplay(char t);
-void uicleanup(void);
-void uidisplay(Item *entry);
-char *uiprompt(char *fmt, ...);
-Item *uiselectitem(Item *entry);
-void uisetup(void);
-void uisigwinch(int signal);
-void uistatus(char *fmt, ...);
+extern const char *typedisplay(char);
+extern int itemuri(Item *, char *, size_t);
+extern void yankitem(Item *);
+extern void uicleanup(void);
+extern void uidisplay(Item *);
+extern char *uiprompt(char *, ...);
+extern Item *uiselectitem(Item *);
+extern void uisetup(void);
+extern void uisigwinch(int);
+extern void uistatus(char *, ...);
diff --git a/config.def.h b/config.def.h
index f744d34..e96a877 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,8 @@
 #define _key_pgprev	'h' /* view previous item */
 #define _key_cururi	'U' /* print page uri */
 #define _key_seluri	'u' /* print item uri */
+#define _key_yankcur	'Y' /* yank page uri */
+#define _key_yanksel	'y' /* yank item uri */
 #define _key_fetch	'L' /* refetch current item */
 #define _key_help	'?' /* display help */
 #define _key_quit	'q' /* exit sacc */
@@ -20,6 +22,11 @@
 #define _key_searchnext	'n' /* search same string forward */
 #define _key_searchprev	'N' /* search same string backward */
 
+#ifdef NEED_CONF
+
+/* default yanker */
+static char *yanker = "xclip";
+
 /* default plumber */
 static char *plumber = "xdg-open";
 
@@ -50,3 +57,5 @@ static char *typestr[] = {
 	[UNK] = " ? +",
 	[BRK] = "!  |", /* malformed entry */
 };
+
+#endif /* NEED_CONF */
diff --git a/config.mk b/config.mk
index 406fd2b..b824b48 100644
--- a/config.mk
+++ b/config.mk
@@ -3,7 +3,7 @@ PREFIX = /usr/local
 MANDIR = $(PREFIX)/share/man/man1
 
 # Version to put in the ident string
-VERSION = "1.04"
+VERSION = "1.06"
 GETVER = $$(git rev-parse --is-inside-work-tree >/dev/null 2>&1 && \
 	    git describe --tags || echo $(VERSION))
 
diff --git a/debian/changelog b/debian/changelog
index bc0b8d5..3b9cf58 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+sacc (1.06-1) unstable; urgency=medium
+
+  * New upstream version 1.06
+  * d/control: bump Standards-Version to 4.6.1, no changes needed
+  * d/copyright: update copyright years for debian/*
+
+ -- Paride Legovini <paride@debian.org>  Thu, 16 Jun 2022 19:53:42 +0000
+
+sacc (1.05-1) unstable; urgency=medium
+
+  * New upstream version 1.05
+  * d/gbp.conf: set debian-branch = debian/latest (DEP-14)
+
+ -- Paride Legovini <paride@debian.org>  Thu, 06 Jan 2022 10:48:24 +0000
+
 sacc (1.04-1) unstable; urgency=medium
 
   * New upstream version 1.04
diff --git a/debian/control b/debian/control
index c1ca18d..84e2f99 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@ Build-Depends:
  debhelper-compat (= 13),
  libncurses-dev,
  libtls-dev,
-Standards-Version: 4.6.0
+Standards-Version: 4.6.1
 Homepage: gopher://bitreich.org/1/scm/sacc
 Vcs-Git: https://salsa.debian.org/debian/sacc.git
 Vcs-Browser: https://salsa.debian.org/debian/sacc/
diff --git a/debian/copyright b/debian/copyright
index 0bfbfcb..7fb25c1 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -18,7 +18,7 @@ Copyright:
 License: OpenBSD
 
 Files: debian/*
-Copyright: 2018-2021, Paride Legovini <paride@debian.org>
+Copyright: 2018-2022, Paride Legovini <paride@debian.org>
 License: OpenBSD
 
 License: OpenBSD
diff --git a/debian/gbp.conf b/debian/gbp.conf
index 0cfd45b..666a424 100644
--- a/debian/gbp.conf
+++ b/debian/gbp.conf
@@ -1,5 +1,5 @@
 [DEFAULT]
-debian-branch = debian/sid
+debian-branch = debian/latest
 upstream-branch =
 upstream-tag = %(version)s
 pristine-tar = True
diff --git a/sacc.1 b/sacc.1
index b2c6739..8ff2bfa 100644
--- a/sacc.1
+++ b/sacc.1
@@ -1,4 +1,4 @@
-.TH SACC 1 2018-02-24
+.TH SACC 1 2022-04-11 %VERSION%
 .SH NAME
 sacc \- a terminal gopher client
 .SH SYNOPSIS
@@ -65,6 +65,12 @@ Print the URI of the current page.
 .B u
 Print the URI of the highlighted item.
 .TP
+.B Y
+Yank the current page URI to an external program.
+.TP
+.B y
+Yank the highlighted item URI to an external program.
+.TP
 .B ?
 Show the help message of shortcuts.
 .TP
@@ -95,6 +101,14 @@ can be customized by creating a custom
 .B config.h
 and (re)compiling the source
 code. This keeps it fast, secure and simple.
+.SH VERSION
+It is possible to get
+.B sacc
+version
+from the binary
+with the standard
+.BR what (1)
+tool.
 .SH AUTHORS
 See the
 .B LICENSE
@@ -108,5 +122,6 @@ file for the terms of redistribution.
 .BR xdg-open (1)
 .BR geomyidae (8)
 .BR clic (1)
+.BR what (1)
 .SH BUGS
 Please report them to Quentin Rameau <quinq@fifth.space>
diff --git a/sacc.c b/sacc.c
index 31b123e..096b4ce 100644
--- a/sacc.c
+++ b/sacc.c
@@ -20,18 +20,21 @@
 
 #include "common.h"
 #include "io.h"
+#define NEED_CONF
 #include "config.h"
+#undef NEED_CONF
+
+void (*diag)(char *, ...);
 
 const char ident[] = "@(#) sacc(omys): " VERSION;
 
+static char intbuf[256]; /* 256B ought to be enough for any URI */
 static char *mainurl;
 static Item *mainentry;
 static int devnullfd;
 static int parent = 1;
 static int interactive;
 
-void (*diag)(char *fmt, ...);
-
 static void
 stddiag(char *fmt, ...)
 {
@@ -265,6 +268,43 @@ typedisplay(char t)
 	}
 }
 
+int
+itemuri(Item *item, char *buf, size_t bsz)
+{
+	int n;
+
+	switch (item->type) {
+	case '8':
+		n = snprintf(buf, bsz, "telnet://%s@%s:%s",
+		             item->selector, item->host, item->port);
+		break;
+	case 'T':
+		n = snprintf(buf, bsz, "tn3270://%s@%s:%s",
+		             item->selector, item->host, item->port);
+		break;
+	case 'h':
+		n = snprintf(buf, bsz, "%s", item->selector +
+		             (strncmp(item->selector, "URL:", 4) ? 0 : 4));
+		break;
+	default:
+		n = snprintf(buf, bsz, "gopher://%s", item->host);
+
+		if (n < bsz-1 && strcmp(item->port, "70"))
+			n += snprintf(buf+n, bsz-n, ":%s", item->port);
+		if (n < bsz-1) {
+			n += snprintf(buf+n, bsz-n, "/%c%s",
+			              item->type, item->selector);
+		}
+		if (n < bsz-1 && item->type == '7' && item->tag) {
+			n += snprintf(buf+n, bsz-n, "%%09%s",
+			              item->tag + strlen(item->selector));
+		}
+		break;
+	}
+
+	return n;
+}
+
 static void
 printdir(Item *item)
 {
@@ -382,14 +422,13 @@ static Dir *
 molddiritem(char *raw)
 {
 	Item *item, *items = NULL;
-	char *s, *nl, *p;
+	char *nl, *p;
 	Dir *dir;
 	size_t i, n, nitems;
 
-	for (s = nl = raw, nitems = 0; p = strchr(nl, '\n'); ++nitems) {
-		s = nl;
-		nl = p+1;
-	}
+	for (nl = raw, nitems = 0; p = strchr(nl, '\n'); nl = p+1)
+		++nitems;
+
 	if (!nitems) {
 		diag("Couldn't parse dir item");
 		return NULL;
@@ -494,7 +533,7 @@ connectto(const char *host, const char *port, struct cnx *c)
 	    .ai_protocol = IPPROTO_TCP,
 	};
 	struct addrinfo *addrs, *ai;
-	int r, err, conn;
+	int r, err;
 
 	sigemptyset(&set);
 	sigaddset(&set, SIGWINCH);
@@ -537,7 +576,7 @@ static int
 download(Item *item, int dest)
 {
 	char buf[BUFSIZ];
-	struct cnx c;
+	struct cnx c = { 0 };
 	ssize_t r, w;
 
 	if (item->tag == NULL) {
@@ -551,7 +590,6 @@ download(Item *item, int dest)
 			errno = 0;
 			return 0;
 		}
-		c.tls = NULL;
 	}
 
 	w = 0;
@@ -641,7 +679,22 @@ fetchitem(Item *item)
 }
 
 static void
-plumb(char *url)
+pipeuri(char *cmd, char *msg, char *uri)
+{
+	FILE *sel;
+
+	if ((sel = popen(cmd, "w")) == NULL) {
+		diag("URI not %s\n", msg);
+		return;
+	}
+
+	fputs(uri, sel);
+	pclose(sel);
+	diag("%s \"%s\"", msg, uri);
+}
+
+static void
+execuri(char *cmd, char *msg, char *uri)
 {
 	switch (fork()) {
 	case -1:
@@ -651,7 +704,7 @@ plumb(char *url)
 		parent = 0;
 		dup2(devnullfd, 1);
 		dup2(devnullfd, 2);
-		if (execlp(plumber, plumber, url, NULL) == -1)
+		if (execlp(cmd, cmd, uri, NULL) == -1)
 			_exit(1);
 	default:
 		if (modalplumber) {
@@ -660,7 +713,7 @@ plumb(char *url)
 		}
 	}
 
-	diag("Plumbed \"%s\"", url);
+	diag("%s \"%s\"", msg, uri);
 }
 
 static void
@@ -711,7 +764,7 @@ plumbitem(Item *item)
 		item->tag = path;
 
 	if (plumbitem)
-		plumb(item->tag);
+		execuri(plumber, "Plumbed", item->tag);
 
 	return;
 cleanup:
@@ -719,6 +772,13 @@ cleanup:
 	return;
 }
 
+void
+yankitem(Item *item)
+{
+	itemuri(item, intbuf, sizeof(intbuf));
+	pipeuri(yanker, "Yanked", intbuf);
+}
+
 static int
 dig(Item *entry, Item *item)
 {
@@ -734,7 +794,7 @@ dig(Item *entry, Item *item)
 	switch (t) {
 	case 'h': /* fallthrough */
 		if (!strncmp(item->selector, "URL:", 4)) {
-			plumb(item->selector+4);
+			execuri(plumber, "Plumbed", item->selector+4);
 			return 0;
 		}
 	case '0':
@@ -757,7 +817,7 @@ dig(Item *entry, Item *item)
 		             item->selector, item->selector ? "@" : "",
 		             item->host, item->port) == -1)
 			return 0;
-		plumb(plumburi);
+		execuri(plumber, "Plumbed", plumburi);
 		free(plumburi);
 		return 0;
 	case 'T':
@@ -765,7 +825,7 @@ dig(Item *entry, Item *item)
 		             item->selector, item->selector ? "@" : "",
 		             item->host, item->port) == -1)
 			return 0;
-		plumb(plumburi);
+		execuri(plumburi, "Plumbed", plumburi);
 		free(plumburi);
 		return 0;
 	default:
@@ -1018,6 +1078,9 @@ setup(void)
 	sigaction(SIGHUP, &sa, NULL);
 	sigaction(SIGTERM, &sa, NULL);
 
+	sa.sa_handler = SIG_IGN;
+	sigaction(SIGCHLD, &sa, NULL);
+
 	if (!mkdtemp(tmpdir))
 		die("mkdir: %s: %s", tmpdir, strerror(errno));
 	if (interactive = isatty(1)) {
diff --git a/ui_ti.c b/ui_ti.c
index 50c5466..e256611 100644
--- a/ui_ti.c
+++ b/ui_ti.c
@@ -75,9 +75,9 @@ uiprompt(char *fmt, ...)
 	putp(tparm(enter_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 
 	va_start(ap, fmt);
-	if (vsnprintf(bufout, sizeof(bufout), fmt, ap) >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	vsnprintf(bufout, sizeof(bufout), fmt, ap);
 	va_end(ap);
+
 	n = mbsprint(bufout, columns);
 
 	putp(tparm(exit_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
@@ -110,9 +110,9 @@ uiprompt(char *fmt, ...)
 static void
 printitem(Item *item)
 {
-	if (snprintf(bufout, sizeof(bufout), "%s %s", typedisplay(item->type),
-	    item->username) >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	snprintf(bufout, sizeof(bufout), "%s %s",
+	         typedisplay(item->type), item->username);
+
 	mbsprint(bufout, columns);
 	putchar('\r');
 }
@@ -138,6 +138,8 @@ help(Item *entry)
 		       S(_key_searchprev) ": search string backward.\n"
 		       S(_key_cururi) ": print page URI.\n"
 		       S(_key_seluri) ": print item URI.\n"
+		       S(_key_yankcur) ": yank page URI to external program.\n"
+		       S(_key_yanksel) ": yank item URI to external program.\n"
 		       S(_key_help) ": show this help.\n"
 		       "^D, " S(_key_quit) ": exit sacc.\n"
 	};
@@ -163,13 +165,12 @@ uistatus(char *fmt, ...)
 	va_end(ap);
 
 	if (n < sizeof(bufout)-1) {
-		n += snprintf(bufout + n, sizeof(bufout) - n,
-		              " [Press a key to continue \xe2\x98\x83]");
+		snprintf(bufout+n, sizeof(bufout)-n,
+		         " [Press a key to continue \xe2\x98\x83]");
 	}
-	if (n >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
 
-	n = mbsprint(bufout, columns);
+	mbsprint(bufout, columns);
+
 	putp(tparm(exit_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 	putp(tparm(clr_eol, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 
@@ -184,22 +185,23 @@ displaystatus(Item *item)
 {
 	Dir *dir = item->dat;
 	char *fmt;
-	size_t n, nitems = dir ? dir->nitems : 0;
+	size_t nitems = dir ? dir->nitems : 0;
 	unsigned long long printoff = dir ? dir->printoff : 0;
 
 	putp(tparm(save_cursor, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 
 	putp(tparm(cursor_address, lines-1, 0, 0, 0, 0, 0, 0, 0, 0));
 	putp(tparm(enter_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+
 	fmt = (strcmp(item->port, "70") && strcmp(item->port, "gopher")) ?
 	      "%1$3lld%%| %2$s:%5$s/%3$c%4$s" : "%3lld%%| %s/%c%s";
-	if (snprintf(bufout, sizeof(bufout), fmt,
-	             (printoff + lines-1 >= nitems) ? 100 :
-	             (printoff + lines-1) * 100 / nitems,
-	             item->host, item->type, item->selector, item->port)
-	    >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
-	n = mbsprint(bufout, columns);
+	snprintf(bufout, sizeof(bufout), fmt,
+	         (printoff + lines-1 >= nitems) ? 100 :
+	         (printoff + lines-1) * 100 / nitems,
+	         item->host, item->type, item->selector, item->port);
+
+	mbsprint(bufout, columns);
+
 	putp(tparm(exit_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 	putp(tparm(clr_eol, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 
@@ -210,8 +212,6 @@ displaystatus(Item *item)
 static void
 displayuri(Item *item)
 {
-	size_t n;
-
 	if (item->type == 0 || item->type == 'i')
 		return;
 
@@ -219,41 +219,11 @@ displayuri(Item *item)
 
 	putp(tparm(cursor_address, lines-1, 0, 0, 0, 0, 0, 0, 0, 0));
 	putp(tparm(enter_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
-	switch (item->type) {
-	case '8':
-		n = snprintf(bufout, sizeof(bufout), "telnet://%s@%s:%s",
-		             item->selector, item->host, item->port);
-		break;
-	case 'h':
-		n = snprintf(bufout, sizeof(bufout), "%s",
-		             item->selector);
-		break;
-	case 'T':
-		n = snprintf(bufout, sizeof(bufout), "tn3270://%s@%s:%s",
-		             item->selector, item->host, item->port);
-		break;
-	default:
-		n = snprintf(bufout, sizeof(bufout), "gopher://%s", item->host);
-
-		if (n < sizeof(bufout) && strcmp(item->port, "70")) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, ":%s",
-			              item->port);
-		}
-		if (n < sizeof(bufout)) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "/%c%s",
-			              item->type, item->selector);
-		}
-		if (n < sizeof(bufout) && item->type == '7' && item->tag) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "%%09%s",
-			              item->tag + strlen(item->selector));
-		}
-		break;
-	}
 
-	if (n >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	itemuri(item, bufout, sizeof(bufout));
+
+	mbsprint(bufout, columns);
 
-	n = mbsprint(bufout, columns);
 	putp(tparm(exit_standout_mode, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 	putp(tparm(clr_eol, 0, 0, 0, 0, 0, 0, 0, 0, 0));
 
@@ -404,7 +374,7 @@ jumptoline(Item *entry, ssize_t line, int absolute)
 	return;
 }
 
-void
+static void
 searchinline(const char *searchstr, Item *entry, int pos)
 {
 	Dir *dir;
@@ -454,7 +424,7 @@ uiselectitem(Item *entry)
 {
 	Dir *dir;
 	char *searchstr = NULL;
-	int plines = lines-2;
+	int c, plines = lines-2;
 
 	if (!entry || !(dir = entry->dat))
 		return NULL;
@@ -465,24 +435,36 @@ uiselectitem(Item *entry)
 			switch (getchar()) {
 			case 0x1b:
 				goto quit;
-			case '[':
+			case 'O': /* application key */
+			case '[': /* DEC */
 				break;
 			default:
 				continue;
 			}
-			switch (getchar()) {
+			c = getchar();
+			switch (c) {
+			case '1':
 			case '4':
-				if (getchar() != '~')
-					continue;
-				goto end;
 			case '5':
-				if (getchar() != '~')
-					continue;
-				goto pgup;
 			case '6':
+			case '7': /* urxvt */
+			case '8': /* urxvt */
 				if (getchar() != '~')
 					continue;
-				goto pgdown;
+				switch (c) {
+				case '1':
+					goto home;
+				case '4':
+					goto end;
+				case '5':
+					goto pgup;
+				case '6':
+					goto pgdown;
+				case '7':
+					goto home;
+				case '8':
+					goto end;
+				}
 			case 'A':
 				goto lnup;
 			case 'B':
@@ -537,7 +519,6 @@ uiselectitem(Item *entry)
 			jumptoline(entry, 0, 0);
 			continue;
 		case _key_search:
-		search:
 			free(searchstr);
 			if (!((searchstr = uiprompt("Search for: ")) &&
 			    searchstr[0])) {
@@ -555,7 +536,6 @@ uiselectitem(Item *entry)
 		quit:
 			return NULL;
 		case _key_fetch:
-		fetch:
 			if (entry->raw)
 				continue;
 			return entry;
@@ -567,6 +547,14 @@ uiselectitem(Item *entry)
 			if (dir)
 				displayuri(&dir->items[dir->curline]);
 			continue;
+		case _key_yankcur:
+			if (dir)
+				yankitem(entry);
+			continue;
+		case _key_yanksel:
+			if (dir)
+				yankitem(&dir->items[dir->curline]);
+			continue;
 		case _key_help: /* FALLTHROUGH */
 			return help(entry);
 		default:
diff --git a/ui_txt.c b/ui_txt.c
index b326d38..80b2e4c 100644
--- a/ui_txt.c
+++ b/ui_txt.c
@@ -12,8 +12,8 @@
 
 static char bufout[256];
 static Item *curentry;
+static int lines, columns;
 static char cmd;
-int lines, columns;
 
 static void
 viewsize(int *ln, int *col)
@@ -43,7 +43,7 @@ uicleanup(void)
 	return;
 }
 
-void
+static void
 help(void)
 {
 	puts("Commands:\n"
@@ -55,6 +55,8 @@ help(void)
 	     "p: show previous page.\n"
 	     "t: go to the top of the page\n"
 	     "b: go to the bottom of the page\n"
+	     "Y: yank page URI.\n"
+	     "y#: yank item number # URI.\n"
 	     "/str: search for string \"str\"\n"
 	     "!: refetch failed item.\n"
 	     "^D, q: quit.\n"
@@ -78,11 +80,9 @@ uistatus(char *fmt, ...)
 	va_end(arg);
 
 	if (n < sizeof(bufout)-1) {
-		n += snprintf(bufout + n, sizeof(bufout) - n,
-		              " [Press Enter to continue \xe2\x98\x83]");
+		snprintf(bufout+n, sizeof(bufout)-n,
+		         " [Press Enter to continue \xe2\x98\x83]");
 	}
-	if (n >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
 
 	mbsprint(bufout, columns);
 	fflush(stdout);
@@ -101,12 +101,11 @@ printstatus(Item *item, char c)
 	fmt = (strcmp(item->port, "70") && strcmp(item->port, "gopher")) ?
 	      "%1$3lld%%%*2$3$c %4$s:%8$s/%5$c%6$s [%7$c]: " :
               "%3lld%% %s/%c%s [%c]: ";
-	if (snprintf(bufout, sizeof(bufout), fmt,
-	             (printoff + lines-1 >= nitems) ? 100 :
-	             (printoff + lines) * 100 / nitems,
-	             item->host, item->type, item->selector, c, item->port)
-	    >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	snprintf(bufout, sizeof(bufout), fmt,
+	         (printoff + lines-1 >= nitems) ? 100 :
+	         (printoff + lines) * 100 / nitems,
+	         item->host, item->type, item->selector, c, item->port);
+
 	mbsprint(bufout, columns);
 }
 
@@ -119,8 +118,7 @@ uiprompt(char *fmt, ...)
 	ssize_t r;
 
 	va_start(ap, fmt);
-	if (vsnprintf(bufout, sizeof(bufout), fmt, ap) >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	vsnprintf(bufout, sizeof(bufout), fmt, ap);
 	va_end(ap);
 
 	mbsprint(bufout, columns);
@@ -158,11 +156,10 @@ uidisplay(Item *entry)
 	nd = ndigits(nitems);
 
 	for (i = dir->printoff; i < nitems && i < nlines; ++i) {
-		if (snprintf(bufout, sizeof(bufout), "%*zu %s %s",
-		             nd, i+1, typedisplay(items[i].type),
-		             items[i].username)
-		    >= sizeof(bufout))
-			bufout[sizeof(bufout)-1] = '\0';
+		snprintf(bufout, sizeof(bufout), "%*zu %s %s",
+		         nd, i+1,typedisplay(items[i].type),
+		         items[i].username);
+
 		mbsprint(bufout, columns);
 		putchar('\n');
 	}
@@ -170,67 +167,19 @@ uidisplay(Item *entry)
 	fflush(stdout);
 }
 
-void
+static void
 printuri(Item *item, size_t i)
 {
-	int n;
-
-	if (!item)
-		return;
-
-	switch (item->type) {
-	case 0:
+	if (!item || item->type == 0 || item->type == 'i')
 		return;
-	case '8':
-		n = snprintf(bufout, sizeof(bufout), "telnet://%s@%s:%s",
-		             item->selector, item->host, item->port);
-		break;
-	case 'i':
-		n = snprintf(bufout, sizeof(bufout), "%zu: %s",
-		             i, item->username);
-		break;
-	case 'h':
-		n = snprintf(bufout, sizeof(bufout), "%zu: %s: %s",
-		         i, item->username, item->selector);
-		break;
-	case 'T':
-		n = snprintf(bufout, sizeof(bufout), "tn3270://%s@%s:%s",
-		             item->selector, item->host, item->port);
-		break;
-	default:
-		n = snprintf(bufout, sizeof(bufout), "%zu: ", i);
-
-		if (n < sizeof(bufout) && *item->username) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "%s: ",
-			              item->username);
-		}
-		if (n < sizeof(bufout)) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "gopher://%s",
-			              item->host);
-		}
-		if (n < sizeof(bufout) && strcmp(item->port, "70")) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, ":%s",
-			              item->port);
-		}
-		if (n < sizeof(bufout)) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "/%c%s",
-			              item->type, item->selector);
-		}
-		if (n < sizeof(bufout) && item->type == '7' && item->tag) {
-			n += snprintf(bufout+n, sizeof(bufout)-n, "%%09%s",
-			              item->tag + strlen(item->selector));
-		}
-		break;
-	}
 
-	if (n >= sizeof(bufout))
-		bufout[sizeof(bufout)-1] = '\0';
+	itemuri(item, bufout, sizeof(bufout));
 
 	mbsprint(bufout, columns);
 	putchar('\n');
 }
 
-void
+static void
 searchinline(const char *searchstr, Item *entry)
 {
 	Dir *dir;
@@ -324,6 +273,12 @@ uiselectitem(Item *entry)
 			if (item > 0 && item <= nitems)
 				printuri(&dir->items[item-1], item);
 			continue;
+		case 'Y':
+			yankitem(entry);
+			continue;
+		case 'y':
+			if (item > 0 && item <= nitems)
+				yankitem(&dir->items[item-1]);
 		case '/':
 			if (*sstr)
 				searchinline(sstr, entry);

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/debug/.build-id/d7/c48f575e64d6dfe9f14bd5c9ab6356b05a93f3.debug

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/debug/.build-id/9c/60954d4d445c27fb55f5150638c2c6dc10b0a2.debug

No differences were encountered between the control files of package sacc

Control files of package sacc-dbgsym: lines which differ (wdiff format)

  • Build-Ids: 9c60954d4d445c27fb55f5150638c2c6dc10b0a2 d7c48f575e64d6dfe9f14bd5c9ab6356b05a93f3

Run locally

More details

Full run details