diff --git a/vsg/rules/after/rule_001.py b/vsg/rules/after/rule_001.py index 4f2185d7..7b6be703 100644 --- a/vsg/rules/after/rule_001.py +++ b/vsg/rules/after/rule_001.py @@ -24,14 +24,14 @@ class rule_001(rule.rule): def _analyze(self, oFile, oLine, iLineNumber): if oLine.insideClockProcess: if oLine.isSequentialEnd: - self.sequentialStatement += oLine.lineNoComment.replace('--', ' ') + self.sequentialStatement += oLine.lineNoComment + " " if not re.match('^\s*.*\safter\s', self.sequentialStatement): self.add_violation(iLineNumber) self.sequentialStatement = "" elif oLine.insideSequential: - self.sequentialStatement += oLine.lineNoComment.replace('--', ' ') + self.sequentialStatement += oLine.lineNoComment + " " elif oLine.isSequential: - self.sequentialStatement = oLine.lineNoComment.replace('--', ' ') + self.sequentialStatement = oLine.lineNoComment + " " def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/utils.py b/vsg/utils.py index df39dbe9..1255c0a4 100644 --- a/vsg/utils.py +++ b/vsg/utils.py @@ -104,7 +104,7 @@ def change_word(oLine, sWord, sNewWord, iMax=1): sNewWord: (string) ''' sLine = oLine.line - tLine = re.subn(r'\b' + sWord + r'\b', sNewWord, sLine, iMax, flags=re.IGNORECASE) + tLine = re.subn(r'\b' + re.escape(sWord) + r'\b', sNewWord, sLine, iMax, flags=re.IGNORECASE) sLine = tLine[0] if tLine[1] == 0: tLine = re.subn(' ' + sWord + ';', sNewWord + ';', sLine, iMax, flags=re.IGNORECASE) @@ -317,7 +317,7 @@ def search_for_and_remove_keyword(oFile, iLineNumber, sKeyword): # Regex to find comments that ignores contents of double quoted strings, # for example, "--" : a two bit std_logic_vector literal of don't cares. -has_comment_re = re.compile(r'.*?(?:".*?(?=").*?)*(?P--.*$)', re.IGNORECASE) +has_comment_re = re.compile(r'^(?:".*"|[^"\n])*?(?P--.*$)', re.IGNORECASE) def remove_comment(sString): ''' @@ -333,7 +333,7 @@ def remove_comment(sString): if match is None: return sString - return sString[:match.start("comment")] + return sString[:match.start("comment")].rstrip() def remove_blank_line(oFile, iLineNumber):