-.TH GLIB-MKENUMS 1 "20 Apr 2001"
+.TH GLIB-MKENUMS 1 "27 Jul 2002"
.SH NAME
glib-mkenums \- C language enum description generation utility
.SH SYNOPSIS
Template for auto-generated comments, the default (for C code generations) is
"/* @comment@ */".
.TP
+\fI--template file
+Read templates from the given file. The templates are enclosed in
+specially-formatted C comments
+.PP
+.RS
+.nf
+/*** BEGIN section ***/
+/*** END section ***/
+.fi
+.PP
+where section may be file-header, file-production, file-tail,
+enumeration-production, value-header, value-production, value-tail or
+comment.
+.TP
\fI-h, --help\fP
Print brief help and exit.
.TP
}
sub version {
- print STDERR "glib-mkenums version glib-2.0\n"; # FIXME: autogen version?
+ print STDERR "glib-mkenums version glib-@GLIB_VERSION@\n";
print STDERR "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
print STDERR "You may redistribute copies of glib-mkenums under the terms of\n";
print STDERR "the GNU General Public License which can be found in the\n";
print STDERR " --vprod <text> value text, produced for each enum value\n";
print STDERR " --vtail <text> value tail, produced after iterating over enum values\n";
print STDERR " --comments <text> comment structure\n";
+ print STDERR " --template file template file\n";
print STDERR " -h, --help show this help message\n";
print STDERR " -v, --version print version informations\n";
print STDERR "Production text substitutions:\n";
# other options
my $comment_tmpl = "/* \@comment\@ */";
+sub read_template_file {
+ my ($file) = @_;
+ my %tmpl = ('file-header', $fhead,
+ 'file-production', $fprod,
+ 'file-tail', $ftail,
+ 'enumeration-production', $eprod,
+ 'value-header', $vhead,
+ 'value-production', $vprod,
+ 'value-tail', $vtail,
+ 'comment', $comment_tmpl);
+ my $in = 'junk';
+ open (FILE, $file) || die "Can't open $file: $!\n";
+ while (<FILE>) {
+ if (/^\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\//) {
+ if (($in eq 'junk') && ($1 eq 'BEGIN') && (exists($tmpl{$2}))) {
+ $in = $2;
+ next;
+ }
+ elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
+ $in = 'junk';
+ next;
+ }
+ else {
+ die "Malformed template file $file\n";
+ }
+ }
+ if (!($in eq 'junk')) {
+ $tmpl{$in} .= $_;
+ }
+ }
+ close (FILE);
+ if (!($in eq 'junk')) {
+ die "Malformed template file $file\n";
+ }
+ $fhead = $tmpl{'file-header'};
+ $fprod = $tmpl{'file-production'};
+ $ftail = $tmpl{'file-tail'};
+ $eprod = $tmpl{'enumeration-production'};
+ $vhead = $tmpl{'value-header'};
+ $vprod = $tmpl{'value-production'};
+ $vtail = $tmpl{'value-tail'};
+ $comment_tmpl = $tmpl{'comment'};
+}
+
if (!defined $ARGV[0]) {
usage;
}
while ($_ = $ARGV[0], /^-/) {
shift;
last if /^--$/;
- if (/^--fhead$/) { $fhead = $fhead . shift }
+ if (/^--template$/) { read_template_file (shift); }
+ elsif (/^--fhead$/) { $fhead = $fhead . shift }
elsif (/^--fprod$/) { $fprod = $fprod . shift }
elsif (/^--ftail$/) { $ftail = $ftail . shift }
elsif (/^--eprod$/) { $eprod = $eprod . shift }
if (length($fhead)) {
my $prod = $fhead;
- $prod =~ s/\@filename\@/$ARGV/g;
+ $prod =~ s/\@filename\@/$ARGV[0]/g;
$prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
$prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;