From: markus schnalke Date: Sat, 14 Apr 2012 18:13:04 +0000 (+0200) Subject: mhl: Don't invoke the pager anymore. X-Git-Tag: mmh-thesis-end~81 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=0e46503be3c855bddaeae3843e1b659279c35d70;p=mmh mhl: Don't invoke the pager anymore. As show(1) will soon be replaced by mhshow(1), mhl will be hidden behind mhshow(1), which does invoke a pager now itself. Hence, no need for mhl(1) to deal with it. --- diff --git a/man/mhl.man1 b/man/mhl.man1 index f9536c0..95c5405 100644 --- a/man/mhl.man1 +++ b/man/mhl.man1 @@ -27,13 +27,6 @@ messages. It is the default method of displaying text messages for (it is the default .IR showproc ). .PP -If -.B mhl -is outputting to a terminal, then -.B mhl -will cause a pager to be placed between the terminal and -.BR mhl . -.PP The .B \-width .I width @@ -229,12 +222,7 @@ appropriate formatfield variable string. .fi .SH "PROFILE COMPONENTS" -.fc ^ ~ -.nf -.ta 2.4i -.ta \w'ExtraBigProfileName 'u -^Pager:~^Program to use as interactive front\-end -.fi +none .SH "SEE ALSO" show(1), ap(8), dp(8) diff --git a/uip/mhl.c b/uip/mhl.c index 58c7d2b..2c1d907 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -172,10 +172,6 @@ static int issue = 0; static int exitstat = 0; static int mhldebug = 0; -#define PITTY (-1) -#define NOTTY 0 -static int ontty = NOTTY; - static unsigned int column; static int lm; @@ -230,13 +226,8 @@ static char *oneline(char *, long); static void putstr(char *); static void putch(char); static void intrser(int); -static void pipeser(int); -static void quitser(int); static void mhladios(char *, char *, ...); static void mhldone(int); -static void m_popen(char *); - -void m_pclose(void); int sc_width(void); /* from termsbr.c */ @@ -340,18 +331,6 @@ main(int argc, char **argv) files[vecp++] = cp; } - if (isatty(fileno(stdout))) { - if (mhl_action) { - SIGNAL(SIGINT, SIG_IGN); - SIGNAL2(SIGQUIT, quitser); - } - SIGNAL2(SIGPIPE, pipeser); - m_popen(defaultpager); - ontty = PITTY; - } else { - ontty = NOTTY; - } - mhl_format(form ? form : mhlformat, width); if (vecp == 0) { @@ -386,9 +365,6 @@ main(int argc, char **argv) adios("output", "error writing"); } - if (ontty == PITTY) - m_pclose(); - return exitstat; } @@ -677,13 +653,11 @@ process(char *fname, int ofilen, int ofilec) fname = "(stdin)"; fp = stdin; } - if (ontty != PITTY) - SIGNAL(SIGINT, intrser); + SIGNAL(SIGINT, intrser); mhlfile(fp, fname, ofilen, ofilec); /* FALL THROUGH! */ default: - if (ontty != PITTY) - SIGNAL(SIGINT, SIG_IGN); + SIGNAL(SIGINT, SIG_IGN); if (mhl_action == NULL && fp != stdin) fclose(fp); if (holder.c_text) { @@ -1219,22 +1193,6 @@ intrser(int i) } -static void -pipeser(int i) -{ - done(NOTOK); -} - - -static void -quitser(int i) -{ - putchar('\n'); - fflush(stdout); - done(NOTOK); -} - - #undef adios #undef done @@ -1259,68 +1217,3 @@ mhldone(int status) else done(exitstat); } - - -static int m_pid = NOTOK; -static int sd = NOTOK; - -static void -m_popen(char *name) -{ - int pd[2]; - - if (mhl_action && (sd = dup(fileno(stdout))) == NOTOK) - adios("standard output", "unable to dup()"); - - if (pipe(pd) == NOTOK) - adios("pipe", "unable to"); - - switch (m_pid = fork()) { - case NOTOK: - adios("fork", "unable to"); - - case OK: - SIGNAL(SIGINT, SIG_DFL); - SIGNAL(SIGQUIT, SIG_DFL); - - close(pd[1]); - if (pd[0] != fileno(stdin)) { - dup2(pd[0], fileno(stdin)); - close(pd[0]); - } - execlp(name, mhbasename(name), NULL); - fprintf(stderr, "unable to exec "); - perror(name); - _exit(-1); - - default: - close(pd[0]); - if (pd[1] != fileno(stdout)) { - dup2(pd[1], fileno(stdout)); - close(pd[1]); - } - } -} - - -void -m_pclose(void) -{ - if (m_pid == NOTOK) - return; - - if (sd != NOTOK) { - fflush(stdout); - if (dup2(sd, fileno(stdout)) == NOTOK) - adios("standard output", "unable to dup2()"); - - clearerr(stdout); - close(sd); - sd = NOTOK; - } - else - fclose(stdout); - - pidwait(m_pid, OK); - m_pid = NOTOK; -}