new contrib: patchcov script

Matthias Klose doko@cs.tu-berlin.de
Wed Sep 22 09:34:00 GMT 2004


Ben Elliston writes:
> # Usage.
> if len (sys.argv) != 2:
>   sys.stderr.write ('Usage: patchcov <gcov data directory>\n')
>   sys.exit (1)

upstream suggests four space indentation, but it should be
consistently two or four spaces.

> while True:

please consider using 1/0, or conditionally define constants. python
versions prior to 2.2.1 don't have these defined.

>   line = sys.stdin.readline ()
>   if re.compile ('^---').match (line):
>     filename = string.split (line) [1] 
>   elif re.compile ('^@@').match (line):
>     temp = string.split (line) [2]
>     if temp[0] == '+':
>       temp = string.split (temp[1:], ',')
>     if len (temp) < 2:
> 	rang = (int (temp[0]), int (temp[0]) + 1)
>     else:
> 	rang = (int (temp[0]), int (temp[0]) + int (temp[1]))
>     try:
> 	hunks[filename].append (rang)
>     except KeyError:
> 	hunks[filename] = [rang]
>   elif line == '':
>     break
> 
> for filename in hunks.keys ():
>     gcov = gcovdir + '/' + os.path.basename (filename) + '.gcov'

gcov = os.path.join (gcovdir, os.path.basename (filename) + '.gcov')



More information about the Gcc-patches mailing list