MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / _replaceCStrings

Method _replaceCStrings

tools/matchcompiler.py:657–677  ·  view source on GitHub ↗
(self, line)

Source from the content-addressed store, hash-verified

655 return line
656
657 def _replaceCStrings(self, line):
658 while True:
659 match = re.search('(==|!=) *"', line)
660 if not match:
661 break
662
663 if self._isInString(line, match.start()):
664 break
665
666 res = self._parseStringComparison(line, match.start())
667 if res is None:
668 break
669
670 startPos = res[0]
671 endPos = res[1]
672 text = line[startPos + 1:endPos - 1]
673 line = line[:startPos] + 'MatchCompiler::makeConstStringBegin' +\
674 text + 'MatchCompiler::makeConstStringEnd' + line[endPos:]
675 line = line.replace('MatchCompiler::makeConstStringBegin', 'MatchCompiler::makeConstString("')
676 line = line.replace('MatchCompiler::makeConstStringEnd', '")')
677 return line
678
679 def convertFile(self, srcname, destname, line_directive):
680 self._reset()

Callers 2

convertFileMethod · 0.95
test_replaceCStringsMethod · 0.80

Calls 3

_isInStringMethod · 0.95
replaceMethod · 0.45

Tested by 1

test_replaceCStringsMethod · 0.64