The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

headers.c File Reference

#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 "hdrmacro.h"
#include "newstr.h"

Include dependency graph for headers.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MAXINC   10

Functions

void headers (TARGET *t)
LISTheaders1 (LIST *l, char *file, int rec, regexp *re[])
void regerror (char *s)


Define Documentation

#define MAXINC   10
 

Definition at line 58 of file headers.c.


Function Documentation

void headers TARGET t  ) 
 

Definition at line 61 of file headers.c.

References frame::args, _target::boundname, evaluate_rule(), FRAME, frame_free(), frame_init(), hcache(), headers1(), L0, LIST, list_new(), list_next, lol_add(), lol_get(), MAXINC, _target::name, regex_compile(), _list::string, TARGET, and var_get().

Referenced by make0(), and make1c().

00062 {
00063     LIST        *hdrscan;
00064     LIST        *hdrrule;
00065     LIST        *headlist = 0;
00066     regexp      *re[ MAXINC ];
00067     int rec = 0;
00068         
00069     if( !( hdrscan = var_get( "HDRSCAN" ) ) || 
00070         !( hdrrule = var_get( "HDRRULE" ) ) )
00071         return;
00072 
00073     if( DEBUG_HEADER )
00074         printf( "header scan %s\n", t->name );
00075 
00076     /* Compile all regular expressions in HDRSCAN */
00077 
00078     while( rec < MAXINC && hdrscan )
00079     {
00080         re[rec++] = regex_compile( hdrscan->string );
00081         hdrscan = list_next( hdrscan );
00082     }
00083 
00084     /* Doctor up call to HDRRULE rule */
00085     /* Call headers1() to get LIST of included files. */
00086     {
00087         FRAME   frame[1];
00088         frame_init( frame );
00089         lol_add( frame->args, list_new( L0, t->name ) );
00090 #ifdef OPT_HEADER_CACHE_EXT
00091         lol_add( frame->args, hcache( t, rec, re, hdrscan ) );
00092 #else
00093         lol_add( frame->args, headers1( headlist, t->boundname, rec, re ) );
00094 #endif
00095 
00096         if( lol_get( frame->args, 1 ) )
00097             evaluate_rule( hdrrule->string, frame );
00098 
00099         /* Clean up */
00100 
00101         frame_free( frame );
00102     }
00103 }

Here is the call graph for this function:

LIST * headers1 LIST l,
char *  file,
int  rec,
regexp re[]
[static]
 

Definition at line 114 of file headers.c.

References regexp::endp, f(), fclose(), file, i, LIST, list_new(), macro_header_get(), newstr(), regex_compile(), regexec(), and regexp::startp.

Referenced by headers().

00119 {
00120         FILE    *f;
00121         char    buf[ 1024 ];
00122         int             i;
00123         static regexp *re_macros = 0;
00124 
00125         
00126 #ifdef OPT_IMPROVED_PATIENCE_EXT
00127         static int count = 0;
00128         ++count;
00129         if ( ((count == 100) || !( count % 1000 )) && DEBUG_MAKE )
00130             printf("...patience...\n");
00131 #endif
00132         
00133         /* the following regexp is used to detect cases where a  */
00134         /* file is included through a line line "#include MACRO" */
00135         if ( re_macros == 0 )
00136         {
00137             re_macros = regex_compile(
00138                 "^[     ]*#[    ]*include[      ]*([A-Za-z][A-Za-z0-9_]*).*$" );
00139         }
00140 
00141 
00142         if( !( f = fopen( file, "r" ) ) )
00143             return l;
00144 
00145         while( fgets( buf, sizeof( buf ), f ) )
00146         {
00147             for( i = 0; i < rec; i++ )
00148                 if( regexec( re[i], buf ) && re[i]->startp[1] )
00149             {
00150                 re[i]->endp[1][0] = '\0';
00151 
00152                 if( DEBUG_HEADER )
00153                     printf( "header found: %s\n", re[i]->startp[1] );
00154 
00155                 l = list_new( l, newstr( re[i]->startp[1] ) );
00156             }
00157             
00158             /* special treatment for #include MACRO */
00159             if ( regexec( re_macros, buf ) && re_macros->startp[1] )
00160             {
00161               char*  header_filename;
00162               
00163               re_macros->endp[1][0] = '\0';
00164               
00165               if ( DEBUG_HEADER )
00166                 printf( "macro header found: %s", re_macros->startp[1] );
00167                 
00168               header_filename = macro_header_get( re_macros->startp[1] );
00169               if (header_filename)
00170               {
00171                 if ( DEBUG_HEADER )
00172                   printf( " resolved to '%s'\n", header_filename );
00173                 l = list_new( l, newstr( header_filename ) );
00174               }
00175               else
00176               {
00177                 if ( DEBUG_HEADER )
00178                   printf( " ignored !!\n" );
00179               }
00180             }
00181         }
00182 
00183         fclose( f );
00184 
00185         return l;
00186 }

Here is the call graph for this function:

void regerror char *  s  ) 
 

Definition at line 189 of file headers.c.

References s.

Referenced by regexec(), regmatch(), and regrepeat().

00190 {
00191         printf( "re error %s\n", s );
00192 }


Generated on Mon Nov 8 17:08:01 2004 for MPT by  doxygen 1.3.9.1