struct stat st;
int c;
- if (stat(fs, &st) == -1) {
- fflush(stdout);
+ ctl->current_line = 0;
+ ctl->file_position = 0;
+ fflush(NULL);
+ if (((ctl->current_file = fopen(fs, "r")) == NULL) ||
+ (fstat(fileno(ctl->current_file), &st) != 0)) {
if (ctl->clear_line_ends)
putp(ctl->erase_line);
warn(_("stat of %s failed"), fs);
putp(ctl->exit_std);
if (ctl->clear_line_ends)
putp(ctl->clear_rest);
- fflush(stdout);
} else
fprintf(stderr, "\a");
+ fflush(NULL);
}
static void reset_tty(struct more_control *ctl)
return;
if (ctl->underline_state) {
putp(ctl->exit_underline);
- fflush(stdout);
ctl->underline_state = 0;
}
+ fflush(NULL);
ctl->output_tty.c_lflag |= ICANON | ECHO;
ctl->output_tty.c_cc[VMIN] = ctl->original_tty.c_cc[VMIN];
ctl->output_tty.c_cc[VTIME] = ctl->original_tty.c_cc[VTIME];
if (ctl->clear_line_ends) {
putchar('\r');
putp(ctl->erase_line);
- fflush(stdout);
- } else if (!ctl->clear_line_ends && (ctl->prompt_len > 0)) {
+ } else if (!ctl->clear_line_ends && (ctl->prompt_len > 0))
erase_to_col(ctl, 0);
- fflush(stdout);
- }
+ fflush(NULL);
free(ctl->previous_search);
free(ctl->shell_line);
free(ctl->line_buf);
fputs(mess, stdout);
if (ctl->exit_std)
putp(ctl->exit_std);
- fflush(stdout);
+ fflush(NULL);
ctl->report_errors++;
}
ctl->prompt_len = 1;
}
sp = buf;
- fflush(stdout);
+ fflush(NULL);
continue;
}
if (slash && (c == ctl->output_tty.c_cc[VKILL] ||
static void sigtstp_handler(struct more_control *ctl)
{
reset_tty(ctl);
- fflush(stdout);
+ fflush(NULL);
kill(0, SIGSTOP);
/* We're back */
set_tty(ctl);
char **args;
int argcount;
- fflush(stdout);
+ fflush(NULL);
for (n = 10; (id = fork()) < 0 && n > 0; n--)
sleep(5);
if (id == 0) {
erase_to_col(ctl, 0);
putchar('!');
- fflush(stdout);
- ctl->prompt_len = 1;
+ fflush(NULL);
if (ctl->run_previous_command && ctl->shell_line)
fputs(ctl->shell_line, stdout);
else {
free(ctl->shell_line);
ctl->shell_line = xstrdup(cmdbuf);
}
- erase_to_col(ctl, 0);
- ctl->prompt_len = printf("!%s", ctl->shell_line);
}
- fflush(stdout);
fputc('\n', stderr);
+ fflush(NULL);
ctl->prompt_len = 0;
execute(ctl, filename, ctl->shell, ctl->shell, "-c", ctl->shell_line, 0);
}
printf(_("\"%s\" line %d"), ctl->file_names[ctl->argv_position], ctl->current_line);
else
ctl->prompt_len = printf(_("[Not a file] line %d"), ctl->current_line);
- fflush(stdout);
+ fflush(NULL);
return -1;
case 'n':
if (nlines == 0) {
case '=':
erase_to_col(ctl, 0);
ctl->prompt_len = printf("%d", ctl->current_line);
- fflush(stdout);
+ fflush(NULL);
break;
case 'n':
if (!ctl->previous_search) {
erase_to_col(ctl, 0);
putchar('/');
ctl->prompt_len = 1;
- fflush(stdout);
+ fflush(NULL);
if (ctl->run_previous_command) {
fputc('\r', stderr);
search(ctl, ctl->previous_search, nlines);
+ 2 * ctl->stdout_glitch;
if (ctl->exit_std)
putp(ctl->exit_std);
- fflush(stdout);
} else
fprintf(stderr, "\a");
+ fflush(NULL);
break;
}
if (done)
putp(ctl->exit_underline);
ctl->underline_state = 0;
}
- fflush(stdout);
+ fflush(NULL);
if ((c = more_getc(ctl)) == EOF) {
if (ctl->clear_line_ends)
putp(ctl->clear_rest);
else
screen(ctl, left);
}
- fflush(stdout);
+ fflush(NULL);
fclose(ctl->current_file);
ctl->current_file = NULL;
ctl->screen_start.line_num = ctl->screen_start.row_num = 0;