diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-15 13:16:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-16 06:10:14 +0000 |
commit | 6742500ccb2ff6d39f527760152d2b08fd9cfe17 (patch) | |
tree | 883ce070db6733f6c548242eb8763129a9f17f5e /bin | |
parent | 64ea8306b0ceb001132ac9cbc945a12afc01b8cd (diff) |
remove unused defines from HRC files in sw/
Change-Id: I74fb244b2440ddf7682362444c20730ac0e58cea
Reviewed-on: https://gerrit.libreoffice.org/35212
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/find-unused-defines-in-hrc-files.py | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/bin/find-unused-defines-in-hrc-files.py b/bin/find-unused-defines-in-hrc-files.py index f24e1a61b6fe..59d917ad1dea 100755 --- a/bin/find-unused-defines-in-hrc-files.py +++ b/bin/find-unused-defines-in-hrc-files.py @@ -57,7 +57,27 @@ exclusionSet = set([ # other places doing calculations "RID_SVXSTR_DEPTH", "RID_SUBSETSTR_", - "ANALYSIS_" + "ANALYSIS_", + "FLD_DOCINFO_CHANGE", + "FLD_EU_", + "FLD_INPUT_", + "FLD_PAGEREF_", + "FLD_STAT_", + "FMT_AUTHOR_", + "FMT_CHAPTER_", + "FMT_DBFLD_", + "FMT_FF_", + "FMT_GETVAR_", + "FMT_MARK_", + "FMT_REF_", + "FMT_SETVAR_", + "STR_AUTH_FIELD_ADDRESS_", + "STR_AUTH_TYPE_", + "STR_AUTOFMTREDL_", + "STR_CONTENT_TYPE_", + "STR_UPDATE_ALL", + "STR_UPDATE_INDEX", + "STR_UPDATE_LINK", ]) @@ -73,7 +93,7 @@ with a.stdout as txt: for line in txt: idx1 = line.find("#define ") idx2 = line.find(" ", idx1 + 9) - idName = line[idx1+8 : idx2] + idName = line[idx1+8 : idx2].strip() # the various _START and _END constants are normally unused outside of the .hrc and .src files, and that's fine if idName.endswith("_START"): continue if idName.endswith("_BEGIN"): continue @@ -83,23 +103,33 @@ with a.stdout as txt: if idName == "RID_SVX_FIRSTFREE": continue if in_exclusion_set(idName): continue # search for the constant - b = subprocess.Popen(["git", "grep", "-wl", idName], stdout=subprocess.PIPE) + b = subprocess.Popen(["git", "grep", "-w", idName], stdout=subprocess.PIPE) found_reason_to_exclude = False with b.stdout as txt2: for line2 in txt2: line2 = line2.strip() # otherwise the comparisons below will not work # check if we found one in actual code - if not line2.endswith(".hrc") and not line2.endswith(".src"): found_reason_to_exclude = True + if not ".hrc:" in line2 and not ".src:" in line2: found_reason_to_exclude = True if idName.startswith("RID_"): - # check that the constant is not being used as an identifier by entries in .src files - if line2.endswith(".src") and line2.find("Identifier = ") != -1: found_reason_to_exclude = True - # check that the constant is not being used by the property controller extension or reportdesigner inspection, + # is the constant being used as an identifier by entries in .src files? + if ".src:" in line2 and "Identifier = " in line2: found_reason_to_exclude = True + # is the constant being used by the property controller extension or reportdesigner inspection, # which use macros to declare constants, hiding them from a search - if line2.find("extensions/source/propctrlr") != -1: found_reason_to_exclude = True - if line2.find("reportdesign/source/ui/inspection/inspection.src") != -1: found_reason_to_exclude = True + if "extensions/source/propctrlr" in line2: found_reason_to_exclude = True + if "reportdesign/source/ui/inspection/inspection.src" in line2: found_reason_to_exclude = True if idName.startswith("HID_"): - # check that the constant is not being used as an identifier by entries in .src files - if line2.endswith(".src") and line2.find("HelpId = ") != -1: found_reason_to_exclude = True + # is the constant being used as an identifier by entries in .src files + if ".src:" in line2 and "HelpId = " in line2: found_reason_to_exclude = True + # is it being used as a constant in an ItemList in .src files? + if ".src:" in line2 and ";> ;" in line2: found_reason_to_exclude = True + # these are used in calculations in other .hrc files + if "sw/inc/rcid.hrc:" in line2: found_reason_to_exclude = True + # calculations + if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "ST_" in line2: found_reason_to_exclude = True + if "sw/source/uibase/inc/ribbar.hrc:" in line2 and "STR_IMGBTN_" in line2: found_reason_to_exclude = True + if "sw/source/core/undo/undo.hrc:" in line2: found_reason_to_exclude = True + if "sw/inc/poolfmt.hrc:" in line2: found_reason_to_exclude = True + if not found_reason_to_exclude: sys.stdout.write(idName + '\n') # otherwise the previous line of output will be incorrectly mixed into the below git output, because of buffering |