Skip to content

Commit 7c9aa01

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts: kernel-doc: replace tabs by spaces
Sphinx has a hard time dealing with tabs, causing it to misinterpret paragraph continuation. As we're now mainly focused on supporting ReST output, replace tabs by spaces, in order to avoid troubles when the output is parsed by Sphinx. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent bdfe2be commit 7c9aa01

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/kernel-doc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ sub tracepoint_munge($) {
15791579
sub syscall_munge() {
15801580
my $void = 0;
15811581

1582-
$prototype =~ s@[\r\n\t]+@ @gos; # strip newlines/CR's/tabs
1582+
$prototype =~ s@[\r\n]+@ @gos; # strip newlines/CR's
15831583
## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
15841584
if ($prototype =~ m/SYSCALL_DEFINE0/) {
15851585
$void = 1;
@@ -1778,6 +1778,8 @@ sub process_file($) {
17781778
while (s/\\\s*$//) {
17791779
$_ .= <IN>;
17801780
}
1781+
# Replace tabs by spaces
1782+
while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
17811783
if ($state == STATE_NORMAL) {
17821784
if (/$doc_start/o) {
17831785
$state = STATE_NAME; # next line is always the function name
@@ -1877,8 +1879,7 @@ sub process_file($) {
18771879
$in_purpose = 0;
18781880
$contents = $newcontents;
18791881
$new_start_line = $.;
1880-
while ((substr($contents, 0, 1) eq " ") ||
1881-
substr($contents, 0, 1) eq "\t") {
1882+
while (substr($contents, 0, 1) eq " ") {
18821883
$contents = substr($contents, 1);
18831884
}
18841885
if ($contents ne "") {
@@ -1947,8 +1948,7 @@ sub process_file($) {
19471948
$contents = $2;
19481949
$new_start_line = $.;
19491950
if ($contents ne "") {
1950-
while ((substr($contents, 0, 1) eq " ") ||
1951-
substr($contents, 0, 1) eq "\t") {
1951+
while (substr($contents, 0, 1) eq " ") {
19521952
$contents = substr($contents, 1);
19531953
}
19541954
$contents .= "\n";

0 commit comments

Comments
 (0)