mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-22 15:25:58 +01:00
Remove buffering to fileio instead of calling fflush
By default text files are line buffered, and this means that -f option will not write the line until a \n is printed. This is not very useful for debugging, so a call to fflush was added. This patch substitute this call (which will be done by each character painted) by the full remove of the buffering in the file. --- st.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
This commit is contained in:
parent
b9d5fec4f2
commit
720cb816dc
1 changed files with 5 additions and 7 deletions
12
st.c
12
st.c
|
@ -355,7 +355,7 @@ static STREscape strescseq;
|
||||||
static int cmdfd;
|
static int cmdfd;
|
||||||
static pid_t pid;
|
static pid_t pid;
|
||||||
static Selection sel;
|
static Selection sel;
|
||||||
static FILE *fileio;
|
static int iofd = -1;
|
||||||
static char **opt_cmd = NULL;
|
static char **opt_cmd = NULL;
|
||||||
static char *opt_io = NULL;
|
static char *opt_io = NULL;
|
||||||
static char *opt_title = NULL;
|
static char *opt_title = NULL;
|
||||||
|
@ -821,9 +821,9 @@ ttynew(void) {
|
||||||
signal(SIGCHLD, sigchld);
|
signal(SIGCHLD, sigchld);
|
||||||
if(opt_io) {
|
if(opt_io) {
|
||||||
if(!strcmp(opt_io, "-")) {
|
if(!strcmp(opt_io, "-")) {
|
||||||
fileio = stdout;
|
iofd = STDOUT_FILENO;
|
||||||
} else {
|
} else {
|
||||||
if(!(fileio = fopen(opt_io, "w"))) {
|
if((iofd = open(opt_io, O_WRONLY | O_CREAT, 0666)) < 0) {
|
||||||
fprintf(stderr, "Error opening %s:%s\n",
|
fprintf(stderr, "Error opening %s:%s\n",
|
||||||
opt_io, strerror(errno));
|
opt_io, strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -1599,10 +1599,8 @@ void
|
||||||
tputc(char *c) {
|
tputc(char *c) {
|
||||||
char ascii = *c;
|
char ascii = *c;
|
||||||
|
|
||||||
if(fileio) {
|
if(iofd != -1)
|
||||||
putc(ascii, fileio);
|
write(iofd, c, 1);
|
||||||
fflush(fileio);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(term.esc & ESC_START) {
|
if(term.esc & ESC_START) {
|
||||||
if(term.esc & ESC_CSI) {
|
if(term.esc & ESC_CSI) {
|
||||||
|
|
Loading…
Reference in a new issue