fix utf_widthadj/utf_skipcols handling for the remaining cases I can spot
This commit is contained in:
4
edit.c
4
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.295 2016/04/14 11:51:26 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.296 2016/05/05 22:56:12 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -1576,7 +1576,7 @@ static void
|
|||||||
x_goto(char *cp)
|
x_goto(char *cp)
|
||||||
{
|
{
|
||||||
cp = cp >= xep ? xep : x_bs0(cp, xbuf);
|
cp = cp >= xep ? xep : x_bs0(cp, xbuf);
|
||||||
if (cp < xbp || cp >= utf_skipcols(xbp, x_displen)) {
|
if (cp < xbp || cp >= utf_skipcols(xbp, x_displen, NULL)) {
|
||||||
/* we are heading off screen */
|
/* we are heading off screen */
|
||||||
xcp = cp;
|
xcp = cp;
|
||||||
x_adjust();
|
x_adjust();
|
||||||
|
13
expr.c
13
expr.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.84 2016/05/05 21:33:46 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.85 2016/05/05 22:56:13 tg Exp $");
|
||||||
|
|
||||||
/* the order of these enums is constrained by the order of opinfo[] */
|
/* the order of these enums is constrained by the order of opinfo[] */
|
||||||
enum token {
|
enum token {
|
||||||
@ -809,19 +809,26 @@ utf_mbswidth(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
utf_skipcols(const char *p, int cols)
|
utf_skipcols(const char *p, int cols, int *colp)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
const char *q;
|
const char *q;
|
||||||
|
|
||||||
while (c < cols) {
|
while (c < cols) {
|
||||||
if (!*p)
|
if (!*p) {
|
||||||
|
/* end of input; special handling for edit.c */
|
||||||
|
if (!colp)
|
||||||
return (p + cols - c);
|
return (p + cols - c);
|
||||||
|
*colp = c;
|
||||||
|
return (p);
|
||||||
|
}
|
||||||
c += utf_widthadj(p, &p);
|
c += utf_widthadj(p, &p);
|
||||||
}
|
}
|
||||||
if (UTFMODE)
|
if (UTFMODE)
|
||||||
while (utf_widthadj(p, &q) == 0)
|
while (utf_widthadj(p, &q) == 0)
|
||||||
p = q;
|
p = q;
|
||||||
|
if (colp)
|
||||||
|
*colp = c;
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
sh.h
6
sh.h
@ -175,9 +175,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.770 2016/04/14 15:38:38 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.771 2016/05/05 22:56:14 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R52 2016/04/14"
|
#define MKSH_VERSION "R52 2016/05/05"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -1756,7 +1756,7 @@ size_t utf_mbtowc(unsigned int *, const char *);
|
|||||||
size_t utf_wctomb(char *, unsigned int);
|
size_t utf_wctomb(char *, unsigned int);
|
||||||
int utf_widthadj(const char *, const char **);
|
int utf_widthadj(const char *, const char **);
|
||||||
size_t utf_mbswidth(const char *) MKSH_A_PURE;
|
size_t utf_mbswidth(const char *) MKSH_A_PURE;
|
||||||
const char *utf_skipcols(const char *, int) MKSH_A_PURE;
|
const char *utf_skipcols(const char *, int, int *);
|
||||||
size_t utf_ptradj(const char *) MKSH_A_PURE;
|
size_t utf_ptradj(const char *) MKSH_A_PURE;
|
||||||
#ifdef MIRBSD_BOOTFLOPPY
|
#ifdef MIRBSD_BOOTFLOPPY
|
||||||
#define utf_wcwidth(i) wcwidth((wchar_t)(i))
|
#define utf_wcwidth(i) wcwidth((wchar_t)(i))
|
||||||
|
4
shf.c
4
shf.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.72 2016/05/05 21:38:12 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.73 2016/05/05 22:56:15 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
@ -1041,7 +1041,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
field = 0;
|
field = 0;
|
||||||
|
|
||||||
nwritten += precision;
|
nwritten += precision;
|
||||||
precision = utf_skipcols(s, precision) - s;
|
precision = utf_skipcols(s, precision, &tmp) - s;
|
||||||
while (precision--)
|
while (precision--)
|
||||||
shf_putc(*s++, shf);
|
shf_putc(*s++, shf);
|
||||||
|
|
||||||
|
10
var.c
10
var.c
@ -28,7 +28,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.201 2016/03/01 20:28:33 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.202 2016/05/05 22:56:15 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -649,14 +649,14 @@ formatstr(struct tbl *vp, const char *s)
|
|||||||
|
|
||||||
p = alloc((psiz = nlen * /* MB_LEN_MAX */ 3 + 1), ATEMP);
|
p = alloc((psiz = nlen * /* MB_LEN_MAX */ 3 + 1), ATEMP);
|
||||||
if (vp->flag & (RJUST|LJUST)) {
|
if (vp->flag & (RJUST|LJUST)) {
|
||||||
int slen = olen, i = 0;
|
int slen = olen;
|
||||||
|
|
||||||
if (vp->flag & RJUST) {
|
if (vp->flag & RJUST) {
|
||||||
const char *qq = s;
|
const char *qq;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
while (i < slen)
|
qq = utf_skipcols(s, slen, &slen);
|
||||||
i += utf_widthadj(qq, &qq);
|
|
||||||
/* strip trailing spaces (AT&T uses qq[-1] == ' ') */
|
/* strip trailing spaces (AT&T uses qq[-1] == ' ') */
|
||||||
while (qq > s && ksh_isspace(qq[-1])) {
|
while (qq > s && ksh_isspace(qq[-1])) {
|
||||||
--qq;
|
--qq;
|
||||||
|
Reference in New Issue
Block a user