save 1640 .text bytes in MKSH_SMALL case by not inlining strdupx, strndupx
This commit is contained in:
parent
88d7b7d08b
commit
bf3194e937
22
misc.c
22
misc.c
@ -6,7 +6,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.88 2008/10/28 14:32:42 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.89 2008/10/28 14:51:06 tg Exp $");
|
||||
|
||||
#undef USE_CHVT
|
||||
#if defined(TIOCSCTTY) && !defined(MKSH_SMALL)
|
||||
@ -1422,3 +1422,23 @@ stristr(const char *b, const char *l)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
char *
|
||||
strndup_(const char *src, size_t len, Area *ap)
|
||||
{
|
||||
char *dst = NULL;
|
||||
|
||||
if (src != NULL) {
|
||||
dst = alloc(++len, ap);
|
||||
strlcpy(dst, src, len);
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
|
||||
char *
|
||||
strdup_(const char *src, Area *ap)
|
||||
{
|
||||
return (src == NULL ? NULL : strndup_(src, strlen(src), ap));
|
||||
}
|
||||
#endif
|
||||
|
15
sh.h
15
sh.h
@ -100,7 +100,7 @@
|
||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.248 2008/10/28 14:32:42 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.249 2008/10/28 14:51:06 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R36 2008/10/28"
|
||||
|
||||
@ -345,6 +345,14 @@ char *ucstrstr(char *, const char *);
|
||||
(dst) = (src) + utf_ptradjx_len; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
#ifdef MKSH_SMALL
|
||||
#define strdupx(d, s, ap) do { \
|
||||
(d) = strdup_((s), (ap)); \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#define strndupx(d, s, n, ap) do { \
|
||||
(d) = strndup_((s), (n), (ap)); \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#else
|
||||
/* be careful to evaluate arguments only once! */
|
||||
#define strdupx(d, s, ap) do { \
|
||||
const char *strdup_src = (s); \
|
||||
@ -368,6 +376,7 @@ char *ucstrstr(char *, const char *);
|
||||
} \
|
||||
(d) = strdup_dst; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
#endif
|
||||
|
||||
#if HAVE_STRCASESTR
|
||||
#define stristr(b,l) ((const char *)strcasestr((b), (l)))
|
||||
@ -1472,6 +1481,10 @@ int make_path(const char *, const char *, char **, XString *, int *);
|
||||
void simplify_path(char *);
|
||||
char *get_phys_path(const char *);
|
||||
void set_current_wd(char *);
|
||||
#ifdef MKSH_SMALL
|
||||
char *strdup_(const char *, Area *);
|
||||
char *strndup_(const char *, size_t, Area *);
|
||||
#endif
|
||||
/* shf.c */
|
||||
struct shf *shf_open(const char *, int, int, int);
|
||||
struct shf *shf_fdopen(int, int, struct shf *);
|
||||
|
Loading…
Reference in New Issue
Block a user