get rid of ulton() - a joke
saves 32 bss, but adds 84 text oO
This commit is contained in:
parent
88bf6422d9
commit
320f503391
9
eval.c
9
eval.c
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.13 2006/08/01 13:43:26 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.14 2006/11/09 23:55:51 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
|
@ -717,7 +717,12 @@ 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 */
|
||||
xp->str = str_save(ulton((unsigned long)c, 10), ATEMP);
|
||||
{
|
||||
char tmpbuf[11];
|
||||
|
||||
shf_snprintf(tmpbuf, 11, "%lu", (unsigned long)c);
|
||||
xp->str = str_save(tmpbuf, ATEMP);
|
||||
}
|
||||
return XSUB;
|
||||
}
|
||||
|
||||
|
|
19
misc.c
19
misc.c
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.21 2006/11/09 23:39:16 tg Exp $\t"
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.22 2006/11/09 23:55:51 tg Exp $\t"
|
||||
MKSH_SH_H_ID);
|
||||
|
||||
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
|
||||
|
@ -49,23 +49,6 @@ initctypes(void)
|
|||
setctypes(" \n\t\"#$&'()*;<>?[]\\`|", C_QUOTE);
|
||||
}
|
||||
|
||||
/* convert unsigned long to base N string */
|
||||
|
||||
char *
|
||||
ulton(long unsigned int n, int base)
|
||||
{
|
||||
char *p;
|
||||
static char buf[20];
|
||||
|
||||
p = &buf[sizeof (buf)];
|
||||
*--p = '\0';
|
||||
do {
|
||||
*--p = "0123456789ABCDEF"[n%base];
|
||||
n /= base;
|
||||
} while (n != 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Allocate a string of size n+1 and copy upto n characters from the possibly
|
||||
* null terminated string s into it. Always returns a null terminated string
|
||||
* (unless n < 0).
|
||||
|
|
3
sh.h
3
sh.h
|
@ -8,7 +8,7 @@
|
|||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||
|
||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.66 2006/11/09 23:39:16 tg Exp $"
|
||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.67 2006/11/09 23:55:52 tg Exp $"
|
||||
#define MKSH_VERSION "R29 2006/11/09"
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
|
@ -1219,7 +1219,6 @@ struct tbl **ktsort(struct table *);
|
|||
/* misc.c */
|
||||
void setctypes(const char *, int);
|
||||
void initctypes(void);
|
||||
char *ulton(unsigned long, int);
|
||||
char *str_save(const char *, Area *);
|
||||
char *str_nsave(const char *, int, Area *);
|
||||
int option(const char *);
|
||||
|
|
15
tree.c
15
tree.c
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.4 2006/05/10 18:54:13 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.5 2006/11/09 23:55:52 tg Exp $");
|
||||
|
||||
#define INDENT 4
|
||||
|
||||
|
@ -371,7 +371,6 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
|
|||
if (c == '%') {
|
||||
long n;
|
||||
char *p;
|
||||
int neg;
|
||||
|
||||
switch ((c = *fmt++)) {
|
||||
case 'c':
|
||||
|
@ -386,16 +385,16 @@ vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
|
|||
p = va_arg(va, char *);
|
||||
tputS(p, shf);
|
||||
break;
|
||||
case 'd': case 'u': /* decimal */
|
||||
case 'd': case 'u': { /* decimal */
|
||||
char tmpbuf[12];
|
||||
|
||||
n = (c == 'd') ? (long)va_arg(va, int) :
|
||||
(long)va_arg(va, unsigned int);
|
||||
neg = c=='d' && n<0;
|
||||
p = ulton((neg) ? -n : n, 10);
|
||||
if (neg)
|
||||
*--p = '-';
|
||||
shf_snprintf((p = tmpbuf), 12,
|
||||
(c == 'd') ? "%ld" : "%lu", n);
|
||||
while (*p)
|
||||
tputc(*p++, shf);
|
||||
break;
|
||||
} break;
|
||||
case 'T': /* format tree */
|
||||
ptree(va_arg(va, struct op *), indent, shf);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue