]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/engine/mkjambase.c
2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
8 * Copyright 2001-2004 David Abrahams.
9 * Distributed under the Boost Software License, Version 1.0.
10 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
14 * mkjambase.c - turn Jambase into a big C structure
16 * Usage: mkjambase jambase.c Jambase ...
18 * Results look like this:
25 * Handles \'s and "'s specially; knows to delete blank and comment lines.
33 int main( int argc
, char * * argv
, char * * envp
)
43 fprintf( stderr
, "usage: %s jambase.c Jambase ...\n", argv
[ 0 ] );
47 if ( !( fout
= fopen( argv
[1], "w" ) ) )
53 /* If the file ends in .c generate a C source file. */
54 if ( ( p
= strrchr( argv
[1], '.' ) ) && !strcmp( p
, ".c" ) )
57 /* Now process the files. */
64 fprintf( fout
, "/* Generated by mkjambase from Jambase */\n" );
65 fprintf( fout
, "char *jambase[] = {\n" );
68 for ( ; argc
--; ++argv
)
70 if ( !( fin
= fopen( *argv
, "r" ) ) )
77 fprintf( fout
, "/* %s */\n", *argv
);
79 fprintf( fout
, "### %s ###\n", *argv
);
81 while ( fgets( buf
, sizeof( buf
), fin
) )
87 /* Strip leading whitespace. */
88 while ( ( *p
== ' ' ) || ( *p
== '\t' ) || ( *p
== '\n' ) )
91 /* Drop comments and empty lines. */
92 if ( ( *p
== '#' ) || !*p
)
97 for ( ; *p
&& ( *p
!= '\n' ); ++p
)
100 case '\\': putc( '\\', fout
); putc( '\\', fout
); break;
101 case '"' : putc( '\\', fout
); putc( '"' , fout
); break;
103 default: putc( *p
, fout
); break;
106 fprintf( fout
, "\\n\",\n" );
110 fprintf( fout
, "%s", buf
);
118 fprintf( fout
, "0 };\n" );