optional (#ifdef MKSH_SMALL) saving of 364 more bytes of .text

intended e.g. for FreeWRT
This commit is contained in:
tg 2006-11-09 21:00:13 +00:00
parent 35776a9d4d
commit c43e701025
2 changed files with 23 additions and 2 deletions

7
sh.h
View File

@ -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.60 2006/11/09 20:53:42 tg Exp $" #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.61 2006/11/09 21:00:13 tg Exp $"
#define MKSH_VERSION "R29 2006/11/09" #define MKSH_VERSION "R29 2006/11/09"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -492,10 +492,15 @@ EXTERN int x_cols I__(80); /* tty columns */
#define shf_fileno(shf) ((shf)->fd) #define shf_fileno(shf) ((shf)->fd)
#define shf_setfileno(shf,nfd) ((shf)->fd = (nfd)) #define shf_setfileno(shf,nfd) ((shf)->fd = (nfd))
#ifdef MKSH_SMALL
int shf_getc(struct shf *);
int shf_putc(int, struct shf *);
#else
#define shf_getc(shf) ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : \ #define shf_getc(shf) ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : \
shf_getchar(shf)) shf_getchar(shf))
#define shf_putc(c, shf) ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) : \ #define shf_putc(c, shf) ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) : \
((shf)->wnleft--, *(shf)->wp++ = (c))) ((shf)->wnleft--, *(shf)->wp++ = (c)))
#endif
#define shf_eof(shf) ((shf)->flags & SHF_EOF) #define shf_eof(shf) ((shf)->flags & SHF_EOF)
#define shf_error(shf) ((shf)->flags & SHF_ERROR) #define shf_error(shf) ((shf)->flags & SHF_ERROR)
#define shf_errno(shf) ((shf)->errno_) #define shf_errno(shf) ((shf)->errno_)

18
shf.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.6 2006/08/02 12:50:20 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/shf.c,v 1.7 2006/11/09 21:00:13 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 */
@ -1000,3 +1000,19 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
return shf_error(shf) ? EOF : nwritten; return shf_error(shf) ? EOF : nwritten;
} }
#ifdef MKSH_SMALL
int
shf_getc(struct shf *shf)
{
return ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ :
shf_getchar(shf));
}
int
shf_putc(int c, struct shf *shf)
{
return ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) :
((shf)->wnleft--, *(shf)->wp++ = (c)));
}
#endif