inline only user of ksh_min, make it more cool; drop ksh_min, ksh_max;

move ksh_isdigit etc. to ksh_isalpha etc. definitions
This commit is contained in:
tg 2015-04-29 19:11:57 +00:00
parent f460677c77
commit 3eb806b72b
2 changed files with 19 additions and 21 deletions

View File

@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.141 2015/04/19 18:50:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.142 2015/04/29 19:11:57 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign;
@ -1234,16 +1234,17 @@ runtrap(Trap *p, bool is_last)
p->set = 0;
if (trapstr == NULL) {
/* SIG_DFL */
if (p->flags & TF_FATAL) {
/* eg, SIGHUP */
exstat = (int)ksh_min(128U + (unsigned)i, 255U);
if (p->flags & (TF_FATAL | TF_DFL_INTR)) {
exstat = (int)(128U + (unsigned)i);
if ((unsigned)exstat > 255U)
exstat = 255;
}
/* e.g. SIGHUP */
if (p->flags & TF_FATAL)
unwind(LLEAVE);
}
if (p->flags & TF_DFL_INTR) {
/* eg, SIGINT, SIGQUIT, SIGTERM, etc. */
exstat = (int)ksh_min(128U + (unsigned)i, 255U);
/* e.g. SIGINT, SIGQUIT, SIGTERM, etc. */
if (p->flags & TF_DFL_INTR)
unwind(LINTR);
}
goto donetrap;
}
if (trapstr[0] == '\0')

21
sh.h
View File

@ -169,7 +169,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.726 2015/04/29 18:38:54 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.727 2015/04/29 19:11:57 tg Exp $");
#endif
#define MKSH_VERSION "R51 2015/04/19"
@ -298,17 +298,6 @@ struct rusage {
} while (/* CONSTCOND */ 0)
#endif
#define ksh_isdigit(c) (((c) >= '0') && ((c) <= '9'))
#define ksh_islower(c) (((c) >= 'a') && ((c) <= 'z'))
#define ksh_isupper(c) (((c) >= 'A') && ((c) <= 'Z'))
#define ksh_tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
#define ksh_toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
#define ksh_isdash(s) (((s)[0] == '-') && ((s)[1] == '\0'))
#define ksh_isspace(c) ((((c) >= 0x09) && ((c) <= 0x0D)) || ((c) == 0x20))
#define ksh_eq(c,u,l) (((c) | 0x20) == (l))
#define ksh_min(x,y) ((x) < (y) ? (x) : (y))
#define ksh_max(x,y) ((x) > (y) ? (x) : (y))
#ifdef MKSH__NO_PATH_MAX
#undef PATH_MAX
#else
@ -937,6 +926,14 @@ extern unsigned char chtypes[];
(chtypes[(unsigned char)(c)] & (t)) )
#define ksh_isalphx(c) ctype((c), C_ALPHA)
#define ksh_isalnux(c) ctype((c), C_ALPHA | C_DIGIT)
#define ksh_isdigit(c) (((c) >= '0') && ((c) <= '9'))
#define ksh_islower(c) (((c) >= 'a') && ((c) <= 'z'))
#define ksh_isupper(c) (((c) >= 'A') && ((c) <= 'Z'))
#define ksh_tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
#define ksh_toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
#define ksh_isdash(s) (((s)[0] == '-') && ((s)[1] == '\0'))
#define ksh_isspace(c) ((((c) >= 0x09) && ((c) <= 0x0D)) || ((c) == 0x20))
#define ksh_eq(c,u,l) (((c) | 0x20) == (l))
EXTERN int ifs0 E_INIT(' '); /* for "$*" */