toxic: 0.15.1 -> 0.16.0
[NixPkgs.git] / pkgs / development / libraries / aspell / data-dirs-from-nix-profiles.patch
blobc19827ba93e4b305435e50ceb7e61d64d064381d
1 diff --git a/common/info.cpp b/common/info.cpp
2 index 8291cc7..6216326 100644
3 --- a/common/info.cpp
4 +++ b/common/info.cpp
5 @@ -36,6 +36,7 @@
6 #include "strtonum.hpp"
7 #include "lock.hpp"
8 #include "string_map.hpp"
9 +#include "file_util.hpp"
11 #include "gettext.h"
13 @@ -495,6 +496,25 @@ namespace acommon {
14 lst.clear();
15 lst.add(config->retrieve("data-dir"));
16 lst.add(config->retrieve("dict-dir"));
17 + if (config->lookup("data-dir") == NULL && config->lookup("dict-dir") == NULL) {
18 + const char* cprofiles = getenv("NIX_PROFILES");
19 + if (cprofiles != NULL) {
20 + char* profiles = strdup(cprofiles);
21 + char* profile = profiles;
22 + char* end = profile;
23 + while (*end != '\0') {
24 + if (*end == ' ') {
25 + *end = '\0';
26 + lst.add(add_possible_dir(profile, "lib/aspell"));
27 + profile = ++end;
28 + } else {
29 + ++end;
30 + }
31 + }
32 + lst.add(add_possible_dir(profile, "lib/aspell"));
33 + free(profiles);
34 + }
35 + }
38 DictExt::DictExt(ModuleInfo * m, const char * e)