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

Function CheckForBadCharacters

util/cpplint.py:1913–1935  ·  view source on GitHub ↗

Logs an error for each line containing bad characters. Two kinds of bad characters: 1. Unicode replacement characters: These indicate that either the file contained invalid UTF-8 (likely) or Unicode replacement characters (which it shouldn't). Note that it's possible for this to throw off

(filename, lines, error)

Source from the content-addressed store, hash-verified

1911
1912
1913def CheckForBadCharacters(filename, lines, error):
1914 """Logs an error for each line containing bad characters.
1915
1916 Two kinds of bad characters:
1917
1918 1. Unicode replacement characters: These indicate that either the file
1919 contained invalid UTF-8 (likely) or Unicode replacement characters (which
1920 it shouldn't). Note that it's possible for this to throw off line
1921 numbering if the invalid UTF-8 occurred adjacent to a newline.
1922
1923 2. NUL bytes. These are problematic for some tools.
1924
1925 Args:
1926 filename: The name of the current file.
1927 lines: An array of strings, each representing a line of the file.
1928 error: The function to call with any errors found.
1929 """
1930 for linenum, line in enumerate(lines):
1931 if '\ufffd' in line:
1932 error(filename, linenum, 'readability/utf8', 5,
1933 'Line contains invalid UTF-8 (or Unicode replacement character).')
1934 if '\0' in line:
1935 error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.')
1936
1937
1938def CheckForNewlineAtEOF(filename, lines, error):

Callers 1

ProcessFileDataFunction · 0.85

Calls 1

errorFunction · 0.85

Tested by

no test coverage detected