Blame SOURCES/0006-checkopts-report-duplicated-options-in-man-page.patch

5eee7b
From 5cff08c4ac6bcb43ac2bc371db189a88c53c8326 Mon Sep 17 00:00:00 2001
5eee7b
From: Aurelien Aptel <aaptel@suse.com>
5eee7b
Date: Wed, 8 Aug 2018 11:38:15 +0200
5eee7b
Subject: [PATCH 06/36] checkopts: report duplicated options in man page
5eee7b
5eee7b
Signed-off-by: Aurelien Aptel <aaptel@suse.com>
5eee7b
(cherry picked from commit 77b028c11fee787d1235a08fd06c8b60d20eb9c0)
5eee7b
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
5eee7b
---
5eee7b
 checkopts | 19 ++++++++++++++++---
5eee7b
 1 file changed, 16 insertions(+), 3 deletions(-)
5eee7b
5eee7b
diff --git a/checkopts b/checkopts
5eee7b
index 26ca271..88e70b1 100755
5eee7b
--- a/checkopts
5eee7b
+++ b/checkopts
5eee7b
@@ -98,9 +98,12 @@ def extract_man_opts(fn):
5eee7b
     state = STATE_BASE
5eee7b
     rx = RX()
5eee7b
     opts = {}
5eee7b
+    ln = 0
5eee7b
 
5eee7b
     with open(fn) as f:
5eee7b
         for s in f.readlines():
5eee7b
+            ln += 1
5eee7b
+
5eee7b
             if state == STATE_EXIT:
5eee7b
                 break
5eee7b
 
5eee7b
@@ -113,7 +116,9 @@ def extract_man_opts(fn):
5eee7b
                     s = chomp(s)
5eee7b
                     names = extract_canonical_opts(s)
5eee7b
                     for name in names:
5eee7b
-                        opts[name] = s
5eee7b
+                        if name not in opts:
5eee7b
+                            opts[name] = []
5eee7b
+                        opts[name].append({'ln':ln, 'fmt':s})
5eee7b
                 elif rx.search(r'^[A-Z]+', s):
5eee7b
                     state = STATE_EXIT
5eee7b
     return opts
5eee7b
@@ -174,6 +179,14 @@ def main():
5eee7b
     def opt_is_doc(o):
5eee7b
         return o in manopts
5eee7b
 
5eee7b
+    print('DUPLICATED DOC OPTIONS')
5eee7b
+    print('======================')
5eee7b
+
5eee7b
+    for opt in sortedset(man_opts_set):
5eee7b
+        if len(manopts[opt]) > 1:
5eee7b
+            lines = ", ".join([str(x['ln']) for x in manopts[opt]])
5eee7b
+            print("OPTION %-20.20s (lines %s)"%(opt, lines))
5eee7b
+    print()
5eee7b
 
5eee7b
     print('UNDOCUMENTED OPTIONS')
5eee7b
     print('====================')
5eee7b
@@ -208,8 +221,8 @@ def main():
5eee7b
     unex_opts = man_opts_set - kernel_opts_set
5eee7b
     # group opts and their negations together
5eee7b
     for opt in sortedset(unex_opts):
5eee7b
-        fmt = manopts[opt]
5eee7b
-        print('OPTION %s ("%s")' % (opt, fmt))
5eee7b
+        man = manopts[opt][0]
5eee7b
+        print('OPTION %s ("%s") line %d' % (opt, man['fmt'], man['ln']))
5eee7b
 
5eee7b
 
5eee7b
     print('')
5eee7b
-- 
5eee7b
1.8.3.1
5eee7b