Patch #1367 2006-08-20 17:51
jthedering
D support added to depslib- Download
- 1367-D_support_adde.patch (7.4 KB)
Index: search.c
===================================================================
--- search.c (Revision 2879)
+++ search.c (Arbeitskopie)
@@ -8,6 +8,9 @@
* are clearly marked.
*
* ALL WARRANTIES ARE HEREBY DISCLAIMED.
+ *
+ * Modifications:
+ * - D support (search for "D support")
*/
#include "jam.h"
#include "hash.h"
@@ -39,6 +42,12 @@
char buf3[MAXJPATH];
int system = (_header[0] == '<');
LIST *list = searchdirs->next;
+
+ //D support
+ int dMode=0;
+ int fnlen=strlen(source);
+ if(source[fnlen-2]=='.' && source[fnlen-1]=='d')
+ dMode=1;
/* <foo.h> --> foo.h */
strcpy(header, _header + 1);
@@ -131,33 +140,37 @@
return newstr(buf);
}
-#if 1
+ if(!dMode)
+ {
#ifdef SEARCH_OPTIM
- // remember that this file could not be found
- {
- char key[MAXJPATH] = "";
- SEARCH search, *s = &search;
- if (!system)
+ // remember that this file could not be found
{
- strcpy(key, buf3);
- strcat(key, ",");
+ char key[MAXJPATH] = "";
+ SEARCH search, *s = &search;
+ if (!system)
+ {
+ strcpy(key, buf3);
+ strcat(key, ",");
+ }
+ strcat(key, _header);
+ s->key = newstr(key);
+ s->time = 0;
+ s->path = NULL;
+ (void) hashenter(searchhash, (HASHDATA **)&s);
}
- strcat(key, _header);
- s->key = newstr(key);
- s->time = 0;
- s->path = NULL;
- (void) hashenter(searchhash, (HASHDATA **)&s);
- }
#endif
- /* C compilers do *not* look in the current directory for #include files */
- *time = 0;
- return NULL;
-#else
- f->f_root.ptr = 0;
- f->f_root.len = 0;
+ /* C compilers do *not* look in the current directory for #include files */
+ *time = 0;
+ return NULL;
+ }
+ //D support (look in current directory)
+ else
+ {
+ f->f_root.ptr = 0;
+ f->f_root.len = 0;
- path_build( f, buf, 1 );
+ path_build( f, buf, 1 );
{
PATHSPLIT f;
@@ -168,13 +181,54 @@
strcpy(buf, buf2);
}
- if( DEBUG_SEARCH )
- printf( "search %s: %s\n", _header, buf );
+ if( DEBUG_SEARCH )
+ printf( "search %s: %s\n", _header, buf );
- timestamp( buf, time );
+ timestamp( buf, time );
- return newstr( buf );
+
+#ifdef SEARCH_OPTIM
+ if (*time)
+ {
+ char key[MAXJPATH] = "";
+ SEARCH search, *s = &search;
+ if (!system)
+ {
+ strcpy(key, buf3);
+ strcat(key, ",");
+ }
+ strcat(key, _header);
+ s->key = newstr(key);
+ s->time = *time;
+ s->path = newstr(buf);
+ (void) hashenter(searchhash, (HASHDATA **)&s);
+ }
#endif
+
+ if (*time)
+ return newstr(buf);
+
+#ifdef SEARCH_OPTIM
+ // remember that this file could not be found
+ {
+ char key[MAXJPATH] = "";
+ SEARCH search, *s = &search;
+ if (!system)
+ {
+ strcpy(key, buf3);
+ strcat(key, ",");
+ }
+ strcat(key, _header);
+ s->key = newstr(key);
+ s->time = 0;
+ s->path = NULL;
+ (void) hashenter(searchhash, (HASHDATA **)&s);
+ }
+#endif
+
+ *time = 0;
+ return NULL;
+ }
}
void search_adddir(const char *path)
Index: headers.c
===================================================================
--- headers.c (Revision 2879)
+++ headers.c (Arbeitskopie)
@@ -8,6 +8,12 @@
* are clearly marked.
*
* ALL WARRANTIES ARE HEREBY DISCLAIMED.
+ *
+ * Modifications:
+ * - D support (search for "D support")
+ * - Depth level counting (needed for D support)
+ * - Simple optimization by avoiding regexec most of the time
+ * - Special cache keys for source files (needed for D support)
*/
#include "jam.h"
#include "alloc.h"
@@ -25,13 +31,26 @@
struct hash *headerhash = 0;
static regexp *hdrre = 0;
+//D support
+static regexp *dimpre = 0;
-LIST *headers1(const char *file)
+LIST *headers1(const char *file, int depth)
{
FILE *f;
regexp *re;
LIST *result = 0;
char buf[1024];
+ int fnlen=strlen(file);
+
+ //D support
+ int dMode=0;
+ int dState=0;
+ if(file[fnlen-2] == '.' && file[fnlen-1] == 'd')
+ {
+ dMode=1;
+ if( DEBUG_HEADER )
+ printf("D file detected\n");
+ }
if (!(f = fopen(file, "r")))
return result;
@@ -42,21 +61,91 @@
if (!hdrre)
hdrre = my_regcomp("^[ ]*#[ ]*include[ ]*([<\"])([^\">]*)([\">]).*$");
re = hdrre;
-
+
+ //D support
+ if(dMode)
+ {
+ if(!dimpre)
+ dimpre = my_regcomp(
+ "^.*import[ \t]*([[A-Za-z_ \t]+=[ \t]*
download for full patch...
History
jthedering 2006-08-20 17:51
This patch adds D import parsing capability to the depslib (contained in the compilergcc plugin).
It also makes the parser faster by using the regular expression only in the case when "include"/"import" is contained in the line, so the performance of the supplied regex library is much less important.
Without this patch, there often was the problem with D projects, that depending code wasn't recompiled when a source file changed, which lead to inconsistencies resulting in mysterious crashes of the compiled program.