save 176 text (92 text 32 bss relative to before last commit)

by making correct use of shf_* functions
This commit is contained in:
tg 2006-11-10 00:09:27 +00:00
parent 320f503391
commit c2aec39358
2 changed files with 11 additions and 26 deletions

9
eval.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.14 2006/11/09 23:55:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.15 2006/11/10 00:09:27 tg Exp $");
/*
* string expansion
@ -717,12 +717,7 @@ varsub(Expand *xp, char *sp, char *word,
if (Flag(FNOUNSET) && c == 0 && !zero_ok)
errorf("%s: parameter not set", sp);
*stypep = 0; /* unqualified variable/string substitution */
{
char tmpbuf[11];
shf_snprintf(tmpbuf, 11, "%lu", (unsigned long)c);
xp->str = str_save(tmpbuf, ATEMP);
}
xp->str = shf_smprintf("%lu", (unsigned long)c);
return XSUB;
}

28
tree.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.5 2006/11/09 23:55:52 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.6 2006/11/10 00:09:27 tg Exp $");
#define INDENT 4
@ -369,32 +369,22 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
while ((c = *fmt++)) {
if (c == '%') {
long n;
char *p;
switch ((c = *fmt++)) {
case 'c':
tputc(va_arg(va, int), shf);
break;
case 's':
p = va_arg(va, char *);
while (*p)
tputc(*p++, shf);
shf_puts(va_arg(va, char *), shf);
break;
case 'S': /* word */
p = va_arg(va, char *);
tputS(p, shf);
tputS(va_arg(va, char *), shf);
break;
case 'd': /* decimal */
shf_fprintf(shf, "%d", va_arg(va, int));
break;
case 'u': /* decimal */
shf_fprintf(shf, "%u", va_arg(va, unsigned));
break;
case 'd': case 'u': { /* decimal */
char tmpbuf[12];
n = (c == 'd') ? (long)va_arg(va, int) :
(long)va_arg(va, unsigned int);
shf_snprintf((p = tmpbuf), 12,
(c == 'd') ? "%ld" : "%lu", n);
while (*p)
tputc(*p++, shf);
} break;
case 'T': /* format tree */
ptree(va_arg(va, struct op *), indent, shf);
break;