From 83c1c0116fc03c0b90ebd6aaa580cb579cf84a51 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Fri, 4 Mar 2005 10:06:05 +0000 Subject: Use command line vars in the Makefile. Make const quiet with gcc -Wwrite-strings Fixed macro usage in COM extension that gcc doesn't like. --- Makefile | 42 +++++++++++++++++++++++++++++------------- jim-win32com.c | 15 ++++++++------- jim.c | 34 +++++++++++++++++----------------- jim.h | 2 +- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 4ad9319..fc4d86d 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,33 @@ +# Jim makefile +# +# This is a simple Makefile as it is expected that most users are likely +# to embed Jim directly into their current build system. Jim is able to +# make use of dynamically loaded extensions on unix provided you have the +# dl library available. If not, set JIM_LIBS= on the make command line. +# +# make CC=gcc jim builds a standard Jim binary using gcc. +# make CC=gcc LIBS= jim avoids attempts to link in libdl.a +# +# + .SUFFIXES: .SUFFIXES: .c .so .xo .o .dll -SHELL= /bin/sh -LD= ld -LDFLAGS= $(PROFILE) -CFLAGS= -Wall -W -O2 -g $(PROFILE) -AR=/usr/bin/ar -RANLIB=/usr/bin/ranlib -LIBPATH=-L. -INSTALL= /usr/bin/install +SHELL = /bin/sh +RM = rm -f +LDFLAGS = $(PROFILE) +CFLAGS = -Wall -Wwrite-strings -W -O2 -g $(PROFILE) +AR = /usr/bin/ar +RANLIB = /usr/bin/ranlib +LIBPATH =-L. +INSTALL = /usr/bin/install INSTALL_PROGRAM= $(INSTALL) INSTALL_DATA= $(INSTALL) -m 644 -DESTDIR= /usr/local/bin/ +DESTDIR = /usr/local/bin/ -PROGRAMS= jim -JIM_OBJECTS= jim.o jimsh.o +PROGRAMS = jim +JIM_OBJECTS = jim.o jimsh.o +LIBS = -ldl stopit: @echo "Use:" @@ -44,14 +57,14 @@ jim-win32com.dll: jim-win32com.o $(CC) -shared -o $@ $< -lole32 -luuid -loleaut32 jim: $(JIM_OBJECTS) - $(CC) $(LDFLAGS) -o jim $(JIM_OBJECTS) -ldl + $(CC) $(LDFLAGS) -o jim $(JIM_OBJECTS) $(LIBS) posix: jim-posix.so win32: jim-win32.dll jim-win32com.dll extensions: posix clean: - rm -f *.o *.so *.dll core .depend .*.swp gmon.out $(PROGRAMS) + $(RM) *.o *.so *.dll core .depend .*.swp gmon.out $(PROGRAMS) test: jim ./jim test.tcl @@ -63,6 +76,9 @@ bench: jim dep: gcc -MM *.[ch] 2> /dev/null +TAGS: jim.h jim.c jim-posix.c jim-win32.c jim-win32com.c + etags -o $@ $^ + wc: wc -l jim.[ch] wc -l *.[ch] diff --git a/jim-win32com.c b/jim-win32com.c index 822aa4f..6b97aaa 100644 --- a/jim-win32com.c +++ b/jim-win32com.c @@ -160,7 +160,7 @@ UnicodeDupInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr) { int len = srcPtr->internalRep.binaryValue.len; JIM_TRACE("UnicodeDupInternalRep 0x%08x duped into 0x%08x\n", (DWORD)srcPtr, (DWORD)dupPtr); - interp; + interp = interp; dupPtr->internalRep.binaryValue.len = len; if (srcPtr->internalRep.binaryValue.data != NULL) { dupPtr->internalRep.binaryValue.data = Jim_Alloc(sizeof(WCHAR) * (len + 1)); @@ -191,11 +191,11 @@ UnicodeSetFromAny(Jim_Interp *interp, Jim_Obj *objPtr) } Jim_Obj * -Jim_NewUnicodeObj(Jim_Interp *interp, LPCWSTR wsz, size_t len) +Jim_NewUnicodeObj(Jim_Interp *interp, LPCWSTR wsz, int len) { Jim_Obj *objPtr; JIM_ASSERT(wsz != NULL); - if (wsz != NULL && len == -1) + if (wsz != NULL && len < 0) len = wcslen(wsz); if (wsz == NULL || len == 0) { objPtr = Jim_NewStringObj(interp, "", 0); @@ -224,7 +224,7 @@ Jim_GetUnicode(Jim_Obj *objPtr, int *lenPtr) objPtr->typePtr->name); } } - + *lenPtr = objPtr->internalRep.binaryValue.len; return (LPWSTR)objPtr->internalRep.binaryValue.data; } @@ -247,7 +247,6 @@ Jim_ObjType ole32ObjType = { void Ole32FreeInternalRep(Jim_Interp *interp, Jim_Obj *objPtr) { - int r = JIM_OK; IDispatch *p = Ole32_DispatchPtr(objPtr); ITypeInfo *t = Ole32_TypeInfoPtr(objPtr); JIM_TRACE("free ole32 object 0x%08x\n", (unsigned long)p); @@ -441,7 +440,7 @@ Jim_NewOle32Obj(Jim_Interp *interp, LPDISPATCH pdispatch) Jim_Obj *objPtr = Jim_NewObj(interp); objPtr->bytes = Jim_Alloc(23); - sprintf(objPtr->bytes, "ole32:%08x", (unsigned long)pdispatch); + sprintf(objPtr->bytes, "ole32:%08lx", (unsigned long)pdispatch); objPtr->length = strlen(objPtr->bytes); Ole32_DispatchPtr(objPtr) = pdispatch; Ole32_TypeInfoPtr(objPtr) = NULL; @@ -449,7 +448,9 @@ Jim_NewOle32Obj(Jim_Interp *interp, LPDISPATCH pdispatch) pdispatch->lpVtbl->GetTypeInfoCount(pdispatch, &n); if (n != 0) - pdispatch->lpVtbl->GetTypeInfo(pdispatch, 0, LOCALE_SYSTEM_DEFAULT, &Ole32_TypeInfoPtr(objPtr)); + pdispatch->lpVtbl->GetTypeInfo(pdispatch, 0, LOCALE_SYSTEM_DEFAULT, + (LPTYPEINFO*)&objPtr->internalRep.twoPtrValue.ptr2); +/* &(Ole32_TypeInfoPtr(objPtr)));*/ objPtr->typePtr = &ole32ObjType; diff --git a/jim.c b/jim.c index 7adc06e..5410319 100644 --- a/jim.c +++ b/jim.c @@ -51,7 +51,7 @@ /* A shared empty string for the objects string representation. * Jim_InvalidateStringRep knows about it and don't try to free. */ -static char *JimEmptyStringRep = ""; +static char *JimEmptyStringRep = (char *)""; /* ----------------------------------------------------------------------------- * Required prototypes of not exported functions @@ -916,11 +916,11 @@ int testHashTable(void) int i; Jim_InitHashTable(&t, &JimStringCopyHashTableType, NULL); - Jim_AddHashEntry(&t, "foo", "bar"); - Jim_AddHashEntry(&t, "ciao", "foobar"); - Jim_AddHashEntry(&t, "a", "1"); - Jim_AddHashEntry(&t, "b", "2"); - Jim_AddHashEntry(&t, "c", "3"); + Jim_AddHashEntry(&t, "foo", (void*)"bar"); + Jim_AddHashEntry(&t, "ciao", (void*)"foobar"); + Jim_AddHashEntry(&t, "a", (void*)"1"); + Jim_AddHashEntry(&t, "b", (void*)"2"); + Jim_AddHashEntry(&t, "c", (void*)"3"); printf("Used: %d, Size: %d\n", t.used, t.size); iterator = Jim_GetHashTableIterator(&t); @@ -2868,7 +2868,7 @@ int Jim_SetVariable(Jim_Interp *interp, Jim_Obj *nameObjPtr, Jim_Obj *valObjPtr) return JIM_OK; } -int Jim_SetVariableString(Jim_Interp *interp, char *name, char *val) +int Jim_SetVariableString(Jim_Interp *interp, const char *name, const char *val) { Jim_Obj *nameObjPtr, *valObjPtr; int result; @@ -2966,7 +2966,7 @@ Jim_Obj *Jim_GetVariable(Jim_Interp *interp, Jim_Obj *nameObjPtr, int flags) } } -Jim_Obj *Jim_GetVariableString(Jim_Interp *interp, char *name, int flags) +Jim_Obj *Jim_GetVariableString(Jim_Interp *interp, const char *name, int flags) { Jim_Obj *nameObjPtr, *varObjPtr; @@ -3702,7 +3702,7 @@ void Jim_FreeInterp(Jim_Interp *i) printf("\n-------------------------------------\n"); printf("Objects still in the free list:\n"); while(objPtr) { - char *type = objPtr->typePtr ? + const char *type = objPtr->typePtr ? objPtr->typePtr->name : ""; printf("%p \"%-10s\": '%.20s' (refCount: %d)\n", objPtr, type, @@ -3812,7 +3812,7 @@ static void JimResetStackTrace(Jim_Interp *interp) } static void JimAppendStackTrace(Jim_Interp *interp, const char *procname, - char *filename, int linenr) + const char *filename, int linenr) { if (Jim_IsShared(interp->stackTrace)) { interp->stackTrace = @@ -5139,7 +5139,7 @@ static int JimParseExprIrrational(struct JimParserCtx *pc); /* Operators table */ typedef struct Jim_ExprOperator { - char *name; + const char *name; int precedence; int arity; int opcode; @@ -5347,7 +5347,7 @@ int JimParseExprOperator(struct JimParserCtx *pc) /* Try to get the longest match. */ for (i = 0; i < (signed)JIM_EXPR_OPERATORS_NUM; i++) { - char *opname = Jim_ExprOperators[i].name; + const char *opname = Jim_ExprOperators[i].name; int oplen = strlen(opname); if (strncmp(opname, pc->p, oplen) == 0 && oplen > bestLen) { @@ -7735,7 +7735,7 @@ static int Jim_DebugCoreCommand(Jim_Interp *interp, int argc, listObjPtr = Jim_NewListObj(interp, NULL, 0); while (objPtr) { char buf[128]; - char *type = objPtr->typePtr ? + const char *type = objPtr->typePtr ? objPtr->typePtr->name : ""; subListObjPtr = Jim_NewListObj(interp, NULL, 0); sprintf(buf, "%p", objPtr); @@ -8211,7 +8211,7 @@ static int Jim_TimeCoreCommand(Jim_Interp *interp, int argc, long i, count = 1; jim_wide start, elapsed; char buf [256]; - char *fmt = "%" JIM_WIDE_MODIFIER " microseconds per iteration"; + const char *fmt = "%" JIM_WIDE_MODIFIER " microseconds per iteration"; if (argc < 2) { Jim_WrongNumArgs(interp, 1, argv, "script ?count?"); @@ -8581,7 +8581,7 @@ static int Jim_SplitCoreCommand(Jim_Interp *interp, int argc, } static struct { - char *name; + const char *name; Jim_CmdProc cmdProc; } Jim_CoreCommandsTable[] = { {"set", Jim_SetCoreCommand}, @@ -8633,7 +8633,7 @@ static struct { /* Some Jim core command is actually a procedure written in Jim itself. */ static void Jim_RegisterCoreProcedures(Jim_Interp *interp) { - Jim_Eval(interp, + Jim_Eval(interp, (char*) "proc lambda {arglist body} {\n" " set name [ref {} function lambdaFinalizer]\n" " proc $name $arglist $body\n" @@ -8679,7 +8679,7 @@ int test_parser(char *filename, int parsetype) JimParserInit(&parser, prg, 1); while(!JimParserEof(&parser)) { - char *type = "", *tok; + const char *type = "", *tok; int len, retval = 0; if (parsetype == 0) retval = JimParseScript(&parser); diff --git a/jim.h b/jim.h index ab9541c..dde4bd8 100644 --- a/jim.h +++ b/jim.h @@ -322,7 +322,7 @@ typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp, typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr); typedef struct Jim_ObjType { - char *name; /* The name of the type. */ + const char *name; /* The name of the type. */ Jim_FreeInternalRepProc *freeIntRepProc; Jim_DupInternalRepProc *dupIntRepProc; Jim_UpdateStringProc *updateStringProc; -- cgit v1.1