[PATCH 15/16] [DocBook] factor out escaping of XML special characters

From: Martin Waitz
Date: Thu Mar 03 2005 - 06:09:26 EST


[DocBook] factor out escaping of XML special characters
Signed-off-by: Martin Waitz <tali@xxxxxxxxxxxxxx>


# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.2039 -> 1.2040
# scripts/kernel-doc 1.26 -> 1.27
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 05/03/03 tali@xxxxxxxxxxxxxx 1.2040
# [DocBook] factor out escaping of XML special characters
#
# Signed-off-by: Martin Waitz <tali@xxxxxxxxxxxxxx>
# --------------------------------------------
#
diff -Nru a/scripts/kernel-doc b/scripts/kernel-doc
--- a/scripts/kernel-doc Thu Mar 3 11:43:21 2005
+++ b/scripts/kernel-doc Thu Mar 3 11:43:21 2005
@@ -1624,6 +1624,15 @@
}
}

+# 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 @@
$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 @@
} 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 @@
# @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 {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/