MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / GetLineWidth

Function GetLineWidth

util/cpplint.py:4210–4229  ·  view source on GitHub ↗

Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters.

(line)

Source from the content-addressed store, hash-verified

4208
4209
4210def GetLineWidth(line):
4211 """Determines the width of the line in column positions.
4212
4213 Args:
4214 line: A string, which may be a Unicode string.
4215
4216 Returns:
4217 The width of the line in column positions, accounting for Unicode
4218 combining characters and wide characters.
4219 """
4220 if isinstance(line, str):
4221 width = 0
4222 for uc in unicodedata.normalize('NFC', line):
4223 if unicodedata.east_asian_width(uc) in ('W', 'F'):
4224 width += 2
4225 elif not unicodedata.combining(uc):
4226 width += 1
4227 return width
4228 else:
4229 return len(line)
4230
4231
4232def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,

Callers 2

CheckBracesFunction · 0.85
CheckStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected