shrink .data a little
This commit is contained in:
parent
dc10f66070
commit
c480656076
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.39 2007/01/12 02:06:34 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.40 2007/01/15 02:48:27 tg Exp $");
|
||||||
|
|
||||||
Trap sigtraps[NSIG + 1];
|
Trap sigtraps[NSIG + 1];
|
||||||
static struct sigaction Sigact_ign, Sigact_trap;
|
static struct sigaction Sigact_ign, Sigact_trap;
|
||||||
@ -943,7 +943,7 @@ hist_finish(void)
|
|||||||
static int
|
static int
|
||||||
sprinkle(int fd)
|
sprinkle(int fd)
|
||||||
{
|
{
|
||||||
static unsigned char mag[] = { HMAGIC1, HMAGIC2 };
|
static const unsigned char mag[] = { HMAGIC1, HMAGIC2 };
|
||||||
|
|
||||||
return(write(fd, mag, 2) != 2);
|
return(write(fd, mag, 2) != 2);
|
||||||
}
|
}
|
||||||
|
8
sh.h
8
sh.h
@ -8,7 +8,7 @@
|
|||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $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 $ */
|
/* $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.97 2007/01/15 00:38:20 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.98 2007/01/15 02:48:27 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2007/01/14"
|
#define MKSH_VERSION "R29 2007/01/14"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
@ -201,10 +201,8 @@ EXTERN uid_t ksheuid; /* effective uid of shell */
|
|||||||
EXTERN int exstat; /* exit status */
|
EXTERN int exstat; /* exit status */
|
||||||
EXTERN int subst_exstat; /* exit status of last $(..)/`..` */
|
EXTERN int subst_exstat; /* exit status of last $(..)/`..` */
|
||||||
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
|
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
|
||||||
#ifndef EXTERN_DEFINED
|
EXTERN const char initvsn[] I__("KSH_VERSION=@(#)MIRBSD KSH " MKSH_VERSION);
|
||||||
static const char initvsn[] = "KSH_VERSION=@(#)MIRBSD KSH " MKSH_VERSION;
|
#define KSH_VERSION (initvsn + 16)
|
||||||
#endif
|
|
||||||
EXTERN const char *KSH_VERSION I__(initvsn + 16);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Area-based allocation built on malloc/free
|
* Area-based allocation built on malloc/free
|
||||||
|
48
shf.c
48
shf.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.10 2007/01/15 00:37:42 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.11 2007/01/15 02:48:28 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 */
|
||||||
@ -727,19 +727,15 @@ shf_smprintf(const char *fmt, ...)
|
|||||||
int
|
int
|
||||||
shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
char c, *s;
|
const char *s;
|
||||||
int tmp = 0;
|
char c, *cp;
|
||||||
int field, precision;
|
int tmp = 0, field, precision, len, flags;
|
||||||
int len;
|
|
||||||
int flags;
|
|
||||||
unsigned long lnum;
|
unsigned long lnum;
|
||||||
/* %#o produces the longest output */
|
/* %#o produces the longest output */
|
||||||
char numbuf[(8 * sizeof(long) + 2) / 3 + 1];
|
char numbuf[(8 * sizeof(long) + 2) / 3 + 1];
|
||||||
/* this stuff for dealing with the buffer */
|
/* this stuff for dealing with the buffer */
|
||||||
int nwritten = 0;
|
int nwritten = 0;
|
||||||
|
|
||||||
static char nulls[] = "(null %s)";
|
|
||||||
|
|
||||||
if (!fmt)
|
if (!fmt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -842,7 +838,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
case 'u':
|
case 'u':
|
||||||
case 'x':
|
case 'x':
|
||||||
flags |= FL_NUMBER;
|
flags |= FL_NUMBER;
|
||||||
s = &numbuf[sizeof(numbuf)];
|
cp = &numbuf[sizeof (numbuf)];
|
||||||
/*-
|
/*-
|
||||||
* XXX any better way to do this?
|
* XXX any better way to do this?
|
||||||
* XXX hopefully the compiler optimises this out
|
* XXX hopefully the compiler optimises this out
|
||||||
@ -869,28 +865,28 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
do {
|
do {
|
||||||
*--s = lnum % 10 + '0';
|
*--cp = lnum % 10 + '0';
|
||||||
lnum /= 10;
|
lnum /= 10;
|
||||||
} while (lnum);
|
} while (lnum);
|
||||||
|
|
||||||
if (c != 'u') {
|
if (c != 'u') {
|
||||||
if (tmp)
|
if (tmp)
|
||||||
*--s = '-';
|
*--cp = '-';
|
||||||
else if (flags & FL_PLUS)
|
else if (flags & FL_PLUS)
|
||||||
*--s = '+';
|
*--cp = '+';
|
||||||
else if (flags & FL_BLANK)
|
else if (flags & FL_BLANK)
|
||||||
*--s = ' ';
|
*--cp = ' ';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
do {
|
do {
|
||||||
*--s = (lnum & 0x7) + '0';
|
*--cp = (lnum & 0x7) + '0';
|
||||||
lnum >>= 3;
|
lnum >>= 3;
|
||||||
} while (lnum);
|
} while (lnum);
|
||||||
|
|
||||||
if ((flags & FL_HASH) && *s != '0')
|
if ((flags & FL_HASH) && *cp != '0')
|
||||||
*--s = '0';
|
*--cp = '0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -900,17 +896,17 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
"0123456789ABCDEF" :
|
"0123456789ABCDEF" :
|
||||||
"0123456789abcdef";
|
"0123456789abcdef";
|
||||||
do {
|
do {
|
||||||
*--s = digits[lnum & 0xf];
|
*--cp = digits[lnum & 0xf];
|
||||||
lnum >>= 4;
|
lnum >>= 4;
|
||||||
} while (lnum);
|
} while (lnum);
|
||||||
|
|
||||||
if (flags & FL_HASH) {
|
if (flags & FL_HASH) {
|
||||||
*--s = (flags & FL_UPPER) ? 'X' : 'x';
|
*--cp = (flags & FL_UPPER) ? 'X' : 'x';
|
||||||
*--s = '0';
|
*--cp = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = &numbuf[sizeof(numbuf)] - s;
|
len = &numbuf[sizeof (numbuf)] - (s = cp);
|
||||||
if (flags & FL_DOT) {
|
if (flags & FL_DOT) {
|
||||||
if (precision > len) {
|
if (precision > len) {
|
||||||
field = precision;
|
field = precision;
|
||||||
@ -921,8 +917,8 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!(s = va_arg(args, char *)))
|
if (!(s = va_arg(args, const char *)))
|
||||||
s = nulls;
|
s = "(null)";
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -942,9 +938,8 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point s should point to a string that is
|
* At this point s should point to a string that is to be
|
||||||
* to be formatted, and len should be the length of the
|
* formatted, and len should be the length of the string.
|
||||||
* string.
|
|
||||||
*/
|
*/
|
||||||
if (!(flags & FL_DOT) || len < precision)
|
if (!(flags & FL_DOT) || len < precision)
|
||||||
precision = len;
|
precision = len;
|
||||||
@ -954,7 +949,8 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
field = -field;
|
field = -field;
|
||||||
/* skip past sign or 0x when padding with 0 */
|
/* skip past sign or 0x when padding with 0 */
|
||||||
if ((flags & FL_ZERO) && (flags & FL_NUMBER)) {
|
if ((flags & FL_ZERO) && (flags & FL_NUMBER)) {
|
||||||
if (*s == '+' || *s == '-' || *s ==' ') {
|
if (*s == '+' || *s == '-' ||
|
||||||
|
*s == ' ') {
|
||||||
shf_putc(*s, shf);
|
shf_putc(*s, shf);
|
||||||
s++;
|
s++;
|
||||||
precision--;
|
precision--;
|
||||||
|
4
var.c
4
var.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.33 2006/11/19 16:43:43 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.34 2007/01/15 02:48:28 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -32,7 +32,7 @@ void
|
|||||||
newblock(void)
|
newblock(void)
|
||||||
{
|
{
|
||||||
struct block *l;
|
struct block *l;
|
||||||
static char *empty[] = {null};
|
static char *empty[] = { null };
|
||||||
|
|
||||||
l = (struct block *) alloc(sizeof(struct block), ATEMP);
|
l = (struct block *) alloc(sizeof(struct block), ATEMP);
|
||||||
l->flags = 0;
|
l->flags = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user