Never forget to uncomment a fix that was commented for testing :P
[openttd-joker.git] / media / extra_grf / assemble_nfo.awk
blobcf6b425c1d8817d302e2a63e58ad17a0a361d117
1 # $Id$
3 # This file is part of OpenTTD.
4 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
5 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 BEGIN {
9 # Very basic variant function; barely any error checking.
10 # Just use the first argument as the file to start from when assembling everything
11 path = ARGV[1];
12 gsub("[^/\\\\]*$", "", path);
13 assemble(ARGV[1]);
16 # Recursive function for assembling by means of resolving the #includes.
17 function assemble(filename) {
18 while ((getline < filename) > 0) {
19 if (NF == 2 && $1 == "#include" ) {
20 # Remove the quotes.
21 gsub("[\"'<>]", "", $2);
22 assemble(path $2);
23 } else {
24 print $0;
28 if (close(filename) < 0) {
29 print "Could not open " filename > "/dev/stderr";
30 exit -1;