/* * Copyright 1993, 2000 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ # include "jam.h" # include "lists.h" # include "parse.h" # include "compile.h" # include "rules.h" # include "variable.h" # include "regexp.h" # include "headers.h" # include "newstr.h" #ifdef OPT_HEADER_CACHE_EXT # include "hcache.h" #endif /* * headers.c - handle #includes in source files * * Using regular expressions provided as the variable $(HDRSCAN), * headers() searches a file for #include files and phonies up a * rule invocation: * * $(HDRRULE) <target> : <include files> ; * * External routines: * headers() - scan a target for include files and call HDRRULE * * Internal routines: * headers1() - using regexp, scan a file and build include LIST * * 04/13/94 (seiwald) - added shorthand L0 for null list pointer * 09/10/00 (seiwald) - replaced call to compile_rule with evaluate_rule, * so that headers() doesn't have to mock up a parse structure * just to invoke a rule. */ #ifndef OPT_HEADER_CACHE_EXT static LIST *headers1( LIST *l, char *file, int rec, regexp *re[] ); #endif /* * headers() - scan a target for include files and call HDRRULE */ # define MAXINC 10 void headers( TARGET *t ) { LIST *hdrscan; LIST *hdrrule; LIST *headlist = 0; LOL lol; regexp *re[ MAXINC ]; int rec = 0; if( !( hdrscan = var_get( "HDRSCAN" ) ) || !( hdrrule = var_get( "HDRRULE" ) ) ) return; if( DEBUG_HEADER ) printf( "header scan %s\n", t->name ); /* Compile all regular expressions in HDRSCAN */ while( rec < MAXINC && hdrscan ) { re[rec++] = regcomp( hdrscan->string ); hdrscan = list_next( hdrscan ); } /* Doctor up call to HDRRULE rule */ /* Call headers1() to get LIST of included files. */ lol_init( &lol ); lol_add( &lol, list_new( L0, t->name ) ); #ifdef OPT_HEADER_CACHE_EXT lol_add( &lol, hcache( t, rec, re, var_get("HDRSCAN") ) ); #else lol_add( &lol, headers1( headlist, t->boundname, rec, re ) ); #endif if( lol_get( &lol, 1 ) ) { #ifdef OPT_HDRRULE_BOUNDNAME_ARG_EXT /* The third argument to HDRRULE is the bound name of * $(<) */ lol_add( &lol, list_new( L0, t->boundname ) ); #endif evaluate_rule( hdrrule->string, &lol ); } /* Clean up */ lol_free( &lol ); while( rec ) free( (char *)re[--rec] ); } /* * headers1() - using regexp, scan a file and build include LIST */ #ifdef OPT_HEADER_CACHE_EXT LIST * #else static LIST * #endif headers1( LIST *l, char *file, int rec, regexp *re[] ) { FILE *f; char buf[ 1024 ]; int i; #ifdef OPT_IMPROVED_PATIENCE_EXT static int count = 0; ++count; if ( ((count == 100) || !( count % 1000 )) && DEBUG_MAKE ) printf("...patience...\n"); #endif if( !( f = fopen( file, "r" ) ) ) return l; while( fgets( buf, sizeof( buf ), f ) ) { for( i = 0; i < rec; i++ ) if( regexec( re[i], buf ) && re[i]->startp[1] ) { re[i]->endp[1][0] = '\0'; if( DEBUG_HEADER ) printf( "header found: %s\n", re[i]->startp[1] ); l = list_new( l, newstr( re[i]->startp[1] ) ); } } fclose( f ); return l; } void regerror( char *s ) { printf( "re error %s\n", s ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 3969 | Matt Armstrong |
Integrate from //guest/matt_armstrong/jam/fix/2/...@3963 -- no real changes. |
||
#7 | 3950 | Matt Armstrong |
Integrate from //guest/matt_armstrong/jam/fix/1/... thru change 3948 and make no changes. |
||
#6 | 2817 | Matt Armstrong | Update with current known working version. | ||
#5 | 2507 | Matt Armstrong | update from the mainline | ||
#4 | 2506 | Matt Armstrong | no substantive change (move comment to ease future merge) | ||
#3 | 2089 | Matt Armstrong | More integrations from upstream. | ||
#2 | 1271 | Matt Armstrong |
This is "my" custom version of Jam. See the LOCAL_DIFFERENCES.txt file for a description of differences from the upstream jam. |
||
#1 | 1270 | Matt Armstrong | In prep for publishing all my patches to jam. | ||
//guest/perforce_software/jam/src/headers.c | |||||
#2 | 486 | Perforce staff |
Jam 2.3. See RELNOTES for a list of changes from 2.2.x. Just about every source file was touched when jam got ANSI-fied. |
||
#1 | 2 | laura | Add Jam/MR 2.2 source |