OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 working directory. | 47 working directory. |
48 */ | 48 */ |
49 Source_file * | 49 Source_file * |
50 Sources::get_file (string file_string, string const ¤t_dir) | 50 Sources::get_file (string file_string, string const ¤t_dir) |
51 { | 51 { |
52 if (file_string != "-") | 52 if (file_string != "-") |
53 { | 53 { |
54 file_string = find_full_path(file_string, current_dir); | 54 file_string = find_full_path(file_string, current_dir); |
55 } | 55 } |
56 | 56 |
| 57 if (file_string.empty ()) |
| 58 { |
| 59 return nullptr; |
| 60 } |
| 61 |
57 Source_file *f = new Source_file (file_string); | 62 Source_file *f = new Source_file (file_string); |
58 add (f); | 63 add (f); |
59 return f; | 64 return f; |
60 } | 65 } |
61 | 66 |
62 string | 67 string |
63 Sources::find_full_path(string file_string, string const ¤t_dir) const | 68 Sources::find_full_path(string file_string, string const ¤t_dir) const |
64 { | 69 { |
65 // First, check for a path relative to the directory of the | 70 // First, check for a path relative to the directory of the |
66 // file currently being parsed. | 71 // file currently being parsed. |
67 if (current_dir.length () | 72 if (current_dir.length () |
68 && file_string.length () | 73 && file_string.length () |
69 && !File_name (file_string).is_absolute () | 74 && !File_name (file_string).is_absolute () |
70 && is_file (current_dir + DIRSEP + file_string)) | 75 && is_file (current_dir + DIRSEP + file_string)) |
71 file_string = current_dir + DIRSEP + file_string; | 76 file_string = current_dir + DIRSEP + file_string; |
72 | 77 |
73 // Otherwise, check the rest of the path. | 78 // Otherwise, check the rest of the path. |
74 else if (path_) | 79 else if (path_) |
75 { | 80 { |
76 string file_string_o = path_->find (file_string); | 81 return path_->find (file_string); |
77 if ((file_string_o == "") && (file_string != "")) | |
78 return 0; | |
79 | |
80 file_string = file_string_o; | |
81 } | 82 } |
82 return file_string; | 83 return file_string; |
83 } | 84 } |
84 | 85 |
85 string Sources::search_path() const { | 86 string Sources::search_path() const { |
86 return path_->to_string(); | 87 return path_->to_string(); |
87 } | 88 } |
88 | 89 |
89 void | 90 void |
90 Sources::add (Source_file *sourcefile) | 91 Sources::add (Source_file *sourcefile) |
(...skipping 27 matching lines...) Expand all Loading... |
118 | 119 |
119 SCM lst = SCM_EOL; | 120 SCM lst = SCM_EOL; |
120 for (vector<string>::const_iterator | 121 for (vector<string>::const_iterator |
121 i = lex->file_name_strings_.begin(); | 122 i = lex->file_name_strings_.begin(); |
122 i != lex->file_name_strings_.end(); ++i) | 123 i != lex->file_name_strings_.end(); ++i) |
123 { | 124 { |
124 lst = scm_cons (ly_string2scm (*i), lst); | 125 lst = scm_cons (ly_string2scm (*i), lst); |
125 } | 126 } |
126 return scm_reverse_x (lst, SCM_EOL); | 127 return scm_reverse_x (lst, SCM_EOL); |
127 } | 128 } |
OLD | NEW |