summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--text-utils/more.c1114
1 files changed, 556 insertions, 558 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index ec1185e12..5f528b3fa 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -86,7 +86,7 @@
#define CARAT "^"
#define RINGBELL '\007'
-#define LINSIZ 256 /* minimal Line buffer size */
+#define MIN_LINE_SZ 256 /* minimal line_buf buffer size */
#define ctrl(letter) (letter & 077)
#define RUBOUT '\177'
#define ESC '\033'
@@ -123,76 +123,76 @@
#define TERM_UNDERLINE "ul"
struct more_control {
- struct termios otty; /* output terminal */
- struct termios savetty0; /* original terminal settings */
- long file_pos; /* file position */
+ struct termios output_tty; /* output terminal */
+ struct termios original_tty; /* original terminal settings */
+ long file_position; /* file position */
long file_size; /* file size */
- int fnum; /* argv[] position */
- int dlines; /* screen size in lines */
- int nscroll; /* number of lines scrolled by 'd' */
- int promptlen; /* message prompt length */
- int Currline; /* line we are currently at */
- char **fnames; /* The list of file names */
- int nfiles; /* Number of files left to process */
+ int argv_position; /* argv[] position */
+ int lines_per_screen; /* screen size in lines */
+ int d_scroll_len; /* number of lines scrolled by 'd' */
+ int prompt_len; /* message prompt length */
+ int current_line; /* line we are currently at */
+ char **file_names; /* The list of file names */
+ int num_files; /* Number of files left to process */
char *shell; /* name of the shell to use */
- int shellp; /* does previous shell command exist */
- sigjmp_buf restore; /* siglongjmp() destination */
- char *Line; /* line buffer */
- size_t LineLen; /* size of Line buffer */
- int Lpp; /* lines per page */
- char *Clear; /* clear screen */
- char *eraseln; /* erase line */
- char *Senter; /* enter standout mode */
- char *Sexit; /* exit standout mode */
- char *ULenter; /* enter underline mode */
- char *ULexit; /* exit underline mode */
- char *chUL; /* underline character */
- char *chBS; /* backspace character */
- char *Home; /* go to home */
- char *cursorm; /* cursor movement */
- char cursorhome[40]; /* contains cursor movement to home */
- char *EodClr; /* clear rest of screen */
- int Mcol; /* number of columns */
- char *previousre; /* previous search() buf[] item */
+ int previous_shell; /* does previous shell command exist */
+ sigjmp_buf destination; /* siglongjmp() destination */
+ char *line_buf; /* line buffer */
+ size_t line_sz; /* size of line_buf buffer */
+ int lines_per_page; /* lines per page */
+ char *clear; /* clear screen */
+ char *erase_line; /* erase line */
+ char *enter_std; /* enter standout mode */
+ char *exit_std; /* exit standout mode */
+ char *enter_underline; /* enter underline mode */
+ char *exit_underline; /* exit underline mode */
+ char *underline_ch; /* underline character */
+ char *backspace_ch; /* backspace character */
+ char *go_home; /* go to home */
+ char *cursor_addr; /* cursor movement */
+ char home_position[40]; /* contains cursor movement to home */
+ char *clear_rest; /* clear rest of screen */
+ int num_columns; /* number of columns */
+ char *previous_search; /* previous search() buf[] item */
struct {
- long chrctr; /* row number */
- long line; /* line number */
+ long row_num; /* row number */
+ long line_num; /* line number */
} context,
screen_start;
- int lastcmd; /* previous more key command */
- int lastarg; /* previous key command argument */
- int lastcolon; /* is a colon-prefixed key command */
+ int last_key_command; /* previous more key command */
+ int last_key_arg; /* previous key command argument */
+ int last_colon_command; /* is a colon-prefixed key command */
char shell_line[SHELL_LINE];
unsigned int
- bad_so:1, /* true if overwriting does not turn off standout */
- catch_susp:1, /* we should catch the SIGTSTP signal */
- clreol:1, /* do not scroll, paint each screen from the top */
- docrterase:1, /* is erase previous supported */
- docrtkill:1, /* is erase input supported */
- dumb:1, /* is terminal type known */
- dum_opt:1, /* suppress bell */
- eatnl:1, /* is newline ignored after 80 cols */
- errors:1, /* is an error reported */
- firstf:1, /* is the input file the first in list */
- fold_opt:1, /* fold long lines */
- hard:1, /* is this hard copy terminal (a printer or such) */
- hardtabs:1, /* print spaces instead of '\t' */
- inwait:1, /* is waiting user input */
- lastp:1, /* run previous key command */
- no_intty:1, /* is input in interactive mode */
- noscroll:1, /* do not scroll, clear the screen and then display text */
- notell:1, /* suppress quit dialog */
- no_tty:1, /* is output in interactive mode */
- Pause:1, /* is output paused */
- pstate:1, /* current UL state */
- soglitch:1, /* terminal has standout mode glitch */
- ssp_opt:1, /* suppress white space */
- startup:1, /* is startup completed */
- stop_opt:1, /* stop after form feeds */
- ulglitch:1, /* terminal has underline mode glitch */
- ul_opt:1, /* underline as best we can */
- within:1, /* true if we are within a file, false if we are between files */
- Wrap:1; /* set if automargins */
+ bad_stdout:1, /* true if overwriting does not turn off standout */
+ catch_suspend:1, /* we should catch the SIGTSTP signal */
+ clear_line_ends:1, /* do not scroll, paint each screen from the top */
+ dumb_tty:1, /* is terminal type known */
+ eat_newline:1, /* is newline ignored after 80 cols */
+ enable_underlining:1, /* underline as best we can */
+ erase_input_ok:1, /* is erase input supported */
+ erase_previous_ok:1, /* is erase previous supported */
+ first_file:1, /* is the input file the first in list */
+ fold_long_lines:1, /* fold long lines */
+ hard_tabs:1, /* print spaces instead of '\t' */
+ hard_tty:1, /* is this hard copy terminal (a printer or such) */
+ is_paused:1, /* is output paused */
+ no_quit_dialog:1, /* suppress quit dialog */
+ no_scroll:1, /* do not scroll, clear the screen and then display text */
+ no_tty_in:1, /* is input in interactive mode */
+ no_tty_out:1, /* is output in interactive mode */
+ report_errors:1, /* is an error reported */
+ run_previous_command:1, /* run previous key command */
+ squeeze_spaces:1, /* suppress white space */
+ starting_up:1, /* is startup completed */
+ stdout_glitch:1, /* terminal has standout mode glitch */
+ stop_after_formfeed:1, /* stop after form feeds */
+ suppress_bell:1, /* suppress bell */
+ underline_glitch:1, /* terminal has underline mode glitch */
+ underline_state:1, /* current UL state */
+ waiting_input:1, /* is waiting user input */
+ within_file:1, /* true if we are within a file, false if we are between files */
+ wrap_margin:1; /* set if automargins */
};
/* FIXME: global_ctl is used in signal handlers. */
@@ -244,31 +244,31 @@ static void argscan(struct more_control *ctl, char *s)
case '8':
case '9':
if (!seen_num) {
- ctl->dlines = 0;
+ ctl->lines_per_screen = 0;
seen_num = 1;
}
- ctl->dlines = ctl->dlines * 10 + *s - '0';
+ ctl->lines_per_screen = ctl->lines_per_screen * 10 + *s - '0';
break;
case 'd':
- ctl->dum_opt = 1;
+ ctl->suppress_bell = 1;
break;
case 'l':
- ctl->stop_opt = 0;
+ ctl->stop_after_formfeed = 0;
break;
case 'f':
- ctl->fold_opt = 0;
+ ctl->fold_long_lines = 0;
break;
case 'p':
- ctl->noscroll = 1;
+ ctl->no_scroll = 1;
break;
case 'c':
- ctl->clreol = 1;
+ ctl->clear_line_ends = 1;
break;
case 's':
- ctl->ssp_opt = 1;
+ ctl->squeeze_spaces = 1;
break;
case 'u':
- ctl->ul_opt = 0;
+ ctl->enable_underlining = 0;
break;
case '-':
case ' ':
@@ -289,19 +289,19 @@ static void argscan(struct more_control *ctl, char *s)
static void more_fseek(struct more_control *ctl, FILE *stream, long pos)
{
- ctl->file_pos = pos;
+ ctl->file_position = pos;
fseek(stream, pos, 0);
}
static int more_getc(struct more_control *ctl, FILE *stream)
{
- ctl->file_pos++;
+ ctl->file_position++;
return getc(stream);
}
static int more_ungetc(struct more_control *ctl, int c, FILE *stream)
{
- ctl->file_pos--;
+ ctl->file_position--;
return ungetc(c, stream);
}
@@ -339,23 +339,23 @@ static int magic(FILE *f, char *fs)
* access. If it is, return the opened file. Otherwise return NULL. */
static FILE *checkf(struct more_control *ctl, char *fs, int *clearfirst)
{
- struct stat stbuf;
+ struct stat st;
FILE *f;
int c;
- if (stat(fs, &stbuf) == -1) {
+ if (stat(fs, &st) == -1) {
fflush(stdout);
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
warn(_("stat of %s failed"), fs);
return NULL;
}
- if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
+ if ((st.st_mode & S_IFMT) == S_IFDIR) {
printf(_("\n*** %s: directory ***\n\n"), fs);
return NULL;
}
- ctl->Currline = 0;
- ctl->file_pos = 0;
+ ctl->current_line = 0;
+ ctl->file_position = 0;
if ((f = fopen(fs, "r")) == NULL) {
fflush(stdout);
warn(_("cannot open %s"), fs);
@@ -369,24 +369,24 @@ static FILE *checkf(struct more_control *ctl, char *fs, int *clearfirst)
c = more_getc(ctl, f);
*clearfirst = (c == '\f');
more_ungetc(ctl, c, f);
- if ((ctl->file_size = stbuf.st_size) == 0)
+ if ((ctl->file_size = st.st_size) == 0)
ctl->file_size = LONG_MAX;
return f;
}
static void prepare_line_buffer(struct more_control *ctl)
{
- size_t nsz = ctl->Mcol * 4;
+ size_t sz = ctl->num_columns * 4;
- if (ctl->LineLen >= nsz)
+ if (ctl->line_sz >= sz)
return;
- if (nsz < LINSIZ)
- nsz = LINSIZ;
+ if (sz < MIN_LINE_SZ)
+ sz = MIN_LINE_SZ;
- /* alloc nsz and extra space for \n\0 */
- ctl->Line = xrealloc(ctl->Line, nsz + 2);
- ctl->LineLen = nsz;
+ /* alloc sz and extra space for \n\0 */
+ ctl->line_buf = xrealloc(ctl->line_buf, sz + 2);
+ ctl->line_sz = sz;
}
/* Get a logical line */
@@ -395,7 +395,7 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
int c;
char *p;
int column;
- static int colflg;
+ static int column_wrap;
#ifdef HAVE_WIDECHAR
size_t i;
@@ -407,23 +407,23 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
size_t mbc_pos = 0; /* Position of the MBC. */
int use_mbc_buffer_flag = 0; /* If 1, mbc has data. */
int break_flag = 0; /* If 1, exit while(). */
- long file_pos_bak = ctl->file_pos;
+ long file_position_bak = ctl->file_position;
memset(&state, '\0', sizeof(mbstate_t));
#endif
prepare_line_buffer(ctl);
- p = ctl->Line;
+ p = ctl->line_buf;
column = 0;
c = more_getc(ctl, f);
- if (colflg && c == '\n') {
- ctl->Currline++;
+ if (column_wrap && c == '\n') {
+ ctl->current_line++;
c = more_getc(ctl, f);
}
- while (p < &ctl->Line[ctl->LineLen - 1]) {
+ while (p < &ctl->line_buf[ctl->line_sz - 1]) {
#ifdef HAVE_WIDECHAR
- if (ctl->fold_opt && use_mbc_buffer_flag && MB_CUR_MAX > 1) {
+ if (ctl->fold_long_lines && use_mbc_buffer_flag && MB_CUR_MAX > 1) {
use_mbc_buffer_flag = 0;
state_bak = state;
mbc[mbc_pos++] = c;
@@ -440,10 +440,9 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
*p++ = mbc[0];
state = state_bak;
column++;
- file_pos_bak++;
-
- if (column >= ctl->Mcol) {
- more_fseek(ctl, f, file_pos_bak);
+ file_position_bak++;
+ if (column >= ctl->num_columns) {
+ more_fseek(ctl, f, file_position_bak);
} else {
memmove(mbc, mbc + 1, --mbc_pos);
if (mbc_pos > 0) {
@@ -455,12 +454,11 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
default:
wc_width = wcwidth(wc);
-
- if (column + wc_width > ctl->Mcol) {
- more_fseek(ctl, f, file_pos_bak);
+ if (column + wc_width > ctl->num_columns) {
+ more_fseek(ctl, f, file_position_bak);
break_flag = 1;
} else {
- for (i = 0; p < &ctl->Line[ctl->LineLen - 1] &&
+ for (i = 0; p < &ctl->line_buf[ctl->line_sz - 1] &&
i < mbc_pos; i++)
*p++ = mbc[i];
if (wc_width > 0)
@@ -468,7 +466,7 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
}
}
- if (break_flag || column >= ctl->Mcol)
+ if (break_flag || column >= ctl->num_columns)
break;
c = more_getc(ctl, f);
@@ -476,34 +474,34 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
}
#endif /* HAVE_WIDECHAR */
if (c == EOF) {
- if (p > ctl->Line) {
+ if (p > ctl->line_buf) {
*p = '\0';
- *length = p - ctl->Line;
+ *length = p - ctl->line_buf;
return column;
}
- *length = p - ctl->Line;
+ *length = p - ctl->line_buf;
return EOF;
}
if (c == '\n') {
- ctl->Currline++;
+ ctl->current_line++;
break;
}
*p++ = c;
if (c == '\t') {
- if (!ctl->hardtabs || (column < ctl->promptlen && !ctl->hard)) {
- if (ctl->hardtabs && ctl->eraseln && !ctl->dumb) {
+ if (!ctl->hard_tabs || (column < ctl->prompt_len && !ctl->hard_tty)) {
+ if (ctl->hard_tabs && ctl->erase_line && !ctl->dumb_tty) {
column = 1 + (column | 7);
- putp(ctl->eraseln);
- ctl->promptlen = 0;
+ putp(ctl->erase_line);
+ ctl->prompt_len = 0;
} else {
- for (--p; p < &ctl->Line[ctl->LineLen - 1];) {
+ for (--p; p < &ctl->line_buf[ctl->line_sz - 1];) {
*p++ = ' ';
if ((++column & 7) == 0)
break;
}
- if (column >= ctl->promptlen)
- ctl->promptlen = 0;
+ if (column >= ctl->prompt_len)
+ ctl->prompt_len = 0;
}
} else
column = 1 + (column | 7);
@@ -513,22 +511,22 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
int next = more_getc(ctl, f);
if (next == '\n') {
p--;
- ctl->Currline++;
+ ctl->current_line++;
break;
}
more_ungetc(ctl, c, f);
column = 0;
- } else if (c == '\f' && ctl->stop_opt) {
+ } else if (c == '\f' && ctl->stop_after_formfeed) {
p[-1] = '^';
*p++ = 'L';
column += 2;
- ctl->Pause = 1;
+ ctl->is_paused = 1;
} else if (c == EOF) {
- *length = p - ctl->Line;
+ *length = p - ctl->line_buf;
return column;
} else {
#ifdef HAVE_WIDECHAR
- if (ctl->fold_opt && MB_CUR_MAX > 1) {
+ if (ctl->fold_long_lines && MB_CUR_MAX > 1) {
memset(mbc, '\0', MB_LEN_MAX);
mbc_pos = 0;
mbc[mbc_pos++] = c;
@@ -539,7 +537,7 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
switch (mblength) {
case (size_t)-2:
p--;
- file_pos_bak = ctl->file_pos - 1;
+ file_position_bak = ctl->file_position - 1;
state = state_bak;
use_mbc_buffer_flag = 1;
break;
@@ -562,26 +560,26 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
}
}
- if (column >= ctl->Mcol && ctl->fold_opt)
+ if (column >= ctl->num_columns && ctl->fold_long_lines)
break;
#ifdef HAVE_WIDECHAR
- if (use_mbc_buffer_flag == 0 && p >= &ctl->Line[ctl->LineLen - 1 - 4])
+ if (use_mbc_buffer_flag == 0 && p >= &ctl->line_buf[ctl->line_sz - 1 - 4])
/* don't read another char if there is no space for
* whole multibyte sequence */
break;
#endif
c = more_getc(ctl, f);
}
- if (column >= ctl->Mcol && ctl->Mcol > 0) {
- if (!ctl->Wrap) {
+ if (column >= ctl->num_columns && ctl->num_columns > 0) {
+ if (!ctl->wrap_margin) {
*p++ = '\n';
}
}
- colflg = column == ctl->Mcol && ctl->fold_opt;
- if (colflg && ctl->eatnl && ctl->Wrap) {
+ column_wrap = column == ctl->num_columns && ctl->fold_long_lines;
+ if (column_wrap && ctl->eat_newline && ctl->wrap_margin) {
*p++ = '\n'; /* simulate normal wrap */
}
- *length = p - ctl->Line;
+ *length = p - ctl->line_buf;
*p = 0;
return column;
}
@@ -590,19 +588,19 @@ static int get_line(struct more_control *ctl, FILE *f, int *length)
static void erasep(struct more_control *ctl, int col)
{
- if (ctl->promptlen == 0)
+ if (ctl->prompt_len == 0)
return;
- if (ctl->hard) {
+ if (ctl->hard_tty) {
putchar('\n');
} else {
if (col == 0)
putchar('\r');
- if (!ctl->dumb && ctl->eraseln)
- putp(ctl->eraseln);
+ if (!ctl->dumb_tty && ctl->erase_line)
+ putp(ctl->erase_line);
else
- printf("%*s", ctl->promptlen - col, "");
+ printf("%*s", ctl->prompt_len - col, "");
}
- ctl->promptlen = 0;
+ ctl->prompt_len = 0;
}
#ifdef HAVE_WIDECHAR
@@ -632,10 +630,10 @@ static void prbuf(struct more_control *ctl, char *s, int n)
int state; /* next output char's UL state */
while (--n >= 0)
- if (!ctl->ul_opt)
+ if (!ctl->enable_underlining)
putchar(*s++);
else {
- if (*s == ' ' && ctl->pstate == 0 && ctl->ulglitch
+ if (*s == ' ' && ctl->underline_state == 0 && ctl->underline_glitch
&& wouldul(s + 1, n - 1)) {
s++;
continue;
@@ -646,15 +644,15 @@ static void prbuf(struct more_control *ctl, char *s, int n)
s += 3;
} else
c = *s++;
- if (state != ctl->pstate) {
- if (c == ' ' && state == 0 && ctl->ulglitch
+ if (state != ctl->underline_state) {
+ if (c == ' ' && state == 0 && ctl->underline_glitch
&& wouldul(s, n - 1))
state = 1;
else
- putp(state ? ctl->ULenter : ctl->ULexit);
+ putp(state ? ctl->enter_underline : ctl->exit_underline);
}
- if (c != ' ' || ctl->pstate == 0 || state != 0
- || ctl->ulglitch == 0)
+ if (c != ' ' || ctl->underline_state == 0 || state != 0
+ || ctl->underline_glitch == 0)
#ifdef HAVE_WIDECHAR
{
wchar_t wc;
@@ -671,11 +669,11 @@ static void prbuf(struct more_control *ctl, char *s, int n)
#else
putchar(c);
#endif /* HAVE_WIDECHAR */
- if (state && *ctl->chUL) {
- fputs(ctl->chBS, stdout);
- putp(ctl->chUL);
+ if (state && *ctl->underline_ch) {
+ fputs(ctl->backspace_ch, stdout);
+ putp(ctl->underline_ch);
}
- ctl->pstate = state;
+ ctl->underline_state = state;
}
}
@@ -683,59 +681,59 @@ static void prbuf(struct more_control *ctl, char *s, int n)
static void kill_line(struct more_control *ctl)
{
erasep(ctl, 0);
- if (!ctl->eraseln || ctl->dumb)
+ if (!ctl->erase_line || ctl->dumb_tty)
putchar('\r');
}
static void prompt(struct more_control *ctl, char *filename)
{
- if (ctl->clreol)
- putp(ctl->eraseln);
- else if (ctl->promptlen > 0)
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
+ else if (ctl->prompt_len > 0)
kill_line(ctl);
- if (!ctl->hard) {
- ctl->promptlen = 0;
- if (ctl->Senter && ctl->Sexit) {
- putp(ctl->Senter);
- ctl->promptlen += (2 * ctl->soglitch);
+ if (!ctl->hard_tty) {
+ ctl->prompt_len = 0;
+ if (ctl->enter_std && ctl->exit_std) {
+ putp(ctl->enter_std);
+ ctl->prompt_len += (2 * ctl->stdout_glitch);
}
- if (ctl->clreol)
- putp(ctl->eraseln);
- ctl->promptlen += printf(_("--More--"));
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
+ ctl->prompt_len += printf(_("--More--"));
if (filename != NULL) {
- ctl->promptlen += printf(_("(Next file: %s)"), filename);
- } else if (!ctl->no_intty) {
- ctl->promptlen +=
+ ctl->prompt_len += printf(_("(Next file: %s)"), filename);
+ } else if (!ctl->no_tty_in) {
+ ctl->prompt_len +=
printf("(%d%%)",
- (int)((ctl->file_pos * 100) / ctl->file_size));
+ (int)((ctl->file_position * 100) / ctl->file_size));
}
- if (ctl->dum_opt) {
- ctl->promptlen +=
+ if (ctl->suppress_bell) {
+ ctl->prompt_len +=
printf(_("[Press space to continue, 'q' to quit.]"));
}
- if (ctl->Senter && ctl->Sexit)
- putp(ctl->Sexit);
- if (ctl->clreol)
- putp(ctl->EodClr);
+ if (ctl->enter_std && ctl->exit_std)
+ putp(ctl->exit_std);
+ if (ctl->clear_line_ends)
+ putp(ctl->clear_rest);
fflush(stdout);
} else
fputc(RINGBELL, stderr);
- ctl->inwait++;
+ ctl->waiting_input++;
}
static void reset_tty(void)
{
- if (global_ctl->no_tty)
+ if (global_ctl->no_tty_out)
return;
- if (global_ctl->pstate) {
- putp(global_ctl->ULexit);
+ if (global_ctl->underline_state) {
+ putp(global_ctl->exit_underline);
fflush(stdout);
- global_ctl->pstate = 0;
+ global_ctl->underline_state = 0;
}
- global_ctl->otty.c_lflag |= ICANON | ECHO;
- global_ctl->otty.c_cc[VMIN] = global_ctl->savetty0.c_cc[VMIN];
- global_ctl->otty.c_cc[VTIME] = global_ctl->savetty0.c_cc[VTIME];
- tcsetattr(STDERR_FILENO, TCSANOW, &global_ctl->savetty0);
+ global_ctl->output_tty.c_lflag |= ICANON | ECHO;
+ global_ctl->output_tty.c_cc[VMIN] = global_ctl->original_tty.c_cc[VMIN];
+ global_ctl->output_tty.c_cc[VTIME] = global_ctl->original_tty.c_cc[VTIME];
+ tcsetattr(STDERR_FILENO, TCSANOW, &global_ctl->original_tty);
}
/* Clean up terminal state and exit. Also come here if interrupt signal received */
@@ -750,17 +748,17 @@ static void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unus
signal(SIGINT, SIG_IGN);
reset_tty();
- if (global_ctl->clreol) {
+ if (global_ctl->clear_line_ends) {
putchar('\r');
- putp(global_ctl->eraseln);
+ putp(global_ctl->erase_line);
fflush(stdout);
- } else if (!global_ctl->clreol && (global_ctl->promptlen > 0)) {
+ } else if (!global_ctl->clear_line_ends && (global_ctl->prompt_len > 0)) {
kill_line(global_ctl);
fflush(stdout);
} else
fputc('\n', stderr);
- free(global_ctl->previousre);
- free(global_ctl->Line);
+ free(global_ctl->previous_search);
+ free(global_ctl->line_buf);
_exit(EXIT_SUCCESS);
}
@@ -773,7 +771,7 @@ static int readch(struct more_control *ctl)
if (errno != EINTR)
end_it(0);
else
- c = ctl->otty.c_cc[VKILL];
+ c = ctl->output_tty.c_cc[VKILL];
}
return c;
}
@@ -786,12 +784,12 @@ static int number(struct more_control *ctl, char *cmd)
char ch;
i = 0;
- ch = ctl->otty.c_cc[VKILL];
+ ch = ctl->output_tty.c_cc[VKILL];
for (;;) {
ch = readch(ctl);
if (isdigit(ch))
i = i * 10 + ch - '0';
- else if ((cc_t) ch == ctl->otty.c_cc[VKILL])
+ else if ((cc_t) ch == ctl->output_tty.c_cc[VKILL])
i = 0;
else {
*cmd = ch;
@@ -808,25 +806,25 @@ static void skipf(struct more_control *ctl, int nskip)
if (nskip == 0)
return;
if (nskip > 0) {
- if (ctl->fnum + nskip > ctl->nfiles - 1)
- nskip = ctl->nfiles - ctl->fnum - 1;
- } else if (ctl->within)
- ctl->fnum++;
- ctl->fnum += nskip;
- if (ctl->fnum < 0)
- ctl->fnum = 0;
+ if (ctl->argv_position + nskip > ctl->num_files - 1)
+ nskip = ctl->num_files - ctl->argv_position - 1;
+ } else if (ctl->within_file)
+ ctl->argv_position++;
+ ctl->argv_position += nskip;
+ if (ctl->argv_position < 0)
+ ctl->argv_position = 0;
puts(_("\n...Skipping "));
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
if (nskip > 0)
fputs(_("...Skipping to file "), stdout);
else
fputs(_("...Skipping back to file "), stdout);
- puts(ctl->fnames[ctl->fnum]);
- if (ctl->clreol)
- putp(ctl->eraseln);
+ puts(ctl->file_names[ctl->argv_position]);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
putchar('\n');
- ctl->fnum--;
+ ctl->argv_position--;
}
static void show(struct more_control *ctl, char c)
@@ -834,33 +832,33 @@ static void show(struct more_control *ctl, char c)
if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
c += (c == RUBOUT) ? -0100 : 0100;
fputs(CARAT, stderr);
- ctl->promptlen++;
+ ctl->prompt_len++;
}
fputc(c, stderr);
- ctl->promptlen++;
+ ctl->prompt_len++;
}
static void more_error(struct more_control *ctl, char *mess)
{
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
else
kill_line(ctl);
- ctl->promptlen += strlen(mess);
- if (ctl->Senter && ctl->Sexit) {
- putp(ctl->Senter);
+ ctl->prompt_len += strlen(mess);
+ if (ctl->enter_std && ctl->exit_std) {
+ putp(ctl->enter_std);
fputs(mess, stdout);
- putp(ctl->Sexit);
+ putp(ctl->exit_std);
} else
fputs(mess, stdout);
fflush(stdout);
- ctl->errors++;
- siglongjmp(ctl->restore, 1);
+ ctl->report_errors++;
+ siglongjmp(ctl->destination, 1);
}
static void erase_one_column(struct more_control *ctl)
{
- if (ctl->docrterase)
+ if (ctl->erase_previous_ok)
fputs(BSB, stderr);
else
fputs(BS, stderr);
@@ -876,12 +874,12 @@ static void ttyin(struct more_control *ctl, char buf[], int nmax, char pchar)
sp = buf;
maxlen = 0;
while (sp - buf < nmax) {
- if (ctl->promptlen > maxlen)
- maxlen = ctl->promptlen;
+ if (ctl->prompt_len > maxlen)
+ maxlen = ctl->prompt_len;
c = readch(ctl);
if (c == '\\') {
slash++;
- } else if (((cc_t) c == ctl->otty.c_cc[VERASE]) && !slash) {
+ } else if (((cc_t) c == ctl->output_tty.c_cc[VERASE]) && !slash) {
if (sp > buf) {
#ifdef HAVE_WIDECHAR
if (MB_CUR_MAX > 1) {
@@ -927,48 +925,48 @@ static void ttyin(struct more_control *ctl, char buf[], int nmax, char pchar)
}
while (mblength--) {
- --ctl->promptlen;
+ --ctl->prompt_len;
--sp;
}
} else
#endif /* HAVE_WIDECHAR */
{
- --ctl->promptlen;
+ --ctl->prompt_len;
erase_one_column(ctl);
--sp;
}
if ((*sp < ' ' && *sp != '\n') || *sp == RUBOUT) {
- --ctl->promptlen;
+ --ctl->prompt_len;
erase_one_column(ctl);
}
continue;
} else {
- if (!ctl->eraseln)
- ctl->promptlen = maxlen;
- siglongjmp(ctl->restore, 1);
+ if (!ctl->erase_line)
+ ctl->prompt_len = maxlen;
+ siglongjmp(ctl->destination, 1);
}
- } else if (((cc_t) c == ctl->otty.c_cc[VKILL]) && !slash) {
- if (ctl->hard) {
+ } else if (((cc_t) c == ctl->output_tty.c_cc[VKILL]) && !slash) {
+ if (ctl->hard_tty) {
show(ctl, c);
putchar('\n');
putchar(pchar);
} else {
putchar('\r');
putchar(pchar);
- if (ctl->eraseln)
+ if (ctl->erase_line)
erasep(ctl, 1);
- else if (ctl->docrtkill)
- while (ctl->promptlen-- > 1)
+ else if (ctl->erase_input_ok)
+ while (ctl->prompt_len-- > 1)
fputs(BSB, stderr);
- ctl->promptlen = 1;
+ ctl->prompt_len = 1;
}
sp = buf;
fflush(stdout);
continue;
}
- if (slash && ((cc_t) c == ctl->otty.c_cc[VKILL]
- || (cc_t) c == ctl->otty.c_cc[VERASE])) {
+ if (slash && ((cc_t) c == ctl->output_tty.c_cc[VKILL]
+ || (cc_t) c == ctl->output_tty.c_cc[VERASE])) {
erase_one_column(ctl);
--sp;
}
@@ -978,17 +976,17 @@ static void ttyin(struct more_control *ctl, char buf[], int nmax, char pchar)
if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
c += (c == RUBOUT) ? -0100 : 0100;
fputs(CARAT, stderr);
- ctl->promptlen++;
+ ctl->prompt_len++;
}
if (c != '\n' && c != ESC) {
fputc(c, stderr);
- ctl->promptlen++;
+ ctl->prompt_len++;
} else
break;
}
*--sp = '\0';
- if (!ctl->eraseln)
- ctl->promptlen = maxlen;
+ if (!ctl->erase_line)
+ ctl->prompt_len = maxlen;
if (sp - buf >= nmax - 1)
more_error(ctl, _("Line too long"));
}
@@ -1002,7 +1000,7 @@ static int expand(struct more_control *ctl, char **outbuf, char *inbuf)
int changed = 0;
int tempsz, xtra, offset;
- xtra = strlen(ctl->fnames[ctl->fnum]) + strlen(ctl->shell_line) + 1;
+ xtra = strlen(ctl->file_names[ctl->argv_position]) + strlen(ctl->shell_line) + 1;
tempsz = 200 + xtra;
temp = xmalloc(tempsz);
inpstr = inbuf;
@@ -1016,15 +1014,15 @@ static int expand(struct more_control *ctl, char **outbuf, char *inbuf)
}
switch (c) {
case '%':
- if (!ctl->no_intty) {
- strcpy(outstr, ctl->fnames[ctl->fnum]);
- outstr += strlen(ctl->fnames[ctl->fnum]);
+ if (!ctl->no_tty_in) {
+ strcpy(outstr, ctl->file_names[ctl->argv_position]);
+ outstr += strlen(ctl->file_names[ctl->argv_position]);
changed++;
} else
*outstr++ = c;
break;
case '!':
- if (!ctl->shellp)
+ if (!ctl->previous_shell)
more_error(ctl, _
("No previous command to substitute for"));
strcpy(outstr, ctl->shell_line);
@@ -1048,26 +1046,26 @@ static int expand(struct more_control *ctl, char **outbuf, char *inbuf)
static void set_tty(struct more_control *ctl)
{
- ctl->otty.c_lflag &= ~(ICANON | ECHO);
- ctl->otty.c_cc[VMIN] = 1; /* read at least 1 char */
- ctl->otty.c_cc[VTIME] = 0; /* no timeout */
- tcsetattr(STDERR_FILENO, TCSANOW, &ctl->otty);
+ ctl->output_tty.c_lflag &= ~(ICANON | ECHO);
+ ctl->output_tty.c_cc[VMIN] = 1; /* read at least 1 char */
+ ctl->output_tty.c_cc[VTIME] = 0; /* no timeout */
+ tcsetattr(STDERR_FILENO, TCSANOW, &ctl->output_tty);
}
/* Come here if a quit signal is received */
static void onquit(int dummy __attribute__((__unused__)))
{
signal(SIGQUIT, SIG_IGN);
- if (!global_ctl->inwait) {
+ if (!global_ctl->waiting_input) {
putchar('\n');
- if (!global_ctl->startup) {
+ if (!global_ctl->starting_up) {
signal(SIGQUIT, onquit);
- siglongjmp(global_ctl->restore, 1);
+ siglongjmp(global_ctl->destination, 1);
} else
- global_ctl->Pause = 1;
- } else if (!global_ctl->dum_opt && global_ctl->notell) {
- global_ctl->promptlen += fprintf(stderr, _("[Use q or Q to quit]"));
- global_ctl->notell = 0;
+ global_ctl->is_paused = 1;
+ } else if (!global_ctl->suppress_bell && global_ctl->no_quit_dialog) {
+ global_ctl->prompt_len += fprintf(stderr, _("[Use q or Q to quit]"));
+ global_ctl->no_quit_dialog = 0;
}
signal(SIGQUIT, onquit);
}
@@ -1098,8 +1096,8 @@ static void onsusp(int dummy __attribute__((__unused__)))
/* We're back */
signal(SIGTSTP, onsusp);
set_tty(global_ctl);
- if (global_ctl->inwait)
- siglongjmp(global_ctl->restore, 1);
+ if (global_ctl->waiting_input)
+ siglongjmp(global_ctl->destination, 1);
}
static void execute(struct more_control *ctl, char *filename, char *cmd, ...)
@@ -1152,13 +1150,13 @@ static void execute(struct more_control *ctl, char *filename, char *cmd, ...)
if (id > 0) {
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- if (ctl->catch_susp)
+ if (ctl->catch_suspend)
signal(SIGTSTP, SIG_DFL);
while (wait(NULL) > 0)
/* nothing */ ;
signal(SIGINT, end_it);
signal(SIGQUIT, onquit);
- if (ctl->catch_susp)
+ if (ctl->catch_suspend)
signal(SIGTSTP, onsusp);
} else
fputs(_("can't fork\n"), stderr);
@@ -1176,8 +1174,8 @@ static void do_shell(struct more_control *ctl, char *filename)
kill_line(ctl);
putchar('!');
fflush(stdout);
- ctl->promptlen = 1;
- if (ctl->lastp)
+ ctl->prompt_len = 1;
+ if (ctl->run_previous_command)
fputs(ctl->shell_line, stdout);
else {
ttyin(ctl, cmdbuf, sizeof(cmdbuf) - 2, '!');
@@ -1196,13 +1194,13 @@ static void do_shell(struct more_control *ctl, char *filename)
return;
} else if (rc > 0) {
kill_line(ctl);
- ctl->promptlen = printf("!%s", ctl->shell_line);
+ ctl->prompt_len = printf("!%s", ctl->shell_line);
}
}
fflush(stdout);
fputc('\n', stderr);
- ctl->promptlen = 0;
- ctl->shellp = 1;
+ ctl->prompt_len = 0;
+ ctl->previous_shell = 1;
execute(ctl, filename, ctl->shell, ctl->shell, "-c", ctl->shell_line, 0);
}
@@ -1216,20 +1214,20 @@ static int colon(struct more_control *ctl, char *filename, int cmd, int nlines)
ch = readch(ctl);
else
ch = cmd;
- ctl->lastcolon = ch;
+ ctl->last_colon_command = ch;
switch (ch) {
case 'f':
kill_line(ctl);
- if (!ctl->no_intty)
- ctl->promptlen =
- printf(_("\"%s\" line %d"), ctl->fnames[ctl->fnum], ctl->Currline);
+ if (!ctl->no_tty_in)
+ ctl->prompt_len =
+ printf(_("\"%s\" line %d"), ctl->file_names[ctl->argv_position], ctl->current_line);
else
- ctl->promptlen = printf(_("[Not a file] line %d"), ctl->Currline);
+ ctl->prompt_len = printf(_("[Not a file] line %d"), ctl->current_line);
fflush(stdout);
return -1;
case 'n':
if (nlines == 0) {
- if (ctl->fnum >= ctl->nfiles - 1)
+ if (ctl->argv_position >= ctl->num_files - 1)
end_it(0);
nlines++;
}
@@ -1238,7 +1236,7 @@ static int colon(struct more_control *ctl, char *filename, int cmd, int nlines)
skipf(ctl, nlines);
return 0;
case 'p':
- if (ctl->no_intty) {
+ if (ctl->no_tty_in) {
fputc(RINGBELL, stderr);
return -1;
}
@@ -1270,19 +1268,19 @@ static void skiplns(struct more_control *ctl, int n, FILE *f)
if (c == EOF)
return;
n--;
- ctl->Currline++;
+ ctl->current_line++;
}
}
/* Clear the screen */
static void doclear(struct more_control *ctl)
{
- if (ctl->Clear && !ctl->hard) {
- putp(ctl->Clear);
+ if (ctl->clear && !ctl->hard_tty) {
+ putp(ctl->clear);
/* Put out carriage return so that system doesn't get
* confused by escape sequences when expanding tabs */
putchar('\r');
- ctl->promptlen = 0;
+ ctl->prompt_len = 0;
}
}
@@ -1293,12 +1291,12 @@ static void rdline(struct more_control *ctl, FILE *f)
prepare_line_buffer(ctl);
- p = ctl->Line;
+ p = ctl->line_buf;
while ((c = more_getc(ctl, f)) != '\n' && c != EOF
- && (size_t)(p - ctl->Line) < ctl->LineLen - 1)
+ && (size_t)(p - ctl->line_buf) < ctl->line_sz - 1)
*p++ = c;
if (c == '\n')
- ctl->Currline++;
+ ctl->current_line++;
*p = '\0';
}
@@ -1306,7 +1304,7 @@ static void rdline(struct more_control *ctl, FILE *f)
* the file */
static void search(struct more_control *ctl, char buf[], FILE *file, int n)
{
- long startline = ctl->file_pos;
+ long startline = ctl->file_position;
long line1 = startline;
long line2 = startline;
long line3;
@@ -1314,8 +1312,8 @@ static void search(struct more_control *ctl, char buf[], FILE *file, int n)
int saveln, rc;
regex_t re;
- ctl->context.line = saveln = ctl->Currline;
- ctl->context.chrctr = startline;
+ ctl->context.line_num = saveln = ctl->current_line;
+ ctl->context.row_num = startline;
lncount = 0;
if (!buf)
goto notfound;
@@ -1327,38 +1325,38 @@ static void search(struct more_control *ctl, char buf[], FILE *file, int n)
while (!feof(file)) {
line3 = line2;
line2 = line1;
- line1 = ctl->file_pos;
+ line1 = ctl->file_position;
rdline(ctl, file);
lncount++;
- if (regexec(&re, ctl->Line, 0, NULL, 0) == 0) {
+ if (regexec(&re, ctl->line_buf, 0, NULL, 0) == 0) {
if (--n == 0) {
- if (lncount > 3 || (lncount > 1 && ctl->no_intty)) {
+ if (lncount > 3 || (lncount > 1 && ctl->no_tty_in)) {
putchar('\n');
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
fputs(_("...skipping\n"), stdout);
}
- if (!ctl->no_intty) {
- ctl->Currline -=
+ if (!ctl->no_tty_in) {
+ ctl->current_line -=
(lncount >= 3 ? 3 : lncount);
more_fseek(ctl, file, line3);
- if (ctl->noscroll) {
- if (ctl->clreol) {
- putp(ctl->Home);
- putp(ctl->eraseln);
+ if (ctl->no_scroll) {
+ if (ctl->clear_line_ends) {
+ putp(ctl->go_home);
+ putp(ctl->erase_line);
} else
doclear(ctl);
}
} else {
kill_line(ctl);
- if (ctl->noscroll) {
- if (ctl->clreol) {
- putp(ctl->Home);
- putp(ctl->eraseln);
+ if (ctl->no_scroll) {
+ if (ctl->clear_line_ends) {
+ putp(ctl->go_home);
+ putp(ctl->erase_line);
} else
doclear(ctl);
}
- puts(ctl->Line);
+ puts(ctl->line_buf);
}
break;
}
@@ -1366,15 +1364,15 @@ static void search(struct more_control *ctl, char buf[], FILE *file, int n)
}
regfree(&re);
if (feof(file)) {
- if (!ctl->no_intty) {
- ctl->Currline = saveln;
+ if (!ctl->no_tty_in) {
+ ctl->current_line = saveln;
more_fseek(ctl, file, startline);
} else {
fputs(_("\nPattern not found\n"), stdout);
end_it(0);
}
- free(ctl->previousre);
- ctl->previousre = NULL;
+ free(ctl->previous_search);
+ ctl->previous_search = NULL;
notfound:
more_error(ctl, _("Pattern not found"));
}
@@ -1394,23 +1392,23 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
char comchar, cmdbuf[INIT_BUF];
done = 0;
- if (!ctl->errors)
+ if (!ctl->report_errors)
prompt(ctl, filename);
else
- ctl->errors = 0;
+ ctl->report_errors = 0;
for (;;) {
nlines = number(ctl, &comchar);
- ctl->lastp = colonch = 0;
+ ctl->run_previous_command = colonch = 0;
if (comchar == '.') { /* Repeat last command */
- ctl->lastp++;
- comchar = ctl->lastcmd;
- nlines = ctl->lastarg;
- if (ctl->lastcmd == ':')
- colonch = ctl->lastcolon;
+ ctl->run_previous_command++;
+ comchar = ctl->last_key_command;
+ nlines = ctl->last_key_arg;
+ if (ctl->last_key_command == ':')
+ colonch = ctl->last_colon_command;
}
- ctl->lastcmd = comchar;
- ctl->lastarg = nlines;
- if ((cc_t) comchar == ctl->otty.c_cc[VERASE]) {
+ ctl->last_key_command = comchar;
+ ctl->last_key_arg = nlines;
+ if ((cc_t) comchar == ctl->output_tty.c_cc[VERASE]) {
kill_line(ctl);
prompt(ctl, filename);
continue;
@@ -1426,7 +1424,7 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
{
int initline;
- if (ctl->no_intty) {
+ if (ctl->no_tty_in) {
fputc(RINGBELL, stderr);
return -1;
}
@@ -1437,27 +1435,27 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
putchar('\r');
erasep(ctl, 0);
putchar('\n');
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
printf(P_("...back %d page",
"...back %d pages", nlines),
nlines);
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
putchar('\n');
- initline = ctl->Currline - ctl->dlines * (nlines + 1);
- if (!ctl->noscroll)
+ initline = ctl->current_line - ctl->lines_per_screen * (nlines + 1);
+ if (!ctl->no_scroll)
--initline;
if (initline < 0)
initline = 0;
more_fseek(ctl, f, 0L);
- ctl->Currline = 0; /* skiplns() will make Currline correct */
+ ctl->current_line = 0; /* skiplns() will make current_line correct */
skiplns(ctl, initline, f);
- if (!ctl->noscroll) {
- retval = ctl->dlines + 1;
+ if (!ctl->no_scroll) {
+ retval = ctl->lines_per_screen + 1;
} else {
- retval = ctl->dlines;
+ retval = ctl->lines_per_screen;
}
done = 1;
break;
@@ -1465,17 +1463,17 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
case ' ':
case 'z':
if (nlines == 0)
- nlines = ctl->dlines;
+ nlines = ctl->lines_per_screen;
else if (comchar == 'z')
- ctl->dlines = nlines;
+ ctl->lines_per_screen = nlines;
retval = nlines;
done = 1;
break;
case 'd':
case ctrl('D'):
if (nlines != 0)
- ctl->nscroll = nlines;
- retval = ctl->nscroll;
+ ctl->d_scroll_len = nlines;
+ retval = ctl->d_scroll_len;
done = 1;
break;
case 'q':
@@ -1487,18 +1485,18 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
if (nlines == 0)
nlines++;
if (comchar == 'f')
- nlines *= ctl->dlines;
+ nlines *= ctl->lines_per_screen;
putchar('\r');
erasep(ctl, 0);
putchar('\n');
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
printf(P_("...skipping %d line",
"...skipping %d lines", nlines),
nlines);
- if (ctl->clreol)
- putp(ctl->eraseln);
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
putchar('\n');
while (nlines > 0) {
@@ -1508,26 +1506,26 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
done++;
goto endsw;
}
- ctl->Currline++;
+ ctl->current_line++;
nlines--;
}
- retval = ctl->dlines;
+ retval = ctl->lines_per_screen;
done = 1;
break;
case '\n':
if (nlines != 0)
- ctl->dlines = nlines;
+ ctl->lines_per_screen = nlines;
else
nlines = 1;
retval = nlines;
done = 1;
break;
case '\f':
- if (!ctl->no_intty) {
+ if (!ctl->no_tty_in) {
doclear(ctl);
- more_fseek(ctl, f, ctl->screen_start.chrctr);
- ctl->Currline = ctl->screen_start.line;
- retval = ctl->dlines;
+ more_fseek(ctl, f, ctl->screen_start.row_num);
+ ctl->current_line = ctl->screen_start.line_num;
+ retval = ctl->lines_per_screen;
done = 1;
break;
} else {
@@ -1535,12 +1533,12 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
break;
}
case '\'':
- if (!ctl->no_intty) {
+ if (!ctl->no_tty_in) {
kill_line(ctl);
fputs(_("\n***Back***\n\n"), stdout);
- more_fseek(ctl, f, ctl->context.chrctr);
- ctl->Currline = ctl->context.line;
- retval = ctl->dlines;
+ more_fseek(ctl, f, ctl->context.row_num);
+ ctl->current_line = ctl->context.line_num;
+ retval = ctl->lines_per_screen;
done = 1;
break;
} else {
@@ -1549,34 +1547,34 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
}
case '=':
kill_line(ctl);
- ctl->promptlen = printf("%d", ctl->Currline);
+ ctl->prompt_len = printf("%d", ctl->current_line);
fflush(stdout);
break;
case 'n':
- if (!ctl->previousre) {
+ if (!ctl->previous_search) {
more_error(ctl, _("No previous regular expression"));
break;
}
- ctl->lastp++;
+ ctl->run_previous_command++;
/* fallthrough */
case '/':
if (nlines == 0)
nlines++;
kill_line(ctl);
putchar('/');
- ctl->promptlen = 1;
+ ctl->prompt_len = 1;
fflush(stdout);
- if (ctl->lastp) {
+ if (ctl->run_previous_command) {
fputc('\r', stderr);
- search(ctl, ctl->previousre, f, nlines);
+ search(ctl, ctl->previous_search, f, nlines);
} else {
ttyin(ctl, cmdbuf, sizeof(cmdbuf) - 2, '/');
fputc('\r', stderr);
- free(ctl->previousre);
- ctl->previousre = xstrdup(cmdbuf);
+ free(ctl->previous_search);
+ ctl->previous_search = xstrdup(cmdbuf);
search(ctl, cmdbuf, f, nlines);
}
- retval = ctl->dlines - 1;
+ retval = ctl->lines_per_screen - 1;
done = 1;
break;
case '!':
@@ -1584,7 +1582,7 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
break;
case '?':
case 'h':
- if (ctl->noscroll)
+ if (ctl->no_scroll)
doclear(ctl);
fputs(_("\n"
"Most commands optionally preceded by integer argument k. "
@@ -1617,13 +1615,13 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
prompt(ctl, filename);
break;
case 'v': /* This case should go right before default */
- if (!ctl->no_intty) {
+ if (!ctl->no_tty_in) {
/* Earlier: call vi +n file. This also
* works for emacs. POSIX: call vi -c n
* file (when editor is vi or ex). */
char *editor, *p;
- int n = (ctl->Currline - ctl->dlines <= 0 ? 1 :
- ctl->Currline - (ctl->dlines + 1) / 2);
+ int n = (ctl->current_line - ctl->lines_per_screen <= 0 ? 1 :
+ ctl->current_line - (ctl->lines_per_screen + 1) / 2);
int split = 0;
editor = getenv("VISUAL");
@@ -1646,31 +1644,31 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
kill_line(ctl);
printf("%s %s %s", editor, cmdbuf,
- ctl->fnames[ctl->fnum]);
+ ctl->file_names[ctl->argv_position]);
if (split) {
cmdbuf[2] = 0;
execute(ctl, filename, editor, editor,
cmdbuf, cmdbuf + 3,
- ctl->fnames[ctl->fnum], (char *)0);
+ ctl->file_names[ctl->argv_position], (char *)0);
} else
execute(ctl, filename, editor, editor,
- cmdbuf, ctl->fnames[ctl->fnum],
+ cmdbuf, ctl->file_names[ctl->argv_position],
(char *)0);
break;
}
/* fallthrough */
default:
- if (ctl->dum_opt) {
+ if (ctl->suppress_bell) {
kill_line(ctl);
- if (ctl->Senter && ctl->Sexit) {
- putp(ctl->Senter);
- ctl->promptlen =
+ if (ctl->enter_std && ctl->exit_std) {
+ putp(ctl->enter_std);
+ ctl->prompt_len =
printf(_
("[Press 'h' for instructions.]"))
- + 2 * ctl->soglitch;
- putp(ctl->Sexit);
+ + 2 * ctl->stdout_glitch;
+ putp(ctl->exit_std);
} else
- ctl->promptlen =
+ ctl->prompt_len =
printf(_
("[Press 'h' for instructions.]"));
fflush(stdout);
@@ -1683,8 +1681,8 @@ static int command(struct more_control *ctl, char *filename, FILE *f)
}
putchar('\r');
endsw:
- ctl->inwait = 0;
- ctl->notell = 1;
+ ctl->waiting_input = 0;
+ ctl->no_quit_dialog = 1;
return retval;
}
@@ -1697,61 +1695,61 @@ static void screen(struct more_control *ctl, FILE *f, int num_lines)
static int prev_len = 1; /* length of previous line */
for (;;) {
- while (num_lines > 0 && !ctl->Pause) {
+ while (num_lines > 0 && !ctl->is_paused) {
if ((nchars = get_line(ctl, f, &length)) == EOF) {
- if (ctl->clreol)
- putp(ctl->EodClr);
+ if (ctl->clear_line_ends)
+ putp(ctl->clear_rest);
return;
}
- if (ctl->ssp_opt && length == 0 && prev_len == 0)
+ if (ctl->squeeze_spaces && length == 0 && prev_len == 0)
continue;
prev_len = length;
- if (ctl->bad_so
- || ((ctl->Senter && *ctl->Senter == ' ') && (ctl->promptlen > 0)))
+ if (ctl->bad_stdout
+ || ((ctl->enter_std && *ctl->enter_std == ' ') && (ctl->prompt_len > 0)))
erasep(ctl, 0);
/* must clear before drawing line since tabs on
* some terminals do not erase what they tab
* over. */
- if (ctl->clreol)
- putp(ctl->eraseln);
- prbuf(ctl, ctl->Line, length);
- if (nchars < ctl->promptlen)
- erasep(ctl, nchars); /* erasep () sets promptlen to 0 */
+ if (ctl->clear_line_ends)
+ putp(ctl->erase_line);
+ prbuf(ctl, ctl->line_buf, length);
+ if (nchars < ctl->prompt_len)
+ erasep(ctl, nchars); /* erasep () sets prompt_len to 0 */
else
- ctl->promptlen = 0;
- if (nchars < ctl->Mcol || !ctl->fold_opt)
+ ctl->prompt_len = 0;
+ if (nchars < ctl->num_columns || !ctl->fold_long_lines)
prbuf(ctl, "\n", 1); /* will turn off UL if necessary */
num_lines--;
}
- if (ctl->pstate) {
- putp(ctl->ULexit);
- ctl->pstate = 0;
+ if (ctl->underline_state) {
+ putp(ctl->exit_underline);
+ ctl->underline_state = 0;
}
fflush(stdout);
if ((c = more_getc(ctl, f)) == EOF) {
- if (ctl->clreol)
- putp(ctl->EodClr);
+ if (ctl->clear_line_ends)
+ putp(ctl->clear_rest);
return;
}
- if (ctl->Pause && ctl->clreol)
- putp(ctl->EodClr);
+ if (ctl->is_paused && ctl->clear_line_ends)
+ putp(ctl->clear_rest);
more_ungetc(ctl, c, f);
- sigsetjmp(ctl->restore, 1);
- ctl->Pause = 0;
- ctl->startup = 0;
+ sigsetjmp(ctl->destination, 1);
+ ctl->is_paused = 0;
+ ctl->starting_up = 0;
if ((num_lines = command(ctl, NULL, f)) == 0)
return;
- if (ctl->hard && ctl->promptlen > 0)
+ if (ctl->hard_tty && ctl->prompt_len > 0)
erasep(ctl, 0);
- if (ctl->noscroll && num_lines >= ctl->dlines) {
- if (ctl->clreol)
- putp(ctl->Home);
+ if (ctl->no_scroll && num_lines >= ctl->lines_per_screen) {
+ if (ctl->clear_line_ends)
+ putp(ctl->go_home);
else
doclear(ctl);
}
- ctl->screen_start.line = ctl->Currline;
- ctl->screen_start.chrctr = ctl->file_pos;
+ ctl->screen_start.line_num = ctl->current_line;
+ ctl->screen_start.row_num = ctl->file_position;
}
}
@@ -1763,14 +1761,14 @@ static void chgwinsz(int dummy __attribute__((__unused__)))
signal(SIGWINCH, SIG_IGN);
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1) {
if (win.ws_row != 0) {
- global_ctl->Lpp = win.ws_row;
- global_ctl->nscroll = global_ctl->Lpp / 2 - 1;
- if (global_ctl->nscroll <= 0)
- global_ctl->nscroll = 1;
- global_ctl->dlines = global_ctl->Lpp - 1;
+ global_ctl->lines_per_page = win.ws_row;
+ global_ctl->d_scroll_len = global_ctl->lines_per_page / 2 - 1;
+ if (global_ctl->d_scroll_len <= 0)
+ global_ctl->d_scroll_len = 1;
+ global_ctl->lines_per_screen = global_ctl->lines_per_page - 1;
}
if (win.ws_col != 0)
- global_ctl->Mcol = win.ws_col;
+ global_ctl->num_columns = win.ws_col;
}
signal(SIGWINCH, chgwinsz);
}
@@ -1792,48 +1790,48 @@ static void initterm(struct more_control *ctl)
struct winsize win;
#ifndef NON_INTERACTIVE_MORE
- ctl->no_tty = tcgetattr(STDOUT_FILENO, &ctl->otty);
+ ctl->no_tty_out = tcgetattr(STDOUT_FILENO, &ctl->output_tty);
#endif
- if (!ctl->no_tty) {
- ctl->docrterase = (ctl->otty.c_cc[VERASE] != 255);
- ctl->docrtkill = (ctl->otty.c_cc[VKILL] != 255);
+ if (!ctl->no_tty_out) {
+ ctl->erase_previous_ok = (ctl->output_tty.c_cc[VERASE] != 255);
+ ctl->erase_input_ok = (ctl->output_tty.c_cc[VKILL] != 255);
if ((term = getenv("TERM")) == NULL) {
- ctl->dumb = 1;
- ctl->ul_opt = 0;
+ ctl->dumb_tty = 1;
+ ctl->enable_underlining = 0;
}
setupterm(term, 1, &ret);
if (ret <= 0) {
- ctl->dumb = 1;
- ctl->ul_opt = 0;
+ ctl->dumb_tty = 1;
+ ctl->enable_underlining = 0;
} else {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) < 0) {
- ctl->Lpp = tigetnum(TERM_LINES);
- ctl->Mcol = tigetnum(TERM_COLS);
+ ctl->lines_per_page = tigetnum(TERM_LINES);
+ ctl->num_columns = tigetnum(TERM_COLS);
} else {
- if ((ctl->Lpp = win.ws_row) == 0)
- ctl->Lpp = tigetnum(TERM_LINES);
- if ((ctl->Mcol = win.ws_col) == 0)
- ctl->Mcol = tigetnum(TERM_COLS);
+ if ((ctl->lines_per_page = win.ws_row) == 0)
+ ctl->lines_per_page = tigetnum(TERM_LINES);
+ if ((ctl->num_columns = win.ws_col) == 0)
+ ctl->num_columns = tigetnum(TERM_COLS);
}
- if ((ctl->Lpp <= 0) || tigetflag(TERM_HARD_COPY)) {
- ctl->hard = 1;
- ctl->Lpp = LINES_PER_PAGE;
+ if ((ctl->lines_per_page <= 0) || tigetflag(TERM_HARD_COPY)) {
+ ctl->hard_tty = 1;
+ ctl->lines_per_page = LINES_PER_PAGE;
}
if (tigetflag(TERM_EAT_NEW_LINE))
/* Eat newline at last column + 1; dec, concept */
- ctl->eatnl++;
- if (ctl->Mcol <= 0)
- ctl->Mcol = NUM_COLUMNS;
-
- ctl->Wrap = tigetflag(TERM_AUTO_RIGHT_MARGIN);
- ctl->bad_so = tigetflag(TERM_CEOL);
- ctl->eraseln = tigetstr(TERM_CLEAR_TO_LINE_END);
- ctl->Clear = tigetstr(TERM_CLEAR);
- ctl->Senter = tigetstr(TERM_STANDARD_MODE);
- ctl->Sexit = tigetstr(TERM_EXIT_STANDARD_MODE);
+ ctl->eat_newline++;
+ if (ctl->num_columns <= 0)
+ ctl->num_columns = NUM_COLUMNS;
+
+ ctl->wrap_margin = tigetflag(TERM_AUTO_RIGHT_MARGIN);
+ ctl->bad_stdout = tigetflag(TERM_CEOL);
+ ctl->erase_line = tigetstr(TERM_CLEAR_TO_LINE_END);
+ ctl->clear = tigetstr(TERM_CLEAR);
+ ctl->enter_std = tigetstr(TERM_STANDARD_MODE);
+ ctl->exit_std = tigetstr(TERM_EXIT_STANDARD_MODE);
if (0 < tigetnum(TERM_STD_MODE_GLITCH))
- ctl->soglitch = 1;
+ ctl->stdout_glitch = 1;
/* Set up for underlining: some terminals don't
* need it; others have start/stop sequences,
@@ -1843,51 +1841,51 @@ static void initterm(struct more_control *ctl)
* available, settle for standout sequence. */
if (tigetflag(TERM_UNDERLINE)
|| tigetflag(TERM_OVER_STRIKE))
- ctl->ul_opt = 0;
- if ((ctl->chUL = tigetstr(TERM_UNDERLINE_CHAR)) == NULL)
- ctl->chUL = "";
- if (((ctl->ULenter =
+ ctl->enable_underlining = 0;
+ if ((ctl->underline_ch = tigetstr(TERM_UNDERLINE_CHAR)) == NULL)
+ ctl->underline_ch = "";
+ if (((ctl->enter_underline =
tigetstr(TERM_ENTER_UNDERLINE)) == NULL
- || (ctl->ULexit =
+ || (ctl->exit_underline =
tigetstr(TERM_EXIT_UNDERLINE)) == NULL)
- && !*ctl->chUL) {
- if ((ctl->ULenter = ctl->Senter) == NULL
- || (ctl->ULexit = ctl->Sexit) == NULL) {
- ctl->ULenter = "";
- ctl->ULexit = "";
+ && !*ctl->underline_ch) {
+ if ((ctl->enter_underline = ctl->enter_std) == NULL
+ || (ctl->exit_underline = ctl->exit_std) == NULL) {
+ ctl->enter_underline = "";
+ ctl->exit_underline = "";
} else
- ctl->ulglitch = ctl->soglitch;
+ ctl->underline_glitch = ctl->stdout_glitch;
} else {
- ctl->ulglitch = 0;
+ ctl->underline_glitch = 0;
}
- ctl->Home = tigetstr(TERM_HOME);
- if (ctl->Home == NULL || *ctl->Home == '\0') {
- if ((ctl->cursorm =
+ ctl->go_home = tigetstr(TERM_HOME);
+ if (ctl->go_home == NULL || *ctl->go_home == '\0') {
+ if ((ctl->cursor_addr =
tigetstr(TERM_CURSOR_ADDRESS)) != NULL) {
const char *t =
- (const char *)tparm(ctl->cursorm, 0,
+ (const char *)tparm(ctl->cursor_addr, 0,
0);
- xstrncpy(ctl->cursorhome, t,
- sizeof(ctl->cursorhome));
- ctl->Home = ctl->cursorhome;
+ xstrncpy(ctl->home_position, t,
+ sizeof(ctl->home_position));
+ ctl->go_home = ctl->home_position;
}
}
- ctl->EodClr = tigetstr(TERM_CLEAR_TO_SCREEN_END);
- if ((ctl->chBS = tigetstr(TERM_LINE_DOWN)) == NULL)
- ctl->chBS = BS;
+ ctl->clear_rest = tigetstr(TERM_CLEAR_TO_SCREEN_END);
+ if ((ctl->backspace_ch = tigetstr(TERM_LINE_DOWN)) == NULL)
+ ctl->backspace_ch = BS;
}
if ((ctl->shell = getenv("SHELL")) == NULL)
ctl->shell = "/bin/sh";
}
- ctl->no_intty = tcgetattr(STDIN_FILENO, &ctl->otty);
- tcgetattr(STDERR_FILENO, &ctl->otty);
- ctl->savetty0 = ctl->otty;
- ctl->hardtabs = (ctl->otty.c_oflag & TABDLY) != TAB3;
- if (!ctl->no_tty) {
- ctl->otty.c_lflag &= ~(ICANON | ECHO);
- ctl->otty.c_cc[VMIN] = 1;
- ctl->otty.c_cc[VTIME] = 0;
+ ctl->no_tty_in = tcgetattr(STDIN_FILENO, &ctl->output_tty);
+ tcgetattr(STDERR_FILENO, &ctl->output_tty);
+ ctl->original_tty = ctl->output_tty;
+ ctl->hard_tabs = (ctl->output_tty.c_oflag & TABDLY) != TAB3;
+ if (!ctl->no_tty_out) {
+ ctl->output_tty.c_lflag &= ~(ICANON | ECHO);
+ ctl->output_tty.c_cc[VMIN] = 1;
+ ctl->output_tty.c_cc[VTIME] = 0;
}
}
@@ -1897,23 +1895,23 @@ int main(int argc, char **argv)
char *s;
int chr;
int left;
- int prnames = 0;
- int initopt = 0;
- int srchopt = 0;
- int clearit = 0;
- int initline = 0;
+ int print_names = 0;
+ int init = 0;
+ int search_at_start = 0;
+ int skip_file = 0;
+ int start_at_line = 0;
char *initbuf = NULL;
struct more_control ctl = {
- .firstf = 1,
- .fold_opt = 1,
- .notell = 1,
- .startup = 1,
- .stop_opt = 1,
- .ul_opt = 1,
- .Wrap = 1,
- .Lpp = LINES_PER_PAGE,
- .Mcol = NUM_COLUMNS,
- .nscroll = SCROLL_LEN,
+ .first_file = 1,
+ .fold_long_lines = 1,
+ .no_quit_dialog = 1,
+ .starting_up = 1,
+ .stop_after_formfeed = 1,
+ .enable_underlining = 1,
+ .wrap_margin = 1,
+ .lines_per_page = LINES_PER_PAGE,
+ .num_columns = NUM_COLUMNS,
+ .d_scroll_len = SCROLL_LEN,
0
};
global_ctl = &ctl;
@@ -1933,169 +1931,169 @@ int main(int argc, char **argv)
}
}
- ctl.nfiles = argc;
- ctl.fnames = argv;
+ ctl.num_files = argc;
+ ctl.file_names = argv;
setlocale(LC_ALL, "");
initterm(&ctl);
/* Auto set no scroll on when binary is called page */
if (!(strcmp(program_invocation_short_name, "page")))
- ctl.noscroll++;
+ ctl.no_scroll++;
prepare_line_buffer(&ctl);
- ctl.nscroll = ctl.Lpp / 2 - 1;
- if (ctl.nscroll <= 0)
- ctl.nscroll = 1;
+ ctl.d_scroll_len = ctl.lines_per_page / 2 - 1;
+ if (ctl.d_scroll_len <= 0)
+ ctl.d_scroll_len = 1;
if ((s = getenv("MORE")) != NULL)
argscan(&ctl, s);
- while (--ctl.nfiles > 0) {
- if ((chr = (*++ctl.fnames)[0]) == '-') {
- argscan(&ctl, *ctl.fnames + 1);
+ while (--ctl.num_files > 0) {
+ if ((chr = (*++ctl.file_names)[0]) == '-') {
+ argscan(&ctl, *ctl.file_names + 1);
} else if (chr == '+') {
- s = *ctl.fnames;
+ s = *ctl.file_names;
if (*++s == '/') {
- srchopt++;
+ search_at_start++;
initbuf = xstrdup(s + 1);
} else {
- initopt++;
- for (initline = 0; *s != '\0'; s++)
+ init++;
+ for (start_at_line = 0; *s != '\0'; s++)
if (isdigit(*s))
- initline =
- initline * 10 + *s - '0';
- --initline;
+ start_at_line =
+ start_at_line * 10 + *s - '0';
+ --start_at_line;
}
} else
break;
}
- /* allow clreol only if Home and eraseln and EodClr strings are
- * defined, and in that case, make sure we are in noscroll mode */
- if (ctl.clreol) {
- if ((ctl.Home == NULL) || (*ctl.Home == '\0') ||
- (ctl.eraseln == NULL) || (*ctl.eraseln == '\0') ||
- (ctl.EodClr == NULL) || (*ctl.EodClr == '\0'))
- ctl.clreol = 0;
+ /* allow clear_line_ends only if go_home and erase_line and clear_rest strings are
+ * defined, and in that case, make sure we are in no_scroll mode */
+ if (ctl.clear_line_ends) {
+ if ((ctl.go_home == NULL) || (*ctl.go_home == '\0') ||
+ (ctl.erase_line == NULL) || (*ctl.erase_line == '\0') ||
+ (ctl.clear_rest == NULL) || (*ctl.clear_rest == '\0'))
+ ctl.clear_line_ends = 0;
else
- ctl.noscroll = 1;
+ ctl.no_scroll = 1;
}
- if (ctl.dlines == 0)
- ctl.dlines = ctl.Lpp - 1;
- left = ctl.dlines;
- if (ctl.nfiles > 1)
- prnames++;
- if (!ctl.no_intty && ctl.nfiles == 0) {
+ if (ctl.lines_per_screen == 0)
+ ctl.lines_per_screen = ctl.lines_per_page - 1;
+ left = ctl.lines_per_screen;
+ if (ctl.num_files > 1)
+ print_names++;
+ if (!ctl.no_tty_in && ctl.num_files == 0) {
warnx(_("bad usage"));
errtryhelp(EXIT_FAILURE);
} else
f = stdin;
- if (!ctl.no_tty) {
+ if (!ctl.no_tty_out) {
signal(SIGQUIT, onquit);
signal(SIGINT, end_it);
signal(SIGWINCH, chgwinsz);
if (signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
signal(SIGTSTP, onsusp);
- ctl.catch_susp++;
+ ctl.catch_suspend++;
}
- tcsetattr(STDERR_FILENO, TCSANOW, &ctl.otty);
+ tcsetattr(STDERR_FILENO, TCSANOW, &ctl.output_tty);
}
- if (ctl.no_intty) {
- if (ctl.no_tty)
+ if (ctl.no_tty_in) {
+ if (ctl.no_tty_out)
copy_file(stdin);
else {
if ((chr = getc(f)) == '\f')
doclear(&ctl);
else {
ungetc(chr, f);
- if (ctl.noscroll && (chr != EOF)) {
- if (ctl.clreol)
- putp(ctl.Home);
+ if (ctl.no_scroll && (chr != EOF)) {
+ if (ctl.clear_line_ends)
+ putp(ctl.go_home);
else
doclear(&ctl);
}
}
- if (srchopt) {
- free(ctl.previousre);
- ctl.previousre = xstrdup(initbuf);
+ if (search_at_start) {
+ free(ctl.previous_search);
+ ctl.previous_search = xstrdup(initbuf);
search(&ctl, initbuf, stdin, 1);
- if (ctl.noscroll)
+ if (ctl.no_scroll)
left--;
- } else if (initopt)
- skiplns(&ctl, initline, stdin);
+ } else if (init)
+ skiplns(&ctl, start_at_line, stdin);
screen(&ctl, stdin, left);
}
- ctl.no_intty = 0;
- prnames++;
- ctl.firstf = 0;
+ ctl.no_tty_in = 0;
+ print_names++;
+ ctl.first_file = 0;
}
- while (ctl.fnum < ctl.nfiles) {
- if ((f = checkf(&ctl, ctl.fnames[ctl.fnum], &clearit)) != NULL) {
- ctl.context.line = ctl.context.chrctr = 0;
- ctl.Currline = 0;
- if (ctl.firstf)
- sigsetjmp(ctl.restore, 1);
- if (ctl.firstf) {
- ctl.firstf = 0;
- if (srchopt) {
- free(ctl.previousre);
- ctl.previousre = xstrdup(initbuf);
+ while (ctl.argv_position < ctl.num_files) {
+ if ((f = checkf(&ctl, ctl.file_names[ctl.argv_position], &skip_file)) != NULL) {
+ ctl.context.line_num = ctl.context.row_num = 0;
+ ctl.current_line = 0;
+ if (ctl.first_file)
+ sigsetjmp(ctl.destination, 1);
+ if (ctl.first_file) {
+ ctl.first_file = 0;
+ if (search_at_start) {
+ free(ctl.previous_search);
+ ctl.previous_search = xstrdup(initbuf);
search(&ctl, initbuf, f, 1);
- if (ctl.noscroll)
+ if (ctl.no_scroll)
left--;
- } else if (initopt)
- skiplns(&ctl, initline, f);
- } else if (ctl.fnum < ctl.nfiles && !ctl.no_tty) {
- sigsetjmp(ctl.restore, 1);
- left = command(&ctl, ctl.fnames[ctl.fnum], f);
+ } else if (init)
+ skiplns(&ctl, start_at_line, f);
+ } else if (ctl.argv_position < ctl.num_files && !ctl.no_tty_out) {
+ sigsetjmp(ctl.destination, 1);
+ left = command(&ctl, ctl.file_names[ctl.argv_position], f);
}
if (left != 0) {
- if ((ctl.noscroll || clearit)
+ if ((ctl.no_scroll || skip_file)
&& (ctl.file_size != LONG_MAX)) {
- if (ctl.clreol)
- putp(ctl.Home);
+ if (ctl.clear_line_ends)
+ putp(ctl.go_home);
else
doclear(&ctl);
}
- if (prnames) {
- if (ctl.bad_so)
+ if (print_names) {
+ if (ctl.bad_stdout)
erasep(&ctl, 0);
- if (ctl.clreol)
- putp(ctl.eraseln);
+ if (ctl.clear_line_ends)
+ putp(ctl.erase_line);
fputs("::::::::::::::", stdout);
- if (ctl.promptlen > 14)
+ if (ctl.prompt_len > 14)
erasep(&ctl, 14);
putchar('\n');
- if (ctl.clreol)
- putp(ctl.eraseln);
- puts(ctl.fnames[ctl.fnum]);
- if (ctl.clreol)
- putp(ctl.eraseln);
+ if (ctl.clear_line_ends)
+ putp(ctl.erase_line);
+ puts(ctl.file_names[ctl.argv_position]);
+ if (ctl.clear_line_ends)
+ putp(ctl.erase_line);
fputs("::::::::::::::\n", stdout);
- if (left > ctl.Lpp - 4)
- left = ctl.Lpp - 4;
+ if (left > ctl.lines_per_page - 4)
+ left = ctl.lines_per_page - 4;
}
- if (ctl.no_tty)
+ if (ctl.no_tty_out)
copy_file(f);
else {
- ctl.within = 1;
+ ctl.within_file = 1;
screen(&ctl, f, left);
- ctl.within = 0;
+ ctl.within_file = 0;
}
}
- sigsetjmp(ctl.restore, 1);
+ sigsetjmp(ctl.destination, 1);
fflush(stdout);
fclose(f);
- ctl.screen_start.line = ctl.screen_start.chrctr = 0L;
- ctl.context.line = ctl.context.chrctr = 0L;
+ ctl.screen_start.line_num = ctl.screen_start.row_num = 0L;
+ ctl.context.line_num = ctl.context.row_num = 0L;
}
- ctl.fnum++;
- ctl.firstf = 0;
+ ctl.argv_position++;
+ ctl.first_file = 0;
}
- free(ctl.previousre);
+ free(ctl.previous_search);
free(initbuf);
- free(ctl.Line);
+ free(ctl.line_buf);
reset_tty();
exit(EXIT_SUCCESS);
}