diff options
author | Toomas Soome <tsoome@me.com> | 2017-01-21 23:55:58 +0200 |
---|---|---|
committer | Hans Rosenfeld <hans.rosenfeld@joyent.com> | 2019-01-07 10:11:17 +0100 |
commit | f33b666290305a2b2c134d23cbd1e70e06bf36fd (patch) | |
tree | 6f7f14aa477cbed036be5ba80932930a12179fa1 | |
parent | adc2b73db62a4506a57dfd1ce89bcadc4a60a29d (diff) | |
download | illumos-joyent-f33b666290305a2b2c134d23cbd1e70e06bf36fd.tar.gz |
7796 uts: ldterm default to utf-8
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
-rw-r--r-- | usr/src/uts/common/io/ldterm.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr/src/uts/common/io/ldterm.c b/usr/src/uts/common/io/ldterm.c index ff36dab948..2bf991769d 100644 --- a/usr/src/uts/common/io/ldterm.c +++ b/usr/src/uts/common/io/ldterm.c @@ -728,11 +728,25 @@ ldtermopen(queue_t *q, dev_t *devp, int oflag, int sflag, cred_t *crp) tp->eucwioc.scrw[0] = 1; tp->t_maxeuc = 1; /* the max len in bytes of an EUC char */ tp->t_eucp = NULL; - tp->t_eucp_mp = NULL; - tp->t_eucwarn = 0; /* no bad chars seen yet */ - - tp->t_csdata = default_cs_data; tp->t_csmethods = cs_methods[LDTERM_CS_TYPE_EUC]; + tp->t_csdata = default_cs_data; + + /* + * Try to switch to UTF-8 mode by allocating buffer for multibyte + * chars, keep EUC if allocation fails. + */ + if ((tp->t_eucp_mp = allocb(_TTY_BUFSIZ, BPRI_HI)) != NULL) { + tp->t_eucp = tp->t_eucp_mp->b_rptr; + tp->t_state = TS_MEUC; /* Multibyte mode. */ + tp->t_maxeuc = 4; /* the max len in bytes of an UTF-8 char */ + tp->t_csdata.codeset_type = LDTERM_CS_TYPE_UTF8; + tp->t_csdata.csinfo_num = 4; + /* locale_name needs string length with terminating NUL */ + tp->t_csdata.locale_name = (char *)kmem_alloc(6, KM_SLEEP); + (void) strcpy(tp->t_csdata.locale_name, "UTF-8"); + tp->t_csmethods = cs_methods[LDTERM_CS_TYPE_UTF8]; + } + tp->t_eucwarn = 0; /* no bad chars seen yet */ qprocson(q); |