summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rwxr-xr-xdeheader34
-rw-r--r--deheader.xml3
-rw-r--r--test/regress.chk2
4 files changed, 24 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index c258e7a..4ec7817 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@
0.4 @
Script now removes generated objects.
Duplicate inclusions are now detected.
+ Absence of some headers required for portability is now detected.
0.3 @ 2010-12-09
Add a dependencies table to head off common cross-platform problems.
diff --git a/deheader b/deheader
index 18738e9..5f60a9f 100755
--- a/deheader
+++ b/deheader
@@ -40,17 +40,17 @@ version = "0.3"
# We list those here. Home port is Linux; these are mostly extracted from
# observing compiles on BSD systems.
requirements = map(lambda (r, h): (re.compile(r), h), (
- (r"a64l\s*\(", "<stdlib.h>"),
- (r"l64a\s*\(", "<stdlib.h>"),
- (r"access\s*\(", "<unistd.h>"),
- (r"acos\s*\(", "<math.h>"),
- (r"acosh\s*\(", "<math.h>"),
- (r"advance\s*\(", "<regexp.h>"),
- (r"atan\s*\(", "<math.h>"),
- (r"atanh\s*\(", "<math.h>"),
- (r"atan2\s*\(", "<math.h>"),
- (r"umask\s*\(", "<sys/stat.h>|<sys/types.h>"),
- (r"<sys/socket.h>", "<sys/stat.h>|<sys/types.h>"),
+ (r"a64l\s*\(", ["<stdlib.h>"]),
+ (r"l64a\s*\(", ["<stdlib.h>"]),
+ (r"access\s*\(", ["<unistd.h>"]),
+ (r"acos\s*\(", ["<math.h>"]),
+ (r"acosh\s*\(", ["<math.h>"]),
+ (r"advance\s*\(", ["<regexp.h>"]),
+ (r"atan\s*\(", ["<math.h>"]),
+ (r"atanh\s*\(", ["<math.h>"]),
+ (r"atan2\s*\(", ["<math.h>"]),
+ (r"umask\s*\(", ["<sys/stat.h>", "<sys/types.h>"]),
+ (r"<sys/socket.h>", ["<sys/stat.h>", "<sys/types.h>"]),
))
class Baton:
@@ -134,10 +134,10 @@ class InclusionMap:
print "deheader: ignoring %s (conditional inclusion)" % name
for (r, h) in requirements:
if r.search(line):
- if h not in requires:
+ if not set(h).issubset(set(requires)):
if verbosity >= PROGRESS_DEBUG:
- print "deheader: %s has requires %s from %s" % (sourcefile, h, r.pattern)
- requires.append(h)
+ print "deheader: %s has requires %s from %s" % (sourcefile, ",".join(h), r.pattern)
+ requires += h
self.depends_on[sourcefile] = includes
self.requires[sourcefile] = requires
# Duplicate-header detection
@@ -247,6 +247,12 @@ def c_analyze(sourcefile, maker, includes, requires, verbosity):
saveit.revert()
if verbosity == BATON_DEBUG:
baton.end()
+ # 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.\n" % (sourcefile, required)
return unneeded
def deheader(sourcefile, maker, includes, requires, remove, verbose):
diff --git a/deheader.xml b/deheader.xml
index 6e0794a..d765e4e 100644
--- a/deheader.xml
+++ b/deheader.xml
@@ -49,7 +49,8 @@ directives are left alone, because trying to reason about potential
combinations of -D and U options would be too complicated and prone to
weird errors.</para>
-<para>The tool will also emit warnings about duplicate emissions.</para>
+<para>The tool will also emit warnings about duplicate inclusions, and
+inclusions required for portability but not present.</para>
<para>It is recommended that you arrange to compile with options that
will stop the compiler on warnings when using this tool; otherwise it
diff --git a/test/regress.chk b/test/regress.chk
index 13b2dc2..1a18836 100644
--- a/test/regress.chk
+++ b/test/regress.chk
@@ -7,7 +7,7 @@ deheader: test/atol.c has requires <stdlib.h> from l64a\s*\(
deheader: test/atol.c includes <stdlib.h>
deheader: test/umask.c includes <sys/stat.h>
deheader: test/umask.c includes <sys/types.h>
-deheader: test/umask.c has requires <sys/stat.h>|<sys/types.h> from umask\s*\(
+deheader: test/umask.c has requires <sys/stat.h>,<sys/types.h> from umask\s*\(
deheader: test/a64l.c has requires <stdlib.h> from a64l\s*\(
deheader: test/a64l.c includes <stdlib.h>
deheader: test/atexit.c includes <stdlib.h>