Commit fed8f1cb authored by Alexandre Julliard's avatar Alexandre Julliard

Modified makedep to handle #include <> correctly (based on a patch by

Patrik Stridvall).
parent 651a8ba8
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <unistd.h> #include <unistd.h>
/* Max first-level includes per file */ /* Max first-level includes per file */
#define MAX_INCLUDES 124 #define MAX_INCLUDES 200
typedef struct _INCL_FILE typedef struct _INCL_FILE
{ {
...@@ -20,6 +20,7 @@ typedef struct _INCL_FILE ...@@ -20,6 +20,7 @@ typedef struct _INCL_FILE
char *filename; char *filename;
struct _INCL_FILE *included_by; /* file that included this one */ struct _INCL_FILE *included_by; /* file that included this one */
int included_line; /* line where this file was included */ int included_line; /* line where this file was included */
int system; /* is it a system include (#include <name>) */
struct _INCL_FILE *owner; struct _INCL_FILE *owner;
struct _INCL_FILE *files[MAX_INCLUDES]; struct _INCL_FILE *files[MAX_INCLUDES];
} INCL_FILE; } INCL_FILE;
...@@ -134,7 +135,7 @@ static INCL_FILE *add_src_file( const char *name ) ...@@ -134,7 +135,7 @@ static INCL_FILE *add_src_file( const char *name )
* *
* Add an include file if it doesn't already exists. * Add an include file if it doesn't already exists.
*/ */
static INCL_FILE *add_include( INCL_FILE *pFile, const char *name, int line ) static INCL_FILE *add_include( INCL_FILE *pFile, const char *name, int line, int system )
{ {
INCL_FILE **p = &firstInclude; INCL_FILE **p = &firstInclude;
int pos; int pos;
...@@ -155,6 +156,7 @@ static INCL_FILE *add_include( INCL_FILE *pFile, const char *name, int line ) ...@@ -155,6 +156,7 @@ static INCL_FILE *add_include( INCL_FILE *pFile, const char *name, int line )
(*p)->name = xstrdup(name); (*p)->name = xstrdup(name);
(*p)->included_by = pFile; (*p)->included_by = pFile;
(*p)->included_line = line; (*p)->included_line = line;
(*p)->system = system || pFile->system;
} }
pFile->files[pos] = *p; pFile->files[pos] = *p;
return *p; return *p;
...@@ -207,6 +209,8 @@ static FILE *open_include_file( INCL_FILE *pFile ) ...@@ -207,6 +209,8 @@ static FILE *open_include_file( INCL_FILE *pFile )
} }
free( filename ); free( filename );
} }
if (!file && pFile->system) return NULL; /* ignore system files we cannot find */
/* try in src file directory */ /* try in src file directory */
if (!file) if (!file)
{ {
...@@ -224,6 +228,7 @@ static FILE *open_include_file( INCL_FILE *pFile ) ...@@ -224,6 +228,7 @@ static FILE *open_include_file( INCL_FILE *pFile )
if (!file) if (!file)
{ {
if (pFile->included_by->system) return NULL; /* ignore if included by a system file */
if (firstPath) perror( pFile->name ); if (firstPath) perror( pFile->name );
else fprintf( stderr, "%s: %s: File not found\n", else fprintf( stderr, "%s: %s: File not found\n",
ProgramName, pFile->name ); ProgramName, pFile->name );
...@@ -257,9 +262,11 @@ static void parse_file( INCL_FILE *pFile, int src ) ...@@ -257,9 +262,11 @@ static void parse_file( INCL_FILE *pFile, int src )
} }
file = src ? open_src_file( pFile ) : open_include_file( pFile ); file = src ? open_src_file( pFile ) : open_include_file( pFile );
if (!file) return;
while (fgets( buffer, sizeof(buffer)-1, file )) while (fgets( buffer, sizeof(buffer)-1, file ))
{ {
char quote;
char *p = buffer; char *p = buffer;
line++; line++;
while (*p && isspace(*p)) p++; while (*p && isspace(*p)) p++;
...@@ -268,9 +275,11 @@ static void parse_file( INCL_FILE *pFile, int src ) ...@@ -268,9 +275,11 @@ static void parse_file( INCL_FILE *pFile, int src )
if (strncmp( p, "include", 7 )) continue; if (strncmp( p, "include", 7 )) continue;
p += 7; p += 7;
while (*p && isspace(*p)) p++; while (*p && isspace(*p)) p++;
if (*p++ != '\"') continue; if (*p != '\"' && *p != '<' ) continue;
quote = *p++;
if (quote == '<') quote = '>';
include = p; include = p;
while (*p && (*p != '\"')) p++; while (*p && (*p != quote)) p++;
if (!*p) if (!*p)
{ {
fprintf( stderr, "%s:%d: Malformed #include directive\n", fprintf( stderr, "%s:%d: Malformed #include directive\n",
...@@ -278,7 +287,7 @@ static void parse_file( INCL_FILE *pFile, int src ) ...@@ -278,7 +287,7 @@ static void parse_file( INCL_FILE *pFile, int src )
exit(1); exit(1);
} }
*p = 0; *p = 0;
add_include( pFile, include, line ); add_include( pFile, include, line, (quote == '>') );
} }
fclose(file); fclose(file);
} }
...@@ -293,6 +302,7 @@ static void output_include( FILE *file, INCL_FILE *pFile, ...@@ -293,6 +302,7 @@ static void output_include( FILE *file, INCL_FILE *pFile,
int i; int i;
if (pFile->owner == owner) return; if (pFile->owner == owner) return;
if (!pFile->filename) return;
pFile->owner = owner; pFile->owner = owner;
if (*column + strlen(pFile->filename) + 1 > 70) if (*column + strlen(pFile->filename) + 1 > 70)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment