aboutsummaryrefslogtreecommitdiff
path: root/libbutl/default-options.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-08-05 11:20:30 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-08-05 12:14:19 +0300
commit1cdb233cedd12069a4aa5d761e20b42e842ec58f (patch)
tree9f8a50e9e6876f5cd03eb662db949d7b7a67eeb2 /libbutl/default-options.cxx
parent060bb0b8ca44affa817600f21caa33cf54d5ecad (diff)
Convert default_options_start() to template function which accepts iterators range
Diffstat (limited to 'libbutl/default-options.cxx')
-rw-r--r--libbutl/default-options.cxx73
1 files changed, 0 insertions, 73 deletions
diff --git a/libbutl/default-options.cxx b/libbutl/default-options.cxx
deleted file mode 100644
index 28f6fb7..0000000
--- a/libbutl/default-options.cxx
+++ /dev/null
@@ -1,73 +0,0 @@
-// file : libbutl/default-options.cxx -*- C++ -*-
-// license : MIT; see accompanying LICENSE file
-
-#ifndef __cpp_modules_ts
-#include <libbutl/default-options.mxx>
-#endif
-
-#include <cassert>
-
-#ifndef __cpp_lib_modules_ts
-#include <vector>
-#endif
-
-// Other includes.
-
-#ifdef __cpp_modules_ts
-module butl.default_options;
-
-// Only imports additional to interface.
-#ifdef __clang__
-#ifdef __cpp_lib_modules_ts
-import std.core;
-#endif
-import butl.path;
-import butl.optional;
-import butl.small_vector;
-#endif
-
-#endif
-
-using namespace std;
-
-namespace butl
-{
- optional<dir_path>
- default_options_start (const optional<dir_path>& home,
- const vector<dir_path>& dirs)
- {
- if (home)
- assert (home->absolute () && home->normalized ());
-
- if (dirs.empty ())
- return nullopt;
-
- // Use the first directory as a start.
- //
- auto i (dirs.begin ());
- dir_path d (*i);
-
- // Try to find a common prefix for each subsequent directory.
- //
- for (++i; i != dirs.end (); ++i)
- {
- bool p (false);
-
- for (;
- !(d.root () || (home && d == *home));
- d = d.directory ())
- {
- if (i->sub (d))
- {
- p = true;
- break;
- }
- }
-
- if (!p)
- return nullopt;
- }
-
- return d;
- }
-}