1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2010 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "src/language/lexer/include-path.h"
23 #include "data/file-name.h"
24 #include "libpspp/string-array.h"
26 #include "gl/configmake.h"
27 #include "gl/relocatable.h"
28 #include "gl/xvasprintf.h"
30 static struct string_array the_include_path;
31 static struct string_array default_include_path;
33 static void include_path_init__ (void);
36 include_path_clear (void)
38 include_path_init__ ();
39 string_array_clear (&the_include_path);
43 include_path_add (const char *dir)
45 include_path_init__ ();
46 string_array_append (&the_include_path, dir);
50 include_path_search (const char *base_name)
52 return fn_search_path (base_name, include_path ());
55 const struct string_array *
56 include_path_default (void)
58 include_path_init__ ();
59 return &default_include_path;
65 include_path_init__ ();
66 string_array_terminate_null (&the_include_path);
67 return the_include_path.strings;
71 include_path_init__ (void)
80 string_array_init (&the_include_path);
81 string_array_append (&the_include_path, ".");
82 home = getenv ("HOME");
84 string_array_append_nocopy (&the_include_path,
85 xasprintf ("%s/.pspp", home));
86 string_array_append (&the_include_path, relocate (PKGDATADIR));
88 string_array_clone (&default_include_path, &the_include_path);