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

Function headers1

src/engine/headers.c:119–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

hcacheFunction · 0.85
headersFunction · 0.85

Calls 10

out_printfFunction · 0.85
out_flushFunction · 0.85
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