mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
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.
This commit is contained in:
parent
dfd83f419c
commit
6d1474e7f1
@ -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
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!@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);
|
||||
|
Loading…
Reference in New Issue
Block a user