From 47f9ea83d7637cd1304acfbdd9ed02a18d5755cc Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 12 Sep 2011 13:13:46 +1000 Subject: Trim the size of the boostrap jimsh source By removing comments and some large blocks of unnecessary code Signed-off-by: Steve Bennett --- jim-aio.c | 20 ++++++++++---------- jim.c | 9 ++++++--- jimregexp.c | 5 ++--- make-bootstrap-jim | 13 ++++++++++--- tests/Makefile | 2 +- utf8.c | 4 ++-- utf8.h | 4 ++-- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/jim-aio.c b/jim-aio.c index c5758db..5f35fb3 100644 --- a/jim-aio.c +++ b/jim-aio.c @@ -76,7 +76,7 @@ #endif #endif -#ifndef JIM_ANSIC +#if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) union sockaddr_any { struct sockaddr sa; struct sockaddr_in sin; @@ -95,7 +95,7 @@ const char *inet_ntop(int af, const void *src, char *dst, int size) return dst; } #endif -#endif +#endif /* JIM_BOOTSTRAP */ typedef struct AioFile { @@ -117,7 +117,7 @@ typedef struct AioFile static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv); -#ifndef JIM_ANSIC +#if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) static int JimParseIPv6Address(Jim_Interp *interp, const char *hostport, union sockaddr_any *sa, int *salen) { #if IPV6 @@ -259,7 +259,7 @@ static int JimParseDomainAddress(Jim_Interp *interp, const char *path, struct so return JIM_OK; } #endif -#endif +#endif /* JIM_BOOTSTRAP */ static void JimAioSetError(Jim_Interp *interp, Jim_Obj *name) { @@ -503,7 +503,7 @@ static int aio_cmd_puts(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_ERR; } -#ifndef JIM_ANSIC +#if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) static int aio_cmd_recvfrom(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { AioFile *af = Jim_CmdPrivData(interp); @@ -639,7 +639,7 @@ static int aio_cmd_listen(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } -#endif +#endif /* JIM_BOOTSTRAP */ static int aio_cmd_flush(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { @@ -873,7 +873,7 @@ static const jim_subcmd_type aio_command_table[] = { .maxargs = 2, .description = "Write the string, with newline unless -nonewline" }, -#ifndef JIM_ANSIC +#if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) { .cmd = "recvfrom", .args = "len ?addrvar?", .function = aio_cmd_recvfrom, @@ -899,7 +899,7 @@ static const jim_subcmd_type aio_command_table[] = { .maxargs = 1, .description = "Set the listen backlog for server socket" }, -#endif +#endif /* JIM_BOOTSTRAP */ { .cmd = "flush", .function = aio_cmd_flush, .description = "Flush the stream" @@ -1050,7 +1050,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc, return JIM_OK; } -#ifndef JIM_ANSIC +#if !defined(JIM_ANSIC) && !defined(JIM_BOOTSTRAP) /** * Creates a channel for fd. @@ -1353,7 +1353,7 @@ static int JimAioSockCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JimMakeChannel(interp, argv[1], hdlfmt, sock, family, mode); } -#endif +#endif /* JIM_BOOTSTRAP */ FILE *Jim_AioFilehandle(Jim_Interp *interp, Jim_Obj *command) { diff --git a/jim.c b/jim.c index 5bfc0e5..353151a 100644 --- a/jim.c +++ b/jim.c @@ -4776,11 +4776,12 @@ static const Jim_HashTableType JimRefMarkHashTableType = { /* Performs the garbage collection. */ int Jim_Collect(Jim_Interp *interp) { + int collected = 0; +#ifndef JIM_BOOTSTRAP Jim_HashTable marks; Jim_HashTableIterator *htiter; Jim_HashEntry *he; Jim_Obj *objPtr; - int collected = 0; /* Avoid recursive calls */ if (interp->lastCollectId == -1) { @@ -4905,6 +4906,7 @@ int Jim_Collect(Jim_Interp *interp) Jim_FreeHashTable(&marks); interp->lastCollectId = interp->referenceNextId; interp->lastCollectTime = time(NULL); +#endif /* JIM_BOOTSTRAP */ return collected; } @@ -12046,7 +12048,7 @@ static int Jim_AppendCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *a /* [debug] */ static int Jim_DebugCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { -#ifdef JIM_DEBUG_COMMAND +#if defined(JIM_DEBUG_COMMAND) && !defined(JIM_BOOTSTRAP) static const char * const options[] = { "refcount", "objcount", "objects", "invstr", "scriptlen", "exprlen", "exprbc", "show", @@ -12247,7 +12249,8 @@ static int Jim_DebugCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *ar return JIM_ERR; } /* unreached */ -#else +#endif /* JIM_BOOTSTRAP */ +#if !defined(JIM_DEBUG_COMMAND) Jim_SetResultString(interp, "unsupported", -1); return JIM_ERR; #endif diff --git a/jimregexp.c b/jimregexp.c index b138cb1..4b30efa 100644 --- a/jimregexp.c +++ b/jimregexp.c @@ -1340,7 +1340,6 @@ static int regmatch(regex_t *preg, int prog) int c; #ifdef DEBUG if (regnarrate) { - //fprintf(stderr, "%s...\n", regprop(scan)); fprintf(stderr, "%3d: %s...\n", scan, regprop(OP(preg, scan))); /* Where, what. */ } #endif @@ -1568,7 +1567,7 @@ static int regnext(regex_t *preg, int p ) return(p+offset); } -#ifdef DEBUG +#if defined(DEBUG) && !defined(JIM_BOOTSTRAP) /* - regdump - dump a regexp onto stdout in vaguely comprehensible form @@ -1712,7 +1711,7 @@ static const char *regprop( int op ) return(buf); } } -#endif +#endif /* JIM_BOOTSTRAP */ size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) { diff --git a/make-bootstrap-jim b/make-bootstrap-jim index fb6de59..cc2cd5d 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -77,9 +77,16 @@ cat <