diff --git a/codespell.py b/codespell.py index 51373650b7..868459ee93 100755 --- a/codespell.py +++ b/codespell.py @@ -20,10 +20,10 @@ # file1 .. fileN Files to check spelling class Mispell: - def __init__(self, data, fix): + def __init__(self, data, fix, reason): self.data = data self.fix = fix - + self.reason = reason class TermColors: def __init__(self): @@ -66,7 +66,18 @@ def build_dict(filename): with open(filename, 'r') as f: for line in f: [key, data] = line.split('->') - misspellings[key] = Mispell(data, data.find(',') + 1) + fix = data.find(',') + + if fix != (len(data) - 1) and fix > 0: + reason = data.split(',')[-1] + else: + reason = '' + + if fix > 0: + fix = True + data = "%s\n" % data[:data.rfind(',')] + + misspellings[key] = Mispell(data, fix, reason) def parse_file(filename, colors): if filename == '-': diff --git a/example/code.c b/example/code.c index 87bcf6ff0f..81210c3f6a 100644 --- a/example/code.c +++ b/example/code.c @@ -1,12 +1,18 @@ +int f(int type) +{ + return type; +} int main(void) { - int fd; + int fd, clas; /* tis code does nothing */ f(1, 2, 3); fd = opem("/tmp/a", O_RDONLY); - return 0; + + // buring your cpu + return f(clas); } diff --git a/example/dict.txt b/example/dict.txt index 702837bb9a..b2b2fe0558 100644 --- a/example/dict.txt +++ b/example/dict.txt @@ -1,2 +1,4 @@ tis->this opem->open +buring->burying, burning, burin, during, +clas->class, disabled due to name clash in c++