#!/usr/bin/python # Scan .hrc files for conflicting SID constants # # This is not as easy as it sounds because some of the constants depend on other # constants whose names do not start with SID_ # import subprocess sidNameToValue = dict() sidNameToOriginalLine = dict() def extractSidValue(sidValue): if isinstance(sidValue, int): return sidValue if sidValue.isdigit(): return int(sidValue) if sidValue[0:2] == "0x": return int(sidValue, 16) if sidValue.find("+") != -1: tokens = sidValue.split("+") tokens1 = tokens[0].strip() tokens2 = tokens[1].strip() return extractSidValue(tokens1) + extractSidValue(tokens2) rv = extractSidValue(sidNameToValue[sidValue]) sidNameToValue[sidValue] = rv return rv #a = subprocess.Popen(r"git grep -P '#define\s+(SID_|SC_|DETECTIVE_|DRAWTEXTBAR_|DRAW_BAR_|RID_|OBJBAR_FORMAT_|TAB_POPUP_|DATA_MENU_|EXTRA_MENU_|FORMAT_MENU_|INSERT_MENU_|VIEW_MENU_|EDIT_MENU_|FILE_MENU_|SC_FUNCTION_|RC_)'", stdout=subprocess.PIPE, shell=True) a = subprocess.Popen(r"git grep -Pn '#define\s+(\S+)' -- *.hrc", stdout=subprocess.PIPE, shell=True) with a.stdout as txt: for line in txt: originalLine = line.strip() # strip the '#define' off the front idx1 = line.find(" ") line = line[idx1 : len(line)].strip() # extract the name idx1 = line.find(" ") if (idx1 == -1): continue sidName = line[0:idx1].strip() line = line[idx1:len(line)].strip() # strip any trailing comments idx1 = line.find("//") if (idx1 != -1): line = line[0:idx1].strip() idx1 = line.find("/*") if (idx1 != -1): line = line[0:idx1].strip() if len(line) == 0: continue # strip brackets if line[0] == "(": line = line[1:] if line[len(line)-1] == ")": line = line[0:len(line)-1] sidTextValue = line.strip() # ignore the #define strings if (sidTextValue.find("\"") != -1): continue # ignore the multiline macros if (sidTextValue.find("\\") != -1): continue # check for redefinitions if sidName[0:4] == "SID_" and sidNameToValue.has_key(sidName): print("Redefinition:\n\t", sidNameToOriginalLine[sidName], "\n\t" , originalLine) else: sidNameToValue[sidName] = sidTextValue sidNameToOriginalLine[sidName] = originalLine # decode the constants into their numeric values recursively sidNamesToIgnore = set() for sidName in sidNameToValue: sidTextValue = sidNameToValue[sidName] try: sidValueNum = extractSidValue(sidTextValue) sidNameToValue[sidName] = sidValueNum except KeyError: sidNamesToIgnore.add(sidName) # check for conflicts sidValueToName = dict() for sidName in sidNameToValue: if sidName in sidNamesToIgnore: continue if sidName[0:4] != "SID_": continue sidValue = sidNameToValue[sidName] if sidValueToName.has_key(sidValue): print("conflict:\n\t", sidNameToOriginalLine[sidName], "\n\t", sidNameToOriginalLine[sidValueToName[sidValue]]) else: sidValueToName[sidValue] = sidName ption> LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/embedserv/util
AgeCommit message (Expand)Author
2013-12-17Adapt all (non-extension, SharedLibrary) .components to environment="..."Stephan Bergmann
2012-10-01Use prefixTor Lillqvist
2012-07-13re-base on ALv2 code. Includes:Michael Meeks
2012-03-10embedserv: convert to gbuildMatúš Kukan
2011-10-03chmod -xTor Lillqvist
2011-08-17Fix MSVC build with debugging C/C++ runtime, i.e. with --enable-dbgutilTor Lillqvist
2011-08-17Bin a couple of duplicated and unneeded linesTor Lillqvist
2011-07-12Remove component_getImplementationEnvironmentMatus Kukan
2011-05-16Use current terminology and socket libraryTor Lillqvist
2010-09-10sb129: #i113189# change UNO components to use passive registrationsb
2010-02-12changefileheader2: #i109125#: change source file copyright notice from Sun Mi...Jens-Heiner Rechtien
2008-06-06INTEGRATION: CWS mingwport13 (1.16.4); FILE MERGEDVladimir Glazounov
2008-04-11INTEGRATION: CWS changefileheader (1.15.2); FILE MERGEDRüdiger Timm
2008-02-25INTEGRATION: CWS supdremove02 (1.14.16); FILE MERGEDOliver Bolte
2007-06-05INTEGRATION: CWS obo12 (1.13.6); FILE MERGEDIvo Hinkelmann
2007-03-26INTEGRATION: CWS mingwport03 (1.11.6); FILE MERGEDVladimir Glazounov
2007-02-28INTEGRATION: CWS obo09 (1.11.22); FILE MERGEDVladimir Glazounov
2006-06-20INTEGRATION: CWS warnings01 (1.10.16); FILE MERGEDJens-Heiner Rechtien