File: detect_self_assignment.py

package info (click to toggle)
gdal 3.6.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 89,664 kB
  • sloc: cpp: 1,136,033; ansic: 197,355; python: 35,910; java: 5,511; xml: 4,011; sh: 3,950; cs: 2,443; yacc: 1,047; makefile: 288
file content (25 lines) | stat: -rwxr-xr-x 549 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python

import sys

f = open(sys.argv[1], "rt")
lines = f.readlines()
ret = 0
for i, line in enumerate(lines):
    if line and line[len(line) - 1] == "\n":
        line = line[0:-1]
    tab = line.split("=")
    if len(tab) != 2:
        continue
    left = tab[0].strip()
    right = tab[1].strip()
    if right and right[len(right) - 1] == ";":
        right = right[0:-1]
    else:
        continue
    right = right.strip()
    if left == right:
        print("%s: %d: %s" % (sys.argv[1], i + 1, line))
        ret = 1

sys.exit(ret)