/* * Copyright 1993, 1995 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ /* * mkjambase.c - turn Jambase into a big C structure * * Usage: mkjambase jambase.c Jambase ... * * Results look like this: * * char *jambase[] = { * "...\n", * ... * 0 }; * * Handles \'s and "'s specially; knows to delete blank and comment lines. * * 11/04/02 (seiwald) - const-ing for string literals */ # include <stdio.h> # include <string.h> main( int argc, char **argv, char **envp ) { char buf[ 1024 ]; FILE *fin; FILE *fout; char *p; int doDotC = 0; if( argc < 3 ) { fprintf( stderr, "usage: %s jambase.c Jambase ...\n", argv[0] ); return -1; } if( !( fout = fopen( argv[1], "w" ) ) ) { perror( argv[1] ); return -1; } /* If the file ends in .c generate a C source file */ if( ( p = strrchr( argv[1], '.' ) ) && !strcmp( p, ".c" ) ) doDotC++; /* Now process the files */ argc -= 2, argv += 2; if( doDotC ) { fprintf( fout, "/* Generated by mkjambase from Jambase */\n" ); fprintf( fout, "const char *jambase[] = {\n" ); } for( ; argc--; argv++ ) { if( !( fin = fopen( *argv, "r" ) ) ) { perror( *argv ); return -1; } if( doDotC ) { fprintf( fout, "/* %s */\n", *argv ); } else { fprintf( fout, "### %s ###\n", *argv ); } while( fgets( buf, sizeof( buf ), fin ) ) { if( doDotC ) { char *p = buf; /* Strip leading whitespace. */ while( *p == ' ' || *p == '\t' || *p == '\n' ) p++; /* Drop comments and empty lines. */ if( *p == '#' || !*p ) continue; /* Copy */ putc( '"', fout ); for( ; *p && *p != '\n'; p++ ) switch( *p ) { case '\\': putc( '\\', fout ); putc( '\\', fout ); break; case '"': putc( '\\', fout ); putc( '"', fout ); break; default: putc( *p, fout ); break; } fprintf( fout, "\\n\",\n" ); } else { fprintf( fout, "%s", buf ); } } fclose( fin ); } if( doDotC ) fprintf( fout, "0 };\n" ); fclose( fout ); return 0; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 4331 | Chris Comparini |
Branch of what I hope is _everyone's_ jam branches, if that makes sense. |
||
//guest/perforce_software/jam/src/mkjambase.c | |||||
#4 | 2493 | rmg |
Rewrite the past: update all jam's source with comments to reflect changes since about 2.3, very early 2001. Whitespace only change. === computer:1666: Change 37660 by seiwald@play-seiwald on 2002/11/06 22:41:35 Note: I regenerated jamgram.c on my linux 7.3 system prior to the submit, since patch was so unhappy trying to lay down the changes from Christopher's change. Presumably this is just due to different yacc/bison/whatever particulars on the system where Christopher made the changes originally. - rmg |
||
#3 | 2491 | rmg |
Some consting in jam to make it more compilable by C++ compilers. No functional change. === computer:1666: Change 37433 by perforce@perforce on 2002/10/30 16:08:51 Recreational const-ing of jam, for compilers that don't allow "string" to be passed as a non-const char *. This included a few places where we were modifying what could possibly have been read-only storage, oddly enough. No functional change. === computer:1666: Change 37602 by seiwald@play-seiwald on 2002/11/04 17:25:40 |
||
#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 |