Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 70783
b: refs/heads/master
c: 6b5b55f
h: refs/heads/master
i:
  70781: 9ac53b0
  70779: 3f6336c
  70775: f2a0be0
  70767: 31d510a
  70751: ffdc6a1
  70719: b8bfced
  70655: 8cebdcc
v: v3
  • Loading branch information
Randy Dunlap authored and Linus Torvalds committed Oct 17, 2007
1 parent af75f4c commit 8431834
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 51448e2ad72c3cdb50e4118edc47fbcbcc1d03d3
refs/heads/master: 6b5b55f6c404fa730a09a8254eb19f5a038afcc2
41 changes: 32 additions & 9 deletions trunk/scripts/kernel-doc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use strict;
## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
## Copyright (C) 2001 Simon Huggins ##
## Copyright (C) 2005-2007 Randy Dunlap ##
## ##
## #define enhancements by Armin Kuster <akuster@mvista.com> ##
## Copyright (c) 2000 MontaVista Software, Inc. ##
Expand Down Expand Up @@ -161,7 +162,7 @@ my $type_constant = '\%([-_\w]+)';
my $type_func = '(\w+)\(\)';
my $type_param = '\@(\w+)';
my $type_struct = '\&((struct\s*)*[_\w]+)';
my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)';
my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
my $type_env = '(\$\w+)';

# Output conversion substitutions.
Expand All @@ -173,7 +174,9 @@ my %highlights_html = ( $type_constant, "<i>\$1</i>",
$type_struct_xml, "<i>\$1</i>",
$type_env, "<b><i>\$1</i></b>",
$type_param, "<tt><b>\$1</b></tt>" );
my $blankline_html = "<p>";
my $local_lt = "\\\\\\\\lt:";
my $local_gt = "\\\\\\\\gt:";
my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"

# XML, docbook format
my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
Expand Down Expand Up @@ -391,17 +394,19 @@ sub output_highlight {
# confess "output_highlight got called with no args?\n";
# }

if ($output_mode eq "html") {
$contents = local_unescape($contents);
# convert data read & converted thru xml_escape() into &xyz; format:
$contents =~ s/\\\\\\/&/g;
}
# print STDERR "contents b4:$contents\n";
eval $dohighlight;
die $@ if $@;
if ($output_mode eq "html") {
$contents =~ s/\\\\//;
}
# print STDERR "contents af:$contents\n";

foreach $line (split "\n", $contents) {
if ($line eq ""){
print $lineprefix, $blankline;
print $lineprefix, local_unescape($blankline);
} else {
$line =~ s/\\\\\\/\&/g;
if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
Expand Down Expand Up @@ -1752,7 +1757,13 @@ sub process_state3_type($$) {
}
}

# replace <, >, and &
# xml_escape: replace <, >, and & in the text stream;
#
# however, formatting controls that are generated internally/locally in the
# kernel-doc script are not escaped here; instead, they begin life like
# $blankline_html (4 of '\' followed by a mnemonic + ':'), then these strings
# are converted to their mnemonic-expected output, without the 4 * '\' & ':',
# just before actual output; (this is done by local_unescape())
sub xml_escape($) {
my $text = shift;
if (($output_mode eq "text") || ($output_mode eq "man")) {
Expand All @@ -1764,6 +1775,18 @@ sub xml_escape($) {
return $text;
}

# convert local escape strings to html
# local escape strings look like: '\\\\menmonic:' (that's 4 backslashes)
sub local_unescape($) {
my $text = shift;
if (($output_mode eq "text") || ($output_mode eq "man")) {
return $text;
}
$text =~ s/\\\\\\\\lt:/</g;
$text =~ s/\\\\\\\\gt:/>/g;
return $text;
}

sub process_file($) {
my $file;
my $identifier;
Expand Down Expand Up @@ -1903,7 +1926,7 @@ sub process_file($) {
} elsif ($state == 4) {
# Documentation block
if (/$doc_block/) {
dump_section($section, $contents);
dump_section($section, xml_escape($contents));
output_intro({'sectionlist' => \@sectionlist,
'sections' => \%sections });
$contents = "";
Expand All @@ -1923,7 +1946,7 @@ sub process_file($) {
}
elsif (/$doc_end/)
{
dump_section($section, $contents);
dump_section($section, xml_escape($contents));
output_intro({'sectionlist' => \@sectionlist,
'sections' => \%sections });
$contents = "";
Expand Down

0 comments on commit 8431834

Please sign in to comment.