From 1d4d238577cd0bc69478385c3604e36da207f44d Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 26 May 2022 13:22:12 +0200 Subject: [PATCH] Rename func to keyfunc --- src/builtins/path.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/builtins/path.cpp b/src/builtins/path.cpp index 5e09cbcfa..c220bec4f 100644 --- a/src/builtins/path.cpp +++ b/src/builtins/path.cpp @@ -723,14 +723,14 @@ static int path_sort(parser_t &parser, io_streams_t &streams, int argc, const wc int retval = parse_opts(&opts, &optind, 0, argc, argv, parser, streams); if (retval != STATUS_CMD_OK) return retval; - auto func = +[] (const wcstring &x) { + auto keyfunc = +[] (const wcstring &x) { return wbasename(x); }; if (opts.have_key) { if (std::wcscmp(opts.key, L"basename") == 0) { // Do nothing, this is the default } else if (std::wcscmp(opts.key, L"dirname") == 0) { - func = +[] (const wcstring &x) { + keyfunc = +[] (const wcstring &x) { return wdirname(x); }; } else if (std::wcscmp(opts.key, L"path") == 0) { @@ -749,10 +749,10 @@ static int path_sort(parser_t &parser, io_streams_t &streams, int argc, const wc } if (opts.have_key) { - // Keep a map to avoid repeated func calls and to keep things alive. - std::map funced; + // Keep a map to avoid repeated keyfunc calls and to keep things alive. + std::map key; for (const auto &arg : list) { - funced[arg] = func(arg); + key[arg] = keyfunc(arg); } // We use a stable sort here, and also explicit < and >, @@ -760,14 +760,14 @@ static int path_sort(parser_t &parser, io_streams_t &streams, int argc, const wc std::stable_sort(list.begin(), list.end(), [&](const wcstring &a, const wcstring &b) { if (!opts.invert) - return (wcsfilecmp_glob(funced[a].c_str(), funced[b].c_str()) < 0); + return (wcsfilecmp_glob(key[a].c_str(), key[b].c_str()) < 0); else - return (wcsfilecmp_glob(funced[a].c_str(), funced[b].c_str()) > 0); + return (wcsfilecmp_glob(key[a].c_str(), key[b].c_str()) > 0); }); if (opts.unique) { list.erase(std::unique(list.begin(), list.end(), [&](const wcstring &a, const wcstring &b) { - return funced[a] == funced[b]; + return key[a] == key[b]; }), list.end()); }