summaryrefslogtreecommitdiff
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorMartin Waitz <tali@admingilde.org>2005-03-11 16:40:16 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-11 16:40:16 -0800
commitd32e0c137a0a43a4766682b4a1434a47fe87e006 (patch)
tree3bb9bcc0cf7bda86b345feb47345e614ec5a4e2c /scripts/kernel-doc
parentbb445dd47e2ed04fb0fff87584b4912b5578bf4c (diff)
[PATCH] docbook: factor out escaping of XML special characters
Factor out escaping of XML special characters Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc24
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 7cc1e6464db1..d985f80957c2 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1624,6 +1624,15 @@ sub process_state3_type($$) {
}
}
+# replace <, >, and &
+sub xml_escape($) {
+ shift;
+ s/\&/\\\\\\amp;/g;
+ s/\</\\\\\\lt;/g;
+ s/\>/\\\\\\gt;/g;
+ return $_;
+}
+
sub process_file($) {
my ($file) = "$ENV{'SRCTREE'}@_";
my $identifier;
@@ -1695,10 +1704,7 @@ sub process_file($) {
$newcontents = $2;
if ($contents ne "") {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
}
@@ -1710,10 +1716,7 @@ sub process_file($) {
} elsif (/$doc_end/) {
if ($contents ne "") {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
$contents = "";
}
@@ -1727,10 +1730,7 @@ sub process_file($) {
# @parameter line to signify start of description
if ($1 eq "" &&
($section =~ m/^@/ || $section eq $section_context)) {
- $contents =~ s/\&/\\\\\\amp;/g;
- $contents =~ s/\</\\\\\\lt;/g;
- $contents =~ s/\>/\\\\\\gt;/g;
- dump_section($section, $contents);
+ dump_section($section, xml_escape($contents));
$section = $section_default;
$contents = "";
} else {