Index | Thread | Search

From:
Jonathan Gray <jsg@jsg.id.au>
Subject:
remove uncalled less(1) functions
To:
tech@openbsd.org
Date:
Tue, 16 Apr 2024 15:33:34 +1000

Download raw body.

Thread
missed in LESSOPEN/LESSCLOSE removal

Index: usr.bin/less/filename.c
===================================================================
RCS file: /cvs/src/usr.bin/less/filename.c,v
diff -u -p -r1.31 filename.c
--- usr.bin/less/filename.c	14 Apr 2024 18:11:54 -0000	1.31
+++ usr.bin/less/filename.c	16 Apr 2024 05:26:25 -0000
@@ -379,85 +379,6 @@ bin_file(int f)
 }
 
 /*
- * Read a string from a file.
- * Return a pointer to the string in memory.
- */
-static char *
-readfd(FILE *fd)
-{
-	int len;
-	int ch;
-	char *buf;
-	char *p;
-
-	/*
-	 * Make a guess about how many chars in the string
-	 * and allocate a buffer to hold it.
-	 */
-	len = 100;
-	buf = ecalloc(len, sizeof (char));
-	for (p = buf; ; p++) {
-		if ((ch = getc(fd)) == '\n' || ch == EOF)
-			break;
-		if (p >= buf + len-1) {
-			/*
-			 * The string is too big to fit in the buffer we have.
-			 * Allocate a new buffer, twice as big.
-			 */
-			len *= 2;
-			*p = '\0';
-			p = ecalloc(len, sizeof (char));
-			strlcpy(p, buf, len);
-			free(buf);
-			buf = p;
-			p = buf + strlen(buf);
-		}
-		*p = (char)ch;
-	}
-	*p = '\0';
-	return (buf);
-}
-
-/*
- * Execute a shell command.
- * Return a pointer to a pipe connected to the shell command's standard output.
- */
-static FILE *
-shellcmd(char *cmd)
-{
-	FILE *fd;
-
-	char *shell;
-
-	shell = lgetenv("SHELL");
-	if (shell != NULL && *shell != '\0') {
-		char *scmd;
-		char *esccmd;
-
-		/*
-		 * Read the output of <$SHELL -c cmd>.
-		 * Escape any metacharacters in the command.
-		 */
-		esccmd = shell_quote(cmd);
-		if (esccmd == NULL) {
-			fd = popen(cmd, "r");
-		} else {
-			scmd = easprintf("%s -c %s", shell, esccmd);
-			free(esccmd);
-			fd = popen(scmd, "r");
-			free(scmd);
-		}
-	} else {
-		fd = popen(cmd, "r");
-	}
-	/*
-	 * Redirection in `popen' might have messed with the
-	 * standard devices.  Restore binary input mode.
-	 */
-	return (fd);
-}
-
-/*
  * Expand a filename, doing any system-specific metacharacter substitutions.
  */
 char *