diff options
-rwxr-xr-x | deheader | 15 | ||||
-rw-r--r-- | deheader.xml | 5 | ||||
-rw-r--r-- | test/README | 2 |
3 files changed, 15 insertions, 7 deletions
@@ -147,6 +147,7 @@ requirements = ( (r"fputwc()", ["<stdio.h>"]), (r"fputws()", ["<stdio.h>"]), (r"fread()", ["<stdio.h>"]), + (r"free()", ["<stdlib.h>"]), # Header dependencies implies by SuS (r"<dirent.h>", ["<sys/types.h>"]), (r"<fcntl.h>", ["<sys/stat.h>", "<sys/types.h>"]), @@ -223,12 +224,16 @@ class InclusionMap: for sourcefile in self.files: includes = [] requires = [] - ifdepth = 0 + conditions = [] for line in open(sourcefile): - if line.startswith("#if") or line.startswith("#ifndef"): - ifdepth += 1 + if line.startswith("#ifndef"): + conditions.append(line[7:].strip()) + elif line.startswith("#ifdef"): + conditions.append(line[6:].strip()) + elif line.startswith("#if"): + conditions.append(line[3:].strip()) elif line.startswith("#endif"): - ifdepth -= 1 + conditions.pop() elif line.startswith("#include"): if verbosity >= PROGRESS_DEBUG: name = trim(line) @@ -237,7 +242,7 @@ class InclusionMap: if verbosity >= PROGRESS_DEBUG: print "deheader: ignoring %s (exclusion match with %s)." % (name, ignore.pattern) continue - if ifdepth == 0: + if not conditions or conditions == ["S_SPLINT_S"]: includes.append(line) elif verbose > 1: print "deheader: ignoring %s (conditional inclusion)" % name diff --git a/deheader.xml b/deheader.xml index d765e4e..ea6044b 100644 --- a/deheader.xml +++ b/deheader.xml @@ -47,7 +47,10 @@ name of the current directory had been passed to it.</para> <para>Inclusions within the scope of #if/#ifdef/#else/#endif 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> +weird errors. One exception: headers protected only by S_SPLINT_S, the +conditional for blocking scanning by the static analysis tool +<citerefentry><refentrytitle>splint</refentrytitle><manvolnum>1</manvolnum></citerefentry>, +are scanned normally.</para> <para>The tool will also emit warnings about duplicate inclusions, and inclusions required for portability but not present.</para> diff --git a/test/README b/test/README index ffe1b30..0c2b63f 100644 --- a/test/README +++ b/test/README @@ -37,7 +37,7 @@ stdio.h - fgetpos(), fgets(), fileno(), f*lockfile(), fopen(), not tested. wchar.h - fgetwc(), fgetws() not tested. fmtmsg.h - fmtmsg() not tested. fnmatch.h - fnmatch() not tested. -unistd.h - fork(), fpathconf() not tested. +unistd.h - fork(), fpathconf(), free() not tested. stdio.h - *printf*, fputc(), fputwc(), fputws(), fread() not tested. For other dependencies not tested, see the commented-out lines in deheader's |