Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 48 lines (36 sloc) 0.819 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/usr/bin/env perl
#
# Generate a .c file with a print_copyright() function in it to print
# out the contents of all the files on the command line...
#
# Copyright (c) 2009, Wesley Darlington. All Rights Reserved.

use warnings;
use strict;

die "usage: $0 LICENCE ...\n" unless @ARGV;

sub c_stringify {
    my $line = shift;
    chomp($line);

    $line =~ s/\\/\\\\/;
    $line =~ s/"/\\"/;
    $line =~ s/\n/"\n"/g;

    return $line;
}

print qq{
/* AUTO GENERATED FILE - DO NOT MODIFY - SEE $0 FOR DETAILS */

#include <stdlib.h>

#include "copyright.h"
#include "eprintf.h"

void
print_copyright(void)
\{
EPRINTF_RAW(0, "\\n");
};

while (<>) {
    my $safe = c_stringify($_);
    print " EPRINTF_RAW(0, \"" . c_stringify($safe) . "\\n\");\n";
}

print qq{
EPRINTF_RAW(0, "\\n");

exit(0);
\}
};
Something went wrong with that request. Please try again.