Commit 6d1474e7 authored by Christian Persch's avatar Christian Persch

Add @basename@ substitution to glib-mkenums

Since @filename@ contains the full filename as given to the glib-mkenum
command, possibly including path elements (e.g. when using a non-srcdir
build), it is unsuitable to use in a #include statement in the generated
file if one wants to distribute it. This patch adds @basename@ which
expands to the base name of the input filename. Bug #587307.
parent dfd83f41
......@@ -118,6 +118,9 @@ The same as \fI@type@\fP with all letters uppercased (e.g. FLAGS).
.TP 12
\fI@filename@
The name of the input file currently being processed (e.g. foo.h).
.TP 12
\fI@basename@
The base name of the input file currently being processed (e.g. foo.h). (Since: 2.22)
.SS Trigraph extensions
Some C comments are treated specially in the parsed enum definitions, such comments
......
#!@PERL_PATH@ -w
use File::Basename;
# glib-mkenums.pl
# Information about the current enumeration
my $flags; # Is enumeration a bitmask?
......@@ -160,6 +162,7 @@ sub usage {
print " \@Type\@ either Enum or Flags\n";
print " \@TYPE\@ either ENUM or FLAGS\n";
print " \@filename\@ name of current input file\n";
print " \@basename\@ base name of the current input file (Since: 2.22)\n";
exit 0;
}
......@@ -247,8 +250,10 @@ while ($_=$ARGV[0],/^-/) {
if (length($fhead)) {
my $prod = $fhead;
my $base = basename ($ARGV[0]);
$prod =~ s/\@filename\@/$ARGV[0]/g;
$prod =~ s/\@basename\@/$base/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;
chomp ($prod);
......@@ -397,8 +402,10 @@ while (<>) {
if (length($fprod)) {
my $prod = $fprod;
my $base = basename ($ARGV);
$prod =~ s/\@filename\@/$ARGV/g;
$prod =~ s/\@basename\@/$base/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;
chomp ($prod);
......@@ -485,8 +492,10 @@ while (<>) {
if (length($ftail)) {
my $prod = $ftail;
my $base = basename ($ARGV);
$prod =~ s/\@filename\@/$ARGV/g;
$prod =~ s/\@basename\@/$base/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;
chomp ($prod);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment