• rewrite code to no longer use statements-as-expressions

• optimise a little
• Build.sh: remove HAVE_EXPSTMT test
• Build.sh, */Makefile: sort tests, regenerate
• mksh.hts: sync clog
This commit is contained in:
tg
2008-10-28 14:32:43 +00:00
parent 5167e7398b
commit 88d7b7d08b
16 changed files with 174 additions and 229 deletions

42
misc.c
View File

@@ -6,7 +6,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.87 2008/10/26 21:51:26 ahoka Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.88 2008/10/28 14:32:42 tg Exp $");
#undef USE_CHVT
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
@@ -63,34 +63,6 @@ initctypes(void)
setctypes(" \n\t\"#$&'()*;<>?[]\\`|", C_QUOTE);
}
#if defined(MKSH_SMALL) || !HAVE_EXPSTMT
char *
str_nsave(const char *s, int n, Area *ap)
{
char *rv = NULL;
if ((n >= 0) && (s != NULL))
strlcpy(rv = alloc(n + 1, ap), s, n + 1);
return (rv);
}
char *
str_save(const char *s, Area *ap)
{
#ifdef MKSH_SMALL
return (s ? str_nsave(s, strlen(s), ap) : NULL);
#else
char *rv = NULL;
if (s != NULL) {
size_t sz = strlen(s) + 1;
strlcpy(rv = alloc(sz, ap), s, sz);
}
return (rv);
#endif
}
#endif
/* called from XcheckN() to grow buffer */
char *
Xcheck_grow_(XString *xsp, const char *xp, unsigned int more)
@@ -230,7 +202,8 @@ getoptions(void)
for (i = 0; i < NELEM(options); i++)
if (options[i].c && Flag(i))
*cp++ = options[i].c;
return (str_nsave_(m, cp - m, ATEMP));
strndupx(cp, m, cp - m, ATEMP);
return (cp);
}
/* change a Flag(*) value; takes care of special actions */
@@ -1449,12 +1422,3 @@ stristr(const char *b, const char *l)
}
#endif
#endif
#if !HAVE_EXPSTMT
bool
ksh_isspace_(unsigned int ksh_isspace_c)
{
return ((ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) ||
(ksh_isspace_c == 0x20));
}
#endif