600 bytes more for the small version aren't worth it; it looks
as if there are not many NULL pointers to be optimised away
This commit is contained in:
parent
b6236be77a
commit
06b83a8df8
36
misc.c
36
misc.c
|
@ -6,7 +6,7 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.81 2008/07/12 17:23:00 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.82 2008/07/12 17:47:21 tg Exp $");
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||||
|
@ -63,34 +63,26 @@ initctypes(void)
|
||||||
setctypes(" \n\t\"#$&'()*;<>?[]\\`|", C_QUOTE);
|
setctypes(" \n\t\"#$&'()*;<>?[]\\`|", C_QUOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MKSH_SMALL
|
#if defined(MKSH_SMALL) || !HAVE_EXPSTMT
|
||||||
char *
|
char *
|
||||||
str_save_s(const char *s, Area *ap)
|
str_save(const char *s, Area *ap)
|
||||||
{
|
|
||||||
char *rv;
|
|
||||||
size_t sz;
|
|
||||||
|
|
||||||
sz = strlen(s) + 1;
|
|
||||||
strlcpy(rv = alloc(sz, ap), s, sz);
|
|
||||||
return (rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
str_nsave_s(const char *s, int n, Area *ap)
|
|
||||||
{
|
{
|
||||||
char *rv = NULL;
|
char *rv = NULL;
|
||||||
|
|
||||||
if (n >= 0)
|
if (s != NULL) {
|
||||||
strlcpy(rv = alloc(n + 1, ap), s, n + 1);
|
size_t sz = strlen(s) + 1;
|
||||||
|
strlcpy(rv = alloc(sz, ap), s, sz);
|
||||||
|
}
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
#elif !HAVE_EXPSTMT
|
|
||||||
char *
|
|
||||||
str_nsave_ns(const char *s, unsigned int sz, Area *ap)
|
|
||||||
{
|
|
||||||
char *rv;
|
|
||||||
|
|
||||||
strlcpy(rv = alloc(sz, ap), s, sz);
|
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);
|
return (rv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
34
sh.h
34
sh.h
|
@ -100,7 +100,7 @@
|
||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.225 2008/07/12 17:23:00 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.226 2008/07/12 17:47:21 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R35 2008/07/10"
|
#define MKSH_VERSION "R35 2008/07/10"
|
||||||
|
|
||||||
|
@ -1422,28 +1422,20 @@ struct tbl **ktsort(struct table *);
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
void setctypes(const char *, int);
|
void setctypes(const char *, int);
|
||||||
void initctypes(void);
|
void initctypes(void);
|
||||||
#ifdef MKSH_SMALL
|
#if defined(MKSH_SMALL) || !HAVE_EXPSTMT
|
||||||
#define str_save(s,ap) ((s) ? str_save_s((s), (ap)) : NULL)
|
char *str_save(const char *, Area *);
|
||||||
#define str_nsave(s,n,ap) ((s) ? str_nsave_s((s), (n), (ap)) : NULL)
|
char *str_nsave(const char *, int, Area *);
|
||||||
char *str_save_s(const char *, Area *);
|
|
||||||
char *str_nsave_s(const char *, int, Area *);
|
|
||||||
#else
|
#else
|
||||||
#if HAVE_EXPSTMT
|
#define str_nsave_(s,n,ap) ({ \
|
||||||
#define str_nsave_ns(s,sz,ap) ({ \
|
size_t str_save_sz = (n) + 1; \
|
||||||
unsigned int str_nsave_ns_sz = (sz); \
|
char *str_save_rv = alloc(str_save_sz, (ap)); \
|
||||||
char *str_nsave_ns_rv = alloc(str_nsave_ns_sz, (ap)); \
|
strlcpy(str_save_rv, (s), str_save_sz); \
|
||||||
strlcpy(str_nsave_ns_rv, (s), str_nsave_ns_sz); \
|
(str_save_rv); \
|
||||||
(str_nsave_ns_rv); \
|
|
||||||
})
|
})
|
||||||
#else
|
#define str_save(s,ap) \
|
||||||
char *str_nsave_ns(const char *, unsigned int, Area *);
|
(!(s) ? NULL : str_nsave_((s), strlen(s), (ap)))
|
||||||
#endif
|
#define str_nsave(s,n,ap) \
|
||||||
#define str_save(s,ap) ((s) \
|
(!(s) || (n) < 0 ? NULL : str_nsave_((s), (n), (ap)))
|
||||||
? str_nsave_ns((s), strlen(s) + 1, (ap)) \
|
|
||||||
: NULL)
|
|
||||||
#define str_nsave(s,n,ap) (((s) && ((n) >= 0)) \
|
|
||||||
? str_nsave_ns((s), (n) + 1, (ap)) \
|
|
||||||
: NULL)
|
|
||||||
#endif
|
#endif
|
||||||
size_t option(const char *);
|
size_t option(const char *);
|
||||||
char *getoptions(void);
|
char *getoptions(void);
|
||||||
|
|
Loading…
Reference in New Issue