Lines Matching refs:line

916 def IsCppString(line):  argument
929 line = line.replace(r'\\', 'XX') # after this, \\" does not match to \"
930 return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1
977 def CleanseComments(line): argument
986 commentpos = line.find('//')
987 if commentpos != -1 and not IsCppString(line[:commentpos]):
988 line = line[:commentpos].rstrip()
990 return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line)
1038 def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): argument
1051 for i in xrange(startpos, len(line)):
1052 if line[i] == startchar:
1054 elif line[i] == endchar:
1079 line = clean_lines.elided[linenum]
1080 startchar = line[pos]
1082 return (line, clean_lines.NumLines(), -1)
1088 end_pos = FindEndOfExpressionInLine(line, pos, 0, startchar, endchar)
1090 return (line, linenum, end_pos)
1091 tail = line[pos:]
1095 line = clean_lines.elided[linenum]
1096 delta = line.count(startchar) - line.count(endchar)
1098 return (line, linenum,
1099 FindEndOfExpressionInLine(line, 0, num_open, startchar, endchar))
1103 return (line, clean_lines.NumLines(), -1)
1110 for line in xrange(1, min(len(lines), 11)):
1111 if re.search(r'Copyright', lines[line], re.I): break
1161 for linenum, line in enumerate(lines):
1162 linesplit = line.split()
1172 if line.startswith('#endif'):
1173 endif = line
1230 for linenum, line in enumerate(lines):
1231 if u'\ufffd' in line:
1271 line = clean_lines.elided[linenum]
1275 line = line.replace('\\\\', '')
1277 if line.count('/*') > line.count('*/'):
1285 if (line.count('"') - line.count('\\"')) % 2:
1324 line = clean_lines.elided[linenum]
1326 ix = line.find(single_thread_function)
1328 if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and
1329 line[ix - 1] not in ('_', '.', '>'))):
1358 line = clean_lines.elided[linenum]
1359 if _RE_PATTERN_INVALID_INCREMENT.match(line):
1422 line = clean_lines.elided[i]
1423 depth += line.count('{') - line.count('}')
1444 line = clean_lines.raw_lines[linenum]
1458 and not Match(r'};*\s*(//|/\*).*\bnamespace\b', line)):
1477 line):
1483 if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
1534 def UpdatePreprocessor(self, line): argument
1556 if Match(r'^\s*#\s*(if|ifdef|ifndef)\b', line):
1560 elif Match(r'^\s*#\s*(else|elif)\b', line):
1575 elif Match(r'^\s*#\s*endif\b', line):
1600 line = clean_lines.elided[linenum]
1603 self.UpdatePreprocessor(line)
1609 depth_change = line.count('(') - line.count(')')
1616 _MATCH_ASM.match(line)):
1636 namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line)
1643 line = namespace_decl_match.group(2)
1644 if line.find('{') != -1:
1646 line = line[line.find('{') + 1:]
1672 '(([^=>]|<[^<>]*>)*)$', line)
1678 line = class_decl_match.group(5)
1687 access_match = Match(r'\s*(public|private|protected)\s*:', line)
1694 matched = Match(r'^[^{;)}]*([{;)}])(.*)$', line)
1707 if _MATCH_ASM.match(line):
1725 line = matched.group(2)
1787 line = clean_lines.lines[linenum]
1789 if Search(r'printf\s*\(.*".*%[-+ ]?\d*q', line):
1793 if Search(r'printf\s*\(.*".*%\d+\$', line):
1798 line = line.replace('\\\\', '')
1800 if Search(r'("|\').*\\(%|\[|\(|{)', line):
1805 line = clean_lines.elided[linenum]
1811 line):
1815 if Match(r'\s*#\s*endif\s*[^/\s]+', line):
1819 if Match(r'\s*class\s+(\w+\s*::\s*)+\w+\s*;', line):
1824 line):
1828 if Search(r'^\s*const\s*string\s*&\s*\w+\s*;', line):
1855 line)
1864 def CheckSpacingForFunctionCall(filename, line, linenum, error): argument
1878 fncall = line # if there's no control flow construct, look at whole line
1883 match = Search(pattern, line)
1934 def IsBlankLine(line): argument
1946 return not line or line.isspace()
1973 line = lines[linenum]
1980 match_result = Match(regexp, line)
1999 function = Search(r'((\w|:)*)\(', line).group(1)
2012 elif Match(r'^\}\s*$', line): # function end
2015 elif not Match(r'^\s*$', line):
2062 line = clean_lines.elided[linenum] # get rid of comments and strings
2066 r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line)
2093 line = init_suffix
2105 match = Search(r'^[^<>(),;\[\]]*([<>(),;\[\]])(.*)$', line)
2109 line = match.group(2)
2144 line = clean_lines.elided[linenum]
2163 line = init_prefix
2167 match = Search(r'^(.*)([<>(),;\[\]])[^<>(),;\[\]]*$', line)
2171 line = match.group(1)
2203 line = clean_lines.elided[linenum]
2228 line = raw[linenum]
2242 if IsBlankLine(line) and not nesting_state.InNamespaceBody():
2304 commentpos = line.find('//')
2308 if (line.count('"', 0, commentpos) -
2309 line.count('\\"', 0, commentpos)) % 2 == 0: # not in quotes
2311 if (not Match(r'^\s*{ //', line) and
2313 line[commentpos-1] not in string.whitespace) or
2315 line[commentpos-2] not in string.whitespace))):
2320 if commentend < len(line) and not line[commentend] == ' ':
2328 match = (Search(r'[=/-]{4,}\s*$', line[commentend:]) or
2329 Search(r'^/$', line[commentend:]) or
2330 Search(r'^/+ ', line[commentend:]))
2334 CheckComment(line[commentpos:], filename, linenum, error)
2336 line = clean_lines.elided[linenum] # get rid of comments and strings
2339 line = re.sub(r'operator(==|!=|<|<<|<=|>=|>>|>)\(', 'operator\(', line)
2345 if Search(r'[\w.]=[\w.]', line) and not Search(r'\b(if|while) ', line):
2357 match = Search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line)
2363 match = Search(r'(\S)(?:L|UL|ULL|l|ul|ull)?<<(\S)', line)
2367 elif not Match(r'#.*include', line):
2369 reduced_line = line.replace('->', '')
2403 match = Search(r'>>[a-zA-Z_]', line)
2409 match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line)
2415 match = Search(r' (if\(|for\(|while\(|switch\()', line)
2427 line)
2432 not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)):
2441 if Search(r',[^\s]', line):
2449 if Search(r';[^\s};\\)/]', line):
2454 CheckSpacingForFunctionCall(filename, line, linenum, error)
2460 if Search(r'[^ ({]{', line):
2465 if Search(r'}else', line):
2471 if Search(r'\w\s+\[', line) and not Search(r'delete\s+\[', line):
2478 if Search(r':\s*;\s*$', line):
2481 elif Search(r'^\s*;\s*$', line):
2485 elif (Search(r'\s+;\s*$', line) and
2486 not Search(r'\bfor\b', line)):
2493 if (Search('for *\(.*[^:]:[^: ]', line) or
2494 Search('for *\(.*[^: ]:[^:]', line)):
2587 line = clean_lines.elided[linenum] # get rid of comments and strings
2589 if Match(r'\s*{\s*$', line):
2604 if Match(r'\s*else\s*', line):
2612 if Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line):
2613 if Search(r'}\s*else if([^{]*)$', line): # could be multi-line if
2615 pos = line.find('else if')
2616 pos = line.find('(', pos)
2627 if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line):
2632 if Match(r'\s*do [^\s{]', line):
2642 if Match(r'\s+{.*}\s*;', line) and not prevline.count(';'):
2643 line = prevline + line
2646 if (Search(r'{.*}\s*;', line) and
2647 line.count('{') == line.count('}') and
2648 not Search(r'struct|class|enum|\s*=\s*{', line)):
2666 line = clean_lines.elided[linenum]
2667 if Match(r'\s*(for|while)\s*\(', line):
2670 clean_lines, linenum, line.find('('))
2680 def ReplaceableCheck(operator, macro, line): argument
2712 return Match(match_this, line) and not Search(r'NULL|&&|\|\|', line)
2736 line = clean_lines.elided[linenum] # get rid of comments and strings
2740 if ReplaceableCheck(operator, current_macro, line):
2757 line = clean_lines.elided[linenum]
2760 if Match(r'^\s*#', line):
2771 if line.find('/*') >= 0 or line.find('*/') >= 0:
2774 for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line):
2780 def GetLineWidth(line): argument
2790 if isinstance(line, unicode):
2792 for uc in unicodedata.normalize('NFC', line):
2799 return len(line)
2821 line = raw_lines[linenum]
2823 if line.find('\t') != -1:
2841 while initial_spaces < len(line) and line[initial_spaces] == ' ':
2843 if line and line[-1].isspace():
2853 elif not initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$',
2854 line):
2866 if (line.startswith('#ifndef %s' % cppvar) or
2867 line.startswith('#define %s' % cppvar) or
2868 line.startswith('#endif // %s' % cppvar)):
2878 if (not line.startswith('#include') and not is_header_guard and
2879 not Match(r'^\s*//.*http(s?)://\S*$', line) and
2880 not Match(r'^// \$Id:.*#[0-9]+ \$$', line)):
2881 line_width = GetLineWidth(line)
3044 line = clean_lines.lines[linenum]
3047 if _RE_PATTERN_INCLUDE_NEW_STYLE.search(line):
3054 match = _RE_PATTERN_INCLUDE.search(line)
3087 match = _RE_PATTERN_INCLUDE.match(line)
3170 line = clean_lines.elided[linenum]
3171 if not line:
3174 match = _RE_PATTERN_INCLUDE.search(line)
3183 extended_line = line + clean_lines.elided[linenum + 1]
3185 extended_line = line
3199 fnline = line.split('{', 1)[0]
3223 r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line)
3231 not (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or
3232 Match(r'^\s*MockCallback<.*>', line))):
3247 CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum],
3255 if CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum],
3260 CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum],
3267 r'(&\([^)]+\)[\w(])|(&(static|dynamic|reinterpret)_cast\b)', line):
3278 line)
3290 if Search(r'\bdynamic_cast<', line) and not _IsTestFilename(filename):
3296 if Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line):
3310 if Search(r'\bshort port\b', line):
3311 if not Search(r'\bunsigned short port\b', line):
3315 match = Search(r'\b(short|long(?! +double)|long long)\b', line)
3321 match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line)
3329 if Search(r'\bsprintf\b', line):
3332 match = Search(r'\b(strcpy|strcat)\b', line)
3337 if Search(r'\bsscanf\b', line):
3347 if Search(r'\boperator\s*&\s*\(\s*\)', line):
3353 if Search(r'\}\s*if\s*\(', line):
3364 printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(')
3369 line, re.I).group(1)
3375 match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line)
3381 if Search(r'\busing namespace\b', line):
3387 match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line)
3432 line)
3449 and Search(r'\bnamespace\s*{', line)
3450 and line[-1] != '\\'):
3457 def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, argument
3477 match = Search(pattern, line)
3482 sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1])
3489 if (line[0:match.start(1) - 1].endswith(' operator++') or
3490 line[0:match.start(1) - 1].endswith(' operator--')):
3493 remainder = line[match.end(0):]
3655 for line in headerfile:
3657 clean_line = CleanseComments(line)
3689 line = clean_lines.elided[linenum]
3690 if not line or line[0] == '#':
3694 matched = _RE_PATTERN_STRING.search(line)
3698 prefix = line[:matched.start()]
3703 if pattern.search(line):
3707 if not '<' in line: # Reduces the cpu time usage by skipping lines.
3711 if pattern.search(line):
3776 line = raw[linenum]
3777 match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line)
3785 def ProcessLine(filename, file_extension, clean_lines, line, argument
3807 ParseNolintSuppressions(filename, raw_lines[line], line, error)
3808 nesting_state.Update(filename, clean_lines, line, error)
3811 CheckForFunctionLengths(filename, clean_lines, line, function_state, error)
3812 CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error)
3813 CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error)
3814 CheckLanguage(filename, clean_lines, line, file_extension, include_state,
3816 CheckForNonStandardConstructs(filename, clean_lines, line,
3818 CheckPosixThreading(filename, clean_lines, line, error)
3819 CheckInvalidIncrement(filename, clean_lines, line, error)
3820 CheckMakePairUsesDeduction(filename, clean_lines, line, error)
3822 check_fn(filename, clean_lines, line, error)
3855 for line in xrange(clean_lines.NumLines()):
3856 ProcessLine(filename, file_extension, clean_lines, line,