MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / extractCString

Function extractCString

preprocessor/parser.py:113–132  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

111# contents of the C/C++ string as a python string. None if
112# the lines did not encode a C/C++ style string.
113def extractCString(source):
114 returnString = ""
115 isInQuotes = False
116 prevWasEscape = False
117
118 for line in source.splitlines(True):
119 for c in line:
120 if c == "\"" and not prevWasEscape:
121 isInQuotes = not isInQuotes
122 elif isInQuotes:
123 returnString += c
124 prevWasEscape = c == "\\"
125 else:
126 if not (c.isspace()):
127 return None
128
129 if isInQuotes:
130 return None
131
132 return returnString
133
134# Attempt to extract a single argument in a C++ function invocation given
135# the argument's start position (immediately after left parenthesis or comma)

Callers 2

processFileFunction · 0.85
test_extractCStringMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_extractCStringMethod · 0.68