/* * Copyright 1993, 2000 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ #include "Headers.hpp" #include "Compile.hpp" #include "RegExp.hpp" #include "String.hpp" #include "Variable.hpp" using Jam::List; using Jam::String; /* * 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. */ static List *headers1( List *l, const char *file, int rec, regexp *re[] ); /* * 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::list_next( hdrscan ); } /* Doctor up call to HDRRULE rule */ /* Call headers1() to get List of included files. */ lol_init( &lol ); lol_add( &lol, List::list_new( NULL, t->name ) ); lol_add( &lol, headers1( headlist, t->boundname, rec, re ) ); if( lol_get( &lol, 1 ) ) { 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 */ static List * headers1( List *l, const char *file, int rec, regexp *re[] ) { FILE *f; char buf[ 1024 ]; int i; 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::list_new( l, String::newstr( re[i]->startp[1] ) ); } } } fclose( f ); return l; } void regerror( char *s ) { printf( "re error %s\n", s ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 1162 | bob_summerwill | Converted LIST into a List class, with all static methods. | ||
#9 | 1153 | bob_summerwill | NewStr has been renamed as String. | ||
#8 | 1146 | bob_summerwill | Moved the NewStr global functions into a static class Jam::String. | ||
#7 | 1138 | bob_summerwill | Removed all extern "C" wrappers, so the program now has C++ linkage throughout, ready for refactoring. | ||
#6 | 1132 | bob_summerwill | All of the non-generated, non-platform-specific files are now mixed-case C++ source files. | ||
#5 | 1131 | bob_summerwill | More .C to .CPP conversions. | ||
#4 | 1130 | bob_summerwill | More .C to .CPP conversions. | ||
#3 | 1127 | bob_summerwill | More file renaming. | ||
#2 | 1126 | bob_summerwill | #include dependencies between headers are now modelled explicitly, with #includes as required in header files, rather than it being a client-code responsibility. | ||
#1 | 1124 | bob_summerwill | More .c to .cpp conversions. | ||
//guest/bob_summerwill/jam/src/headers.c | |||||
#2 | 1120 | bob_summerwill | A fair-size chunk of char* const-correctness modifications. | ||
#1 | 1106 | bob_summerwill | Integrated Jam from "public" to "guest/bob_summerwill". | ||
//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 |