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

Function headers1

src/engine/headers.cpp:122–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

headersFunction · 0.85
hcacheFunction · 0.85

Calls 11

out_printfFunction · 0.85
out_flushFunction · 0.85
object_newFunction · 0.85
regex_compileFunction · 0.85
object_freeFunction · 0.85
object_strFunction · 0.85
err_printfFunction · 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