From 8d1edbd95e5dc9986370b78de71f818e5aa8ff22 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 16 Jul 2011 17:07:35 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A3=20merge=20from=20mksh=20R40-stable=20?= =?UTF-8?q?use=20common=20macro=20bodies=20shf=5F{get,put}c=5F=20for=20def?= =?UTF-8?q?inition=20of=20shf=5F{put,get}c=20as=20functions=20(MKSH=5FSMAL?= =?UTF-8?q?L)=20or=20macros,=20respectively?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sh.h | 22 ++++++++++++---------- shf.c | 8 +++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sh.h b/sh.h index a4d5aab..caf108c 100644 --- a/sh.h +++ b/sh.h @@ -151,7 +151,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.484 2011/07/07 20:24:52 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.485 2011/07/16 17:07:34 tg Exp $"); #endif #define MKSH_VERSION "R40 2011/07/07" @@ -877,21 +877,16 @@ EXTERN mksh_ari_t x_lins I__(-1); /* tty lines */ * Shell file I/O routines */ -#define SHF_BSIZE 512 +#define SHF_BSIZE 512 -#define shf_fileno(shf) ((shf)->fd) +#define shf_fileno(shf) ((shf)->fd) #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 ? \ +#define shf_getc_(shf) ((shf)->rnleft > 0 ? \ (shf)->rnleft--, *(shf)->rp++ : \ shf_getchar(shf)) -#define shf_putc(c, shf) ((shf)->wnleft == 0 ? \ +#define shf_putc_(c, shf) ((shf)->wnleft == 0 ? \ shf_putchar((c), (shf)) : \ ((shf)->wnleft--, *(shf)->wp++ = (c))) -#endif #define shf_eof(shf) ((shf)->flags & SHF_EOF) #define shf_error(shf) ((shf)->flags & SHF_ERROR) #define shf_errno(shf) ((shf)->errno_) @@ -1778,6 +1773,13 @@ int shf_read(char *, int, struct shf *); char *shf_getse(char *, int, struct shf *); int shf_getchar(struct shf *s); int shf_ungetc(int, struct shf *); +#ifdef MKSH_SMALL +int shf_getc(struct shf *); +int shf_putc(int, struct shf *); +#else +#define shf_getc shf_getc_ +#define shf_putc shf_putc_ +#endif int shf_putchar(int, struct shf *); int shf_puts(const char *, struct shf *); int shf_write(const char *, int, struct shf *); diff --git a/shf.c b/shf.c index 06502f3..4e7b46f 100644 --- a/shf.c +++ b/shf.c @@ -24,7 +24,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.41 2011/03/13 01:20:23 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.42 2011/07/16 17:07:35 tg Exp $"); /* flags to shf_emptybuf() */ #define EB_READSW 0x01 /* about to switch to reading */ @@ -1028,14 +1028,12 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args) int shf_getc(struct shf *shf) { - return ((shf)->rnleft > 0 ? (shf)->rnleft--, *(shf)->rp++ : - shf_getchar(shf)); + return (shf_getc_(shf)); } int shf_putc(int c, struct shf *shf) { - return ((shf)->wnleft == 0 ? shf_putchar((c), (shf)) : - ((shf)->wnleft--, *(shf)->wp++ = (c))); + return (shf_putc_(c, shf)); } #endif