summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-13 06:32:19 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-13 06:32:19 -0500
commit3120ab50edccf92cde6b947522c6999f03f50e55 (patch)
tree1979ad1e8e0c77084ec77c70149a6f71a3e0b01d
parente177e3758fd45a12824761f1f76a6cacf64605a4 (diff)
downloaddeheader-3120ab50edccf92cde6b947522c6999f03f50e55.tar.gz
deheader-3120ab50edccf92cde6b947522c6999f03f50e55.tar.bz2
deheader-3120ab50edccf92cde6b947522c6999f03f50e55.tar.xz
deheader-3120ab50edccf92cde6b947522c6999f03f50e55.zip
Improved progress messages.
-rwxr-xr-xdeheader97
-rw-r--r--test/regress.chk72
2 files changed, 88 insertions, 81 deletions
diff --git a/deheader b/deheader
index ef541cc..ae427cb 100755
--- a/deheader
+++ b/deheader
@@ -38,54 +38,54 @@ version = "0.3"
# platform compatibility you sometimes want to leave "unneeded" headers alone
# because they're required in order to satify dependencies on other platforms.
# We list those here. In general they fall into two categrories:
-requirements = map(lambda (r, h): (re.compile(r), h), (
+requirements = (
# Headers mandated by SuS that may not be required by a particular compiler,
# usually because all the argument types and the return type are composed
# from C scalar types.
- (r"\Wa64l\s*\(", ["<stdlib.h>"]),
- (r"\Wl64a\s*\(", ["<stdlib.h>"]),
- (r"\Wabort\s*\(", ["<stdlib.h>"]),
- (r"\Waccess\s*\(", ["<unistd.h>"]),
- (r"\Wacos\s*\(", ["<math.h>"]),
- (r"\Wacosh\s*\(", ["<math.h>"]),
- (r"\Wadvance\s*\(", ["<regexp.h>"]),
- (r"\Watan\s*\(", ["<math.h>"]),
- (r"\Watanh\s*\(", ["<math.h>"]),
- (r"\Watan2\s*\(", ["<math.h>"]),
- (r"\Wbasename\s*\(", ["<libgen.h>"]),
- (r"\Wbcmp\s*\(", ["<string.h>"]),
- (r"\Wbrk\s*\(", ["<unistd.h>"]),
- (r"\Wbsd_signal\s*\(", ["<signal.h>"]),
- (r"\Wbsort\s*\(", ["<stdlib.h>"]),
- (r"\Wbtowc\s*\(", ["<stdio.h>", "<wchar.h>"]),
- (r"\Wbzero\s*\(", ["<string.h>"]),
- (r"\Wcalloc\s*\(", ["<stdlib.h>"]),
- (r"\Wcatclose\s*\(", ["<nl_types.h>"]),
- (r"\Wcatgets\s*\(", ["<nl_types.h>"]),
- (r"\Wcatopen\s*\(", ["<nl_types.h>"]),
- (r"\Wcbrt\s*\(", ["<math.h>"]),
- (r"\Wceil\s*\(", ["<math.h>"]),
- (r"\Wcfgetispeed\s*\(", ["<termios.h>"]),
- (r"\Wcfgetospeed\s*\(", ["<termios.h>"]),
- (r"\Wcfsetispeed\s*\(", ["<termios.h>"]),
- (r"\Wcfsetospeed\s*\(", ["<termios.h>"]),
- (r"\Wchdir\s*\(", ["<unistd.h>"]),
- (r"\Wchmod\s*\(", ["<sys/stat.h>", "<sys/types.h>"]),
- (r"\Wchown\s*\(", ["<sys/types.h>", "<unistd.h>"]),
- (r"\Wchroot\s*\(", ["<unistd.h>"]),
- (r"\Wclock\s*\(", ["<time.h>"]),
- (r"\Wclose\s*\(", ["<unistd.h>"]),
- (r"\Wconfstr\s*\(", ["<unistd.h>"]),
- (r"\Wcos\s*\(", ["<math.h>"]),
- (r"\Wcosh\s*\(", ["<math.h>"]),
- (r"\Wumask\s*\(", ["<sys/stat.h>", "<sys/types.h>"]),
+ (r"a64l()", ["<stdlib.h>"]),
+ (r"l64a()", ["<stdlib.h>"]),
+ (r"abort()", ["<stdlib.h>"]),
+ (r"access()", ["<unistd.h>"]),
+ (r"acos()", ["<math.h>"]),
+ (r"acosh()", ["<math.h>"]),
+ (r"advance()", ["<regexp.h>"]),
+ (r"atan()", ["<math.h>"]),
+ (r"atanh()", ["<math.h>"]),
+ (r"atan2()", ["<math.h>"]),
+ (r"basename()", ["<libgen.h>"]),
+ (r"bcmp()", ["<string.h>"]),
+ (r"brk()", ["<unistd.h>"]),
+ (r"bsd_signal()", ["<signal.h>"]),
+ (r"bsort()", ["<stdlib.h>"]),
+ (r"btowc()", ["<stdio.h>", "<wchar.h>"]),
+ (r"bzero()", ["<string.h>"]),
+ (r"calloc()", ["<stdlib.h>"]),
+ (r"catclose()", ["<nl_types.h>"]),
+ (r"catgets()", ["<nl_types.h>"]),
+ (r"catopen()", ["<nl_types.h>"]),
+ (r"cbrt()", ["<math.h>"]),
+ (r"ceil()", ["<math.h>"]),
+ (r"cfgetispeed()", ["<termios.h>"]),
+ (r"cfgetospeed()", ["<termios.h>"]),
+ (r"cfsetispeed()", ["<termios.h>"]),
+ (r"cfsetospeed()", ["<termios.h>"]),
+ (r"chdir()", ["<unistd.h>"]),
+ (r"chmod()", ["<sys/stat.h>", "<sys/types.h>"]),
+ (r"chown()", ["<sys/types.h>", "<unistd.h>"]),
+ (r"chroot()", ["<unistd.h>"]),
+ (r"clock()", ["<time.h>"]),
+ (r"close()", ["<unistd.h>"]),
+ (r"confstr()", ["<unistd.h>"]),
+ (r"cos()", ["<math.h>"]),
+ (r"cosh()", ["<math.h>"]),
+ (r"umask()", ["<sys/stat.h>", "<sys/types.h>"]),
# Header dependencies implies by SuS
- (r"<dirent.h>", ["<sys/types.h>"]),
- (r"<fcntl.h>", ["<sys/stat.h>", "<sys/types.h>"]),
+ (r"<dirent.h>", ["<sys/types.h>"]),
+ (r"<fcntl.h>", ["<sys/stat.h>", "<sys/types.h>"]),
# Dependencies observed on systems other than the Linux this was
# developed under.
- (r"<sys/socket.h>", ["<sys/stat.h>", "<sys/types.h>"]),
- ))
+ (r"<sys/socket.h>", ["<sys/stat.h>", "<sys/types.h>"]),
+ )
class Baton:
"Ship progress indications to stderr."
@@ -130,6 +130,13 @@ class InclusionMap:
"Build the initial inclusion map."
self.verbosity = verbosity
self.files = []
+ compiled = []
+ for (r, h) in requirements:
+ if r.endswith("()"):
+ c = re.compile(r"\W" + r.replace("()", r"\s*\("))
+ else:
+ c = re.compile(r)
+ compiled.append((r, c, h))
for root in roots:
if not os.path.isdir(root):
if InclusionMap.c_source(root):
@@ -166,11 +173,11 @@ class InclusionMap:
includes.append(line)
elif verbose > 1:
print "deheader: ignoring %s (conditional inclusion)" % name
- for (r, h) in requirements:
- if r.search(line):
+ 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.pattern)
+ print "deheader: %s has requires %s from %s" % (sourcefile, ",".join(h), r)
requires += h
self.depends_on[sourcefile] = includes
self.requires[sourcefile] = requires
diff --git a/test/regress.chk b/test/regress.chk
index 2e743c5..591374b 100644
--- a/test/regress.chk
+++ b/test/regress.chk
@@ -1,100 +1,100 @@
-deheader: ./chdir.c has requires <unistd.h> from \Wchdir\s*\(
+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 <string.h> from \Wbzero\s*\(
+deheader: ./bzero.c has requires <string.h> from bzero()
deheader: ./bzero.c includes <string.h>
-deheader: ./cfsetospeed.c has requires <termios.h> from \Wcfsetospeed\s*\(
+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 \Wbrk\s*\(
+deheader: ./brk.c has requires <unistd.h> from brk()
deheader: ./brk.c includes <unistd.h>
deheader: ./closedir.c includes <sys/types.h>
deheader: ./closedir.c includes <dirent.h>
deheader: ./closedir.c has requires <sys/types.h> from <dirent.h>
deheader: ./asinh.c includes <math.h>
-deheader: ./atol.c has requires <stdlib.h> from \Wl64a\s*\(
+deheader: ./atol.c has requires <stdlib.h> from l64a()
deheader: ./atol.c includes <stdlib.h>
-deheader: ./umask.c has requires <sys/stat.h>,<sys/types.h> from \Wumask\s*\(
+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 \Wcfgetispeed\s*\(
+deheader: ./cfgetispeed.c has requires <termios.h> from cfgetispeed()
deheader: ./cfgetispeed.c includes <termios.h>
-deheader: ./a64l.c has requires <stdlib.h> from \Wa64l\s*\(
+deheader: ./a64l.c has requires <stdlib.h> from a64l()
deheader: ./a64l.c includes <stdlib.h>
-deheader: ./bcmp.c has requires <string.h> from \Wbcmp\s*\(
+deheader: ./bcmp.c has requires <string.h> from bcmp()
deheader: ./bcmp.c includes <string.h>
-deheader: ./ceil.c has requires <math.h> from \Wceil\s*\(
+deheader: ./ceil.c has requires <math.h> from ceil()
deheader: ./ceil.c includes <math.h>
deheader: ./bcopy.c includes <string.h>
deheader: ./atexit.c includes <stdlib.h>
-deheader: ./btowc.c has requires <stdio.h>,<wchar.h> from \Wbtowc\s*\(
+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 includes <stdlib.h>
-deheader: ./calloc.c has requires <stdlib.h> from \Wcalloc\s*\(
+deheader: ./calloc.c has requires <stdlib.h> from calloc()
deheader: ./calloc.c includes <stdlib.h>
-deheader: ./bsd_signal.c has requires <signal.h> from \Wbsd_signal\s*\(
+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 \Waccess\s*\(
+deheader: ./access.c has requires <unistd.h> from access()
deheader: ./access.c includes <unistd.h>
-deheader: ./atoi.c has requires <stdlib.h> from \Wl64a\s*\(
+deheader: ./atoi.c has requires <stdlib.h> from l64a()
deheader: ./atoi.c includes <stdlib.h>
-deheader: ./cfsetispeed.c has requires <termios.h> from \Wcfsetispeed\s*\(
+deheader: ./cfsetispeed.c has requires <termios.h> from cfsetispeed()
deheader: ./cfsetispeed.c includes <termios.h>
deheader: ./sbrk.c includes <unistd.h>
deheader: ./alarm.c includes <unistd.h>
-deheader: ./cfgetospeed.c has requires <termios.h> from \Wcfgetospeed\s*\(
+deheader: ./cfgetospeed.c has requires <termios.h> from cfgetospeed()
deheader: ./cfgetospeed.c includes <termios.h>
-deheader: ./acos.c has requires <math.h> from \Wacos\s*\(
+deheader: ./acos.c has requires <math.h> from acos()
deheader: ./acos.c includes <math.h>
deheader: ./clock_gettime.c includes <time.h>
-deheader: ./abort.c has requires <stdlib.h> from \Wabort\s*\(
+deheader: ./abort.c has requires <stdlib.h> from abort()
deheader: ./abort.c includes <stdlib.h>
-deheader: ./atanh.c has requires <math.h> from \Watanh\s*\(
+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 \Wchmod\s*\(
+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 \Wl64a\s*\(
+deheader: ./atof.c has requires <stdlib.h> from l64a()
deheader: ./atof.c includes <stdlib.h>
-deheader: ./acosh.c has requires <math.h> from \Wacosh\s*\(
+deheader: ./acosh.c has requires <math.h> from acosh()
deheader: ./acosh.c includes <math.h>
-deheader: ./atan.c has requires <math.h> from \Watan\s*\(
+deheader: ./atan.c has requires <math.h> from atan()
deheader: ./atan.c includes <math.h>
-deheader: ./clock.c has requires <time.h> from \Wclock\s*\(
+deheader: ./clock.c has requires <time.h> from clock()
deheader: ./clock.c includes <time.h>
-deheader: ./basename.c has requires <libgen.h> from \Wbasename\s*\(
+deheader: ./basename.c has requires <libgen.h> from basename()
deheader: ./basename.c includes <libgen.h>
deheader: ./clearerr.c includes <stdio.h>
deheader: ./asin.c includes <math.h>
-deheader: ./bsort.c has requires <stdlib.h> from \Wbsort\s*\(
+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: ./chroot.c has requires <unistd.h> from \Wchroot\s*\(
+deheader: ./chroot.c has requires <unistd.h> from chroot()
deheader: ./chroot.c includes <unistd.h>
-deheader: ./catgets.c has requires <nl_types.h> from \Wcatgets\s*\(
+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 \Wcbrt\s*\(
+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 \Wchown\s*\(
+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 includes <time.h>
deheader: ./clock_getres.c includes <time.h>
-deheader: ./advance.c has requires <regexp.h> from \Wadvance\s*\(
+deheader: ./advance.c has requires <regexp.h> from advance()
deheader: ./advance.c includes <regexp.h>
-deheader: ./catopen.c has requires <nl_types.h> from \Wcatopen\s*\(
+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 \Wclose\s*\(
+deheader: ./close.c has requires <unistd.h> from close()
deheader: ./close.c includes <unistd.h>
-deheader: ./atan2.c has requires <math.h> from \Watan2\s*\(
+deheader: ./atan2.c has requires <math.h> from atan2()
deheader: ./atan2.c includes <math.h>
-deheader: ./catclose.c has requires <nl_types.h> from \Wcatclose\s*\(
+deheader: ./catclose.c has requires <nl_types.h> from catclose()
deheader: ./catclose.c includes <nl_types.h>
deheader: in ./atan2.c, retaining required '#include <math.h>\n'
deheader: ./asin.c without <math.h> succeeded.