From fa68b74c218b40476d0c5bac124141c27a00c902 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 16 Sep 2017 13:15:09 +1000 Subject: [PATCH] remove special regexpValue internal rep To avoid an explosion of different internal rep structures, simply use the existing ptrIntValue for jim-regexp Signed-off-by: Steve Bennett --- jim-regexp.c | 16 ++++++++++------ jim.h | 5 ----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/jim-regexp.c b/jim-regexp.c index 8eb457d..771773a 100644 --- a/jim-regexp.c +++ b/jim-regexp.c @@ -58,10 +58,14 @@ static void FreeRegexpInternalRep(Jim_Interp *interp, Jim_Obj *objPtr) { - regfree(objPtr->internalRep.regexpValue.compre); - Jim_Free(objPtr->internalRep.regexpValue.compre); + regfree(objPtr->internalRep.ptrIntValue.ptr); + Jim_Free(objPtr->internalRep.ptrIntValue.ptr); } +/* internal rep is stored in ptrIntvalue + * ptr = compiled regex + * int1 = flags + */ static const Jim_ObjType regexpObjType = { "regexp", FreeRegexpInternalRep, @@ -78,9 +82,9 @@ static regex_t *SetRegexpFromAny(Jim_Interp *interp, Jim_Obj *objPtr, unsigned f /* Check if the object is already an uptodate variable */ if (objPtr->typePtr == ®expObjType && - objPtr->internalRep.regexpValue.compre && objPtr->internalRep.regexpValue.flags == flags) { + objPtr->internalRep.ptrIntValue.ptr && objPtr->internalRep.ptrIntValue.int1 == flags) { /* nothing to do */ - return objPtr->internalRep.regexpValue.compre; + return objPtr->internalRep.ptrIntValue.ptr; } /* Not a regexp or the flags do not match */ @@ -102,8 +106,8 @@ static regex_t *SetRegexpFromAny(Jim_Interp *interp, Jim_Obj *objPtr, unsigned f Jim_FreeIntRep(interp, objPtr); objPtr->typePtr = ®expObjType; - objPtr->internalRep.regexpValue.flags = flags; - objPtr->internalRep.regexpValue.compre = compre; + objPtr->internalRep.ptrIntValue.int1 = flags; + objPtr->internalRep.ptrIntValue.ptr = compre; return compre; } diff --git a/jim.h b/jim.h index 85a6918..65bf7cc 100644 --- a/jim.h +++ b/jim.h @@ -337,11 +337,6 @@ typedef struct Jim_Obj { struct Jim_Obj *varNameObjPtr; struct Jim_Obj *indexObjPtr; } dictSubstValue; - /* Regular expression pattern */ - struct { - void *compre; /* really an allocated (regex_t *) */ - unsigned flags; - } regexpValue; struct { int line; int argc; -- 2.11.4.GIT