diff -Nur util-linux-2.9r/text-utils/more.c util-linux-2.9r.pld/text-utils/more.c --- util-linux-2.9r/text-utils/more.c Sat Mar 20 21:20:18 1999 +++ util-linux-2.9r.pld/text-utils/more.c Sun May 23 13:47:46 1999 @@ -138,7 +138,7 @@ char *shell; /* The name of the shell to use */ int shellp; /* A previous shell command exists */ char ch; -jmp_buf restore; +sigjmp_buf restore; char Line[LINSIZ]; /* Line buffer */ int Lpp = 24; /* lines per page */ char *Clear; /* clear screen */ @@ -151,7 +151,6 @@ char *cursorm; /* cursor movement */ char cursorhome[40]; /* contains cursor movement to home */ char *EodClr; /* clear rest of screen */ -char *tgetstr(); int Mcol = 80; /* number of columns */ int Wrap = 1; /* set if automargins */ int soglitch; /* terminal has standout mode glitch */ @@ -159,6 +158,9 @@ int pstate = 0; /* current UL state */ char *getenv(); static int magic(); +char termbuffer[2048]; +char tcbuffer[2048]; +char * strbuf = termbuffer; struct { long chrctr, line; } context, screen_start; @@ -297,7 +299,7 @@ if ((f = checkf (fnames[fnum], &clearit)) != NULL) { context.line = context.chrctr = 0; Currline = 0; - if (firstf) setjmp (restore); + if (firstf) sigsetjmp (restore, 1); if (firstf) { firstf = 0; if (srchopt) { @@ -309,7 +311,7 @@ skiplns (initline, f); } else if (fnum < nfiles && !no_tty) { - setjmp (restore); + sigsetjmp (restore, 1); left = command (fnames[fnum], f); } if (left != 0) { @@ -343,7 +345,7 @@ within = 0; } } - setjmp (restore); + sigsetjmp (restore, 1); fflush(stdout); fclose(f); screen_start.line = screen_start.chrctr = 0L; @@ -514,7 +516,7 @@ num_lines--; } if (pstate) { - putp (ULexit); + tputs (ULexit, 1, putchar); pstate = 0; } fflush(stdout); @@ -528,7 +530,7 @@ if (Pause && clreol) clreos (); Ungetc (c, f); - setjmp (restore); + sigsetjmp (restore, 1); Pause = 0; startup = 0; if ((num_lines = command (NULL, f)) == 0) return; @@ -557,7 +559,7 @@ putchar ('\n'); if (!startup) { signal(SIGQUIT, onquit); - longjmp (restore, 1); + siglongjmp (restore, 1); } else Pause++; @@ -744,7 +746,7 @@ if (!hard) { promptlen = 8; if (Senter && Sexit) { - putp (Senter); + tputs (Senter, 1, putchar); promptlen += (2 * soglitch); } if (clreol) @@ -760,7 +762,7 @@ promptlen += pr(_("[Press space to continue, 'q' to quit.]")); } if (Senter && Sexit) - putp (Sexit); + tputs (Sexit, 1, putchar); if (clreol) clreos (); fflush(stdout); @@ -807,7 +809,7 @@ if (!hardtabs || (column < promptlen && !hard)) { if (hardtabs && eraseln && !dumb) { column = 1 + (column | 7); - putp (eraseln); + tputs (eraseln, 1, putchar); promptlen = 0; } else { @@ -876,7 +878,7 @@ if (col == 0) putchar ('\r'); if (!dumb && eraseln) - putp (eraseln); + tputs (eraseln, 1, putchar); else for (col = promptlen - col; col > 0; col--) putchar (' '); @@ -900,12 +902,12 @@ */ void cleareol() { - putp(eraseln); + tputs(eraseln, 1, putchar); } void clreos() { - putp(EodClr); + tputs(EodClr, 1, putchar); } /* @@ -949,13 +951,13 @@ if (c == ' ' && state == 0 && ulglitch && wouldul(s, n-1)) state = 1; else - putp(state ? ULenter : ULexit); + tputs(state ? ULenter : ULexit, 1, putchar); } if (c != ' ' || pstate == 0 || state != 0 || ulglitch == 0) putchar(c); if (state && *chUL) { pr(chBS); - putp(chUL); + tputs(chUL, 1, putchar); } pstate = state; } @@ -968,7 +970,7 @@ doclear() { if (Clear && !hard) { - putp(Clear); + tputs(Clear, 1, putchar); /* Put out carriage return so that system doesn't ** get confused by escape sequences when expanding tabs @@ -984,7 +986,7 @@ void home() { - putp(Home); + tputs(Home, 1, putchar); } static int lastcmd, lastarg, lastp; @@ -1200,9 +1202,9 @@ if (dum_opt) { kill_line (); if (Senter && Sexit) { - putp (Senter); + tputs (Senter, 1, putchar); promptlen = pr (_("[Press 'h' for instructions.]")) + (2 * soglitch); - putp (Sexit); + tputs (Sexit, 1, putchar); } else promptlen = pr (_("[Press 'h' for instructions.]")); @@ -1569,7 +1571,7 @@ if ((term = getenv("TERM")) == 0) { dumb++; ul_opt = 0; } - setupterm(term, 1, &ret); + ret = tgetent(tcbuffer, getenv("TERM")); if (ret <= 0) { dumb++; ul_opt = 0; } @@ -1577,35 +1579,35 @@ #ifdef TIOCGWINSZ if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) { #endif - Lpp = tigetnum("lines"); - Mcol = tigetnum("cols"); + Lpp = tgetnum("li"); + Mcol = tgetnum("co"); #ifdef TIOCGWINSZ } else { if ((Lpp = win.ws_row) == 0) - Lpp = tigetnum("lines"); + Lpp = tgetnum("li"); if ((Mcol = win.ws_col) == 0) - Mcol = tigetnum("cols"); + Mcol = tgetnum("co"); } #endif - if ((Lpp <= 0) || tigetflag("hc")) { + if ((Lpp <= 0) || tgetflag("hc")) { hard++; /* Hard copy terminal */ Lpp = 24; } - if (tigetflag("xenl")) + if (tgetflag("xn")) eatnl++; /* Eat newline at last column + 1; dec, concept */ if (Mcol <= 0) Mcol = 80; if (tailequ (fnames[0], "page")) noscroll++; - Wrap = tigetflag("am"); - bad_so = tigetflag ("xhp"); - eraseln = tigetstr("el"); - Clear = tigetstr("clear"); - Senter = tigetstr("smso"); - Sexit = tigetstr("rmso"); - if ((soglitch = tigetnum("xmc")) < 0) + Wrap = tgetflag("am"); + bad_so = tgetflag ("xs"); + eraseln = tgetstr("ce", &strbuf); + Clear = tgetstr("cl", &strbuf); + Senter = tgetstr("co", &strbuf); + Sexit = tgetstr("se", &strbuf); + if ((soglitch = tgetnum("sg")) < 0) soglitch = 0; /* @@ -1616,12 +1618,12 @@ * isn't available, settle for standout sequence. */ - if (tigetflag("ul") || tigetflag("os")) + if (tgetflag("ul") || tgetflag("os")) ul_opt = 0; - if ((chUL = tigetstr("uc")) == NULL ) + if ((chUL = tgetstr("uc", &strbuf)) == NULL ) chUL = ""; - if (((ULenter = tigetstr("smul")) == NULL || - (ULexit = tigetstr("rmul")) == NULL) && !*chUL) { + if (((ULenter = tgetstr("us", &strbuf)) == NULL || + (ULexit = tgetstr("ue", &strbuf)) == NULL) && !*chUL) { if ((ULenter = Senter) == NULL || (ULexit = Sexit) == NULL) { ULenter = ""; ULexit = ""; @@ -1631,20 +1633,20 @@ ulglitch = 0; } - if ((padstr = tigetstr("pad")) != NULL) + if ((padstr = tgetstr("pc", &strbuf)) != NULL) PC = *padstr; - Home = tigetstr("home"); + Home = tgetstr("ho", &strbuf); if (Home == 0 || *Home == '\0') { - if ((cursorm = tigetstr("cup")) != NULL) { - const char *t = (const char *)tparm(cursorm, 0, 0); + if ((cursorm = tgetstr("cm", &strbuf)) != NULL) { + const char *t = (const char *)tgoto(cursorm, 0, 0); strncpy(cursorhome, t, sizeof(cursorhome)); cursorhome[sizeof(cursorhome)-1] = 0; Home = cursorhome; } } - EodClr = tigetstr("ed"); - if ((chBS = tigetstr("cub1")) == NULL) + EodClr = tgetstr("cd", &strbuf); + if ((chBS = tgetstr("le", &strbuf)) == NULL) chBS = "\b"; } @@ -1716,7 +1718,7 @@ } else { if (!eraseln) promptlen = maxlen; - longjmp (restore, 1); + siglongjmp (restore, 1); } } else if ((ch == otty.c_cc[VKILL]) && !slash) { @@ -1857,15 +1859,15 @@ kill_line (); promptlen += strlen (mess); if (Senter && Sexit) { - putp (Senter); + tputs (Senter, 1, putchar); pr(mess); - putp (Sexit); + tputs (Sexit, 1, putchar); } else pr (mess); fflush(stdout); errors++; - longjmp (restore, 1); + siglongjmp (restore, 1); } @@ -1937,5 +1939,5 @@ signal (SIGTSTP, onsusp); set_tty (); if (inwait) - longjmp (restore, 1); + siglongjmp (restore, 1); }