MCPcopy Create free account
hub / github.com/boostorg/build / headers1

Function headers1

v2/engine/headers.c:118–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116static
117#endif
118LIST * headers1( LIST * l, OBJECT * file, int rec, regexp * re[] )
119{
120 FILE * f;
121 char buf[ 1024 ];
122 int i;
123 static regexp * re_macros = 0;
124
125#ifdef OPT_IMPROVED_PATIENCE_EXT
126 static int count = 0;
127 ++count;
128 if ( ( ( count == 100 ) || !( count % 1000 ) ) && DEBUG_MAKE )
129 {
130 printf( "...patience...\n" );
131 fflush( stdout );
132 }
133#endif
134
135 /* The following regexp is used to detect cases where a file is included
136 * through a line like "#include MACRO".
137 */
138 if ( re_macros == 0 )
139 {
140 OBJECT * const re_str = object_new(
141 "#[ \t]*include[ \t]*([A-Za-z][A-Za-z0-9_]*).*$" );
142 re_macros = regex_compile( re_str );
143 object_free( re_str );
144 }
145
146 if ( !( f = fopen( object_str( file ), "r" ) ) )
147 return l;
148
149 while ( fgets( buf, sizeof( buf ), f ) )
150 {
151 for ( i = 0; i < rec; ++i )
152 if ( regexec( re[ i ], buf ) && re[ i ]->startp[ 1 ] )
153 {
154 ( (char *)re[ i ]->endp[ 1 ] )[ 0 ] = '\0';
155 if ( DEBUG_HEADER )
156 printf( "header found: %s\n", re[ i ]->startp[ 1 ] );
157 l = list_push_back( l, object_new( re[ i ]->startp[ 1 ] ) );
158 }
159
160 /* Special treatment for #include MACRO. */
161 if ( regexec( re_macros, buf ) && re_macros->startp[ 1 ] )
162 {
163 OBJECT * header_filename;
164 OBJECT * macro_name;
165
166 ( (char *)re_macros->endp[ 1 ] )[ 0 ] = '\0';
167
168 if ( DEBUG_HEADER )
169 printf( "macro header found: %s", re_macros->startp[ 1 ] );
170
171 macro_name = object_new( re_macros->startp[ 1 ] );
172 header_filename = macro_header_get( macro_name );
173 object_free( macro_name );
174 if ( header_filename )
175 {

Callers 2

hcacheFunction · 0.85
headersFunction · 0.85

Calls 8

object_newFunction · 0.85
regex_compileFunction · 0.85
object_freeFunction · 0.85
object_strFunction · 0.85
regexecFunction · 0.85
list_push_backFunction · 0.85
macro_header_getFunction · 0.85
object_copyFunction · 0.85

Tested by

no test coverage detected