[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 18/29] scripts: kernel-doc: fix troubles with line counts
From: |
Paolo Bonzini |
Subject: |
[PATCH 18/29] scripts: kernel-doc: fix troubles with line counts |
Date: |
Tue, 17 Nov 2020 17:53:01 +0100 |
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
There's currently a bug with the way kernel-doc script
counts line numbers that can be seen with:
$ ./scripts/kernel-doc -rst -enable-lineno include/linux/math64.h >all
&& ./scripts/kernel-doc -rst -internal -enable-lineno include/linux/math64.h
>int && diff -U0 int all
--- int 2020-09-28 12:58:08.927486808 +0200
+++ all 2020-09-28 12:58:08.905486845 +0200
@@ -1 +1 @@
-#define LINENO 27
+#define LINENO 26
@@ -3 +3 @@
-#define LINENO 16
+#define LINENO 15
@@ -9 +9 @@
-#define LINENO 17
+#define LINENO 16
...
This is happening with perl version 5.30.3, but I'm not
so sure if this is a perl bug, or if this is due to something
else.
In any case, fixing it is easy. Basically, when "-internal"
parameter is used, the process_export_file() function opens the
handle "IN". This makes the line number to be incremented, as the
handler for the main open is also "IN".
Fix the problem by using a different handler for the
main open().
While here, add a missing close for it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/kernel-doc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 75ddd3b5e6..f33a4b1cc7 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2268,7 +2268,7 @@ sub process_file($) {
$file = map_filename($orig_file);
- if (!open(IN,"<$file")) {
+ if (!open(IN_FILE,"<$file")) {
print STDERR "Error: Cannot open file $file\n";
++$errors;
return;
@@ -2277,9 +2277,9 @@ sub process_file($) {
$. = 1;
$section_counter = 0;
- while (<IN>) {
+ while (<IN_FILE>) {
while (s/\\\s*$//) {
- $_ .= <IN>;
+ $_ .= <IN_FILE>;
}
# Replace tabs by spaces
while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
@@ -2311,6 +2311,7 @@ sub process_file($) {
print STDERR "${file}:1: warning: no structured comments found\n";
}
}
+ close IN_FILE;
}
--
2.28.0
- [PATCH 07/29] Replace HTTP links with HTTPS ones: documentation, (continued)
- [PATCH 07/29] Replace HTTP links with HTTPS ones: documentation, Paolo Bonzini, 2020/11/17
- [PATCH 08/29] scripts/kernel-doc: parse __ETHTOOL_DECLARE_LINK_MODE_MASK, Paolo Bonzini, 2020/11/17
- [PATCH 09/29] scripts/kernel-doc: handle function pointer prototypes, Paolo Bonzini, 2020/11/17
- [PATCH 10/29] scripts/kernel-doc: optionally treat warnings as errors, Paolo Bonzini, 2020/11/17
- [PATCH 12/29] kernel-doc: add support for ____cacheline_aligned attribute, Paolo Bonzini, 2020/11/17
- [PATCH 11/29] kernel-doc: include line numbers for function prototypes, Paolo Bonzini, 2020/11/17
- [PATCH 13/29] scripts: kernel-doc: add support for typedef enum, Paolo Bonzini, 2020/11/17
- [PATCH 14/29] Revert "scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments", Paolo Bonzini, 2020/11/17
- [PATCH 15/29] Revert "kernel-doc: Use c:struct for Sphinx 3.0 and later", Paolo Bonzini, 2020/11/17
- [PATCH 16/29] scripts: kernel-doc: make it more compatible with Sphinx 3.x, Paolo Bonzini, 2020/11/17
- [PATCH 18/29] scripts: kernel-doc: fix troubles with line counts,
Paolo Bonzini <=
- [PATCH 17/29] scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x, Paolo Bonzini, 2020/11/17
- [PATCH 19/29] scripts: kernel-doc: reimplement -nofunction argument, Paolo Bonzini, 2020/11/17
- [PATCH 20/29] scripts: kernel-doc: fix typedef identification, Paolo Bonzini, 2020/11/17
- [PATCH 25/29] Revert "kernel-doc: Handle function typedefs without asterisks", Paolo Bonzini, 2020/11/17
- [PATCH 21/29] scripts: kernel-doc: don't mangle with parameter list, Paolo Bonzini, 2020/11/17
- [PATCH 22/29] scripts: kernel-doc: allow passing desired Sphinx C domain dialect, Paolo Bonzini, 2020/11/17
- [PATCH 23/29] scripts: kernel-doc: fix line number handling, Paolo Bonzini, 2020/11/17
- [PATCH 24/29] scripts: kernel-doc: try to use c:function if possible, Paolo Bonzini, 2020/11/17
- [PATCH 26/29] Revert "kernel-doc: Handle function typedefs that return pointers", Paolo Bonzini, 2020/11/17
- [PATCH 27/29] scripts: kernel-doc: fix typedef parsing, Paolo Bonzini, 2020/11/17