addch(ind);
}
+/**
+ * Sets the global cfg variable and restores related state to match the new
+ * cfg.
+ */
+static void setcfg(settings newcfg)
+{
+ cfg = newcfg;
+ /* Synchronize the global function pointers to match the new cfg. */
+ entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
+ namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
+}
+
static void savecurctx(char *path, char *curname, int nextctx)
{
settings tmpcfg = cfg;
}
tmpcfg.curctx = nextctx;
- cfg = tmpcfg;
- /* Restore the global function pointers alongside the cfg. */
- entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
- namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
+ setcfg(tmpcfg);
}
#ifndef NOSSN
r = 'd';
}
+ /* Ensure function pointers are in sync with cfg. */
entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
} else if (r == CONTROL('T')) {
lastdir = g_ctx[r].c_last;
lastname = g_ctx[r].c_name;
- cfg = g_ctx[r].c_cfg;
- /* Restore the global function pointers alongside the cfg. */
- entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
- namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
+ g_ctx[r].c_cfg.curctx = r;
+ setcfg(g_ctx[r].c_cfg);
- cfg.curctx = r;
setdirwatch();
goto begin;
}