From 621b13f3391aea844d9ca5886b265377312b1bda Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 4 Oct 1995 09:33:39 +0000 Subject: Make more pass +linenumber to vi (and emacs), even if $EDITOR is used. Closes PR#441, but with a more generic method. --- usr.bin/more/command.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'usr.bin/more') diff --git a/usr.bin/more/command.c b/usr.bin/more/command.c index 1585245..b26fa22 100644 --- a/usr.bin/more/command.c +++ b/usr.bin/more/command.c @@ -39,6 +39,7 @@ static char sccsid[] = "@(#)command.c 8.1 (Berkeley) 6/6/93"; #include #include #include +#include #include #include "pathnames.h" @@ -594,16 +595,25 @@ editfile() extern char *current_file; static int dolinenumber; static char *editor; + char *base; int c; char buf[MAXPATHLEN * 2 + 20], *getenv(); if (editor == NULL) { editor = getenv("EDITOR"); - /* pass the line number to vi */ - if (editor == NULL || *editor == '\0') { + + /* default editor is vi */ + if (editor == NULL || *editor == '\0') editor = _PATH_VI; + + /* check last component in case of full path */ + base = strrchr(editor, '/'); + if (!base) + base = editor; + + /* emacs also accepts vi-style +nnnn */ + if (strcmp(base, "vi") == 0 || strcmp(base, "emacs") == 0) dolinenumber = 1; - } else dolinenumber = 0; } -- cgit v1.1