/* FIXME: global_ctl is used in signal handlers. */
struct more_control *global_ctl;
-static void putstring(char *s)
-{
- tputs(s, fileno(stdout), putchar); /* putp(s); */
-}
-
static void __attribute__((__noreturn__)) usage(void)
{
FILE *out = stdout;
return ungetc(c, stream);
}
-/* force clear to end of line */
-static void cleareol(struct more_control *ctl)
-{
- putstring(ctl->eraseln);
-}
-
/* magic --
* check for file magic numbers. This code would best be shared
* with the file(1) program or, perhaps, more should not try to be
if (stat(fs, &stbuf) == -1) {
fflush(stdout);
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
warn(_("stat of %s failed"), fs);
return NULL;
}
return column;
}
-static void clreos(struct more_control *ctl)
-{
- putstring(ctl->EodClr);
-}
-
/* Erase the rest of the prompt, assuming we are starting at column col. */
static void erasep(struct more_control *ctl, register int col)
{
if (col == 0)
putchar('\r');
if (!ctl->dumb && ctl->eraseln)
- putstring(ctl->eraseln);
+ putp(ctl->eraseln);
else
printf("%*s", ctl->promptlen - col, "");
}
#endif /* HAVE_WIDECHAR */
if (state && *ctl->chUL) {
fputs(ctl->chBS, stdout);
- putstring(ctl->chUL);
+ putp(ctl->chUL);
}
ctl->pstate = state;
}
static void prompt(struct more_control *ctl, char *filename)
{
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
else if (ctl->promptlen > 0)
kill_line(ctl);
if (!ctl->hard) {
ctl->promptlen = 0;
if (ctl->Senter && ctl->Sexit) {
- putstring(ctl->Senter);
+ putp(ctl->Senter);
ctl->promptlen += (2 * ctl->soglitch);
}
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
ctl->promptlen += printf(_("--More--"));
if (filename != NULL) {
ctl->promptlen += printf(_("(Next file: %s)"), filename);
printf(_("[Press space to continue, 'q' to quit.]"));
}
if (ctl->Senter && ctl->Sexit)
- putstring(ctl->Sexit);
+ putp(ctl->Sexit);
if (ctl->clreol)
- clreos(ctl);
+ putp(ctl->EodClr);
fflush(stdout);
} else
fputc(RINGBELL, stderr);
ctl->inwait++;
}
-static int ourputch(int c)
-{
- return putc(c, stdout);
-}
-
static void reset_tty(void)
{
if (global_ctl->no_tty)
return;
if (global_ctl->pstate) {
- tputs(global_ctl->ULexit, fileno(stdout), ourputch);
+ putp(global_ctl->ULexit);
fflush(stdout);
global_ctl->pstate = 0;
}
reset_tty();
if (global_ctl->clreol) {
putchar('\r');
- clreos(global_ctl);
+ putp(global_ctl->eraseln);
fflush(stdout);
} else if (!global_ctl->clreol && (global_ctl->promptlen > 0)) {
kill_line(global_ctl);
ctl->fnum = 0;
puts(_("\n...Skipping "));
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
if (nskip > 0)
fputs(_("...Skipping to file "), stdout);
else
fputs(_("...Skipping back to file "), stdout);
puts(ctl->fnames[ctl->fnum]);
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
putchar('\n');
ctl->fnum--;
}
static void more_error(struct more_control *ctl, char *mess)
{
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
else
kill_line(ctl);
ctl->promptlen += strlen(mess);
*p = '\0';
}
-/* Go to home position */
-static void home(struct more_control *ctl)
-{
- putp(ctl->Home);
-}
-
/* Search for nth occurrence of regular expression contained in buf in
* the file */
static void search(struct more_control *ctl, char buf[], FILE *file, register int n)
if (lncount > 3 || (lncount > 1 && ctl->no_intty)) {
putchar('\n');
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
fputs(_("...skipping\n"), stdout);
}
if (!ctl->no_intty) {
more_fseek(ctl, file, line3);
if (ctl->noscroll) {
if (ctl->clreol) {
- home(ctl);
- cleareol(ctl);
+ putp(ctl->Home);
+ putp(ctl->eraseln);
} else
doclear(ctl);
}
kill_line(ctl);
if (ctl->noscroll) {
if (ctl->clreol) {
- home(ctl);
- cleareol(ctl);
+ putp(ctl->Home);
+ putp(ctl->eraseln);
} else
doclear(ctl);
}
erasep(ctl, 0);
putchar('\n');
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
printf(P_("...back %d page",
"...back %d pages", nlines),
nlines);
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
putchar('\n');
initline = ctl->Currline - ctl->dlines * (nlines + 1);
erasep(ctl, 0);
putchar('\n');
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
printf(P_("...skipping %d line",
"...skipping %d lines", nlines),
nlines);
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
putchar('\n');
while (nlines > 0) {
if (ctl->dum_opt) {
kill_line(ctl);
if (ctl->Senter && ctl->Sexit) {
- putstring(ctl->Senter);
+ putp(ctl->Senter);
ctl->promptlen =
printf(_
("[Press 'h' for instructions.]"))
+ 2 * ctl->soglitch;
- putstring(ctl->Sexit);
+ putp(ctl->Sexit);
} else
ctl->promptlen =
printf(_
while (num_lines > 0 && !ctl->Pause) {
if ((nchars = get_line(ctl, f, &length)) == EOF) {
if (ctl->clreol)
- clreos(ctl);
+ putp(ctl->EodClr);
return;
}
if (ctl->ssp_opt && length == 0 && prev_len == 0)
* some terminals do not erase what they tab
* over. */
if (ctl->clreol)
- cleareol(ctl);
+ putp(ctl->eraseln);
prbuf(ctl, ctl->Line, length);
if (nchars < ctl->promptlen)
erasep(ctl, nchars); /* erasep () sets promptlen to 0 */
fflush(stdout);
if ((c = more_getc(ctl, f)) == EOF) {
if (ctl->clreol)
- clreos(ctl);
+ putp(ctl->EodClr);
return;
}
if (ctl->Pause && ctl->clreol)
- clreos(ctl);
+ putp(ctl->EodClr);
more_ungetc(ctl, c, f);
sigsetjmp(ctl->restore, 1);
ctl->Pause = 0;
erasep(ctl, 0);
if (ctl->noscroll && num_lines >= ctl->dlines) {
if (ctl->clreol)
- home(ctl);
+ putp(ctl->Home);
else
doclear(ctl);
}
ungetc(chr, f);
if (ctl.noscroll && (chr != EOF)) {
if (ctl.clreol)
- home(&ctl);
+ putp(ctl.Home);
else
doclear(&ctl);
}
if ((ctl.noscroll || clearit)
&& (ctl.file_size != LONG_MAX)) {
if (ctl.clreol)
- home(&ctl);
+ putp(ctl.Home);
else
doclear(&ctl);
}
if (ctl.bad_so)
erasep(&ctl, 0);
if (ctl.clreol)
- cleareol(&ctl);
+ putp(ctl.eraseln);
fputs("::::::::::::::", stdout);
if (ctl.promptlen > 14)
erasep(&ctl, 14);
putchar('\n');
if (ctl.clreol)
- cleareol(&ctl);
+ putp(ctl.eraseln);
puts(ctl.fnames[ctl.fnum]);
if (ctl.clreol)
- cleareol(&ctl);
+ putp(ctl.eraseln);
fputs("::::::::::::::\n", stdout);
if (left > ctl.Lpp - 4)
left = ctl.Lpp - 4;