|
@@ -63,8 +63,12 @@ my @core_exports; # filled with select definitions from core (if -c is used)
|
|
my ($sel_grp_name, $sel_var_name);
|
|
my ($sel_grp_name, $sel_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_selline="SELLINE";
|
|
|
|
|
|
|
|
|
|
sub show_patch
|
|
sub show_patch
|
|
@@ -113,6 +117,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
|
|
@@ -128,6 +133,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)
|
|
@@ -454,6 +490,7 @@ if ($#ARGV < 0 || ! GetOptions( 'help|h|?' => \$opt_help,
|
|
'file|f=s' => \$file,
|
|
'file|f=s' => \$file,
|
|
'core|c=s' => \$core_file,
|
|
'core|c=s' => \$core_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,
|
|
@@ -473,6 +510,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_selline="SELLINE";
|
|
|
|
+}elsif (defined $opt_docbook){
|
|
|
|
+ $output_format_header="DOCBOOK_HEADER";
|
|
|
|
+ $output_format_footer="DOCBOOK_FOOTER";
|
|
|
|
+ $output_format_selline="DOCBOOK_SELLINE";
|
|
|
|
+}
|
|
|
|
+
|
|
process_file($file, \@sel_exports, defined $opt_is_tu);
|
|
process_file($file, \@sel_exports, defined $opt_is_tu);
|
|
process_file($core_file, \@core_exports, 0) if (defined $core_file);
|
|
process_file($core_file, \@core_exports, 0) if (defined $core_file);
|
|
print(STDERR "Done.\n") if $dbg;
|
|
print(STDERR "Done.\n") if $dbg;
|
|
@@ -485,23 +532,24 @@ if (@sel_exports > 0){
|
|
$i=0;
|
|
$i=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) {
|
|
- $sel_grp_name=$opt_force_grp_name;
|
|
|
|
|
|
+ $sel_grp_name=output_esc($opt_force_grp_name);
|
|
}elsif (!defined $sel_grp_name && defined $opt_grp_name) {
|
|
}elsif (!defined $sel_grp_name && defined $opt_grp_name) {
|
|
- $sel_grp_name=$opt_grp_name;
|
|
|
|
|
|
+ $sel_grp_name=output_esc($opt_grp_name);
|
|
}
|
|
}
|
|
print(STDERR "Generating select list...\n") if $dbg;
|
|
print(STDERR "Generating select list...\n") if $dbg;
|
|
my @sels = gen_selects "0";
|
|
my @sels = gen_selects "0";
|
|
- $~ = "HEADER"; write;
|
|
|
|
- $~ = "SELLINE" ;
|
|
|
|
|
|
+ $~ = $output_format_header; write;
|
|
|
|
+ $~ = $output_format_selline ;
|
|
for $s (@sels){
|
|
for $s (@sels){
|
|
- $extra_txt="";
|
|
|
|
- $desc="";
|
|
|
|
- $name=$s;
|
|
|
|
|
|
+ $extra_txt=output_esc("");
|
|
|
|
+ $desc=output_esc("");
|
|
|
|
+ $name=output_esc($s);
|
|
$i++;
|
|
$i++;
|
|
- #$extra_txt.="Returns an array." if ($flags & 1 );
|
|
|
|
|
|
+ #$extra_txt.=output_esc("Returns an array.") if ($flags & 1 );
|
|
# generate txt description
|
|
# generate txt description
|
|
write;
|
|
write;
|
|
}
|
|
}
|
|
|
|
+ $~ = $output_format_footer; write;
|
|
}else{
|
|
}else{
|
|
die "no selects found in $file\n";
|
|
die "no selects found in $file\n";
|
|
}
|
|
}
|
|
@@ -526,6 +574,9 @@ Selects@*
|
|
|
|
|
|
.
|
|
.
|
|
|
|
|
|
|
|
+format FOOTER =
|
|
|
|
+.
|
|
|
|
+
|
|
format SELLINE =
|
|
format SELLINE =
|
|
@>>. @*
|
|
@>>. @*
|
|
$i, $name
|
|
$i, $name
|
|
@@ -534,3 +585,34 @@ $i, $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="select_list@*">
|
|
|
|
+(valid_grp_name $sel_grp_name) ? "." . $sel_grp_name : ""
|
|
|
|
+ <title>Selects List@*</title>
|
|
|
|
+(valid_grp_name $sel_grp_name) ? " for " . $sel_grp_name : ""
|
|
|
|
+ <orderedlist>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+.
|
|
|
|
+
|
|
|
|
+format DOCBOOK_FOOTER =
|
|
|
|
+ </orderedlist>
|
|
|
|
+</chapter>
|
|
|
|
+.
|
|
|
|
+
|
|
|
|
+format DOCBOOK_SELLINE =
|
|
|
|
+ <listitem>@*
|
|
|
|
+ $name
|
|
|
|
+~~<para>^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< </para>
|
|
|
|
+ $desc
|
|
|
|
+~~<para>^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< </para>
|
|
|
|
+ $extra_txt
|
|
|
|
+ </listitem>
|
|
|
|
+
|
|
|
|
+.
|