Subject: some more clean-up

From: "jan.nijtmans" <[email-masked]>
Date: Mon, 5 Sep 2016 14:52:01 +0000

---
 generic/tclCompile.c  | 10 ++++------
 generic/tclEnsemble.c | 10 ++++------
 generic/tclLiteral.c  |  4 +++-
 generic/tclObj.c      | 12 +++++-------
 4 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index ee36bff..f6b3c52 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -1783,17 +1783,15 @@ CompileCmdLiteral(
     int numBytes;
     const char *bytes;
     Command *cmdPtr;
-    int cmdLitIdx, extraLiteralFlags = 0;
+    int cmdLitIdx, extraLiteralFlags = LITERAL_CMD_NAME;
 
     cmdPtr = (Command *) Tcl_GetCommandFromObj(interp, cmdObj);
-    if (cmdPtr != NULL) {
-	if ((cmdPtr->flags & CMD_VIA_RESOLVER)) {
-	    extraLiteralFlags = LITERAL_UNSHARED;
-	}
+    if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
+	extraLiteralFlags |= LITERAL_UNSHARED;
     }
 
     bytes = Tcl_GetStringFromObj(cmdObj, &numBytes);
-    cmdLitIdx = TclRegisterLiteral(envPtr, (char *)bytes, numBytes, extraLiteralFlags|LITERAL_CMD_NAME);
+    cmdLitIdx = TclRegisterLiteral(envPtr, (char *)bytes, numBytes, extraLiteralFlags);
 
     if (cmdPtr) {
 	TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLitIdx), cmdPtr);
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index 67ee65e..6fedf29 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -3306,7 +3306,7 @@ CompileToInvokedCommand(
     Tcl_Token *tokPtr;
     Tcl_Obj *objPtr, **words;
     char *bytes;
-    int length, i, numWords, cmdLit, extraLiteralFlags = 0;
+    int length, i, numWords, cmdLit, extraLiteralFlags = LITERAL_CMD_NAME;
     DefineLineInformation;
 
     /*
@@ -3349,12 +3349,10 @@ CompileToInvokedCommand(
     objPtr = Tcl_NewObj();
     Tcl_GetCommandFullName(interp, (Tcl_Command) cmdPtr, objPtr);
     bytes = Tcl_GetStringFromObj(objPtr, &length);
-    if (cmdPtr != NULL) {
-	if ((cmdPtr->flags & CMD_VIA_RESOLVER)) {
-	    extraLiteralFlags = LITERAL_UNSHARED;
-	}
+    if ((cmdPtr != NULL) && (cmdPtr->flags & CMD_VIA_RESOLVER)) {
+	extraLiteralFlags |= LITERAL_UNSHARED;
     }
-    cmdLit = TclRegisterLiteral(envPtr, (char *)bytes, length, extraLiteralFlags|LITERAL_CMD_NAME);
+    cmdLit = TclRegisterLiteral(envPtr, (char *)bytes, length, extraLiteralFlags);
     TclSetCmdNameObj(interp, TclFetchLiteral(envPtr, cmdLit), cmdPtr);
     TclEmitPush(cmdLit, envPtr);
     TclDecrRefCount(objPtr);
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 484b86b..c329ed7 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -249,7 +249,6 @@ TclCreateLiteral(
 	if (globalPtrPtr != NULL) {
 	    *globalPtrPtr = NULL;
 	}
-	/*fprintf(stderr, "UNSHARED LITERAL <%s>\n", bytes);*/
 	return objPtr;
     }
 
@@ -1167,6 +1166,9 @@ TclVerifyLocalLiteralTable(
 	    if (LookupLiteralEntry((Tcl_Interp *) envPtr->iPtr,
 		    localPtr->objPtr) == NULL) {
 		bytes = Tcl_GetStringFromObj(localPtr->objPtr, &length);
+		Tcl_Panic("%s: local literal \"%.*s\" is not global",
+			"TclVerifyLocalLiteralTable",
+			(length>60? 60 : length), bytes);
 	    }
 	    if (localPtr->objPtr->bytes == NULL) {
 		Tcl_Panic("%s: literal has NULL string rep",
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 661ab48..283c8d2 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -4219,10 +4219,10 @@ TclSetCmdNameObj(
     const char *name;
 
     if (objPtr->typePtr == &tclCmdNameType) {
-        resPtr = objPtr->internalRep.twoPtrValue.ptr1;
-        if (resPtr->cmdPtr == cmdPtr) {
-            return;
-        }
+	resPtr = objPtr->internalRep.twoPtrValue.ptr1;
+	if (resPtr->cmdPtr == cmdPtr) {
+	    return;
+	}
     }
 
     cmdPtr->refCount++;
@@ -4400,9 +4400,7 @@ SetCmdNameFromAny(
 	cmdPtr->refCount++;
 	resPtr = objPtr->internalRep.twoPtrValue.ptr1;
 	if ((objPtr->typePtr == &tclCmdNameType)
-            && resPtr != NULL
-            && (resPtr->refCount == 1)
-            ) {
+		&& resPtr && (resPtr->refCount == 1)) {
 	    /*
 	     * Reuse the old ResolvedCmdName struct instead of freeing it
 	     */
-- 
cgit v0.12