* check.t: add new regression test "typeset-padding-1" according to TFM

* edit.c: remove debug stuff again; next time better use shl.c functions ;)
* sh.h: add format attributes to a few shf functions
* histrap.c, var.c: fix format string mistakes
* main.c, sh.h: error_prefix and warningf take bool not int
* misc.c: make chvt() stuff use shf_* functions
* misc.c: rewrite the TIOCSTTY stuff to be better integrated in mksh,
  since it originally was an external patch
* misc.c: chvt() no longer fails if e.g. chown fails due to e.g. R/O / fs
* var.c: fix typeset padding for right-justified zero-filled
This commit is contained in:
tg
2006-11-10 01:13:52 +00:00
parent c2aec39358
commit 273ca89019
7 changed files with 81 additions and 100 deletions

12
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.23 2006/08/18 18:48:26 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.24 2006/11/10 01:13:52 tg Exp $");
/*
* Variables
@ -510,10 +510,12 @@ formatstr(struct tbl *vp, const char *s)
s += slen - vp->u2.field;
slen = vp->u2.field;
}
shf_snprintf(p, nlen + 1,
((vp->flag & ZEROFIL) && digit(*s)) ?
"%0*s%.*s" : "%*s%.*s",
vp->u2.field - slen, null, slen, s);
if (vp->u2.field - slen)
memset(p, (vp->flag & ZEROFIL) ? '0' : ' ',
vp->u2.field - slen);
shf_snprintf(p + vp->u2.field - slen,
nlen + 1 - (vp->u2.field - slen),
"%.*s", slen, s);
} else {
/* strip leading spaces/zeros */
while (isspace((unsigned char)*s))