summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Clarke <jrtc27@jrtc27.com>2015-08-29 11:15:29 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-08-30 02:12:55 +0200
commitcf99d571fb1cb77fbdf2cb84a0890835173b50af (patch)
tree0e76506a3f65f0acf37639409edc7fe935b4c659
parent2c1cccc529737527ad9ef981952d2c14d3dd13ec (diff)
Fix printk not handling ANSI escape codes
* i386/i386at/kd.c (kdstart): Moved escape sequence handling to new kd_putc_esc function. (kd_putc_esc): New function with logic from kdstart. (kdcnputc): Call kd_putc_esc rather than kd_putc to allow for ANSI escape codes. * i386/i386at/kd.h (kd_putc_esc): New function.
-rw-r--r--i386/i386at/kd.c63
-rw-r--r--i386/i386at/kd.h1
2 files changed, 40 insertions, 24 deletions
diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c
index 5656e830..9ed3958a 100644
--- a/i386/i386at/kd.c
+++ b/i386/i386at/kd.c
@@ -1059,7 +1059,6 @@ kdstart(struct tty *tp)
{
spl_t o_pri;
int ch;
- unsigned char c;
if (tp->t_state & TS_TTSTOP)
return;
@@ -1069,33 +1068,12 @@ kdstart(struct tty *tp)
break;
if ((tp->t_outq.c_cc <= 0) || (ch = getc(&tp->t_outq)) == -1)
break;
- c = ch;
/*
* Drop priority for long screen updates. ttstart() calls us at
* spltty.
*/
o_pri = splsoftclock(); /* block timeout */
- if (c == (K_ESC)) {
- if (esc_spt == esc_seq) {
- *(esc_spt++)=(K_ESC);
- *(esc_spt) = '\0';
- } else {
- kd_putc((K_ESC));
- esc_spt = esc_seq;
- }
- } else {
- if (esc_spt - esc_seq) {
- if (esc_spt - esc_seq > K_MAXESC - 1)
- esc_spt = esc_seq;
- else {
- *(esc_spt++) = c;
- *(esc_spt) = '\0';
- kd_parseesc();
- }
- } else {
- kd_putc(c);
- }
- }
+ kd_putc_esc(ch);
splx(o_pri);
}
if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
@@ -1237,6 +1215,43 @@ kd_bellon(void)
/*
*
+ * Function kd_putc_esc():
+ *
+ * This function puts a character on the screen, handling escape
+ * sequences.
+ *
+ * input : character to be displayed (or part of an escape code)
+ * output : character is displayed, or some action is taken
+ *
+ */
+void
+kd_putc_esc(u_char c)
+{
+ if (c == (K_ESC)) {
+ if (esc_spt == esc_seq) {
+ *(esc_spt++)=(K_ESC);
+ *(esc_spt) = '\0';
+ } else {
+ kd_putc((K_ESC));
+ esc_spt = esc_seq;
+ }
+ } else {
+ if (esc_spt - esc_seq) {
+ if (esc_spt - esc_seq > K_MAXESC - 1)
+ esc_spt = esc_seq;
+ else {
+ *(esc_spt++) = c;
+ *(esc_spt) = '\0';
+ kd_parseesc();
+ }
+ } else {
+ kd_putc(c);
+ }
+ }
+}
+
+/*
+ *
* Function kd_putc():
*
* This function simply puts a character on the screen. It does some
@@ -2950,7 +2965,7 @@ kdcnputc(dev_t dev, int c)
/* Note that tab is handled in kd_putc */
if (c == '\n')
kd_putc('\r');
- kd_putc(c);
+ kd_putc_esc(c);
return 0;
}
diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h
index 0cfed695..60cee7e3 100644
--- a/i386/i386at/kd.h
+++ b/i386/i386at/kd.h
@@ -702,6 +702,7 @@ extern void kd_setleds1 (u_char);
extern void kd_setleds2 (void);
extern void cnsetleds (u_char);
extern void kdreboot (void);
+extern void kd_putc_esc (u_char);
extern void kd_putc (u_char);
extern void kd_parseesc (void);
extern void kd_down (void);