diff --git a/src/lib66/tree/tree_sethome.c b/src/lib66/tree/tree_sethome.c index 38c8fcef0ee46ad7a5d45ff428fed3ff0e9c0f81..cb547f91ce5f944a19b17790b419743c426decc4 100644 --- a/src/lib66/tree/tree_sethome.c +++ b/src/lib66/tree/tree_sethome.c @@ -36,13 +36,15 @@ int tree_sethome(ssexec_t *info) int r ; - if (!info->treename.len) { + if (!info->opt_tree) { - if (!tree_find_current(&info->tree, base)) + if (!tree_find_current(&info->tree, base)) { /** no current tree found. Use the default one. */ + info->tree.len = 0 ; if (!auto_stra(&info->tree, base, SS_SYSTEM, "/", SS_DEFAULT_TREENAME)) return 0 ; - + } + info->treename.len = 0 ; if (!tree_setname(&info->treename, info->tree.s)) return -2 ; @@ -57,17 +59,18 @@ int tree_sethome(ssexec_t *info) return 0 ; } else if (!r) { + /** Tree doesn't exist yet. * Let see if we have a seed file to create it */ - if (!tree_seed_isvalid(info->treename.s)) log_warnu_return(LOG_EXIT_ZERO,"find a seed file to create the tree: ", info->treename.s) ; - int nargc = 3 ; + int nargc = 4 ; char const *newargv[nargc] ; unsigned int m = 0 ; - newargv[m++] = "66 tree" ; + newargv[m++] = "66" ; + newargv[m++] = "tree" ; newargv[m++] = info->treename.s ; newargv[m++] = 0 ; @@ -77,6 +80,7 @@ int tree_sethome(ssexec_t *info) log_warnu_return(LOG_EXIT_ZERO,"create tree: ",info->treename.s) ; PROG = prog ; } + /** The tree_sethome() function can be recursively called. The info->tree may not be empty. * Be sure to clean up before using it. */ info->tree.len = 0 ;