diff options
Diffstat (limited to '')
| -rw-r--r-- | st.c | 32 |
1 files changed, 29 insertions, 3 deletions
| @@ -108,6 +108,7 @@ typedef struct { | |||
| 108 | static void execsh(char **); | 108 | static void execsh(char **); |
| 109 | static void stty(char **); | 109 | static void stty(char **); |
| 110 | static void sigchld(int); | 110 | static void sigchld(int); |
| 111 | static void ttywriteraw(const char *, size_t); | ||
| 111 | 112 | ||
| 112 | static void csidump(void); | 113 | static void csidump(void); |
| 113 | static void csihandle(void); | 114 | static void csihandle(void); |
| @@ -786,13 +787,38 @@ ttyread(void) | |||
| 786 | void | 787 | void |
| 787 | ttywrite(const char *s, size_t n, int may_echo) | 788 | ttywrite(const char *s, size_t n, int may_echo) |
| 788 | { | 789 | { |
| 789 | fd_set wfd, rfd; | 790 | const char *next; |
| 790 | ssize_t r; | ||
| 791 | size_t lim = 256; | ||
| 792 | 791 | ||
| 793 | if (may_echo && IS_SET(MODE_ECHO)) | 792 | if (may_echo && IS_SET(MODE_ECHO)) |
| 794 | twrite(s, n, 1); | 793 | twrite(s, n, 1); |
| 795 | 794 | ||
| 795 | if (!IS_SET(MODE_CRLF)) { | ||
| 796 | ttywriteraw(s, n); | ||
| 797 | return; | ||
| 798 | } | ||
| 799 | |||
| 800 | /* This is similar to how the kernel handles ONLCR for ttys */ | ||
| 801 | while (n > 0) { | ||
| 802 | if (*s == '\r') { | ||
| 803 | next = s + 1; | ||
| 804 | ttywriteraw("\r\n", 2); | ||
| 805 | } else { | ||
| 806 | next = memchr(s, '\r', n); | ||
| 807 | DEFAULT(next, s + n); | ||
| 808 | ttywriteraw(s, next - s); | ||
| 809 | } | ||
| 810 | n -= next - s; | ||
| 811 | s = next; | ||
| 812 | } | ||
| 813 | } | ||
| 814 | |||
| 815 | void | ||
| 816 | ttywriteraw(const char *s, size_t n) | ||
| 817 | { | ||
| 818 | fd_set wfd, rfd; | ||
| 819 | ssize_t r; | ||
| 820 | size_t lim = 256; | ||
| 821 | |||
| 796 | /* | 822 | /* |
| 797 | * Remember that we are using a pty, which might be a modem line. | 823 | * Remember that we are using a pty, which might be a modem line. |
| 798 | * Writing too much will clog the line. That's why we are doing this | 824 | * Writing too much will clog the line. That's why we are doing this |
