# # # patch "lua_hooks.cc" # from [63fe915d3ab06723dd4f5efcdc1ef72c17fbd2eb] # to [d1dfa884bd60fb972f699b276bd6f2530edcd864] # # patch "lua_hooks.hh" # from [647093e940b9ce9013f8bd3d3e4660e9018351ba] # to [95318fcba841b387acf518bb214bba667b9220b1] # # patch "selectors.cc" # from [d56d5fcd51a1f321224be53036bc52e18d536061] # to [4dfc19bef7db1186ea36424cb158a578425c690b] # ============================================================ --- lua_hooks.cc 63fe915d3ab06723dd4f5efcdc1ef72c17fbd2eb +++ lua_hooks.cc d1dfa884bd60fb972f699b276bd6f2530edcd864 @@ -203,6 +203,14 @@ lua_hooks::load_rcfile(any_path const & } } +bool +lua_hooks::hook_exists(std::string const & func_name) +{ + return Lua(st) + .func(func_name) + .ok(); +} + // concrete hooks // nb: if you're hooking lua to return your passphrase, you don't care if we ============================================================ --- lua_hooks.hh 647093e940b9ce9013f8bd3d3e4660e9018351ba +++ lua_hooks.hh 95318fcba841b387acf518bb214bba667b9220b1 @@ -40,6 +40,7 @@ public: void default_rcfilename(system_path & file); void load_rcfile(utf8 const & file); void load_rcfile(any_path const & file, bool required); + bool hook_exists(std::string const & func_name); // cert hooks bool hook_expand_selector(std::string const & sel, std::string & exp); ============================================================ --- selectors.cc d56d5fcd51a1f321224be53036bc52e18d536061 +++ selectors.cc 4dfc19bef7db1186ea36424cb158a578425c690b @@ -87,14 +87,29 @@ namespace selectors /* a selector date-related should be validated */ if (sel_date==type || sel_later==type || sel_earlier==type) { - N (app.lua.hook_expand_date(sel, tmp), - F ("selector '%s' is not a valid date\n") % sel); + if (app.lua.hook_exists("expand_date")) + { + N(app.lua.hook_expand_date(sel, tmp), + F("selector '%s' is not a valid date\n") % sel); + } + else + { + // if expand_date is not available, start with something + tmp = sel; + } + // if we still have a too short datetime string, expand it with + // default values, but only if the type is earlier or later; + // for searching a specific date cert this makes no sense + // FIXME: this is highly speculative if expand_date wasn't called + // beforehand - tmp could be _anything_ but a partial date string if (tmp.size()<8 && (sel_later==type || sel_earlier==type)) tmp += "-01T00:00:00"; else if (tmp.size()<11 && (sel_later==type || sel_earlier==type)) tmp += "T00:00:00"; - N(tmp.size()==19 || sel_date==type, F ("selector '%s' is not a valid date (%s)") % sel % tmp); + N(tmp.size()==19 || sel_date==type, + F("selector '%s' is not a valid date (%s)") % sel % tmp); + if (sel != tmp) { P (F ("expanded date '%s' -> '%s'\n") % sel % tmp);