annotate src/depend/depend.cpp @ 12216:08028442797f draft

(svn r16630) -Fix (r16629): forgot a continue
author glx <glx@openttd.org>
date Tue, 23 Jun 2009 00:04:37 +0000
parents c9a5d02546e4
children bc7926153e19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
1 /* $Id$ */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
2
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
3 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
4 * @file depend/depend.cpp Custom implementation of Makedepend.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
5 *
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
6 * We previously used makedepend, but that could not handle the amount of
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
7 * files we have and does not handle conditional includes in a sane manner.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
8 * This caused many link problems because not enough files were recompiled.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
9 * This has lead to the development of our own dependency generator. It is
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
10 * meant to be a substitute to the (relatively slow) dependency generation
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
11 * via gcc. It thus helps speeding up compilation. It will also ignore
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
12 * system headers making it less error prone when system headers are moved
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
13 * or renamed.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
14 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
15
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
16 #include <stdio.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
17 #include <stdlib.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
18 #include <string.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
19 #include <ctype.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
20 #include <limits.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
21 #include <unistd.h>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
22 #include <map>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
23 #include <set>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
24 #include <stack>
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
25
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
26 /** Simple string comparator using strcmp as implementation */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
27 struct StringCompare {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
28 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
29 * Compare a to b using strcmp.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
30 * @param a string to compare.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
31 * @param b string to compare.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
32 * @return whether a is less than b.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
33 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
34 bool operator () (const char *a, const char *b) const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
35 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
36 return strcmp(a, b) < 0;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
37 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
38 };
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
39 /** Set of C-style strings. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
40 typedef std::set<const char*, StringCompare> StringSet;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
41 /** Mapping of C-style string to a set of C-style strings. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
42 typedef std::map<const char*, StringSet*, StringCompare> StringMap;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
43 /** Pair of C-style string and a set of C-style strings. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
44 typedef std::pair<const char*, StringSet*> StringMapItem;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
45
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
46 /** Include directory to search in. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
47 static StringSet _include_dirs;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
48 /** Files that have been parsed/handled with their dependencies. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
49 static StringMap _files;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
50 /** Dependencies of headers. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
51 static StringMap _headers;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
52 /** The current 'active' defines. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
53 static StringSet _defines;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
54
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
55 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
56 * Helper class to read a file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
57 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
58 class File {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
59 public:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
60 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
61 * Create the helper by opening the given file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
62 * @param filename the file to open
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
63 * @post the file is open; otherwise the application is killed.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
64 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
65 File(const char *filename) : filename(filename)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
66 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
67 this->fp = fopen(filename, "r");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
68 if (this->fp == NULL) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
69 fprintf(stdout, "Could not open %s for reading\n", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
70 exit(1);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
71 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
72 this->dirname = strdup(filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
73 char *last = strrchr(this->dirname, '/');
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
74 if (last != NULL) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
75 *last = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
76 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
77 *this->dirname = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
78 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
79 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
80
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
81 /** Free everything we have allocated. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
82 ~File()
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
83 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
84 fclose(this->fp);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
85 free(this->dirname);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
86 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
87
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
88 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
89 * Get a single character from the file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
90 * If we are reading beyond the end of the file '\0' is returned.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
91 * @return the read character.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
92 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
93 char GetChar() const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
94 {
12126
2838b01593ed (svn r16542) -Fix [FS#2971](r16307): depend failed on architectures with unsigned char
smatz <smatz@openttd.org>
parents: 12004
diff changeset
95 int c = fgetc(this->fp);
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
96 return (c == EOF) ? '\0' : c;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
97 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
98
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
99 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
100 * Get the directory name of the file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
101 * @return the directory name.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
102 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
103 const char *GetDirname() const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
104 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
105 return this->dirname;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
106 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
107
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
108 private:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
109 FILE *fp; ///< The currently opened file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
110 char *dirname; ///< The directory of the file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
111 const char *filename; ///< The name of the file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
112 };
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
113
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
114 /** A token returned by the tokenizer. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
115 enum Token {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
116 TOKEN_UNKNOWN, ///< Unknown token
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
117 TOKEN_END, ///< End of document
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
118 TOKEN_EOL, ///< End of line
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
119 TOKEN_SHARP, ///< # character, usually telling something important comes.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
120 TOKEN_LOCAL, ///< Read a local include
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
121 TOKEN_GLOBAL, ///< Read a global include
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
122 TOKEN_IDENTIFIER, ///< Identifier within the data.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
123 TOKEN_DEFINE, ///< (#)define in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
124 TOKEN_IF, ///< (#)if in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
125 TOKEN_IFDEF, ///< (#)ifdef in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
126 TOKEN_IFNDEF, ///< (#)ifndef in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
127 TOKEN_ELIF, ///< (#)elif in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
128 TOKEN_ELSE, ///< (#)else in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
129 TOKEN_ENDIF, ///< (#)endif in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
130 TOKEN_UNDEF, ///< (#)undef in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
131 TOKEN_OR, ///< '||' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
132 TOKEN_AND, ///< '&&' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
133 TOKEN_DEFINED, ///< 'defined' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
134 TOKEN_OPEN, ///< '(' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
135 TOKEN_CLOSE, ///< ')' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
136 TOKEN_NOT, ///< '!' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
137 TOKEN_ZERO, ///< '0' within #if expression
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
138 TOKEN_INCLUDE, ///< (#)include in code
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
139 };
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
140
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
141 /** Mapping from a C-style keyword representation to a Token. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
142 typedef std::map<const char*, Token, StringCompare> KeywordList;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
143
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
144 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
145 * Lexer of a file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
146 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
147 class Lexer {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
148 public:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
149 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
150 * Create the lexer and fill the keywords table.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
151 * @param file the file to read from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
152 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
153 Lexer(const File *file) : file(file), current_char('\0'), string(NULL), token(TOKEN_UNKNOWN)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
154 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
155 this->keywords["define"] = TOKEN_DEFINE;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
156 this->keywords["defined"] = TOKEN_DEFINED;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
157 this->keywords["if"] = TOKEN_IF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
158 this->keywords["ifdef"] = TOKEN_IFDEF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
159 this->keywords["ifndef"] = TOKEN_IFNDEF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
160 this->keywords["include"] = TOKEN_INCLUDE;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
161 this->keywords["elif"] = TOKEN_ELIF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
162 this->keywords["else"] = TOKEN_ELSE;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
163 this->keywords["endif"] = TOKEN_ENDIF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
164 this->keywords["undef"] = TOKEN_UNDEF;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
165
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
166 /* Initialise currently read character. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
167 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
168
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
169 /* Allocate the buffer. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
170 this->buf_len = 32;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
171 this->buf = (char*)malloc(sizeof(*this->buf) * this->buf_len);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
172 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
173
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
174 /** Free everything */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
175 ~Lexer()
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
176 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
177 free(this->buf);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
178 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
179
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
180 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
181 * Read the next character into 'current_char'.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
182 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
183 void Next()
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
184 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
185 this->current_char = this->file->GetChar();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
186 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
187
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
188 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
189 * Get the current token.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
190 * @return the token.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
191 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
192 Token GetToken() const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
193 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
194 return this->token;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
195 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
196
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
197 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
198 * Read the currenty processed string.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
199 * @return the string, can be NULL.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
200 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
201 const char *GetString() const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
202 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
203 return this->string;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
204 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
205
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
206 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
207 * Perform the lexing/tokenizing of the file till we can return something
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
208 * that must be parsed.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
209 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
210 void Lex()
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
211 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
212 for (;;) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
213 free(this->string);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
214 this->string = NULL;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
215 this->token = TOKEN_UNKNOWN;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
216
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
217 switch (this->current_char) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
218 /* '\0' means End-Of-File */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
219 case '\0': this->token = TOKEN_END; return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
220
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
221 /* Skip some chars, as they don't do anything */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
222 case '\t': this->Next(); break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
223 case '\r': this->Next(); break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
224 case ' ': this->Next(); break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
225
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
226 case '\\':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
227 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
228 if (this->current_char == '\n') this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
229 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
230
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
231 case '\n':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
232 this->token = TOKEN_EOL;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
233 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
234 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
235
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
236 case '#':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
237 this->token = TOKEN_SHARP;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
238 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
239 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
240
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
241 case '"':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
242 this->ReadString('"', TOKEN_LOCAL);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
243 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
244 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
245
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
246 case '<':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
247 this->ReadString('>', TOKEN_GLOBAL);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
248 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
249 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
250
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
251 case '&':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
252 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
253 if (this->current_char == '&') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
254 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
255 this->token = TOKEN_AND;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
256 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
257 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
258 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
259
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
260 case '|':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
261 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
262 if (this->current_char == '|') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
263 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
264 this->token = TOKEN_OR;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
265 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
266 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
267 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
268
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
269 case '(':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
270 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
271 this->token = TOKEN_OPEN;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
272 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
273
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
274 case ')':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
275 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
276 this->token = TOKEN_CLOSE;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
277 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
278
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
279 case '!':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
280 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
281 if (this->current_char != '=') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
282 this->token = TOKEN_NOT;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
283 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
284 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
285 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
286
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
287 /* Possible begin of comment */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
288 case '/':
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
289 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
290 switch (this->current_char) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
291 case '*': {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
292 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
293 char previous_char = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
294 while ((this->current_char != '/' || previous_char != '*') && this->current_char != '\0') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
295 previous_char = this->current_char;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
296 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
297 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
298 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
299 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
300 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
301 case '/': while (this->current_char != '\n' && this->current_char != '\0') this->Next(); break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
302 default: break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
303 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
304 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
305
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
306 default:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
307 if (isalpha(this->current_char) || this->current_char == '_') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
308 /* If the name starts with a letter, it is an identifier */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
309 this->ReadIdentifier();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
310 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
311 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
312 if (isdigit(this->current_char)) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
313 bool zero = this->current_char == '0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
314 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
315 if (this->current_char == 'x' || this->current_char == 'X') Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
316 while (isdigit(this->current_char) || this->current_char == '.' || (this->current_char >= 'a' && this->current_char <= 'f') || (this->current_char >= 'A' && this->current_char <= 'F')) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
317 zero &= this->current_char == '0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
318 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
319 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
320 if (zero) this->token = TOKEN_ZERO;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
321 return;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
322 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
323 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
324 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
325 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
326 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
327 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
328
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
329 private:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
330 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
331 * The token based on keyword with a given name.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
332 * @param name the actual keyword.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
333 * @return the token of the keyword.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
334 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
335 Token FindKeyword(const char *name) const
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
336 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
337 KeywordList::const_iterator it = this->keywords.find(name);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
338 if (it == this->keywords.end()) return TOKEN_IDENTIFIER;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
339 return (*it).second;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
340 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
341
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
342 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
343 * Read an identifier.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
344 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
345 void ReadIdentifier()
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
346 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
347 size_t count = 0;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
348
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
349 /* Read the rest of the identifier */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
350 do {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
351 this->buf[count++] = this->current_char;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
352 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
353
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
354 if (count >= buf_len) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
355 /* Scale the buffer if required */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
356 this->buf_len *= 2;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
357 this->buf = (char *)realloc(this->buf, sizeof(*this->buf) * this->buf_len);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
358 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
359 } while ((isalpha(this->current_char) || this->current_char == '_' || isdigit(this->current_char)));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
360 this->buf[count] = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
361
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
362 free(this->string);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
363 this->string = strdup(this->buf);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
364 this->token = FindKeyword(this->string);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
365 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
366
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
367 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
368 * Read a string up to a given character, then set the given token.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
369 * @param end the 'marker' for the end of the string.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
370 * @param token the token to set after returning.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
371 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
372 void ReadString(char end, Token token)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
373 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
374 size_t count = 0;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
375 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
376 while (this->current_char != end && this->current_char != ')' && this->current_char != '\n' && this->current_char != '\0') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
377 this->buf[count++] = this->current_char;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
378 this->Next();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
379
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
380 if (count >= this->buf_len) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
381 /* Scale the buffer if required */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
382 this->buf_len *= 2;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
383 this->buf = (char *)realloc(this->buf, sizeof(*this->buf) * this->buf_len);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
384 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
385 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
386 this->buf[count] = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
387 free(this->string);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
388 this->string = strdup(this->buf);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
389 this->token = token;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
390 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
391
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
392 const File *file; ///< The file to read from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
393 char current_char; ///< The current character to process.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
394 char *string; ///< Currently processed string.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
395 Token token; ///< The current token to process.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
396 char *buf; ///< Temporary buffer.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
397 size_t buf_len; ///< Length of the temporary buffer.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
398 KeywordList keywords; ///< All keywords we know of.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
399 };
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
400
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
401 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
402 * Generate a path from a directory name and a relative filename.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
403 * If the file is not local the include directory names will be used instead
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
404 * of the passed parameter with directory name. If the file is local both will
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
405 * be queried where the parameter takes precedence.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
406 * @param dirname the directory to look in.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
407 * @param filename the file to look for.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
408 * @param local whether to look locally (in dirname) for the file.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
409 * @return the absolute path, or NULL if the file doesn't exist.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
410 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
411 const char *GeneratePath(const char *dirname, const char *filename, bool local)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
412 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
413 if (local) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
414 if (access(filename, R_OK) == 0) return strdup(filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
415
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
416 char path[PATH_MAX];
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
417 strcpy(path, dirname);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
418 const char *p = filename;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
419 /* Remove '..' from the begin of the filename. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
420 while (*p == '.') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
421 if (*(++p) == '.') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
422 *(strrchr(path, '/')) = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
423 p += 2;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
424 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
425 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
426 strcat(path, "/");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
427 strcat(path, p);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
428
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
429 if (access(path, R_OK) == 0) return strdup(path);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
430 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
431
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
432 for (StringSet::iterator it = _include_dirs.begin(); it != _include_dirs.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
433 char path[PATH_MAX];
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
434 strcpy(path, *it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
435 const char *p = filename;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
436 /* Remove '..' from the begin of the filename. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
437 while (*p == '.') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
438 if (*(++p) == '.') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
439 *(strrchr(path, '/')) = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
440 p += 2;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
441 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
442 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
443 strcat(path, "/");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
444 strcat(path, p);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
445
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
446 if (access(path, R_OK) == 0) return strdup(path);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
447 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
448
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
449 return NULL;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
450 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
451
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
452 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
453 * Try to parse a 'defined(expr)' expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
454 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
455 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
456 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
457 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
458 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
459 bool ExpressionDefined(Lexer *lexer, StringSet *defines, bool verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
460
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
461 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
462 * Try to parse a 'expr || expr' expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
463 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
464 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
465 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
466 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
467 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
468 bool ExpressionOr(Lexer *lexer, StringSet *defines, bool verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
469
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
470 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
471 * Try to parse a '!expr' expression. Also parses the '(expr)', '0' and
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
472 * identifiers. Finally it also consumes any unknown tokens.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
473 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
474 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
475 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
476 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
477 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
478 bool ExpressionNot(Lexer *lexer, StringSet *defines, bool verbose)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
479 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
480 if (lexer->GetToken() == TOKEN_NOT) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
481 if (verbose) fprintf(stderr, "!");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
482 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
483 bool value = !ExpressionDefined(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
484 if (verbose) fprintf(stderr, "[%d]", value);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
485 return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
486 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
487
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
488 if (lexer->GetToken() == TOKEN_OPEN) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
489 if (verbose) fprintf(stderr, "(");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
490 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
491 bool value = ExpressionOr(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
492 if (verbose) fprintf(stderr, ")[%d]", value);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
493 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
494 return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
495 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
496
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
497 if (lexer->GetToken() == TOKEN_ZERO) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
498 if (verbose) fprintf(stderr, "0");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
499 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
500 if (verbose) fprintf(stderr, "[0]");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
501 return false;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
502 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
503
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
504 bool first = true;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
505 while (lexer->GetToken() == TOKEN_UNKNOWN || lexer->GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
506 if (verbose && first) fprintf(stderr, "<assumed true>");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
507 first = false;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
508 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
509 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
510
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
511 return true;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
512 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
513
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
514 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
515 * Try to parse a 'defined(expr)' expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
516 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
517 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
518 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
519 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
520 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
521 bool ExpressionDefined(Lexer *lexer, StringSet *defines, bool verbose)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
522 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
523 bool value = ExpressionNot(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
524
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
525 if (lexer->GetToken() != TOKEN_DEFINED) return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
526 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
527 if (verbose) fprintf(stderr, "defined");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
528 bool open = (lexer->GetToken() == TOKEN_OPEN);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
529 if (open) lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
530 if (verbose) fprintf(stderr, open ? "(" : " ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
531 if (lexer->GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
532 if (verbose) fprintf(stderr, "%s", lexer->GetString());
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
533 value = defines->find(lexer->GetString()) != defines->end();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
534 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
535 if (open) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
536 if (verbose) fprintf(stderr, ")");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
537 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
538 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
539 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
540 if (verbose) fprintf(stderr, "[%d]", value);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
541 return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
542 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
543
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
544 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
545 * Try to parse a 'expr && expr' expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
546 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
547 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
548 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
549 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
550 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
551 bool ExpressionAnd(Lexer *lexer, StringSet *defines, bool verbose)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
552 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
553 bool value = ExpressionDefined(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
554
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
555 while (true) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
556 if (lexer->GetToken() != TOKEN_AND) return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
557 if (verbose) fprintf(stderr, " && ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
558 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
559 value = value && ExpressionDefined(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
560 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
561 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
562
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
563 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
564 * Try to parse a 'expr || expr' expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
565 * @param lexer the lexer to get tokens from.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
566 * @param defines the set of known defines.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
567 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
568 * @return the value of the expression.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
569 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
570 bool ExpressionOr(Lexer *lexer, StringSet *defines, bool verbose)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
571 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
572 bool value = ExpressionAnd(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
573
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
574 while (true) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
575 if (lexer->GetToken() != TOKEN_OR) return value;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
576 if (verbose) fprintf(stderr, " || ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
577 lexer->Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
578 value = value || ExpressionAnd(lexer, defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
579 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
580 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
581
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
582 /** Enumerator to tell how long to ignore 'stuff'. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
583 enum Ignore {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
584 NOT_IGNORE, ///< No ignoring.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
585 IGNORE_UNTIL_ELSE, ///< Ignore till a #else is reached.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
586 IGNORE_UNTIL_ENDIF, ///< Ignore till a #endif is reached.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
587 };
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
588
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
589 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
590 * Scan a file for includes, defines and the lot.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
591 * @param filename the name of the file to scan.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
592 * @param ext the extension of the filename.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
593 * @param header whether the file is a header or not.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
594 * @param verbose whether to give verbose debugging information.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
595 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
596 void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
597 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
598 static StringSet defines;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
599 static std::stack<Ignore> ignore;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
600 /* Copy in the default defines (parameters of depend) */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
601 if (!header) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
602 for (StringSet::iterator it = _defines.begin(); it != _defines.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
603 defines.insert(strdup(*it));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
604 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
605 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
606
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
607 File file(filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
608 Lexer lexer(&file);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
609
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
610 /* Start the lexing! */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
611 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
612
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
613 while (lexer.GetToken() != TOKEN_END) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
614 switch (lexer.GetToken()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
615 /* We reached the end of the file... yay, we're done! */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
616 case TOKEN_END: break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
617
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
618 /* The line started with a # (minus whitespace) */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
619 case TOKEN_SHARP:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
620 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
621 switch (lexer.GetToken()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
622 case TOKEN_INCLUDE:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
623 if (verbose) fprintf(stderr, "%s #include ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
624 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
625 switch (lexer.GetToken()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
626 case TOKEN_LOCAL:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
627 case TOKEN_GLOBAL: {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
628 if (verbose) fprintf(stderr, "%s", lexer.GetString());
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
629 if (!ignore.empty() && ignore.top() != NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
630 if (verbose) fprintf(stderr, " (ignored)");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
631 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
632 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
633 const char *h = GeneratePath(file.GetDirname(), lexer.GetString(), lexer.GetToken() == TOKEN_LOCAL);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
634 if (h != NULL) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
635 StringMap::iterator it = _headers.find(h);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
636 if (it == _headers.end()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
637 it = (_headers.insert(StringMapItem(strdup(h), new StringSet()))).first;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
638 if (verbose) fprintf(stderr, "\n");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
639 ScanFile(h, ext, true, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
640 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
641 StringMap::iterator curfile;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
642 if (header) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
643 curfile = _headers.find(filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
644 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
645 /* Replace the extension with the provided extension of '.o'. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
646 char path[PATH_MAX];
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
647 strcpy(path, filename);
12004
c2d9b54aaa63 (svn r16410) -Fix (r16307): don't assume the extension starts with the first '.', but with the last '.'. This way depend doesn't fail if there's a dot in your path, e.g. 'gcc-4.4'.
rubidium <rubidium@openttd.org>
parents: 11907
diff changeset
648 *(strrchr(path, '.')) = '\0';
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
649 strcat(path, ext != NULL ? ext : ".o");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
650 curfile = _files.find(path);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
651 if (curfile == _files.end()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
652 curfile = (_files.insert(StringMapItem(strdup(path), new StringSet()))).first;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
653 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
654 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
655 if (it != _headers.end()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
656 for (StringSet::iterator header = it->second->begin(); header != it->second->end(); header++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
657 if (curfile->second->find(*header) == curfile->second->end()) curfile->second->insert(strdup(*header));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
658 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
659 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
660 if (curfile->second->find(h) == curfile->second->end()) curfile->second->insert(strdup(h));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
661 free((void*)h);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
662 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
663 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
664 /* Fall through */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
665 default: break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
666 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
667 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
668
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
669 case TOKEN_DEFINE:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
670 if (verbose) fprintf(stderr, "%s #define ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
671 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
672 if (lexer.GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
673 if (verbose) fprintf(stderr, "%s", lexer.GetString());
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
674 if (!ignore.empty() && ignore.top() != NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
675 if (verbose) fprintf(stderr, " (ignored)");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
676 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
677 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
678 if (defines.find(lexer.GetString()) == defines.end()) defines.insert(strdup(lexer.GetString()));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
679 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
680 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
681 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
682
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
683 case TOKEN_UNDEF:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
684 if (verbose) fprintf(stderr, "%s #undef ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
685 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
686 if (lexer.GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
687 if (verbose) fprintf(stderr, "%s", lexer.GetString());
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
688 if (!ignore.empty() && ignore.top() != NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
689 if (verbose) fprintf(stderr, " (ignored)");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
690 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
691 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
692 StringSet::iterator it = defines.find(lexer.GetString());
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
693 if (it != defines.end()) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
694 free((void*)*it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
695 defines.erase(it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
696 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
697 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
698 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
699 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
700
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
701 case TOKEN_ENDIF:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
702 if (verbose) fprintf(stderr, "%s #endif", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
703 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
704 if (!ignore.empty()) ignore.pop();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
705 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
706 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
707
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
708 case TOKEN_ELSE: {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
709 if (verbose) fprintf(stderr, "%s #else", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
710 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
711 Ignore last = ignore.empty() ? NOT_IGNORE : ignore.top();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
712 if (!ignore.empty()) ignore.pop();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
713 if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
714 ignore.push(last == IGNORE_UNTIL_ELSE ? NOT_IGNORE : IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
715 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
716 ignore.push(IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
717 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
718 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
719 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
720 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
721
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
722 case TOKEN_ELIF: {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
723 if (verbose) fprintf(stderr, "%s #elif ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
724 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
725 Ignore last = ignore.empty() ? NOT_IGNORE : ignore.top();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
726 if (!ignore.empty()) ignore.pop();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
727 if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
728 bool value = ExpressionOr(&lexer, &defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
729 ignore.push(last == IGNORE_UNTIL_ELSE ? (value ? NOT_IGNORE : IGNORE_UNTIL_ELSE) : IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
730 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
731 ignore.push(IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
732 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
733 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
734 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
735 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
736
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
737 case TOKEN_IF: {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
738 if (verbose) fprintf(stderr, "%s #if ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
739 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
740 if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
741 bool value = ExpressionOr(&lexer, &defines, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
742 ignore.push(value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
743 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
744 ignore.push(IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
745 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
746 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
747 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
748 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
749
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
750 case TOKEN_IFDEF:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
751 if (verbose) fprintf(stderr, "%s #ifdef ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
752 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
753 if (lexer.GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
754 bool value = defines.find(lexer.GetString()) != defines.end();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
755 if (verbose) fprintf(stderr, "%s[%d]", lexer.GetString(), value);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
756 if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
757 ignore.push(value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
758 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
759 ignore.push(IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
760 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
761 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
762 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
763 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
764
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
765 case TOKEN_IFNDEF:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
766 if (verbose) fprintf(stderr, "%s #ifndef ", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
767 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
768 if (lexer.GetToken() == TOKEN_IDENTIFIER) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
769 bool value = defines.find(lexer.GetString()) != defines.end();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
770 if (verbose) fprintf(stderr, "%s[%d]", lexer.GetString(), value);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
771 if (ignore.empty() || ignore.top() == NOT_IGNORE) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
772 ignore.push(!value ? NOT_IGNORE : IGNORE_UNTIL_ELSE);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
773 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
774 ignore.push(IGNORE_UNTIL_ENDIF);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
775 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
776 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
777 if (verbose) fprintf(stderr, " -> %signore", (!ignore.empty() && ignore.top() != NOT_IGNORE) ? "" : "not ");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
778 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
779
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
780 default:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
781 if (verbose) fprintf(stderr, "%s #<unknown>", filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
782 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
783 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
784 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
785 if (verbose) fprintf(stderr, "\n");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
786 /* Fall through */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
787 default:
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
788 /* Ignore the rest of the garbage on this line */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
789 while (lexer.GetToken() != TOKEN_EOL && lexer.GetToken() != TOKEN_END) lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
790 lexer.Lex();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
791 break;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
792 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
793 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
794
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
795 if (!header) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
796 for (StringSet::iterator it = defines.begin(); it != defines.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
797 free((void*)*it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
798 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
799 defines.clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
800 while (!ignore.empty()) ignore.pop();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
801 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
802 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
803
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
804 /**
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
805 * Entry point. Arguably the most common function in all applications.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
806 * @param argc the number of arguments.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
807 * @param argv the actual arguments.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
808 * @return return value for the caller to tell we succeed or not.
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
809 */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
810 int main(int argc, char *argv[])
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
811 {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
812 bool ignorenext = true;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
813 char *filename = NULL;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
814 char *ext = NULL;
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
815 char *delimiter = NULL;
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
816 bool append = false;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
817 bool verbose = false;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
818
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
819 for (int i = 0; i < argc; i++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
820 if (ignorenext) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
821 ignorenext = false;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
822 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
823 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
824 if (argv[i][0] == '-') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
825 /* Append */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
826 if (strncmp(argv[i], "-a", 2) == 0) append = true;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
827 /* Include dir */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
828 if (strncmp(argv[i], "-I", 2) == 0) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
829 if (argv[i][2] == '\0') {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
830 i++;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
831 _include_dirs.insert(strdup(argv[i]));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
832 } else {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
833 _include_dirs.insert(strdup(&argv[i][2]));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
834 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
835 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
836 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
837 /* Define */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
838 if (strncmp(argv[i], "-D", 2) == 0) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
839 char *p = strchr(argv[i], '=');
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
840 if (p != NULL) *p = '\0';
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
841 _defines.insert(strdup(&argv[i][2]));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
842 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
843 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
844 /* Output file */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
845 if (strncmp(argv[i], "-f", 2) == 0) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
846 if (filename != NULL) continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
847 filename = strdup(&argv[i][2]);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
848 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
849 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
850 /* Object file extension */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
851 if (strncmp(argv[i], "-o", 2) == 0) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
852 if (ext != NULL) continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
853 ext = strdup(&argv[i][2]);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
854 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
855 }
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
856 /* Starting string delimiter */
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
857 if (strncmp(argv[i], "-s", 2) == 0) {
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
858 if (delimiter != NULL) continue;
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
859 delimiter = strdup(&argv[i][2]);
12216
08028442797f (svn r16630) -Fix (r16629): forgot a continue
glx <glx@openttd.org>
parents: 12215
diff changeset
860 continue;
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
861 }
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
862 /* Verbose */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
863 if (strncmp(argv[i], "-v", 2) == 0) verbose = true;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
864 continue;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
865 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
866 ScanFile(argv[i], ext, false, verbose);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
867 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
868
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
869 /* Default output file is Makefile */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
870 if (filename == NULL) filename = strdup("Makefile");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
871
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
872 /* Default delimiter string */
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
873 if (delimiter == NULL) delimiter = strdup("# DO NOT DELETE");
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
874
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
875 char backup[PATH_MAX];
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
876 strcpy(backup, filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
877 strcat(backup, ".bak");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
878
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
879 char *content = NULL;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
880 long size = 0;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
881
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
882 /* Read in the current file; so we can overwrite everything from the
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
883 * end of non-depend data marker down till the end. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
884 FILE *src = fopen(filename, "rb");
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
885 if (src != NULL) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
886 fseek(src, 0, SEEK_END);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
887 size = ftell(src);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
888 rewind(src);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
889 content = (char*)malloc(size * sizeof(*content));
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
890 fread(content, 1, size, src);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
891 fclose(src);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
892 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
893
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
894 FILE *dst = fopen(filename, "w");
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
895 bool found_delimiter = false;
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
896
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
897 if (size != 0) {
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
898 src = fopen(backup, "wb");
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
899 fwrite(content, 1, size, src);
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
900 fclose(src);
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
901
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
902 /* Then append it to the real file. */
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
903 src = fopen(backup, "rb");
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
904 while (fgets(content, size, src) != NULL) {
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
905 fputs(content, dst);
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
906 if (!strncmp(content, delimiter, strlen(delimiter))) found_delimiter = true;
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
907 if (!append && found_delimiter) break;
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
908 }
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
909 fclose(src);
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
910 }
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
911 if (!found_delimiter) fprintf(dst, "\n%s\n", delimiter);
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
912
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
913 for (StringMap::iterator it = _files.begin(); it != _files.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
914 for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
915 fprintf(dst, "%s: %s\n", it->first, *h);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
916 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
917 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
918
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
919 /* Clean up our mess. */
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
920 fclose(dst);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
921
12215
c9a5d02546e4 (svn r16629) -Fix: depend hang on solaris
glx <glx@openttd.org>
parents: 12126
diff changeset
922 free(delimiter);
11907
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
923 free(filename);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
924 free(ext);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
925 free(content);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
926
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
927 for (StringMap::iterator it = _files.begin(); it != _files.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
928 for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
929 free((void*)*h);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
930 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
931 it->second->clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
932 delete it->second;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
933 free((void*)it->first);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
934 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
935 _files.clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
936
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
937 for (StringMap::iterator it = _headers.begin(); it != _headers.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
938 for (StringSet::iterator h = it->second->begin(); h != it->second->end(); h++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
939 free((void*)*h);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
940 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
941 it->second->clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
942 delete it->second;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
943 free((void*)it->first);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
944 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
945 _headers.clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
946
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
947 for (StringSet::iterator it = _defines.begin(); it != _defines.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
948 free((void*)*it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
949 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
950 _defines.clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
951
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
952 for (StringSet::iterator it = _include_dirs.begin(); it != _include_dirs.end(); it++) {
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
953 free((void*)*it);
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
954 }
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
955 _include_dirs.clear();
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
956
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
957 return 0;
ae4ef10e7535 (svn r16307) -Fix: makedepend can't handle the amount of files we have and it also miss some dependencies. That's why we introduce our custom implementation of makedepend.
glx <glx@openttd.org>
parents:
diff changeset
958 }