fix typeset -L vs. Unicode: snprintf second arg was wrong

This commit is contained in:
tg 2018-05-07 00:07:23 +00:00
parent 2d0c795605
commit 3560784571
3 changed files with 27 additions and 7 deletions

26
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.803 2018/04/28 07:07:35 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.804 2018/05/07 00:07:18 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
@ -30,7 +30,7 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
@(#)MIRBSD KSH R56 2018/04/28
@(#)MIRBSD KSH R56 2018/05/07
description:
Check base version of full shell
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: !shell:legacy-yes
---
expected-stdout:
@(#)LEGACY KSH R56 2018/04/28
@(#)LEGACY KSH R56 2018/05/07
description:
Check base version of legacy shell
stdin:
@ -8478,6 +8478,26 @@ stdin:
expected-stdout:
<16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
---
name: typeset-padding-3
description:
Check for a regression in which Unicode wasnt left-padded right
stdin:
set -U
nl=$'\n'
typeset -L20 x='. ak'
typeset -R20 y='. ak'
print -r -- "<$x> (1$nl<12345678910 345678920$nl<$y> 1)"
typeset -L20 x='. aẞ'
typeset -R20 y='. aẞ'
print -r -- "<$x> (2$nl<12345678910 345678920$nl<$y> 2)"
expected-stdout:
<. ak > (1
<12345678910 345678920
< . ak> 1)
<. aẞ > (2
<12345678910 345678920
< . aẞ> 2)
---
name: utf8bom-1
description:
Check that the UTF-8 Byte Order Mark is ignored as the first

4
sh.h
View File

@ -182,9 +182,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.860 2018/04/28 07:07:37 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.861 2018/05/07 00:07:21 tg Exp $");
#endif
#define MKSH_VERSION "R56 2018/04/28"
#define MKSH_VERSION "R56 2018/05/07"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES

4
var.c
View File

@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.224 2018/04/28 07:07:39 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.225 2018/05/07 00:07:23 tg Exp $");
/*-
* Variables
@ -707,7 +707,7 @@ formatstr(struct tbl *vp, const char *s)
if (vp->flag & ZEROFIL)
while (*s == '0')
s++;
shf_snprintf(p, nlen + 1, "%-*.*s",
shf_snprintf(p, psiz, "%-*.*s",
vp->u2.field, vp->u2.field, s);
}
} else