diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-03-03 15:47:14 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:48 +1000 |
commit | ef6d52c15295a03e343a1ffc12452f7900bb94cd (patch) | |
tree | 3a802c37c2e470f28c982f256b427b8c66b5b98d | |
parent | 749b69330051cdfa0d009c41604472427aaebcd4 (diff) | |
download | jimtcl-ef6d52c15295a03e343a1ffc12452f7900bb94cd.zip jimtcl-ef6d52c15295a03e343a1ffc12452f7900bb94cd.tar.gz jimtcl-ef6d52c15295a03e343a1ffc12452f7900bb94cd.tar.bz2 |
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 <steveb@workware.net.au>
-rw-r--r-- | jim.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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); |