scripts: kernel-doc: fix troubles with line counts
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 28 Sep 2020 10:52:34 +0000 (12:52 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 15 Oct 2020 05:49:36 +0000 (07:49 +0200)
commitdbe8ba00e5adc7573b8a91855f28a383c9728991
treed1cb026761a4b2237e69bb76dffc65d2c9a6176f
parente3ad05fe6e6ff645aa91e9a555231ff53470daba
scripts: kernel-doc: fix troubles with line counts

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>
scripts/kernel-doc