Merge branch 'dict' into v1.0.x
diff --git a/codespell.py b/codespell.py
index cf81490..0d627ec 100755
--- a/codespell.py
+++ b/codespell.py
@@ -25,7 +25,7 @@
USAGE = """
\t%prog [OPTIONS] dict_filename [file1 file2 ... fileN]
"""
-VERSION = '1.0'
+VERSION = '1.0.2'
misspellings = {}
options = None
@@ -164,8 +164,13 @@
i = 1
for line in lines:
+ fixed_words = set()
for word in re.findall('\w+', line):
lword = word.lower()
+
+ if lword in fixed_words:
+ continue
+
if lword in misspellings:
if word == word.capitalize():
fixword = misspellings[lword].data.capitalize()
@@ -178,7 +183,8 @@
if options.write_changes and misspellings[lword].fix:
changed = True
- lines[i - 1] = line.replace(word, fixword, 1)
+ lines[i - 1] = re.sub(r'\b%s\b' % word, fixword, lines[i - 1])
+ fixed_words.add(lword)
continue
cfilename = "%s%s%s" % (colors.FILE, filename, colors.DISABLE)