From ef6d52c15295a03e343a1ffc12452f7900bb94cd Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 3 Mar 2010 15:47:14 +1000 Subject: Fix unexpected change in list order Need to create string rep of list before converting in case it needs to be converted back, thus not losing order Signed-off-by: Steve Bennett --- jim.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'jim.c') diff --git a/jim.c b/jim.c index 02a7d92..6fb67e2 100644 --- a/jim.c +++ b/jim.c @@ -5904,9 +5904,14 @@ static int SetDictFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr) const char *str; int i, strLen; + /* Get the string representation. Do this first so we don't + * change order in case of fast conversion to dict + */ + str = Jim_GetString(objPtr, &strLen); + #ifdef JIM_OPTIMIZATION - /* If the object is of type "list" we can use - * a specialized version + /* If the object is of type "list" with a string rep, we can use + * a specialized version. */ if (Jim_IsList(objPtr)) { if (SetDictFromList(interp, objPtr) != JIM_OK) { @@ -5916,9 +5921,6 @@ static int SetDictFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr) } #endif - /* Get the string representation */ - str = Jim_GetString(objPtr, &strLen); - /* Free the old internal repr just now and initialize the * new one just now. The string->list conversion can't fail. */ Jim_FreeIntRep(interp, objPtr); -- cgit v1.1