Skip to content

Commit

Permalink
Merge pull request #1975 from islas/registryOutOfSourceBuild
Browse files Browse the repository at this point in the history
Add the ability for registry code generation to be out of source
  • Loading branch information
islas authored Jan 17, 2024
2 parents fefb8b9 + 484cba6 commit 715df80
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tools/reg_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,30 @@ pre_parse( char * dir, FILE * infile, FILE * outfile )
for ( p = inln ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
if ( !strncmp( p , "include", 7 ) && ! ( ifdef_stack_ptr >= 0 && ! ifdef_stack[ifdef_stack_ptr] ) ) {
FILE *include_fp ;
char include_file_name_local_registry[128] ;
char include_file_name[128] ;
p += 7 ; for ( ; ( *p == ' ' || *p == ' ' ) && *p != '\0' ; p++ ) ;
if ( strlen( p ) > 127 ) { fprintf(stderr,"Registry warning: invalid include file name: %s\n", p ) ; }
else {
sprintf( include_file_name , "%s/%s", dir , p ) ;

sprintf( include_file_name_local_registry, "./Registry/%s", p ) ;
sprintf( include_file_name, "%s/%s", dir , p ) ;

if ( (p=index(include_file_name_local_registry,'\n')) != NULL ) *p = '\0' ;
if ( (p=index(include_file_name,'\n')) != NULL ) *p = '\0' ;

fprintf(stderr,"opening %s\n",include_file_name) ;
if (( include_fp = fopen( include_file_name , "r" )) != NULL ) {
if ( ( ( include_fp = fopen( include_file_name_local_registry, "r" ) ) != NULL ) || // Use short circuit logic here to try both sequentially
( ( include_fp = fopen( include_file_name, "r" ) ) != NULL ) )
{

fprintf(stderr,"including %s\n",include_file_name ) ;
pre_parse( dir , include_fp , outfile ) ;

fclose( include_fp ) ;
} else {
fprintf(stderr,"Registry warning: cannot open %s. Ignoring.\n", include_file_name ) ;
}
else {
fprintf(stderr,"Registry warning: cannot open %s. Tried %s and %s Ignoring.\n", include_file_name, include_file_name, include_file_name_local_registry ) ;
}
}
}
Expand Down

0 comments on commit 715df80

Please sign in to comment.