diff options
| author | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-12 21:51:55 +0200 |
|---|---|---|
| committer | Roberto E. Vargas Caballero <k0ga@shike2.com> | 2012-09-12 21:51:55 +0200 |
| commit | 720cb816dcff55f8b75bdc2a8ffa265f460f5d55 (patch) | |
| tree | 1e399c343f102eca23f2cbe97c2d33414b42bb93 | |
| parent | b9d5fec4f277b688b3bb4741134abf152e801e90 (diff) | |
| download | st-720cb816dcff55f8b75bdc2a8ffa265f460f5d55.tar.gz st-720cb816dcff55f8b75bdc2a8ffa265f460f5d55.zip | |
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(-)
| -rw-r--r-- | st.c | 12 |
1 files changed, 5 insertions, 7 deletions
| @@ -355,7 +355,7 @@ static STREscape strescseq; | |||
| 355 | static int cmdfd; | 355 | static int cmdfd; |
| 356 | static pid_t pid; | 356 | static pid_t pid; |
| 357 | static Selection sel; | 357 | static Selection sel; |
| 358 | static FILE *fileio; | 358 | static int iofd = -1; |
| 359 | static char **opt_cmd = NULL; | 359 | static char **opt_cmd = NULL; |
| 360 | static char *opt_io = NULL; | 360 | static char *opt_io = NULL; |
| 361 | static char *opt_title = NULL; | 361 | static char *opt_title = NULL; |
| @@ -821,9 +821,9 @@ ttynew(void) { | |||
| 821 | signal(SIGCHLD, sigchld); | 821 | signal(SIGCHLD, sigchld); |
| 822 | if(opt_io) { | 822 | if(opt_io) { |
| 823 | if(!strcmp(opt_io, "-")) { | 823 | if(!strcmp(opt_io, "-")) { |
| 824 | fileio = stdout; | 824 | iofd = STDOUT_FILENO; |
| 825 | } else { | 825 | } else { |
| 826 | if(!(fileio = fopen(opt_io, "w"))) { | 826 | if((iofd = open(opt_io, O_WRONLY | O_CREAT, 0666)) < 0) { |
| 827 | fprintf(stderr, "Error opening %s:%s\n", | 827 | fprintf(stderr, "Error opening %s:%s\n", |
| 828 | opt_io, strerror(errno)); | 828 | opt_io, strerror(errno)); |
| 829 | } | 829 | } |
| @@ -1599,10 +1599,8 @@ void | |||
| 1599 | tputc(char *c) { | 1599 | tputc(char *c) { |
| 1600 | char ascii = *c; | 1600 | char ascii = *c; |
| 1601 | 1601 | ||
| 1602 | if(fileio) { | 1602 | if(iofd != -1) |
| 1603 | putc(ascii, fileio); | 1603 | write(iofd, c, 1); |
| 1604 | fflush(fileio); | ||
| 1605 | } | ||
| 1606 | 1604 | ||
| 1607 | if(term.esc & ESC_START) { | 1605 | if(term.esc & ESC_START) { |
| 1608 | if(term.esc & ESC_CSI) { | 1606 | if(term.esc & ESC_CSI) { |
