|
@@ -72,8 +72,12 @@ my @cfg_default; # filled with config var defaults
|
|
my ($cfg_grp_name, $def_cfg_name, $cfg_var_name);
|
|
my ($cfg_grp_name, $def_cfg_name, $cfg_var_name);
|
|
|
|
|
|
my ($opt_help, $opt_txt, $opt_is_tu, $dbg, $opt_grp_name, $opt_patch);
|
|
my ($opt_help, $opt_txt, $opt_is_tu, $dbg, $opt_grp_name, $opt_patch);
|
|
-my $opt_force_grp_name;
|
|
|
|
|
|
+my ($opt_force_grp_name, $opt_docbook);
|
|
|
|
|
|
|
|
+# default output formats
|
|
|
|
+my $output_format_header="HEADER";
|
|
|
|
+my $output_format_footer="FOOTER";
|
|
|
|
+my $output_format_varline="VARLINE2";
|
|
|
|
|
|
|
|
|
|
sub show_patch
|
|
sub show_patch
|
|
@@ -121,6 +125,7 @@ Options:
|
|
is autodetected (see also -g).
|
|
is autodetected (see also -g).
|
|
--gcc gcc_name - run gcc_name instead of gcc.
|
|
--gcc gcc_name - run gcc_name instead of gcc.
|
|
-t | --txt - text mode output.
|
|
-t | --txt - text mode output.
|
|
|
|
+ --docbook | --xml - docbook output (xml).
|
|
-T | --tu - the input file is in raw gcc translation
|
|
-T | --tu - the input file is in raw gcc translation
|
|
unit format (as produced by
|
|
unit format (as produced by
|
|
gcc -fdump-translation-unit -c ). If not
|
|
gcc -fdump-translation-unit -c ). If not
|
|
@@ -136,6 +141,37 @@ Options:
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# escape a string for xml use
|
|
|
|
+# params: string to be escaped
|
|
|
|
+# return: escaped string
|
|
|
|
+sub xml_escape{
|
|
|
|
+ my $s=shift;
|
|
|
|
+ my %escapes = (
|
|
|
|
+ '"' => '"',
|
|
|
|
+ "'" => ''',
|
|
|
|
+ '&' => '&',
|
|
|
|
+ '<' => '<',
|
|
|
|
+ '>' => '>'
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $s=~s/(["'&<>])/$escapes{$1}/g;
|
|
|
|
+ return $s;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# escape a string according with the output requirements
|
|
|
|
+# params: string to be escaped
|
|
|
|
+# return: escaped string
|
|
|
|
+sub output_esc{
|
|
|
|
+ return xml_escape(shift) if defined $opt_docbook;
|
|
|
|
+ return shift;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
# eliminate casts and expressions.
|
|
# eliminate casts and expressions.
|
|
# (always go on the first operand)
|
|
# (always go on the first operand)
|
|
# params: node (GCC::Node)
|
|
# params: node (GCC::Node)
|
|
@@ -157,6 +193,7 @@ sub expr_op0{
|
|
if ($#ARGV < 0 || ! GetOptions( 'help|h|?' => \$opt_help,
|
|
if ($#ARGV < 0 || ! GetOptions( 'help|h|?' => \$opt_help,
|
|
'file|f=s' => \$file,
|
|
'file|f=s' => \$file,
|
|
'txt|t' => \$opt_txt,
|
|
'txt|t' => \$opt_txt,
|
|
|
|
+ 'docbook|xml' => \$opt_docbook,
|
|
'tu|T' => \$opt_is_tu,
|
|
'tu|T' => \$opt_is_tu,
|
|
'source|src|s=s' => \$src_fname,
|
|
'source|src|s=s' => \$src_fname,
|
|
'defs|d=s'=>\$c_defs,
|
|
'defs|d=s'=>\$c_defs,
|
|
@@ -176,6 +213,16 @@ if ($#ARGV < 0 || ! GetOptions( 'help|h|?' => \$opt_help,
|
|
do { show_patch(); exit 0; } if (defined $opt_patch);
|
|
do { show_patch(); exit 0; } if (defined $opt_patch);
|
|
do { select(STDERR); help(); exit 1 } if (!defined $file);
|
|
do { select(STDERR); help(); exit 1 } if (!defined $file);
|
|
|
|
|
|
|
|
+if (defined $opt_txt){
|
|
|
|
+ $output_format_header="HEADER";
|
|
|
|
+ $output_format_footer="FOOTER";
|
|
|
|
+ $output_format_varline="VARLINE2";
|
|
|
|
+}elsif (defined $opt_docbook){
|
|
|
|
+ $output_format_header="DOCBOOK_HEADER";
|
|
|
|
+ $output_format_footer="DOCBOOK_FOOTER";
|
|
|
|
+ $output_format_varline="DOCBOOK_VARLINE";
|
|
|
|
+}
|
|
|
|
+
|
|
if (! defined $opt_is_tu){
|
|
if (! defined $opt_is_tu){
|
|
# file is not a gcc translation-unit dump
|
|
# file is not a gcc translation-unit dump
|
|
# => we have to create one
|
|
# => we have to create one
|
|
@@ -342,17 +389,17 @@ if (@cfg_defs > 0){
|
|
}
|
|
}
|
|
# dump the configuration in txt mode
|
|
# dump the configuration in txt mode
|
|
if (defined $opt_force_grp_name) {
|
|
if (defined $opt_force_grp_name) {
|
|
- $cfg_grp_name=$opt_force_grp_name;
|
|
|
|
|
|
+ $cfg_grp_name=output_esc($opt_force_grp_name);
|
|
}elsif (!defined $cfg_grp_name && defined $opt_grp_name) {
|
|
}elsif (!defined $cfg_grp_name && defined $opt_grp_name) {
|
|
- $cfg_grp_name=$opt_grp_name;
|
|
|
|
|
|
+ $cfg_grp_name=output_esc($opt_grp_name);
|
|
}
|
|
}
|
|
- $~ = "HEADER"; write;
|
|
|
|
- $~ = "VARLINE2" ;
|
|
|
|
|
|
+ $~ = $output_format_header; write;
|
|
|
|
+ $~ = $output_format_varline ;
|
|
for $l (@cfg_defs){
|
|
for $l (@cfg_defs){
|
|
($name, $flags, $min, $max, $desc)=@{$l};
|
|
($name, $flags, $min, $max, $desc)=@{$l};
|
|
$type="";
|
|
$type="";
|
|
$extra_txt="";
|
|
$extra_txt="";
|
|
- $default= ($no>0) ? $cfg_default[$i] : "";
|
|
|
|
|
|
+ $default= ($no>0) ? output_esc($cfg_default[$i]) : "";
|
|
|
|
|
|
$i++;
|
|
$i++;
|
|
if ($min==0 && $max==0) {
|
|
if ($min==0 && $max==0) {
|
|
@@ -373,10 +420,13 @@ if (@cfg_defs > 0){
|
|
}
|
|
}
|
|
|
|
|
|
$extra_txt.="Read-only." if ($flags & 128 );
|
|
$extra_txt.="Read-only." if ($flags & 128 );
|
|
- $desc.=".";
|
|
|
|
|
|
+ $extra_txt=output_esc($extra_txt);
|
|
|
|
+ $desc=output_esc($desc . ".");
|
|
|
|
+ $name=output_esc($name);
|
|
# generate txt description
|
|
# generate txt description
|
|
write;
|
|
write;
|
|
}
|
|
}
|
|
|
|
+ $~ = $output_format_footer; write;
|
|
}else{
|
|
}else{
|
|
die "no configuration variables found in $file\n";
|
|
die "no configuration variables found in $file\n";
|
|
}
|
|
}
|
|
@@ -401,6 +451,9 @@ Configuration Variables@*
|
|
|
|
|
|
.
|
|
.
|
|
|
|
|
|
|
|
+format FOOTER =
|
|
|
|
+.
|
|
|
|
+
|
|
format VARLINE =
|
|
format VARLINE =
|
|
@>. @<<<<<<<<<<<<<<<<<<< - ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
@>. @<<<<<<<<<<<<<<<<<<< - ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
$i, $name, $desc
|
|
$i, $name, $desc
|
|
@@ -432,3 +485,43 @@ $i, (valid_grp_name $cfg_grp_name)?$cfg_grp_name . "." . $name : $name
|
|
$extra_txt
|
|
$extra_txt
|
|
|
|
|
|
.
|
|
.
|
|
|
|
+
|
|
|
|
+format DOCBOOK_HEADER =
|
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
+<!-- this file is autogenerated, do not edit! -->
|
|
|
|
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
|
|
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
|
|
+<chapter id="config_vars@*">
|
|
|
|
+(valid_grp_name $cfg_grp_name) ? "." . $cfg_grp_name : ""
|
|
|
|
+ <title> Configuration Variables@*</title>
|
|
|
|
+(valid_grp_name $cfg_grp_name) ? " for " . $cfg_grp_name : ""
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+.
|
|
|
|
+
|
|
|
|
+format DOCBOOK_FOOTER =
|
|
|
|
+</chapter>
|
|
|
|
+.
|
|
|
|
+
|
|
|
|
+format DOCBOOK_VARLINE =
|
|
|
|
+<section id="@*">
|
|
|
|
+ (valid_grp_name $cfg_grp_name)?$cfg_grp_name . "." . $name : $name
|
|
|
|
+ <title>@*</title>
|
|
|
|
+ (valid_grp_name $cfg_grp_name)?$cfg_grp_name . "." . $name : $name
|
|
|
|
+ <para>
|
|
|
|
+~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
+ $desc
|
|
|
|
+ </para>
|
|
|
|
+~ <para>Default value: @*.</para>
|
|
|
|
+ $default
|
|
|
|
+~ <para>Range: @* - @*.</para>
|
|
|
|
+ $min, $max
|
|
|
|
+~ <para>Type: @*.</para>
|
|
|
|
+ $type
|
|
|
|
+ <para>
|
|
|
|
+~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
+ $extra_txt
|
|
|
|
+ </para>
|
|
|
|
+</section>
|
|
|
|
+
|
|
|
|
+.
|