diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-22 17:35:37 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-22 17:35:37 -0500 |
commit | 0ef3952e8ec797c586b61b02d0ed2850345af027 (patch) | |
tree | 5a63115a669fd87052eca6f1d1c7f7d562d61b48 | |
parent | c438d68ae6b8507abdad20b9d2b8461835cdd0aa (diff) | |
download | deheader-0ef3952e8ec797c586b61b02d0ed2850345af027.tar.gz deheader-0ef3952e8ec797c586b61b02d0ed2850345af027.tar.bz2 deheader-0ef3952e8ec797c586b61b02d0ed2850345af027.tar.xz deheader-0ef3952e8ec797c586b61b02d0ed2850345af027.zip |
Make progress messages more informative and less verbose.
-rwxr-xr-x | deheader | 53 | ||||
-rw-r--r-- | test/fchmod.c | 2 | ||||
-rw-r--r-- | test/regress.chk | 191 |
3 files changed, 97 insertions, 149 deletions
@@ -46,13 +46,15 @@ requirements = ( # abort - generate an abnormal process abort (r"abort()", ["<stdlib.h>"]), # abs - return an integer absolute value - (r"abs()", ["<math.h>"]), + (r"abs()", ["<stdlib.h>"]), # access - determine accessibility of a file (r"access()", ["<unistd.h>"]), # acos - arc cosine function (r"acos()", ["<math.h>"]), # acosh, asinh, atanh - inverse hyperbolic functions (r"acosh()", ["<math.h>"]), + (r"asinh()", ["<math.h>"]), + (r"atanh()", ["<math.h>"]), # advance - pattern match given a compiled regular expression (r"advance()", ["<regexp.h>"]), # aio.h - asynchronous input and output @@ -69,6 +71,8 @@ requirements = ( # asctime, asctime_r - convert date and time to a string (r"asctime()", ["<time.h>"]), (r"asctime_r()", ["<time.h>"]), + # asin - arc sine function + (r"asin()", ["<math.h>"]), # atan - arc tangent function (r"atan()", ["<math.h>"]), # atan2 - arc tangent function @@ -91,6 +95,7 @@ requirements = ( (r"bcopy()", ["<strings.h>"]), # brk, sbrk - change space allocation (LEGACY) (r"brk()", ["<unistd.h>"]), + (r"sbrk()", ["<unistd.h>"]), # bsearch - binary search a sorted table (r"bsort()", ["<stdlib.h>"]), # btowc - single-byte to wide-character conversion @@ -124,7 +129,7 @@ requirements = ( # clock_settime, clock_gettime, clock_getres - clock and timer functions (r"clock_settime()", ["<time.h>"]), (r"clock_gettime()", ["<time.h>"]), - (r"clock_getres()", ["<time.h>"]), + (r"clock_getres()", ["<time.h>"]), # close - close a file descriptor (r"close()", ["<unistd.h>"]), # closedir - close a directory stream @@ -259,8 +264,10 @@ requirements = ( # fchdir - change working directory (r"fchdir()", ["<unistd.h>"]), # fchmod - change mode of a file - (r"fchmod()", ["<sys/stat,h>"]), + (r"fchmod()", ["<sys/stat.h>"]), # fchown - change owner and group of a file + (r"fchown()", ["<unistd.h>"]), + # fdopen - associate a stream with a file descriptor (r"fdopen()", ["<stdio.h>"]), # fclose - close a stream (r"fclose()", ["<stdio.h>"]), @@ -1182,6 +1189,7 @@ class InclusionMap: for sourcefile in self.files: includes = [] requires = [] + seen = [] conditions = [] for line in open(sourcefile): if line.startswith("#ifndef"): @@ -1206,10 +1214,9 @@ class InclusionMap: print "deheader: ignoring %s (conditional inclusion)" % name for (r, c, h) in compiled: if c.search(line): - if not set(h).issubset(set(requires)): - if verbosity >= PROGRESS_DEBUG: - print "deheader: %s has requires %s from %s" % (sourcefile, ",".join(h), r) - requires += h + if not set(h).issubset(set(seen)): + requires.append((h, r)) + seen += h self.depends_on[sourcefile] = includes self.requires[sourcefile] = requires # Duplicate-header detection @@ -1301,18 +1308,20 @@ def c_analyze(sourcefile, maker, includes, requires, verbosity): for header in includes: if verbosity == BATON_DEBUG: baton.twirl() - #if requires.pattern: - # print "%s: checking %s against %s" % (sourcefile, `header`, `requires.pattern`) - if requires and re.compile("|".join(requires)).search(header): - if verbosity >= PROGRESS_DEBUG: - print "deheader: in %s, retaining required %s" % (sourcefile, `header`,) - continue - saveit.remove_headers([header]) - (st, t) = testcompile(sourcefile, maker, " without %s" % trim(header), verbosity) - if st == 0: - unneeded.append(header) - includes.remove(header) - keepgoing = True + retain = 0 + for (requirements, trigger) in requires: + for required in requirements: + if required in header: + if verbosity >= PROGRESS_DEBUG: + print "deheader: in %s, %s prevents uninclusion of %s" % (sourcefile, trigger, trim(header)) + retain += 1 + if not retain: + saveit.remove_headers([header]) + (st, t) = testcompile(sourcefile, maker, " without %s" % trim(header), verbosity) + if st == 0: + unneeded.append(header) + includes.remove(header) + keepgoing = True if not keepgoing: break finally: @@ -1322,9 +1331,9 @@ def c_analyze(sourcefile, maker, includes, requires, verbosity): # Missing-require detection. Can't be merged with duplicate-header # detection because this has to be done after unneeded headers are removed. stillhere = map(trim, includes) - for required in requires: - if not required in stillhere: - print "deheader: in %s, %s is required for portability but not present." % (sourcefile, required) + for (requirement, trigger) in requires: + if not set(requirement).issubset(stillhere): + print "deheader: in %s, %s portability requires %s." % (sourcefile, trigger, ",".join(requirement)) return unneeded def deheader(sourcefile, maker, includes, requires, remove, verbose): diff --git a/test/fchmod.c b/test/fchmod.c index 1b97537..e998b70 100644 --- a/test/fchmod.c +++ b/test/fchmod.c @@ -4,7 +4,7 @@ * Not-Detected-by: gcc-4.4.3 + Linux */ -#include <sys/types.h> +#include <sys/stat.h> main(int arg, char **argv) { diff --git a/test/regress.chk b/test/regress.chk index eb9280a..a2ec3dd 100644 --- a/test/regress.chk +++ b/test/regress.chk @@ -1,199 +1,138 @@ -deheader: ./chdir.c has requires <unistd.h> from chdir() deheader: ./chdir.c includes <unistd.h> deheader: ./string.c includes <string.h> -deheader: ./bzero.c has requires <strings.h> from bzero() deheader: ./bzero.c includes <strings.h> -deheader: ./cfsetospeed.c has requires <termios.h> from cfsetospeed() deheader: ./cfsetospeed.c includes <termios.h> deheader: ./duplicate.c includes <stdio.h> deheader: ./duplicate.c includes <stdio.h> deheader: ./duplicate.c has more than one inclusion of <stdio.h> -deheader: ./brk.c has requires <unistd.h> from brk() deheader: ./brk.c includes <unistd.h> -deheader: ./closedir.c has requires <sys/types.h>,<dirent.h> from closedir() deheader: ./closedir.c includes <sys/types.h> deheader: ./closedir.c includes <dirent.h> deheader: ./asinh.c includes <math.h> -deheader: ./fchmod.c has requires <sys/stat,h> from fchmod() -deheader: ./fchmod.c includes <sys/types.h> -deheader: ./atol.c has requires <stdlib.h> from l64a() +deheader: ./fchmod.c includes <sys/stat.h> deheader: ./atol.c includes <stdlib.h> -deheader: ./umask.c has requires <sys/stat.h>,<sys/types.h> from umask() deheader: ./umask.c includes <sys/stat.h> deheader: ./umask.c includes <sys/types.h> -deheader: ./cfgetispeed.c has requires <termios.h> from cfgetispeed() deheader: ./cfgetispeed.c includes <termios.h> -deheader: ./a64l.c has requires <stdlib.h> from a64l() deheader: ./a64l.c includes <stdlib.h> -deheader: ./bcmp.c has requires <strings.h> from bcmp() deheader: ./bcmp.c includes <strings.h> -deheader: ./ceil.c has requires <math.h> from ceil() deheader: ./ceil.c includes <math.h> -deheader: ./bcopy.c has requires <strings.h> from bcopy() deheader: ./bcopy.c includes <strings.h> -deheader: ./atexit.c has requires <stdlib.h> from atexit() deheader: ./atexit.c includes <stdlib.h> -deheader: ./btowc.c has requires <stdio.h>,<wchar.h> from btowc() deheader: ./btowc.c includes <stdio.h> deheader: ./btowc.c includes <wchar.h> -deheader: ./abs.c has requires <math.h> from abs() deheader: ./abs.c includes <stdlib.h> -deheader: ./calloc.c has requires <stdlib.h> from calloc() deheader: ./calloc.c includes <stdlib.h> -deheader: ./bsd_signal.c has requires <signal.h> from bsd_signal() deheader: ./bsd_signal.c includes <signal.h> -deheader: ./access.c has requires <unistd.h> from access() deheader: ./access.c includes <unistd.h> -deheader: ./atoi.c has requires <stdlib.h> from l64a() deheader: ./atoi.c includes <stdlib.h> -deheader: ./cfsetispeed.c has requires <termios.h> from cfsetispeed() deheader: ./cfsetispeed.c includes <termios.h> deheader: ./sbrk.c includes <unistd.h> -deheader: ./ctime.c has requires <time.h> from ctime() deheader: ./ctime.c includes <time.h> -deheader: ./fstat.c has requires <sys/types.h>,<sys/stat.h> from fstat() deheader: ./fstat.c includes <sys/stat.h> deheader: ./fstat.c includes <sys/types.h> -deheader: ./fclose.c has requires <stdio.h> from fclose() deheader: ./fclose.c includes <stdio.h> -deheader: ./alarm.c has requires <unistd.h> from alarm() deheader: ./alarm.c includes <unistd.h> -deheader: ./cfgetospeed.c has requires <termios.h> from cfgetospeed() deheader: ./cfgetospeed.c includes <termios.h> -deheader: ./acos.c has requires <math.h> from acos() deheader: ./acos.c includes <math.h> -deheader: ./clock_gettime.c has requires <time.h> from clock_gettime() deheader: ./clock_gettime.c includes <time.h> -deheader: ./abort.c has requires <stdlib.h> from abort() deheader: ./abort.c includes <stdlib.h> -deheader: ./atanh.c has requires <math.h> from atanh() deheader: ./atanh.c includes <math.h> -deheader: ./chmod.c has requires <sys/stat.h>,<sys/types.h> from chmod() deheader: ./chmod.c includes <sys/types.h> deheader: ./chmod.c includes <sys/stat.h> -deheader: ./atof.c has requires <stdlib.h> from l64a() deheader: ./atof.c includes <stdlib.h> -deheader: ./acosh.c has requires <math.h> from acosh() deheader: ./acosh.c includes <math.h> -deheader: ./atan.c has requires <math.h> from atan() deheader: ./atan.c includes <math.h> -deheader: ./clock.c has requires <time.h> from clock() deheader: ./clock.c includes <time.h> -deheader: ./basename.c has requires <libgen.h> from basename() deheader: ./basename.c includes <libgen.h> -deheader: ./clearerr.c has requires <stdio.h> from clearerr() deheader: ./clearerr.c includes <stdio.h> deheader: ./asin.c includes <math.h> -deheader: ./bsort.c has requires <stdlib.h> from bsort() deheader: ./bsort.c includes <stdio.h> deheader: ignoring <stdio.h> (conditional inclusion) deheader: ./bsort.c includes <string.h> deheader: ignoring <string.h> (conditional inclusion) deheader: ./bsort.c includes <stdlib.h> -deheader: ./bsort.c has requires <string.h> from strcoll() -deheader: ./bsort.c has requires <stdio.h> from scanf() -deheader: ./chroot.c has requires <unistd.h> from chroot() deheader: ./chroot.c includes <unistd.h> -deheader: ./catgets.c has requires <nl_types.h> from catgets() deheader: ./catgets.c includes <nl_types.h> -deheader: ./cbrt.c has requires <math.h> from cbrt() deheader: ./cbrt.c includes <math.h> -deheader: ./chown.c has requires <sys/types.h>,<unistd.h> from chown() deheader: ./chown.c includes <sys/types.h> deheader: ./chown.c includes <unistd.h> -deheader: ./clock_settime.c has requires <time.h> from clock_settime() deheader: ./clock_settime.c includes <time.h> -deheader: ./crypt.c has requires <unistd.h> from crypt() deheader: ./crypt.c includes <unistd.h> -deheader: ./clock_getres.c has requires <time.h> from clock_getres() deheader: ./clock_getres.c includes <time.h> deheader: ./fchown.c includes <unistd.h> -deheader: ./advance.c has requires <regexp.h> from advance() -deheader: ./advance.c has requires <stdio.h> from getc() deheader: ./advance.c includes <regexp.h> -deheader: ./catopen.c has requires <nl_types.h> from catopen() deheader: ./catopen.c includes <nl_types.h> -deheader: ./close.c has requires <unistd.h> from close() deheader: ./close.c includes <unistd.h> -deheader: ./atan2.c has requires <math.h> from atan2() deheader: ./atan2.c includes <math.h> -deheader: ./catclose.c has requires <nl_types.h> from catclose() deheader: ./catclose.c includes <nl_types.h> -deheader: in ./clock_getres.c, retaining required '#include <time.h>\n' -deheader: ./asin.c without <math.h> succeeded. -deheader: remove <math.h> from ./asin.c -deheader: in ./cbrt.c, retaining required '#include <math.h>\n' -deheader: in ./acos.c, retaining required '#include <math.h>\n' -deheader: in ./clock_gettime.c, retaining required '#include <time.h>\n' -deheader: in ./catopen.c, retaining required '#include <nl_types.h>\n' -deheader: in ./brk.c, retaining required '#include <unistd.h>\n' -deheader: in ./atan2.c, retaining required '#include <math.h>\n' +deheader: in ./clock_getres.c, clock_getres() prevents uninclusion of <time.h> +deheader: in ./asin.c, asin() prevents uninclusion of <math.h> +deheader: in ./cbrt.c, cbrt() prevents uninclusion of <math.h> +deheader: in ./acos.c, acos() prevents uninclusion of <math.h> +deheader: in ./clock_gettime.c, clock_gettime() prevents uninclusion of <time.h> +deheader: in ./catopen.c, catopen() prevents uninclusion of <nl_types.h> +deheader: in ./brk.c, brk() prevents uninclusion of <unistd.h> +deheader: in ./atan2.c, atan2() prevents uninclusion of <math.h> deheader: ./string.c without <string.h> succeeded. deheader: remove <string.h> from ./string.c -deheader: in ./bsort.c, retaining required '#include <stdlib.h>\n' -deheader: in ./bsort.c, <string.h> is required for portability but not present. -deheader: in ./bsort.c, <stdio.h> is required for portability but not present. -deheader: in ./cfgetospeed.c, retaining required '#include <termios.h>\n' -deheader: in ./catclose.c, retaining required '#include <nl_types.h>\n' -deheader: in ./cfgetispeed.c, retaining required '#include <termios.h>\n' -deheader: in ./closedir.c, retaining required '#include <dirent.h>\n' -deheader: in ./closedir.c, retaining required '#include <sys/types.h>\n' -deheader: in ./ceil.c, retaining required '#include <math.h>\n' -deheader: in ./bsd_signal.c, retaining required '#include <signal.h>\n' -deheader: ./abs.c without <stdlib.h> succeeded. -deheader: in ./abs.c, <math.h> is required for portability but not present. -deheader: remove <stdlib.h> from ./abs.c -deheader: in ./basename.c, retaining required '#include <libgen.h>\n' -deheader: in ./ctime.c, retaining required '#include <time.h>\n' -deheader: in ./cfsetospeed.c, retaining required '#include <termios.h>\n' -deheader: in ./abort.c, retaining required '#include <stdlib.h>\n' -deheader: in ./atan.c, retaining required '#include <math.h>\n' -deheader: in ./clock_settime.c, retaining required '#include <time.h>\n' +deheader: in ./bsort.c, bsort() prevents uninclusion of <stdlib.h> +deheader: in ./bsort.c, strcoll() portability requires <string.h>. +deheader: in ./bsort.c, scanf() portability requires <stdio.h>. +deheader: in ./cfgetospeed.c, cfgetospeed() prevents uninclusion of <termios.h> +deheader: in ./catclose.c, catclose() prevents uninclusion of <nl_types.h> +deheader: in ./cfgetispeed.c, cfgetispeed() prevents uninclusion of <termios.h> +deheader: in ./closedir.c, closedir() prevents uninclusion of <dirent.h> +deheader: in ./closedir.c, closedir() prevents uninclusion of <sys/types.h> +deheader: in ./ceil.c, ceil() prevents uninclusion of <math.h> +deheader: in ./bsd_signal.c, bsd_signal() prevents uninclusion of <signal.h> +deheader: in ./abs.c, abs() prevents uninclusion of <stdlib.h> +deheader: in ./basename.c, basename() prevents uninclusion of <libgen.h> +deheader: in ./ctime.c, ctime() prevents uninclusion of <time.h> +deheader: in ./cfsetospeed.c, cfsetospeed() prevents uninclusion of <termios.h> +deheader: in ./abort.c, abort() prevents uninclusion of <stdlib.h> +deheader: in ./atan.c, atan() prevents uninclusion of <math.h> +deheader: in ./clock_settime.c, clock_settime() prevents uninclusion of <time.h> deheader: ./duplicate.c without <stdio.h> succeeded. deheader: ./duplicate.c without <stdio.h> succeeded. deheader: remove <stdio.h> from ./duplicate.c deheader: remove <stdio.h> from ./duplicate.c -deheader: in ./chdir.c, retaining required '#include <unistd.h>\n' -deheader: in ./fstat.c, retaining required '#include <sys/types.h>\n' -deheader: in ./fstat.c, retaining required '#include <sys/stat.h>\n' -deheader: in ./atanh.c, retaining required '#include <math.h>\n' -deheader: in ./close.c, retaining required '#include <unistd.h>\n' -deheader: in ./bcopy.c, retaining required '#include <strings.h>\n' -deheader: in ./crypt.c, retaining required '#include <unistd.h>\n' -deheader: in ./cfsetispeed.c, retaining required '#include <termios.h>\n' -deheader: ./fchmod.c without <sys/types.h> succeeded. -deheader: in ./fchmod.c, <sys/stat,h> is required for portability but not present. -deheader: remove <sys/types.h> from ./fchmod.c -deheader: in ./atof.c, retaining required '#include <stdlib.h>\n' -deheader: in ./chroot.c, retaining required '#include <unistd.h>\n' -deheader: in ./atol.c, retaining required '#include <stdlib.h>\n' -deheader: in ./atoi.c, retaining required '#include <stdlib.h>\n' -deheader: ./asinh.c without <math.h> succeeded. -deheader: remove <math.h> from ./asinh.c -deheader: in ./alarm.c, retaining required '#include <unistd.h>\n' -deheader: ./sbrk.c without <unistd.h> succeeded. -deheader: remove <unistd.h> from ./sbrk.c -deheader: in ./fclose.c, retaining required '#include <stdio.h>\n' -deheader: in ./umask.c, retaining required '#include <sys/types.h>\n' -deheader: in ./umask.c, retaining required '#include <sys/stat.h>\n' -deheader: in ./calloc.c, retaining required '#include <stdlib.h>\n' -deheader: in ./atexit.c, retaining required '#include <stdlib.h>\n' -deheader: in ./bzero.c, retaining required '#include <strings.h>\n' -deheader: in ./access.c, retaining required '#include <unistd.h>\n' -deheader: ./fchown.c without <unistd.h> succeeded. -deheader: remove <unistd.h> from ./fchown.c -deheader: in ./btowc.c, retaining required '#include <wchar.h>\n' -deheader: in ./btowc.c, retaining required '#include <stdio.h>\n' -deheader: in ./clock.c, retaining required '#include <time.h>\n' -deheader: in ./acosh.c, retaining required '#include <math.h>\n' -deheader: in ./catgets.c, retaining required '#include <nl_types.h>\n' -deheader: in ./bcmp.c, retaining required '#include <strings.h>\n' -deheader: in ./a64l.c, retaining required '#include <stdlib.h>\n' -deheader: in ./chmod.c, retaining required '#include <sys/stat.h>\n' -deheader: in ./chmod.c, retaining required '#include <sys/types.h>\n' -deheader: in ./chown.c, retaining required '#include <unistd.h>\n' -deheader: in ./chown.c, retaining required '#include <sys/types.h>\n' -deheader: in ./advance.c, retaining required '#include <regexp.h>\n' -deheader: in ./advance.c, <stdio.h> is required for portability but not present. -deheader: in ./clearerr.c, retaining required '#include <stdio.h>\n' -deheader: saw 57 files, 63 includes, 9 removed +deheader: in ./chdir.c, chdir() prevents uninclusion of <unistd.h> +deheader: in ./fstat.c, fstat() prevents uninclusion of <sys/types.h> +deheader: in ./fstat.c, fstat() prevents uninclusion of <sys/stat.h> +deheader: in ./atanh.c, atanh() prevents uninclusion of <math.h> +deheader: in ./close.c, close() prevents uninclusion of <unistd.h> +deheader: in ./bcopy.c, bcopy() prevents uninclusion of <strings.h> +deheader: in ./crypt.c, crypt() prevents uninclusion of <unistd.h> +deheader: in ./cfsetispeed.c, cfsetispeed() prevents uninclusion of <termios.h> +deheader: in ./fchmod.c, fchmod() prevents uninclusion of <sys/stat.h> +deheader: in ./atof.c, l64a() prevents uninclusion of <stdlib.h> +deheader: in ./chroot.c, chroot() prevents uninclusion of <unistd.h> +deheader: in ./atol.c, l64a() prevents uninclusion of <stdlib.h> +deheader: in ./atoi.c, l64a() prevents uninclusion of <stdlib.h> +deheader: in ./asinh.c, asinh() prevents uninclusion of <math.h> +deheader: in ./alarm.c, alarm() prevents uninclusion of <unistd.h> +deheader: in ./sbrk.c, sbrk() prevents uninclusion of <unistd.h> +deheader: in ./fclose.c, fclose() prevents uninclusion of <stdio.h> +deheader: in ./umask.c, umask() prevents uninclusion of <sys/types.h> +deheader: in ./umask.c, umask() prevents uninclusion of <sys/stat.h> +deheader: in ./calloc.c, calloc() prevents uninclusion of <stdlib.h> +deheader: in ./atexit.c, atexit() prevents uninclusion of <stdlib.h> +deheader: in ./bzero.c, bzero() prevents uninclusion of <strings.h> +deheader: in ./access.c, access() prevents uninclusion of <unistd.h> +deheader: in ./fchown.c, fchown() prevents uninclusion of <unistd.h> +deheader: in ./btowc.c, btowc() prevents uninclusion of <wchar.h> +deheader: in ./btowc.c, btowc() prevents uninclusion of <stdio.h> +deheader: in ./clock.c, clock() prevents uninclusion of <time.h> +deheader: in ./acosh.c, acosh() prevents uninclusion of <math.h> +deheader: in ./catgets.c, catgets() prevents uninclusion of <nl_types.h> +deheader: in ./bcmp.c, bcmp() prevents uninclusion of <strings.h> +deheader: in ./a64l.c, a64l() prevents uninclusion of <stdlib.h> +deheader: in ./chmod.c, chmod() prevents uninclusion of <sys/stat.h> +deheader: in ./chmod.c, chmod() prevents uninclusion of <sys/types.h> +deheader: in ./chown.c, chown() prevents uninclusion of <unistd.h> +deheader: in ./chown.c, chown() prevents uninclusion of <sys/types.h> +deheader: in ./advance.c, advance() prevents uninclusion of <regexp.h> +deheader: in ./advance.c, getc() portability requires <stdio.h>. +deheader: in ./clearerr.c, clearerr() prevents uninclusion of <stdio.h> +deheader: saw 57 files, 63 includes, 3 removed |