deheader-1.6/README0000644000175000017500000000060112077631025012145 0ustar esresr deheader deheader analyzes C and C++ files to determine which header enclusions can be removed while still allowing them to compile. This may result in substantial improvements in compilation time, especially on large C++ projects; it also sometimes exposes dependencies and cohesions of which developers were unaware. Eric S. Raymond December 2010 deheader-1.6/COPYING0000644000175000017500000000243612610474667012342 0ustar esresr BSD LICENSE Copyright (c) 2015, Eric S. Raymond All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. deheader-1.6/NEWS0000664000175000017500000000265512773467463012021 0ustar esresr deheader project news 1.6: 2016-09-30 Fix bug that prevented the -b option from being interpreted. Acknowledge Debian bug Debian bug #839179: keywords in comments not ignored. 1.5: 2016-09-27 exit(1) if unneeded includes are detected (useful in Makefiles). 1.4: 2016-09-01 Now runs polyglot under either Python 2 or Python 3 Added assert() to requirements. 1.3 @ 2016-01-12 When compilation fails, also try it directly inside subdirectories. 1.2 @ 2015-07-18 Notice preprocessor directives with whitespace after the hash-mark 1.1 @ 2015-01-26 Allow --version on the command line. Fix up the regression tests. 1.0 @ 2014-06-03 Added --quiet option. 0.8 @ 2013-09-14 Minor documentation fixes. 0.7 @ 2013-01-22 Accept .cc as an extension as well as .cpp. 0.6 @ 2011-02-10 Add the return-status macros from sys/wait.h to the portability list. 0.5 @ 2010-12-22 Source is now checked against all SuS portability requirements. There is an option to exclude files by pattern. 0.4 @ 2010-12-20 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. 0.2 @ 2010-12-02 Make the last line of output a statistical summary. Document some limitations. 0.1 @ 2010-12-01 Initial release. deheader-1.6/deheader0000775000175000017500000021133612773467476013013 0ustar esresr#!/usr/bin/env python """\ deheader -- find (optionally remove) unneeded includes in C or C++ sourcefiles. Usage: deheader [-h] [-i pattern] [-m cmd] [-b dir] [-q] [-r] [-x pattern] [-v] [file...] -h, --help Emit this help message and quit. -m, --maker Set the build command (by default 'make') -b, --builddir Set a build directory relative to where deheader is run -i, --ignore Ignore (don't remove) headers matching the argument regexp -q, --quiet Suppress statistical summary -r, --remove Remove the final set of unneeded headers -v, --verbose Be chatty about what you're doing. -x, --exclude Exclude files matching regexp -V, --version Emit version and exit. This tool takes a list of C or C++ sourcefiles and generates a report on which #includes can be omitted from them -- the test, for each foo.c or foo.cc or foo.cpp, is simply whether 'rm foo.o; make foo.o' returns a zero status. Optionally, with the -r option, the unneeded headers are removed. The tool also reports on headers required for strict portability. If a sourcefile argument is a directory, the report is generated on all source files beneath it. Subdirectories beginning with a dot are ignored. If no arguments are given, the program runs as if the name of the current directory had been passed to it. The original sourcefile is moved to a name with an .orig suffix and restored on interrupt or after processing with its original timestamp, unless the -r option was given and headers removed. The last line of the output is a statistical summary of operations. """ # SPDX-License-Identifier: BSD-2-Clause from __future__ import print_function import sys, os, getopt, time, re, operator, subprocess version = "1.6" try: from subprocess import getstatusoutput except ImportError: from commands import getstatusoutput BATON_DEBUG = 1 PROGRESS_DEBUG = 2 COMMAND_DEBUG = 3 # Difference in various compiler implementations and OSes mean that for cross- # platform compatibility you sometimes want to leave "unneeded" headers alone # because they're required in order to satify dependencies on other platforms. requirements = ( # Headers mandated by SuS Version 2 System Interfaces. # a64l, l64a - convert between a 32-bit integer and a radix-64 ASCII string (r"a64l()", [""]), (r"l64a()", [""]), # abort - generate an abnormal process abort (r"abort()", [""]), # abs - return an integer absolute value (r"abs()", [""]), # access - determine accessibility of a file (r"access()", [""]), # acos - arc cosine function (r"acos()", [""]), # acosh, asinh, atanh - inverse hyperbolic functions (r"acosh()", [""]), (r"asinh()", [""]), (r"atanh()", [""]), # advance - pattern match given a compiled regular expression (r"advance()", [""]), # aio.h - asynchronous input and output (r"aio_cancel()", [""]), (r"aio_error()", [""]), (r"aio_fsync()", [""]), (r"aio_read()", [""]), (r"aio_return()", [""]), (r"aio_suspend()", [""]), (r"aio_write()", [""]), (r"lio_listio()", [""]), # alarm - schedule an alarm signal (r"alarm()", [""]), # asctime, asctime_r - convert date and time to a string (r"asctime()", [""]), (r"asctime_r()", [""]), # asin - arc sine function (r"asin()", [""]), # assert - verify program assertion (r"assert()", [""]), # atan - arc tangent function (r"atan()", [""]), # atan2 - arc tangent function (r"atanh()", [""]), # atanh - hyperbolic arc tangent (r"atan2()", [""]), # atexit - register a function to run at process termination (r"atexit()", [""]), # atof - convert a string to double-precision number (r"atof()", [""]), # atoi - convert a string to integer (r"atol()", [""]), # atol - convert a string to long integer (r"atol()", [""]), # basename - return the last component of a pathname (r"basename()", [""]), # bcmp - memory operations (r"bcmp()", [""]), # bcopy - memory operations (r"bcopy()", [""]), # brk, sbrk - change space allocation (LEGACY) (r"brk()", [""]), (r"sbrk()", [""]), # bsearch - binary search a sorted table (r"bsort()", [""]), # btowc - single-byte to wide-character conversion (r"btowc()", ["", ""]), # bzero - memory operations (r"bzero()", [""]), # calloc - a memory allocator (r"calloc()", [""]), # catclose - close a message catalogue descriptor (r"catclose()", [""]), # catgets - read a program message (r"catgets()", [""]), # catopen - open a message catalogue (r"catopen()", [""]), # cbrt - cube root function (r"cbrt()", [""]), # ceil - ceiling value function (r"ceil()", [""]), # chdir - change working directory (r"chdir()", [""]), # chmod - change mode of a file (r"chmod()", ["", ""]), # chown - change owner and group of a file (r"chown()", ["", ""]), # chroot - change root directory (LEGACY) (r"chroot()", [""]), # clearerr - clear indicators on a stream (r"clearerr()", [""]), # clock - report CPU time used (r"clock()", [""]), # clock_settime, clock_gettime, clock_getres - clock and timer functions (r"clock_settime()", [""]), (r"clock_gettime()", [""]), (r"clock_getres()", [""]), # close - close a file descriptor (r"close()", [""]), # closedir - close a directory stream (r"closedir()", ["", ""]), # closelog, openlog, setlogmask, syslog - control system log (r"closelog()", [""]), (r"openlog()", [""]), (r"setlogmask()", [""]), (r"syslog()", [""]), # compile - produce a compiled regular expression (r"compile()", [""]), # confstr - get configurable variables (r"confstr()", [""]), # cos - cosine function (r"cos()", [""]), # cosh - hyperbolic cosine function (r"cosh()", [""]), # creat - create a new file or rewrite an existing one (r"creat()", ["", "", ""]), # crypt - string encoding function (r"crypt()", [""]), # ctermid - generate a pathname for controlling terminal (r"ctermid()", [""]), # ctime, ctime_r - convert a time value to date and time string (r"ctime()", [""]), (r"ctime_r()", [""]), # ctype.h - character types (r"isalnum()", [""]), (r"isalpha()", [""]), (r"isascii()", [""]), (r"iscntrl()", [""]), (r"isdigit()", [""]), (r"isgraph()", [""]), (r"islower()", [""]), (r"isprint()", [""]), (r"ispunct()", [""]), (r"isspace()", [""]), (r"isupper()", [""]), (r"isxdigit()", [""]), (r"toascii()", [""]), (r"tolower()", [""]), (r"toupper()", [""]), (r"_tolower()", [""]), (r"_toupper()", [""]), # cuserid - character login name of the user (r"cuserid()", [""]), # daylight - daylight savings time flag (r"extern\s+int\s+daylight;", [""]), # dbm_clearerr, dbm_close, dbm_delete, dbm_error, dbm_fetch, dbm_firstkey, dbm_nextkey, dbm_open, dbm_store - database functions (r"dbm_clearerr()", [""]), (r"dbm_close()", [""]), (r"dbm_delete()", [""]), (r"dbm_error()", [""]), (r"dbm_fetch()", [""]), (r"dbm_firstkey()", [""]), (r"dbm_nextkey()", [""]), (r"dbm_open()", [""]), (r"dbm_store()", [""]), # difftime - compute the difference between two calendar time values (r"difftime()", [""]), # dirname - report the parent directory name of a file pathname (r"dirname()", [""]), # div - compute the quotient and remainder of an integer division (r"div()", [""]), # dlclose - close a dlopen() object (r"dlclose()", [""]), # dlerror - get diagnostic information (r"dlerror()", [""]), # dlsym - obtain the address of a symbol from a dlopen() object (r"dlsym()", [""]), # drand48, erand48, jrand48, lcong48, lrand48, mrand48, nrand48, seed48, srand48 - generate uniformly distributed pseudo-random numbers (r"drand48()", [""]), (r"erand48()", [""]), (r"jrand48()", [""]), (r"lcong48()", [""]), (r"lrand48()", [""]), (r"mrand48()", [""]), (r"nrand48()", [""]), (r"seed48()", [""]), (r"srand48()", [""]), # dup, dup2 - duplicate an open file descriptor (r"dup()", [""]), (r"dup2()", [""]), # exit, _exit - terminate a process (r"exit()", [""]), (r"_exit()", [""]), # ecvt, fcvt, gcvt - convert a floating-point number to a string (r"ecvt()", [""]), (r"fcvt()", [""]), (r"gcvt()", [""]), # encrypt - encoding function (r"encrypt()", [""]), # endgrent, getgrent, setgrent - group database entry functions (r"endgrent()", [""]), (r"getgrent()", [""]), (r"setgrent()", [""]), (r"getgrnam()", [""]), (r"getgrgid()", [""]), (r"getgrnam_r()", [""]), (r"getgrgid_r()", [""]), # endpwent, getpwent, setpwent - user database functions (r"endpwent()", [""]), (r"getpwent()", [""]), (r"setpwent()", [""]), (r"getpwnam()", [""]), (r"getpwuid()", [""]), (r"getpwnam_r()", [""]), (r"getpwuid_r()", [""]), # endutxent, getutxent, getutxid, getutxline, pututxline, setutxent - user accounting database functions (r"endutxent()", [""]), (r"getutxent()", [""]), (r"getutxid()", [""]), (r"getutxline()", [""]), (r"pututxline()", [""]), (r"setutxent()", [""]), # erf, erfc - error and complementary error functions (r"erf()", [""]), (r"erfc()", [""]), # environ, execl, execv, execle, execve, execlp, execvp - execute a file (r"extern\s+char\s+\*\*environ;", [""]), (r"execl()", [""]), (r"execv()", [""]), (r"execle()", [""]), (r"execve()", [""]), (r"execlp()", [""]), (r"execvp()", [""]), # exp - exponential function (r"exp()", [""]), # expm1 - compute exponential functions (r"expm1()", [""]), # FD_CLR - macros for synchronous I/O multiplexing (r"FD_CLR()", [""]), (r"FD_ISSET()", [""]), (r"FD_SET()", [""]), (r"FD_ZERO()", [""]), # fabs - absolute value function (r"fabs()", [""]), # fattach - attach a STREAMS-based file descriptor to a file in the file system name space (r"fattach()", [""]), # fchdir - change working directory (r"fchdir()", [""]), # fchmod - change mode of a file (r"fchmod()", [""]), # fchown - change owner and group of a file (r"fchown()", [""]), # fdopen - associate a stream with a file descriptor (r"fdopen()", [""]), # fclose - close a stream (r"fclose()", [""]), # fdatasync - synchronise the data of a file (r"fdatasync()", [""]), # fdetach - detach a name from a STREAMS-based file descriptor (r"fdetach()", [""]), # fdopen - associate a stream with a file descriptor (r"fdopen()", [""]), # ferror - test error indicator on a stream (r"ferror()", [""]), # feof - test end-of-file indicator on a stream (r"feof()", [""]), # fflush - flush a stream (r"fflush()", [""]), # ffs - find first set bit (r"ffs()", [""]), # fgetc - get a byte from a stream (r"fgetc()", [""]), # fgetpos - get current file position information (r"fgetpos()", [""]), # fgets - get a string from a stream (r"fgets()", [""]), # fgetwc - get a wide-character code from a stream (r"fgetwc()", ["", ""]), # fgetws - get a wide-character string from a stream (r"fgetws()", ["", ""]), # fileno - map a stream pointer to a file descriptor (r"fileno()", [""]), # flockfile, ftrylockfile, funlockfile - stdio locking functions (r"flockfile()", [""]), (r"ftrylockfile()", [""]), (r"funlockfile()", [""]), # fmod - floating-point remainder value function (r"fmod()", [""]), # fmtmsg.h - message display structures (r"fmtmsg()", [""]), # fnmatch.h - filename-matching types (r"fnmatch()", [""]), # fopen - open a stream (r"fopen()", [""]), # fork - create a new process (r"fork()", ["", ""]), # fpathconf, pathconf - get configurable pathname variables (r"fpathconf()", [""]), (r"pathconf()", [""]), # fputc - put a byte on a stream (r"fputc()", [""]), # fputs - put a string on a stream (r"fputs()", [""]), # fputwc - put a wide-character code on a stream (r"fputwc()", [""]), # fputws - put a wide-character string on a stream (r"fputws()", [""]), # fread - binary input (r"fread()", [""]), # free - free allocated memory (r"free()", [""]), # freopen - open a stream (r"freopen()", [""]), # frexp - extract mantissa and exponent from a double precision number (r"frexp()", [""]), # fscanf, scanf, sscanf - convert formatted input (r"fscanf()", [""]), (r"scanf()", [""]), (r"sscanf()", [""]), # fseek, fseeko - reposition a file-position indicator in a stream (r"fseek()", [""]), (r"fseeko()", [""]), # fsetpos - set current file position (r"fsetpos()", [""]), # fstat - get file status (r"fstat()", ["", ""]), # fstatvfs, statvfs - get file system information (r"fstatvfs()", [""]), (r"statvfs()", [""]), # fsync - synchronise changes to a file (r"fsync()", [""]), # ftell, ftello - return a file offset in a stream (r"ftell()", [""]), (r"ftello()", [""]), # ftime - get date and time (r"ftime()", [""]), # ftok - generate an IPC key (r"ftok()", [""]), # ftruncate, truncate - truncate a file to a specified length (r"truncate()", [""]), (r"ftruncate()", [""]), # ftw - traverse (walk) a file tree (r"ftw()", [""]), (r"nftw()", [""]), # fwide - set stream orientation (r"fwide()", ["", ""]), # fwprintf, wprintf, swprintf - print formatted wide-character output (r"fwprintf()", ["", ""]), (r"wprintf()", ["", ""]), (r"swprintf()", ["", ""]), # fwrite - binary output (r"fwrite()", [""]), # fwscanf, wscanf, swscanf - convert formatted wide-character input (r"fwscanf()", ["", ""]), (r"wscanf()", ["", ""]), (r"swscanf()", ["", ""]), # gamma, signgam - log gamma function (r"gamma()", [""]), # getc - get a byte from a stream (r"getc()", [""]), # getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked - stdio with explicit client locking (r"getc_unlocked()", [""]), (r"getchar_unlocked()", [""]), (r"putc_unlocked()", [""]), (r"putchar_unlocked()", [""]), # getchar - get a byte from a stdin stream (r"getchar()", [""]), # getcontext, setcontext - get and set current user context (r"getcontext()", [""]), (r"setcontext()", [""]), # getcwd - get the pathname of the current working directory (r"getcwd()", [""]), # getdate - convert user format date and time (r"getdate()", [""]), # getdtablesize - get the file descriptor table size (r"getdtablesize()", [""]), # getegid - get the effective group ID (r"getegid()", ["", ""]), # getenv - get value of an environment variable (r"getenv()", [""]), # geteuid - get the effective user ID (r"geteuid()", ["", ""]), # getgid - get the real group ID (r"getgid()", ["", ""]), # getgrgid, getgrgid_r - get group database entry for a group ID (r"getgrgid()", ["", ""]), (r"getgrgid_r()", ["", ""]), # getgrnam, getgrnam_r - search group database for a name (r"getgrnam()", ["", ""]), (r"getgrnam_r()", ["", ""]), # getgroups - get supplementary group IDs (r"getgroups()", ["", ""]), # gethostid - get an identifier for the current host (r"gethostid()", [""]), # getitimer, setitimer - get or set value of interval timer (r"getitimer()", [""]), (r"setitimer()", [""]), # getlogin, getlogin_r - get login name (r"getlogin()", [""]), (r"getlogin_r()", [""]), # getmsg, getpmsg - receive next message from a STREAMS file (r"getmsg()", [""]), (r"getpmsg()", [""]), # getopt, optarg, optind, opterr, optopt - command option parsing (r"getopt()", [""]), (r"extern\s+char\s+\*\*optarg;", [""]), # getpagesize - get the current page size (r"getpagesize()", [""]), # getpass - read a string of characters without echo (r"getpass()", [""]), # getpgid - get the process group ID for a process (r"getpgid()", [""]), # getpgrp - get the process group ID of the calling process (r"getpgrp()", ["", ""]), # getpid - get the process ID (r"getpid()", ["", ""]), # getppid - get the parent process ID (r"getppid()", ["", ""]), # getpriority, setpriority - get or set the nice value (r"getpriority()", [""]), (r"setpriority()", [""]), # getpwnam, getpwnam_r - search user database for a name (r"getpwnam()", ["", ""]), (r"getpwnam_r()", ["", ""]), # getpwuid, getpwuid_r - search user database for a user ID (r"getpwuid()", ["", ""]), (r"getpwuid_r()", ["", ""]), # getrlimit, setrlimit - control maximum resource consumption (r"getrlimit()", [""]), (r"setrlimit()", [""]), # getrusage - get information about resource utilisation (r"getrusage()", [""]), # gets - get a string from a stdin stream (r"gets()", [""]), # getsid - get the process group ID of session leader (r"getsid()", [""]), # getsubopt - parse suboption arguments from a string (r"getsubopt()", [""]), # gettimeofday - get the date and time (r"gettimeofday()", [""]), # getuid - get a real user ID (r"getuid()", ["", ""]), # getw - get a word from a stream (r"getw()", [""]), # getwc - get a wide-character code from a stream (r"getwc()", ["", ""]), # getws - get a wide-character string from a stream (r"getws()", ["", ""]), # getwchar - get a wide character from a stdin stream (r"getwchar()", [""]), # getwd - get the current working directory pathname (r"getwd()", [""]), # glob.h - pathname pattern-matching types (r"glob()", [""]), (r"globfree()", [""]), # gmtime, gmtime_r - convert a time value to a broken-down UTC time (r"gmtime()", [""]), (r"gmtime_r()", [""]), # grantpt - grant access to the slave pseudo-terminal device (r"grantpt()", [""]), # hcreate, hdestroy, hsearch - manage hash search table (r"hcreate()", [""]), (r"hdestroy()", [""]), (r"hsearch ()", [""]), # hypot - Euclidean distance function (r"hypot()", [""]), # iconv.h - codeset conversion facility (r"iconv_open()", [""]), (r"iconv()", [""]), (r"iconv_close()", [""]), # ilogb - return an unbiased exponent (r"ilogb()", [""]), # index - character string operations (r"index()", [""]), # initstate, random, setstate, srandom - pseudorandom number functions (r"initstate()", [""]), (r"random()", [""]), (r"setstate()", [""]), (r"srandom()", [""]), # insque, remque - insert or remove an element in a queue (r"insque()", [""]), (r"remque()", [""]), # SuS ioctl specifies , but that's just wrong # isastream - test a file descriptor (r"isastream()", [""]), # isnan - test for a NaN (r"isnan()", [""]), # j0, j1, jn - Bessel functions of the first kind (r"j0()", [""]), (r"j1()", [""]), (r"jn()", [""]), # labs - return a long integer absolute value (r"labs()", [""]), # lchown - change the owner and group of a symbolic link (r"lchown()", [""]), # ldexp - load exponent of a floating point number (r"ldexp()", [""]), # ldiv - compute quotient and remainder of a long division (r"ldiv()", [""]), # lgamma - log gamma function (r"lgamma()", [""]), # libgen.h - definitions for pattern matching functions (r"regcmp()", [""]), (r"regex()", [""]), # link - link to a file (r"link()", [""]), # localeconv - determine the program locale (r"localeconv()", [""]), # localtime, localtime_r - convert a time value to a broken-down local time (r"localtime()", [""]), (r"localtime_r()", [""]), # lockf - record locking on files (r"lockf()", [""]), # log - natural logarithm function (r"log()", [""]), # log10 - base 10 logarithm function (r"log10()", [""]), # log1p - compute a natural logarithm (r"log1p()", [""]), # logb - radix-independent exponent (r"logb()", [""]), # lsearch, lfind - linear search and update (r"lfind()", [""]), (r"lsearch()", [""]), # lseek - move the read/write file offset (r"lseek()", ["", ""]), # lstat - get symbolic link status (r"lstat()", [""]), # makecontext, swapcontext - manipulate user contexts (r"makecontext()", [""]), (r"swapcontext()", [""]), # malloc - a memory allocator (r"malloc()", [""]), # mblen - get number of bytes in a character (r"mblen()", [""]), # mbrlen - get number of bytes in a character (restartable) (r"mblren()", [""]), # mbrtowc - convert a character to a wide-character code (restartable) (r"mbrtowc()", [""]), # mbsinit - determine conversion object status (r"mbsinit()", [""]), # mbsrtowcs - convert a character string to a wide-character string (restartable) (r"mbsrtowcs()", [""]), # mbstowcs - convert a character string to a wide-character string (r"mbstowcs()", [""]), # mbtowc - convert a character to a wide-character code (r"mbtowcs()", [""]), # mkdir - make a directory (r"mkdir()", ["", ""]), # mkfifo - make a FIFO special file (r"mkfifo()", ["", ""]), # mknod - make a directory, a special or regular file (r"mknod()", [""]), # mkstemp - make a unique file name (r"mkstemp()", [""]), # mktemp - make a unique filename (r"mktemp()", [""]), # convert broken-down time into time since the Epoch (r"mktime()", [""]), # sys/mman.h - memory management declarations (r"mlock()", [""]), (r"mlockall()", [""]), (r"mmap()", [""]), (r"mprotect()", [""]), (r"msync()", [""]), (r"munlock()", [""]), (r"munlockall()", [""]), (r"munmap()", [""]), (r"shm_open()", [""]), (r"shm_unlink()", [""]), # modf - decompose a floating-point number (r"modf()", [""]), # monetary.h - monetary types (r"strfmon()", [""]), # mqueue.h - message queues (r"mq_close()", [""]), (r"mq_getattr()", [""]), (r"mq_notify()", [""]), (r"mq_open()", [""]), (r"mq_receive()", [""]), (r"mq_send()", [""]), (r"mq_setattr()", [""]), (r"mq_unlink()", [""]), # sys/msg.h - message queue structures (r"msgctl()", [""]), (r"msgget()", [""]), (r"msgrcv()", [""]), (r"msgsnd()", [""]), # nanosleep - high resolution sleep (r"nanosleep()", [""]), # nextafter - next representable double-precision floating-point number (r"nextafter()", [""]), # change nice value of a process (r"nice()", [""]), # nl_langinfo - language information (r"nl_langinfo()", [""]), # open - open a file (r"open()", ["", "", ""]), # opendir - open a directory (r"opendir()", ["", ""]), # pause - suspend the thread until signal is received (r"pause()", [""]), # pclose - close a pipe stream to or from a process (r"pclose()", [""]), # perror - write error messages to standard error (r"perror()", [""]), # pipe - create an interprocess channel (r"pipe()", [""]), # poll - input/output multiplexing (r"poll()", [""]), # popen - initiate pipe streams to or from a process (r"popen()", [""]), # pow - power function (r"pow()", [""]), # pread - read from a file ("pread()", [""]), # pthread.h - threads (r"pthread_attr_destroy()", [""]), (r"pthread_attr_getdetachstate()", [""]), (r"pthread_attr_getguardsize()", [""]), (r"pthread_attr_getinheritsched()", [""]), (r"pthread_attr_getschedparam()", [""]), (r"pthread_attr_getschedpolicy()", [""]), (r"pthread_attr_getscope()", [""]), (r"pthread_attr_getstackaddr()", [""]), (r"pthread_attr_getstacksize()", [""]), (r"pthread_attr_init()", [""]), (r"pthread_attr_setdetachstate()", [""]), (r"pthread_attr_setguardsize()", [""]), (r"pthread_attr_setinheritsched()", [""]), (r"pthread_attr_setschedparam()", [""]), (r"pthread_attr_setschedpolicy()", [""]), (r"pthread_attr_setscope()", [""]), (r"pthread_attr_setstackaddr()", [""]), (r"pthread_attr_setstacksize()", [""]), (r"pthread_cancel()", [""]), (r"pthread_cleanup_push()", [""]), (r"pthread_cleanup_pop()", [""]), (r"pthread_cond_broadcast()", [""]), (r"pthread_cond_destroy()", [""]), (r"pthread_cond_init()", [""]), (r"pthread_cond_signal()", [""]), (r"pthread_cond_timedwait()", [""]), (r"pthread_cond_wait()", [""]), (r"pthread_condattr_destroy()", [""]), (r"pthread_condattr_getpshared()", [""]), (r"pthread_condattr_init()", [""]), (r"pthread_condattr_setpshared()", [""]), (r"pthread_create()", [""]), (r"pthread_detach()", [""]), (r"pthread_equal()", [""]), (r"pthread_exit()", [""]), (r"pthread_getconcurrency()", [""]), (r"pthread_getschedparam()", [""]), (r"pthread_getspecific()", [""]), (r"pthread_join()", [""]), (r"pthread_key_create()", [""]), (r"pthread_key_delete()", [""]), (r"pthread_mutex_destroy()", [""]), (r"pthread_mutex_getprioceiling()", [""]), (r"pthread_mutex_init()", [""]), (r"pthread_mutex_lock()", [""]), (r"pthread_mutex_setprioceiling()", [""]), (r"pthread_mutex_trylock()", [""]), (r"pthread_mutex_unlock()", [""]), (r"pthread_mutexattr_destroy()", [""]), (r"pthread_mutexattr_getprioceiling()",[""]), (r"pthread_mutexattr_getprotocol()", [""]), (r"pthread_mutexattr_getpshared()", [""]), (r"pthread_mutexattr_gettype()", [""]), (r"pthread_mutexattr_init()", [""]), (r"pthread_mutexattr_setprioceiling()",[""]), (r"pthread_mutexattr_setprotocol()", [""]), (r"pthread_mutexattr_setpshared()", [""]), (r"pthread_mutexattr_settype()", [""]), (r"pthread_once()", [""]), (r"pthread_rwlock_destroy()", [""]), (r"pthread_rwlock_init()", [""]), (r"pthread_rwlock_rdlock()", [""]), (r"pthread_rwlock_tryrdlock()", [""]), (r"pthread_rwlock_trywrlock()", [""]), (r"pthread_rwlock_unlock()", [""]), (r"pthread_rwlock_wrlock()", [""]), (r"pthread_rwlockattr_destroy()", [""]), (r"pthread_rwlockattr_getpshared()", [""]), (r"pthread_rwlockattr_init()", [""]), (r"pthread_rwlockattr_setpshared()", [""]), (r"pthread_self()", [""]), (r"pthread_setcancelstate()", [""]), (r"pthread_setcanceltype()", [""]), (r"pthread_setconcurrency()", [""]), (r"pthread_setschedparam()", [""]), (r"pthread_setspecific()", [""]), (r"pthread_testcancel()", [""]), # ptsname - get name of the slave pseudo-terminal device (r"ptsname()", [""]), # putc - put a byte on a stream (r"putc()", [""]), # putc_unlocked - stdio with explicit client locking (r"putc_unlocked()", [""]), # putchar - put byte on stdout stream (r"putchar()", [""]), # putchar_unlocked - stdio with explicit client locking (r"putchar_unlocked()", [""]), # putenv - change or add a value to environment (r"putenv()", [""]), # putmsg, putpmsg - send a message on a STREAM (r"putmsg()", [""]), (r"putpmsg()", [""]), # puts - put a string on standard output (r"puts()", [""]), # putw - put a word on a stream (r"putw()", [""]), # putwc - put a wide-character on a stream (r"putwc()", ["", ""]), # putwchar - put a wide character from a stdin stream (r"putwchar()", [""]), # qsort - sort a table of data (r"qsort()", [""]), # raise - send a signal to the executing process (r"raise()", [""]), # rand, rand_r - pseudo-random number generator (r"rand()", [""]), (r"srand()", [""]), (r"rand_r()", [""]), # random - generate pseudorandom number (r"random()", [""]), # re_comp.h - regular-expression-matching functions for re_comp() (r"re_comp()", [""]), (r"re_exec()", [""]), # read, readv, pread - read from a file ("read()", [""]), ("readv()", [""]), # readdir, readdir_r - read directory (r"readdir()", ["", ""]), (r"readdir_r()", ["", ""]), # readlink - read the contents of a symbolic link ("readlink()", [""]), # realloc - memory reallocator ("realloc()", [""]), # realpath - resolve a pathname ("realpath()", [""]), # regcomp, regexec, regerror, regfree - regular expression matching (r"regcomp()", ["", ""]), (r"regexec()", ["", ""]), (r"regerror()", ["", ""]), (r"regfree()", ["", ""]), # remainder - remainder function (r"remainder()", [""]), # remove - remove files (r"remove()", [""]), # rename - rename a file (r"rename()", [""]), # rewind - reset file position indicator in a stream (r"rewind()", [""]), # rewinddir - reset position of directory stream to the beginning of a directory (r"rewinddir()", ["", ""]), # rindex - character string operations (r"rindex()", [""]), # rint - round-to-nearest integral value (r"rint()", [""]), # rmdir - remove a directory ("rmdir()", [""]), # scalb - load exponent of a radix-independent floating-point number (r"scalb()", [""]), # scanf - convert formatted input (r"scanf()", [""]), # sched.h - execution scheduling (r"sched_get_priority_max()", [""]), (r"sched_get_priority_min()", [""]), (r"sched_getparam()", [""]), (r"sched_getscheduler()", [""]), (r"sched_rr_get_interval()", [""]), (r"sched_setparam()", [""]), (r"sched_setscheduler()", [""]), (r"sched_yield()", [""]), # seekdir - set position of directory stream (r"seekdir()", ["", ""]), # select - synchronous I/O multiplexing (r"select()", [""]), # semaphore.h - semaphores (r"sem_close()", [""]), (r"sem_destroy()", [""]), (r"sem_getvalue()", [""]), (r"sem_init()", [""]), (r"sem_open()", [""]), (r"sem_post()", [""]), (r"sem_trywait()", [""]), (r"sem_unlink()", [""]), (r"sem_wait()", [""]), # sys/sem.h - semaphore facility (r"semctl()", [""]), (r"semget()", [""]), (r"semop()", [""]), # setbuf - assign buffering to a stream (r"setbuf()", [""]), # setgid - set-group-ID (r"setgid()", ["", ""]), # setgrent - reset group database to first entry (r"setgrent()", [""]), # setkey - set encoding key (r"setkey()", [""]), # setpgid - set process group ID for job control (r"setpgid()", ["", ""]), # setpgrp - set process group ID (r"setpgrp()", [""]), # setregid - set real and effective group IDs (r"setregid()", [""]), # setreuid - set real and effective user IDs (r"setreuid()", [""]), # setsid - create session and set process group ID (r"setsid()", ["", ""]), # setuid - set-user-ID (r"setuid()", ["", ""]), # setvbuf - assign buffering to a stream (r"setvbuf()", [""]), # sys/shm.h - shared memory facility (r"shmat()", [""]), (r"shmctl()", [""]), (r"shmdt()", [""]), (r"shmget()", [""]), # setjmp.h - stack environment declarations (r"longjmp()", [""]), (r"siglongjmp()", [""]), (r"_longjmp()", [""]), (r"setjmp()", [""]), (r"sigsetjmp()", [""]), (r"_setjmp()", [""]), # signal.h - signals (r"bsd_signal()", [""]), (r"kill()", [""]), (r"killpg()", [""]), (r"pthread_kill()", [""]), (r"pthread_sigmask()", [""]), (r"raise()", [""]), (r"sigaction()", [""]), (r"sigaddset()", [""]), (r"sigaltstack()", [""]), (r"sigdelset()", [""]), (r"sigemptyset()", [""]), (r"sigfillset()", [""]), (r"sighold()", [""]), (r"sigignore()", [""]), (r"siginterrupt()", [""]), (r"sigismember()", [""]), (r"signal()", [""]), (r"sigpause()", [""]), (r"sigpending()", [""]), (r"sigprocmask()", [""]), (r"sigqueue()", [""]), (r"sigrelse()", [""]), (r"sigset()", [""]), (r"sigstack()", [""]), (r"sigsuspend()", [""]), (r"sigtimedwait()", [""]), (r"sigwait()", [""]), (r"sigwaitinfo()", [""]), # sin - sine function (r"sin()", [""]), # sinh - hyperbolic sine function (r"sinh()", [""]), # sleep - suspend execution for an interval of time (r"sleep()", [""]), # fprintf, printf, snprintf, sprintf - print formatted output (r"fprintf()", [""]), (r"printf()", [""]), (r"snprintf()", [""]), (r"sprintf()", [""]), # sqrt - square root function (r"sqrt()", [""]), # stat - get file status (r"stat()", ["", ""]), # stdarg.h - handle variable argument list (r"va_start()", [""]), (r"va_arg()", [""]), (r"va_end()", [""]), # stddef.h - standard type definitions (r"offsetof()", [""]), # step - pattern match with regular expressions (r"step()", [""]), # strcasecmp, strncasecmp - case-insensitive string comparisons (r"strcasecmp()", [""]), (r"strncasecmp()", [""]), # string.h - string operations (r"memccpy()", [""]), (r"memchr()", [""]), (r"memcmp()", [""]), (r"memcpy()", [""]), (r"memmove()", [""]), (r"memset()", [""]), (r"strcat()", [""]), (r"strchr()", [""]), (r"strcmp()", [""]), (r"strcoll()", [""]), (r"strcpy()", [""]), (r"strcspn()", [""]), (r"strdup()", [""]), (r"strerror()", [""]), (r"strlen()", [""]), (r"strncat()", [""]), (r"strncmp()", [""]), (r"strncpy()", [""]), (r"strpbrk()", [""]), (r"strrchr()", [""]), (r"strspn()", [""]), (r"strstr()", [""]), (r"strtok()", [""]), (r"strtok_r()", [""]), (r"strxfrm()", [""]), # wctype.h - wide-character classification and mapping utilities (r"iswalnum()", [""]), (r"iswalpha()", [""]), (r"iswascii()", [""]), (r"iswcntrl()", [""]), (r"iswdigit()", [""]), (r"iswgraph()", [""]), (r"iswlower()", [""]), (r"iswprint()", [""]), (r"iswpunct()", [""]), (r"iswspace()", [""]), (r"iswupper()", [""]), (r"iswxdigit()", [""]), (r"iswctype()", [""]), (r"towctrans()", [""]), (r"towlower()", [""]), (r"towupper()", [""]), (r"wctrans()", [""]), (r"wctype()", [""]), # strftime - convert date and time to a string (r"strftime()", [""]), # strptime - date and time conversion (r"strptime()", [""]), # strtod - convert string to a double-precision number (r"strtod()", [""]), # strtol - convert string to a long integer (r"strtol()", [""]), # strtoul - convert string to an unsigned long (r"strtoul()", [""]), # swab - swap bytes (r"swab()", [""]), # symlink - make symbolic link to a file (r"symlink()", [""]), # sync - schedule filesystem updates (r"sync()", [""]), # sysconf - get configurable system variables (r"sysconf()", [""]), # system - issue a command (r"system()", [""]), # sys/wait.h - declarations for waiting (r"wait()", ["", ""]), (r"wait3()", ["", ""]), (r"waitid()", ["", ""]), (r"waitpid()", ["", ""]), (r"WEXITSTATUS()", ["", ""]), (r"WIFCONTINUED()", ["", ""]), (r"WIFEXITED()", ["", ""]), (r"WIFSIGNALED()", ["", ""]), (r"WIFSTOPPED()", ["", ""]), (r"WSTOPSIG()", ["", ""]), (r"WTERMSIG()", ["", ""]), # tan - tangent function (r"tan()", [""]), # tanh - hyperbolic tangent function (r"tanh()", [""]), # tcgetpgrp - get the foreground process group ID (r"tcgetpgrp()", ["", ""]), # tcsetpgrp - set the foreground process group ID (r"tcsetpgrp()", ["", ""]), # tdelete - delete node from binary search tree (r"tdelete()", [""]), # telldir - current location of a named directory stream (r"telldir()", [""]), # tempnam - create a name for a temporary file (r"tempnam()", [""]), # termios.h - define values for termios (r"cfgetispeed()", [""]), (r"cfgetospeed()", [""]), (r"cfsetispeed()", [""]), (r"cfsetospeed()", [""]), (r"tcdrain()", [""]), (r"tcflow()", [""]), (r"tcflush()", [""]), (r"tcgetattr()", [""]), (r"tcgetsid()", [""]), (r"tcsendbreak()", [""]), (r"tcsetattr()", [""]), # tdelete, tfind, tsearch, twalk - manage a binary search tree (r"tsearch()", [""]), (r"tfind()", [""]), (r"tdelete()", [""]), (r"twalk()", [""]), # time - get time (r"time()", [""]), # timer_create - create a per-process timer (r"timer_create()", ["", ""]), # timer_delete - delete a per-process timer (r"timer_delete()", ["", ""]), # timer_settime, timer_gettime, timer_getoverrun - per-process timers (r"timer_settime()", [""]), (r"timer_gettime()", [""]), (r"timer_getoverrun()", [""]), # times - get process and waited-for child process times (r"times()", [""]), # tmpfile - create a temporary file (r"tmpfile()", [""]), # tmpnam - create a name for a temporary file (r"tmpnam()", [""]), # truncate - truncate a file to a specified length (r"truncate()", [""]), # ttyname, ttyname_r - find pathname of a terminal ("ttyname()", [""]), ("ttyname_r()", [""]), # ttyslot - find the slot of the current user in the user accounting database ("ttyslot()", [""]), # tzset - set time zone conversion information ("tzset()", [""]), # ualarm - set the interval timer ("ualarm()", [""]), # ulimit - get and set process limits ("ulimit()", [""]), # umask - set and get file mode creation mask (r"umask()", ["", ""]), # uname - get name of current system ("uname()", [""]), # ungetc - push byte back into input stream (r"ungetc()", [""]), # ungetwc - push wide-character code back into input stream (r"ungetwc()", ["", ""]), # unlink - remove a directory entry ("unlink()", [""]), # unlockpt - unlock a pseudo-terminal master/slave pair (r"unlockpt()", [""]), # usleep - suspend execution for an interval ("usleep()", [""]), # utime - set file access and modification times (r"utime()", ["", ""]), # utimes - set file access and modification times (r"utimes()", [""]), # valloc - page-aligned memory allocator (r"valloc()", [""]), # vfork - create new process; share virtual memory ("vfork()", [""]), # vfprintf, vprintf, vsnprintf, vsprintf - format output of a stdarg argument list (r"vfprintf()", ["", ""]), (r"vprintf()", ["", ""]), (r"vsnprintf()", ["", ""]), (r"vsprintf()", ["", ""]), # vfwprintf, vwprintf, vswprintf - wide-character formatted output of a stdarg argument list (r"vwprintf()", ["", "", ""]), (r"vfwprintf()", ["", "", ""]), (r"vswprintf()", ["", "", ""]), # wchar.h - wide-character types (r"wcrtomb()", [""]), # SuSv2 erroneously says (r"wcscat()", [""]), (r"wcschr()", [""]), (r"wcscmp()", [""]), (r"wcscoll()", [""]), (r"wcscpy()", [""]), (r"wcscpy()", [""]), (r"wcsftime()", [""]), (r"wcslen()", [""]), (r"wcsncat()", [""]), (r"wcsncmp()", [""]), (r"wcsncpy()", [""]), (r"wcspbrk()", [""]), (r"wcsrchr()", [""]), (r"wcsrtombs()", [""]), (r"wcsspn()", [""]), (r"wcsstr()", [""]), (r"wcstod()", [""]), (r"wcstok()", [""]), (r"wcstol()", [""]), (r"wcstoul()", [""]), (r"wcswcs()", [""]), (r"wcswidth()", [""]), (r"wcsxfrm()", [""]), (r"wctob()", [""]), (r"wctype()", [""]), (r"wcwidth()", [""]), (r"wmemchr()", [""]), (r"wmemcmp()", [""]), (r"wmemcpy()", [""]), (r"wmemmove()", [""]), (r"wmemset()", [""]), (r"wprintf()", [""]), (r"wscanf()", [""]), # wordexp.h - word-expansion types (r"wordexp()", [""]), (r"wordfree()", [""]), # write, writev, pwrite - write on a file (r"write()", [""]), (r"pwrite()", [""]), (r"writev()", [""]), # y0, y1, yn - Bessel functions of the second kind (r"y0()", [""]), (r"y1()", [""]), (r"yn()", [""]), # Headers mandated by SuS Version 2 Network Services. # sys/socket.h - Internet Protocol family (r"accept()", [""]), (r"bind()", [""]), (r"connect()", [""]), (r"getpeername()", [""]), (r"getsockname()", [""]), (r"getsockopt()", [""]), (r"listen()", [""]), (r"recv()", [""]), (r"recvfrom()", [""]), (r"recvmsg()", [""]), (r"send()", [""]), (r"sendmsg()", [""]), (r"sendto()", [""]), (r"setsockopt()", [""]), (r"shutdown()", [""]), (r"socket()", [""]), (r"socketpair()", [""]), # arpa/inet.h - definitions for internet operations (r"inet_addr()", [""]), (r"inet_lnaof()", [""]), (r"inet_makeaddr()", [""]), (r"inet_netof()", [""]), (r"inet_network()", [""]), (r"inet_ntoa()", [""]), (r"htonl()", [""]), (r"htons()", [""]), (r"ntohl()", [""]), (r"ntohs()", [""]), # netdb.h - definitions for network database operations (r"endhostent()", [""]), (r"endnetent()", [""]), (r"endprotoent()", [""]), (r"endservent()", [""]), (r"gethostbyaddr()", [""]), (r"gethostbyname()", [""]), (r"gethostent()", [""]), (r"getnetbyaddr()", [""]), (r"getnetbyname()", [""]), (r"getnetent()", [""]), (r"getprotobyname()", [""]), (r"getprotobynumber()",[""]), (r"getprotoent()", [""]), (r"getservbyname()", [""]), (r"getservbyport()", [""]), (r"getservent()", [""]), (r"sethostent()", [""]), (r"setnetent()", [""]), (r"setprotoent()", [""]), (r"setservent()", [""]), # unistd.h - standard symbolic constants and types (r"gethostname()", [""]), # stdbool.h - standard boolean type (r"=\s*true", [""]), (r"=\s*false", [""]), # Dependencies observed on systems other than the Linux this was # developed under. (r"", ["", ""]), (r"", [""]), ) class Baton: "Ship progress indications to stderr." def __init__(self, prompt, endmsg=None): self.stream = sys.stderr self.stream.write(prompt + "...") if os.isatty(self.stream.fileno()): self.stream.write(" \b") self.stream.flush() self.count = 0 self.endmsg = endmsg self.time = time.time() return def twirl(self, ch=None): if self.stream is None: return if os.isatty(self.stream.fileno()): if ch: self.stream.write(ch) else: self.stream.write("-/|\\"[self.count % 4]) self.stream.write("\b") self.stream.flush() self.count = self.count + 1 return def end(self, msg=None): if msg == None: msg = self.endmsg if self.stream: self.stream.write("...(%2.2f sec) %s.\n" % (time.time() - self.time, msg)) return class InclusionMap: "Map the inclusion dependencies of a set of files and directories." @staticmethod def c_source(filename): "Predicate: return true if the filename appears to be C or C++ source." return filename.endswith(".c") or filename.endswith(".cpp") or filename.endswith(".cc") def __init__(self, roots, ignore, excludes, verbosity): "Build the initial inclusion map." self.verbosity = verbosity self.files = [] compiled = [] for (r, h) in requirements: if r.endswith("()"): # The prefix is intended to exclude false suffix matches: # also, excluding : prevents matching on C++ method names. c = re.compile(r"[^a-zA-Z0-9:_]" + 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 excludes and excludes.search(root): if verbose > 1: print("deheader: %s excluded" % root) elif InclusionMap.c_source(root): self.files.append(root) else: sys.stderr.write("deheader: can't analyze %s\n" % root) else: sublist = [] for root, dirs, files in os.walk(root): dirs = [x for x in dirs if not x.startswith(".")] for name in files: path = os.path.join(root, name) if excludes and excludes.search(path): if verbose > 1: print("deheader: %s excluded" % root) elif InclusionMap.c_source(path): sublist.append(path) self.files += sublist self.files.sort() self.depends_on = {} self.requires = {} for sourcefile in self.files: includes = [] requires = [] seen = [] conditions = [] for (i, line) in enumerate(open(sourcefile)): c = match_preproc(["ifndef", "ifdef", "if"], line) if c is not False: conditions.append(c) elif match_preproc("endif", line) is not False: try: conditions.pop() except IndexError: sys.stderr.write('"%s", line %d: unbalanced #endif\n' % (sourcefile, i+1)) sys.exit(1) else: f = match_preproc("include", line) if f is not False: if verbosity >= PROGRESS_DEBUG: name = trim(f) print("deheader: %s includes %s" % (sourcefile, name)) if ignore and ignore.search(line): if verbosity >= PROGRESS_DEBUG: print("deheader: ignoring %s (exclusion match with %s)." % (name, ignore.pattern)) continue if not conditions or conditions == ["S_SPLINT_S"]: includes.append(line) elif verbose > 1: print("deheader: ignoring %s (conditional inclusion)" % name) for (r, c, h) in compiled: if c.search(line): 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 trimmedcount = {} for ref in map(trim, includes): trimmedcount[ref] = trimmedcount.get(ref, 0) + 1 for ref in trimmedcount: if trimmedcount[ref] > 1: print("deheader: %s has more than one inclusion of %s" % (sourcefile, ref)) def forget(self, sourcefile, header): "Forget a header dependency." self.depends_on[sourcefile].remove(header) def remember(self, sourcefile, header): "Undo forgetting of a dependency." self.depends_on[sourcefile].append(header) class SaveForModification: "Prepare a file to be temporarily modified, with guaranteed reversion." def __init__(self, filename): self.filename = filename self.original = filename + "-orig" os.rename(self.filename, self.original) def remove_headers(self, removables): "Prepare a version with specified headers deleted." ofp = open(self.filename, "w") for line in open(self.original): if line not in removables: ofp.write(line) ofp.close() def forget(self): "Disable reversion." os.remove(self.original) def revert(self): "Revert modifications on the file at the end of this object's lifetime." if os.path.exists(self.original): try: os.remove(self.filename) except OSError: pass os.rename(self.original, self.filename) def match_preproc(directives, line): if not isinstance(directives, list): directives = [directives] regexp = "|".join([r"#\s*" + d for d in directives]) m = re.match(regexp, line) if m: return line[m.span()[1]:].strip() return False def trim(line): "Get file reference from an #include, retaining <> if a system header." trimmed = re.sub(r"^#\s*include", "", line).strip() if trimmed[0] in '"': return '"' + trimmed.split('"')[1] + '"' elif trimmed[0] == '<': return trimmed.split('>')[0] + ">" else: return repr(line) def clean(derived): "Clean a derived object file preparatory to test-compiling it" if os.path.exists(os.path.join(builddir, derived)): os.remove(os.path.join(builddir, derived)) elif os.path.exists("CMakeList.txt"): subprocess.call(["make","clean"]) def testcompile(source, maker, msg="", verbosity=0, showerrs=False, subdir=""): "Test-compile a sourcefile. Return the status and the compilation time" (stem, _suffix) = os.path.splitext(source) derived = stem + ".o" clean(os.path.join(subdir, derived)) command = maker + " " + derived olddir = os.getcwd() if len(subdir) > 0: os.chdir(subdir) start = time.time() (status, output) = getstatusoutput(command) end = time.time() os.chdir(olddir) if verbosity >= COMMAND_DEBUG or (showerrs and os.WIFEXITED(status) and os.WEXITSTATUS(status) != 0): sys.stdout.write(output + "\n") if status: explain = "failed" if verbosity >= PROGRESS_DEBUG: explain += " (%d)" % status else: explain = "succeeded" if verbosity >= PROGRESS_DEBUG: print("deheader: %s%s %s." % (source, msg, explain)) clean(os.path.join(subdir, derived)) return (status, end - start) def c_analyze(sourcefile, maker, includes, requires, verbosity, subdir=""): "Given a C file and a list of includes, return those that can be omitted." # We'll remove headers in reverse order, because later unnecessary # headers might depend on earlier ones includes.reverse() unneeded = [] if verbosity == BATON_DEBUG: baton = Baton(sourcefile + ": ", "Done") try: saveit = SaveForModification(os.path.join(subdir, sourcefile)) while True: keepgoing = False for header in includes[:]: if verbosity == BATON_DEBUG: baton.twirl() 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" % (os.path.join(subdir, sourcefile), trigger, trim(header))) retain += 1 if not retain: saveit.remove_headers(unneeded + [header]) (st, _t) = testcompile(sourcefile, maker, " without %s" % trim(header), verbosity, showerrs=False, subdir=subdir) if st == 0: unneeded.append(header) includes.remove(header) keepgoing = True if not keepgoing: break finally: 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 = list(map(trim, includes)) for (requirement, trigger) in requires: if not set(requirement).issubset(stillhere): print("deheader: in %s, %s portability requires %s." % (os.path.join(subdir, sourcefile), trigger, ",".join(requirement))) return unneeded def deheader(sourcefile, maker, includes, requires, remove, verbose): # Sanity check against broken sourcefiles; we want this to # complain visibly if the sourcefile won't build at all. subdir = "" (st, _t) = testcompile(sourcefile, maker, verbosity=max(1, verbose), showerrs=False) if st != 0: subdir = os.path.dirname(sourcefile) sourcefile = os.path.basename(sourcefile) (st, _t) = testcompile(sourcefile, maker, verbosity=max(1, verbose), showerrs=True, subdir=subdir) if st == 0: # Now do the analysis if sourcefile.endswith(".c") or sourcefile.endswith(".cpp") or sourcefile.endswith(".cc"): unneeded = c_analyze(sourcefile, maker, includes[:], requires, verbose, subdir=subdir) if unneeded: for line in unneeded: print("deheader: remove %s from %s" % (trim(line), os.path.join(subdir, sourcefile))) if remove: remove_it = SaveForModification(os.path.join(subdir, sourcefile)) remove_it.remove_headers(unneeded) remove_it.forget() del remove_it return Summary([sourcefile], includes, unneeded) else: sys.stderr.write("deheader: basic compilation failed on %s\n" % (sourcefile,)) return Summary([sourcefile], includes, []) # After-action analysis starts here class Summary: "Summarize results from a deheading." def __init__(self, filenames=None, includes=None, unneeded=None): self.filenames = filenames or [] self.includes = includes or [] self.unneeded = unneeded or [] def __add__(self, other): result = Summary() result.filenames = self.filenames + other.filenames result.includes = self.includes + other.includes result.unneeded = self.unneeded + other.unneeded return result def has_unneeded_includes(self): return len(self.unneeded) > 0 def __repr__(self): return "%d files, %d includes, %d removable" % \ (len(self.filenames), len(self.includes), len(self.unneeded)) if __name__ == "__main__": (options, arguments) = getopt.getopt(sys.argv[1:], "bhi:m:qrvx:V", ["builddir", "help", "ignore", "maker", "quiet", "remove", "verbose", "exclude", "version"]) maker = "make" builddir = '.' verbose = 0 quiet = False remove = False ignores = [] exclusions = [] for (switch, val) in options: if switch in ('-h', '--help'): sys.stderr.write(__doc__) sys.exit(0) elif switch in ('-i', '--ignore'): ignores.append(val) elif switch in ('-m', '--maker'): maker = val elif switch in ('-b', '--builddir'): builddir = os.path.abspath(val) elif switch in ('-q', '--quiet'): quiet = True elif switch in ('-r', '--remove'): remove = True elif switch in ('-v', '--verbose'): verbose += 1 elif switch in ('-V', '--version'): print("deheader", version) raise SystemExit(0) elif switch in ('-x', '--exclude'): exclusions.append(val) if not ignores: ignore = None else: ignore = re.compile("|".join(ignores)) if not exclusions: exclusions = None else: exclusions = re.compile("|".join(exclusions)) if not arguments: arguments = ["."] inclusion_map = InclusionMap(arguments, ignore, exclusions, verbose) summaries = [] for sourcefile in sorted(inclusion_map.depends_on.keys()): summaries.append(deheader(sourcefile, maker, inclusion_map.depends_on[sourcefile], inclusion_map.requires[sourcefile], remove, verbose)) stats = Summary() for summary in summaries: stats = stats + summary if not quiet: print("deheader: saw %s" % stats) if stats.has_unneeded_includes(): raise SystemExit(1) else: raise SystemExit(0) # End deheader-1.6/deheader.xml0000664000175000017500000002050212773464075013570 0ustar esresr deheader 1 Dec 01 2010 deheader deheader Development Tools deheader report which includes in C or C++ compiles can be removed deheader -h -m command -b builddir -i pattern -q -r -v -x pattern -V file-or-dir DESCRIPTION This tool takes a list of C or C++ sourcefiles and generates a report on which #includes can be omitted from them; also, what standard inclusions may be required for portability. The test, for each foo.c or foo.cc or foo.cpp, is simply whether "rm foo.o; make foo.o" returns a zero status (but the build command may be overridden). Exception: Under cmake, foo.o is a phoney target. Therefore, when a "CMakeList.txt" is detected, "make clean" is done rather than "rm foo.o". Optionally, with the switch, the unneeded headers are removed from the sourcefiles. Don't use this option unless you have your sourcefiles safely under version control and can revert! If a sourcefile argument is a directory, the report is generated on all source files beneath it. Subdirectories beginning with a dot are assumed to be repository directories for version-control systems and ignored. If no arguments are given, the program runs as if the name of the current directory had been passed to it. 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. One exception: headers protected only by S_SPLINT_S, the conditional for blocking scanning by the static analysis tool splint1, are scanned normally. The tool will also emit warnings about duplicate inclusions, and inclusions required for portability but not present. It is recommended that you arrange to compile with options that will stop the compiler on warnings when using this tool; otherwise it will report headers that only declare prototypes and return types (and thus throw only warnings) as being not required. Under gcc the compiler options to accomplish this are -Werror -Wfatal-errors. If your makefile follows normal conventions, running with -m "make CFLAGS='-Werror -Wfatal-errors'" may do the right thing; you can check this by running with -v -v -v to see what compilation commands are actually emitted. On each test compile, the original sourcefile is moved to a name with an .orig suffix and restored on interrupt or after processing with its original timestamp, unless the option was given and headers removed. If the -b option is given, it tells the program that generated .o files live in a file tree parallel to the source tree but rooted at the specified argument. If the argument is a relative path, it is interpreted relative to the directory in which deaheader is run. If the first test compilation from the top-level directory fails, deheader descends into the subdirectory of the source file and retries compiling inside there. At verbosity level 0, only messages indicating removable headers are issued. At verbosity 1, test compilations are timed and progess indicated with a twirling-baton prompt. At verbosity level 2, you get verbose progress messages on the analysis. At verbosity level 3, you see the output from the make and compilation commands. If the -q (--quiet) option flag was not set, the last line of the output will be a statistical summary. Running deheader will leave a lot of binaries in your directory that were compiled in ways possibly not invoked by your normal build process. Running "make clean" afterwards (or the equivalent under whatever build system you are using) is strongly recommended. OPTIONS -h Display some help and exit. -m Set the build command used for test compiles. Defaults to 'make'. -b Set the build directory for object files. -i Set a pattern for includes to be ignored. Takes a Python regular expression. -q Suppress statistical summary. -r Remove header inclusions from sourcefiles where they are not required. -v Set verbosity. -x Exclude files with names matching the specified Python regexp. -V Show version of program and exit. RETURN VALUES Returns 1 if unneeded includes were found, 0 otherwise. Thus, you can use it for pre-release sanity checking in Makefile. BUGS Very rarely, test-compiling after running with may show that this tool removed some headers that are actually required for your build. This can happen because deheader doesn't know about all the strange things your build system gets up to, and the problem of analyzing your build to understand them would be Turing-complete. Simply revert the altered files and continue. Due to minor variations in system headers, it is possible your program may not port correctly to other Unix variants after being deheadered. This is normally not a problem with the portion of the API specified by POSIX and ANSI C, but may be for headers that are not standardized or only weakly standardized. The sockets API (sys/select.h, sys/sockets.h, and friends such as sys/types.h and sys.stat.h) is perhaps the most serious trouble spot. deheader has an internal table of rules that heads off the most common problems by suppressing deletion of headers that are required for portability, but your mileage may vary. The depenedency scanner does not ignore the text of comments. This, e.g, a reference to "log10" in a comment will produce a spurious warning that <math.h> is required for portability. Sufficiently perverse C++ can silently invalidate the brute-force algorithm this tool uses. Example: if an overloaded function has different overloads from two different files, removing one may expose the other, changing runtime semantics without a compile-time warning. Similarly, removing a later file containing a template specialization may lead to undefined behavior from a template defined in an earlier file. Use this with caution near such features, and test carefully. AUTHOR Eric S. Raymond esr@snark.thyrsus.com; (home page at http://www.catb.org/~esr/). deheader-1.6/deheader.10000664000175000017500000001701512773467566013145 0ustar esresr'\" t .\" Title: deheader .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 09/30/2016 .\" Manual: Development Tools .\" Source: deheader .\" Language: English .\" .TH "DEHEADER" "1" "09/30/2016" "deheader" "Development Tools" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" deheader \- report which includes in C or C++ compiles can be removed .SH "SYNOPSIS" .HP \w'\fBdeheader\fR\ 'u \fBdeheader\fR [\-h] [\-m\ \fIcommand\fR] [\-b\ \fIbuilddir\fR] [\-i\ \fIpattern\fR] [\-q] [\-r] [\-v] [\-x\ \fIpattern\fR] [\-V] [\fIfile\-or\-dir\fR] .SH "DESCRIPTION" .PP This tool takes a list of C or C++ sourcefiles and generates a report on which #includes can be omitted from them; also, what standard inclusions may be required for portability\&. The test, for each foo\&.c or foo\&.cc or foo\&.cpp, is simply whether "rm foo\&.o; make foo\&.o" returns a zero status (but the build command may be overridden)\&. .PP Exception: Under cmake, foo\&.o is a phoney target\&. Therefore, when a "CMakeList\&.txt" is detected, "make clean" is done rather than "rm foo\&.o"\&. .PP Optionally, with the \fB\-r\fR switch, the unneeded headers are removed from the sourcefiles\&. Don\*(Aqt use this option unless you have your sourcefiles safely under version control and can revert! .PP If a sourcefile argument is a directory, the report is generated on all source files beneath it\&. Subdirectories beginning with a dot are assumed to be repository directories for version\-control systems and ignored\&. If no arguments are given, the program runs as if the name of the current directory had been passed to it\&. .PP 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\&. One exception: headers protected only by S_SPLINT_S, the conditional for blocking scanning by the static analysis tool \fBsplint\fR(1), are scanned normally\&. .PP The tool will also emit warnings about duplicate inclusions, and inclusions required for portability but not present\&. .PP It is recommended that you arrange to compile with options that will stop the compiler on warnings when using this tool; otherwise it will report headers that only declare prototypes and return types (and thus throw only warnings) as being not required\&. Under gcc the compiler options to accomplish this are \-Werror \-Wfatal\-errors\&. If your makefile follows normal conventions, running with \fB\-m "make CFLAGS=\*(Aq\-Werror \-Wfatal\-errors\*(Aq" \fR may do the right thing; you can check this by running with \-v \-v \-v to see what compilation commands are actually emitted\&. .PP On each test compile, the original sourcefile is moved to a name with an \&.orig suffix and restored on interrupt or after processing with its original timestamp, unless the \fB\-r\fR option was given and headers removed\&. .PP If the \-b option is given, it tells the program that generated \&.o files live in a file tree parallel to the source tree but rooted at the specified argument\&. If the argument is a relative path, it is interpreted relative to the directory in which deaheader is run\&. .PP If the first test compilation from the top\-level directory fails, deheader descends into the subdirectory of the source file and retries compiling inside there\&. .PP At verbosity level 0, only messages indicating removable headers are issued\&. At verbosity 1, test compilations are timed and progess indicated with a twirling\-baton prompt\&. At verbosity level 2, you get verbose progress messages on the analysis\&. At verbosity level 3, you see the output from the make and compilation commands\&. .PP If the \-q (\-\-quiet) option flag was not set, the last line of the output will be a statistical summary\&. .PP Running deheader will leave a lot of binaries in your directory that were compiled in ways possibly not invoked by your normal build process\&. Running "make clean" afterwards (or the equivalent under whatever build system you are using) is strongly recommended\&. .SH "OPTIONS" .PP \-h .RS 4 Display some help and exit\&. .RE .PP \-m .RS 4 Set the build command used for test compiles\&. Defaults to \*(Aqmake\*(Aq\&. .RE .PP \-b .RS 4 Set the build directory for object files\&. .RE .PP \-i .RS 4 Set a pattern for includes to be ignored\&. Takes a Python regular expression\&. .RE .PP \-q .RS 4 Suppress statistical summary\&. .RE .PP \-r .RS 4 Remove header inclusions from sourcefiles where they are not required\&. .RE .PP \-v .RS 4 Set verbosity\&. .RE .PP \-x .RS 4 Exclude files with names matching the specified Python regexp\&. .RE .PP \-V .RS 4 Show version of program and exit\&. .RE .SH "RETURN VALUES" .PP Returns 1 if unneeded includes were found, 0 otherwise\&. Thus, you can use it for pre\-release sanity checking in Makefile\&. .SH "BUGS" .PP Very rarely, test\-compiling after running with \fB\-r\fR may show that this tool removed some headers that are actually required for your build\&. This can happen because \fBdeheader\fR doesn\*(Aqt know about all the strange things your build system gets up to, and the problem of analyzing your build to understand them would be Turing\-complete\&. Simply revert the altered files and continue\&. .PP Due to minor variations in system headers, it is possible your program may not port correctly to other Unix variants after being deheadered\&. This is normally not a problem with the portion of the API specified by POSIX and ANSI C, but may be for headers that are not standardized or only weakly standardized\&. The sockets API (sys/select\&.h, sys/sockets\&.h, and friends such as sys/types\&.h and sys\&.stat\&.h) is perhaps the most serious trouble spot\&. \fBdeheader\fR has an internal table of rules that heads off the most common problems by suppressing deletion of headers that are required for portability, but your mileage may vary\&. .PP The depenedency scanner does not ignore the text of comments\&. This, e\&.g, a reference to "log10" in a comment will produce a spurious warning that is required for portability\&. .PP Sufficiently perverse C++ can silently invalidate the brute\-force algorithm this tool uses\&. Example: if an overloaded function has different overloads from two different files, removing one may expose the other, changing runtime semantics without a compile\-time warning\&. Similarly, removing a later file containing a template specialization may lead to undefined behavior from a template defined in an earlier file\&. Use this with caution near such features, and test carefully\&. .SH "AUTHOR" .PP Eric S\&. Raymond ; (home page at \m[blue]\fBhttp://www\&.catb\&.org/~esr/\fR\m[])\&. deheader-1.6/Makefile0000664000175000017500000000224412762067177012750 0ustar esresr# # makefile for `deheader' # VERS=$(shell sed main(int arg, char **argv) { struct termios t; cfsetispeed(&t, 0); } deheader-1.6/test/catgets.c0000664000175000017500000000026612762000276014052 0ustar esresr/* * Items: catgets( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) catgets(0, 0, 0, "foobar"); } deheader-1.6/test/alarm.c0000664000175000017500000000023212762000276013505 0ustar esresr/* * Items: alarm( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { alarm(23); } deheader-1.6/test/README0000664000175000017500000000016112742455667013146 0ustar esresrThis directory contains C sourcfiles intended to test deheader, and a check against which to compare the output. deheader-1.6/test/chroot.c0000664000175000017500000000024312762000276013711 0ustar esresr/* * Items: chroot( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)chroot("/"); } deheader-1.6/test/string.c0000664000175000017500000000014612762000276013723 0ustar esresr/* this file has string.h but doesn't need it */ #include main(int arg, char **argv) { } deheader-1.6/test/catclose.c0000664000175000017500000000025012762000276014206 0ustar esresr/* * Items: catclose( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) catclose(0); } deheader-1.6/test/cfgetospeed.c0000664000175000017500000000027512762000276014710 0ustar esresr/* * Items: cfgetospeed( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct termios t; cfgetospeed(&t); } deheader-1.6/test/fclose.c0000664000175000017500000000024012762000276013663 0ustar esresr/* * Items: fclose( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)fclose(stdin); } deheader-1.6/test/atexit.c0000664000175000017500000000023212762000276013707 0ustar esresr/* * Items: atexit( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { atexit(NULL); } deheader-1.6/test/access.c0000664000175000017500000000052212762000276013654 0ustar esresr/* * Items: access( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { /* * Note: use of a symbolic constant like F_OK *will* * cause the compile to fail and the requrement * for to be tetected. */ (void)access("/dev/null", 0); } deheader-1.6/test/duplicate.c0000664000175000017500000000017412762000276014370 0ustar esresr/* this file tests detection of duplicate heafers */ #include #include main(int arg, char **argv) { } deheader-1.6/test/clearerr.c0000664000175000017500000000024412762000276014213 0ustar esresr/* * Items: clearerr( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)clearerr(stdin); } deheader-1.6/test/clock_gettime.c0000664000175000017500000000030612762000276015224 0ustar esresr/* * Items: clock_gettime( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct timespec ts; (void)clock_gettime(0, &ts); } deheader-1.6/test/bzero.c0000664000175000017500000000024412762000276013535 0ustar esresr/* * Items: bzero( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) bzero(0, 0); } deheader-1.6/test/noheaders.c0000664000175000017500000000011612762000276014362 0ustar esresr/* this file has no headers and needs none */ main(int arg, char **argv) { } deheader-1.6/test/a64l.c0000664000175000017500000000030212762000276013155 0ustar esresr/* * Items: a64l(, l64a( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) a64l("2317"); (void) l64a(2317); } deheader-1.6/test/fchown.c0000664000175000017500000000024712762000276013703 0ustar esresr/* * Items: fchown( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)fchown(0, 0, 0); } deheader-1.6/test/asin.c0000664000175000017500000000023112762000276013342 0ustar esresr/* * Items: asin( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { asin(-23.0); } deheader-1.6/test/closedir.c0000664000175000017500000000027012762000276014217 0ustar esresr/* * Items: closedir( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include #include main(int arg, char **argv) { (void)closedir(0); } deheader-1.6/test/regress.chk0000664000175000017500000002223712762001274014416 0ustar esresrdeheader: ./a64l.c includes deheader: ./abort.c includes deheader: ./abs.c includes deheader: ./access.c includes deheader: ./acos.c includes deheader: ./acosh.c includes deheader: ./advance.c includes deheader: ./alarm.c includes deheader: ./asin.c includes deheader: ./asinh.c includes deheader: ./atan.c includes deheader: ./atan2.c includes deheader: ./atanh.c includes deheader: ./atexit.c includes deheader: ./atof.c includes deheader: ./atoi.c includes deheader: ./atol.c includes deheader: ./basename.c includes deheader: ./bcmp.c includes deheader: ./bcopy.c includes deheader: ./brk.c includes deheader: ./bsd_signal.c includes deheader: ./bsort.c includes deheader: ignoring (conditional inclusion) deheader: ./bsort.c includes deheader: ignoring (conditional inclusion) deheader: ./bsort.c includes deheader: ./btowc.c includes deheader: ./btowc.c includes deheader: ./bzero.c includes deheader: ./calloc.c includes deheader: ./catclose.c includes deheader: ./catgets.c includes deheader: ./catopen.c includes deheader: ./cbrt.c includes deheader: ./ceil.c includes deheader: ./cfgetispeed.c includes deheader: ./cfgetospeed.c includes deheader: ./cfsetispeed.c includes deheader: ./cfsetospeed.c includes deheader: ./chdir.c includes deheader: ./chmod.c includes deheader: ./chmod.c includes deheader: ./chown.c includes deheader: ./chown.c includes deheader: ./chroot.c includes deheader: ./clearerr.c includes deheader: ./clock.c includes deheader: ./clock_getres.c includes deheader: ./clock_gettime.c includes deheader: ./clock_settime.c includes deheader: ./close.c includes deheader: ./closedir.c includes deheader: ./closedir.c includes deheader: ./crypt.c includes deheader: ./ctime.c includes deheader: ./duplicate.c includes deheader: ./duplicate.c includes deheader: ./duplicate.c has more than one inclusion of deheader: ./fchmod.c includes deheader: ./fchown.c includes deheader: ./fclose.c includes deheader: ./fstat.c includes deheader: ./fstat.c includes deheader: ./sbrk.c includes deheader: ./string.c includes deheader: ./umask.c includes deheader: ./umask.c includes deheader: ./a64l.c succeeded. deheader: in ./a64l.c, a64l() prevents uninclusion of deheader: ./abort.c succeeded. deheader: in ./abort.c, abort() prevents uninclusion of deheader: ./abs.c succeeded. deheader: in ./abs.c, abs() prevents uninclusion of deheader: ./access.c succeeded. deheader: in ./access.c, access() prevents uninclusion of deheader: ./acos.c succeeded. deheader: in ./acos.c, acos() prevents uninclusion of deheader: ./acosh.c succeeded. deheader: in ./acosh.c, acosh() prevents uninclusion of deheader: ./advance.c succeeded. deheader: in ./advance.c, advance() prevents uninclusion of deheader: in ./advance.c, getc() portability requires . deheader: ./alarm.c succeeded. deheader: in ./alarm.c, alarm() prevents uninclusion of deheader: ./asin.c succeeded. deheader: in ./asin.c, asin() prevents uninclusion of deheader: ./asinh.c succeeded. deheader: in ./asinh.c, asinh() prevents uninclusion of deheader: ./atan.c succeeded. deheader: in ./atan.c, atan() prevents uninclusion of deheader: ./atan2.c succeeded. deheader: in ./atan2.c, atan2() prevents uninclusion of deheader: ./atanh.c succeeded. deheader: in ./atanh.c, atanh() prevents uninclusion of deheader: ./atexit.c succeeded. deheader: in ./atexit.c, atexit() prevents uninclusion of deheader: ./atof.c succeeded. deheader: in ./atof.c, l64a() prevents uninclusion of deheader: ./atoi.c succeeded. deheader: in ./atoi.c, l64a() prevents uninclusion of deheader: ./atol.c succeeded. deheader: in ./atol.c, l64a() prevents uninclusion of deheader: ./basename.c succeeded. deheader: in ./basename.c, basename() prevents uninclusion of deheader: ./bcmp.c succeeded. deheader: in ./bcmp.c, bcmp() prevents uninclusion of deheader: ./bcopy.c succeeded. deheader: in ./bcopy.c, bcopy() prevents uninclusion of deheader: ./brk.c succeeded. deheader: in ./brk.c, brk() prevents uninclusion of deheader: ./bsd_signal.c succeeded. deheader: in ./bsd_signal.c, bsd_signal() prevents uninclusion of deheader: ./bsort.c succeeded. deheader: in ./bsort.c, bsort() prevents uninclusion of deheader: in ./bsort.c, strcoll() portability requires . deheader: in ./bsort.c, scanf() portability requires . deheader: ./btowc.c succeeded. deheader: in ./btowc.c, btowc() prevents uninclusion of deheader: in ./btowc.c, btowc() prevents uninclusion of deheader: ./bzero.c succeeded. deheader: in ./bzero.c, bzero() prevents uninclusion of deheader: ./calloc.c succeeded. deheader: in ./calloc.c, calloc() prevents uninclusion of deheader: ./catclose.c succeeded. deheader: in ./catclose.c, catclose() prevents uninclusion of deheader: ./catgets.c succeeded. deheader: in ./catgets.c, catgets() prevents uninclusion of deheader: ./catopen.c succeeded. deheader: in ./catopen.c, catopen() prevents uninclusion of deheader: ./cbrt.c succeeded. deheader: in ./cbrt.c, cbrt() prevents uninclusion of deheader: ./ceil.c succeeded. deheader: in ./ceil.c, ceil() prevents uninclusion of deheader: ./cfgetispeed.c succeeded. deheader: in ./cfgetispeed.c, cfgetispeed() prevents uninclusion of deheader: ./cfgetospeed.c succeeded. deheader: in ./cfgetospeed.c, cfgetospeed() prevents uninclusion of deheader: ./cfsetispeed.c succeeded. deheader: in ./cfsetispeed.c, cfsetispeed() prevents uninclusion of deheader: ./cfsetospeed.c succeeded. deheader: in ./cfsetospeed.c, cfsetospeed() prevents uninclusion of deheader: ./chdir.c succeeded. deheader: in ./chdir.c, chdir() prevents uninclusion of deheader: ./chmod.c succeeded. deheader: in ./chmod.c, chmod() prevents uninclusion of deheader: in ./chmod.c, chmod() prevents uninclusion of deheader: ./chown.c succeeded. deheader: in ./chown.c, chown() prevents uninclusion of deheader: in ./chown.c, chown() prevents uninclusion of deheader: ./chroot.c succeeded. deheader: in ./chroot.c, chroot() prevents uninclusion of deheader: ./clearerr.c succeeded. deheader: in ./clearerr.c, clearerr() prevents uninclusion of deheader: ./clock.c succeeded. deheader: in ./clock.c, clock() prevents uninclusion of deheader: ./clock_getres.c succeeded. deheader: in ./clock_getres.c, clock_getres() prevents uninclusion of deheader: ./clock_gettime.c succeeded. deheader: in ./clock_gettime.c, clock_gettime() prevents uninclusion of deheader: ./clock_settime.c succeeded. deheader: in ./clock_settime.c, clock_settime() prevents uninclusion of deheader: ./close.c succeeded. deheader: in ./close.c, close() prevents uninclusion of deheader: ./closedir.c succeeded. deheader: in ./closedir.c, closedir() prevents uninclusion of deheader: in ./closedir.c, closedir() prevents uninclusion of deheader: ./crypt.c succeeded. deheader: in ./crypt.c, crypt() prevents uninclusion of deheader: ./ctime.c succeeded. deheader: in ./ctime.c, ctime() prevents uninclusion of deheader: ./duplicate.c succeeded. deheader: ./duplicate.c without succeeded. deheader: ./duplicate.c without succeeded. deheader: remove from ./duplicate.c deheader: remove from ./duplicate.c deheader: ./fchmod.c succeeded. deheader: in ./fchmod.c, fchmod() prevents uninclusion of deheader: ./fchown.c succeeded. deheader: in ./fchown.c, fchown() prevents uninclusion of deheader: ./fclose.c succeeded. deheader: in ./fclose.c, fclose() prevents uninclusion of deheader: ./fstat.c succeeded. deheader: in ./fstat.c, fstat() prevents uninclusion of deheader: in ./fstat.c, fstat() prevents uninclusion of deheader: ./noheaders.c succeeded. deheader: ./sbrk.c succeeded. deheader: in ./sbrk.c, sbrk() prevents uninclusion of deheader: ./string.c succeeded. deheader: ./string.c without succeeded. deheader: remove from ./string.c deheader: ./umask.c succeeded. deheader: in ./umask.c, umask() prevents uninclusion of deheader: in ./umask.c, umask() prevents uninclusion of deheader: saw 57 files, 63 includes, 3 removable deheader-1.6/test/acosh.c0000664000175000017500000000023312762000276013507 0ustar esresr/* * Items: acosh( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { acosh(-23.0); } deheader-1.6/test/close.c0000664000175000017500000000023712762000276013523 0ustar esresr/* * Items: close( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)close(0); } deheader-1.6/test/atoi.c0000664000175000017500000000025412762000276013351 0ustar esresr/* * Items: atoil(, l64a( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) atoi("2317"); } deheader-1.6/test/Makefile0000664000175000017500000000103612772571456013726 0ustar esresrPATH := ..:.:${PATH} SOURCES = $(shell ls *.c) regress: @echo "Testing deheader: no output is good news." @setpython python2 @-deheader -v -v . >/tmp/regress @diff -u regress.chk /tmp/regress @setpython python3 @-deheader -v -v . >/tmp/regress @diff -u regress.chk /tmp/regress @setpython python @rm /tmp/regress makeregress: @-deheader -v -v . >regress.chk # Verify that the test sources build correctly when unaltered verify: for x in $(SOURCES:.c=.o); do make CFLAGS='-Werror -Wfatal-errors' $$x; done clean: rm -f *.o *~ deheader-1.6/test/cbrt.c0000664000175000017500000000023012762000276013341 0ustar esresr/* * Items: cbrt( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { cbrt(23.0); } deheader-1.6/test/bsd_signal.c0000664000175000017500000000031612762000276014521 0ustar esresr/* * Items: bsd_signal( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include void handler(int sig) { } main(int arg, char **argv) { (void) bsd_signal(0, handler); } deheader-1.6/test/basename.c0000664000175000017500000000025712762000276014173 0ustar esresr/* * Items: basename( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)basename("/dev/null"); } deheader-1.6/test/abs.c0000664000175000017500000000022712762000276013162 0ustar esresr/* * Items: abs( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { abs(-23); } deheader-1.6/test/cfsetospeed.c0000664000175000017500000000030012762000276014711 0ustar esresr/* * Items: cfsetospeed( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct termios t; cfsetospeed(&t, 0); } deheader-1.6/test/chmod.c0000664000175000017500000000027512762000276013512 0ustar esresr/* * Items: chmod( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include #include main(int arg, char **argv) { (void)chmod("/", 0); } deheader-1.6/test/clock_getres.c0000664000175000017500000000030412762000276015055 0ustar esresr/* * Items: clock_getres( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct timespec ts; (void)clock_getres(0, &ts); } deheader-1.6/test/sbrk.c0000664000175000017500000000023012762000276013350 0ustar esresr/* * Items: sbrk( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { sbrk(23); } deheader-1.6/test/atan.c0000664000175000017500000000023112762000276013333 0ustar esresr/* * Items: atan( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { atan(-23.0); } deheader-1.6/test/fchmod.c0000664000175000017500000000024612762000276013656 0ustar esresr/* * Items: fchmod( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)fchmod(0, 0); } deheader-1.6/test/cfgetispeed.c0000664000175000017500000000027512762000276014702 0ustar esresr/* * Items: cfgetispeed( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct termios t; cfgetispeed(&t); } deheader-1.6/test/brk.c0000664000175000017500000000022412762000276013170 0ustar esresr/* * Items: brk( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { brk(NULL); } deheader-1.6/test/fstat.c0000664000175000017500000000026512762000276013540 0ustar esresr/* * Items: fstat( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include #include main(int arg, char **argv) { fstat(0, 0); } deheader-1.6/test/btowc.c0000664000175000017500000000026312762000276013533 0ustar esresr/* * Items: btowc( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include #include main(int arg, char **argv) { (void)btowc('a'); } deheader-1.6/test/umask.c0000664000175000017500000000031012762000276013526 0ustar esresr/* * Items: umask( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux * Not-detected-by: BSD */ #include #include main(int arg, char **argv) { umask(777); } deheader-1.6/test/ctime.c0000664000175000017500000000023412762000276013514 0ustar esresr/* * Items: ctime( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)ctime(NULL); } deheader-1.6/test/setpython0000775000175000017500000000104312673555707014250 0ustar esresr#!/bin/sh # # setpython - create a local link from 'python' to a specified version # # This script is used to to redirect the 'python' in reposurgeon's # shebang line to a specified version when running regression tests. if [ -z "$1" ] then ls -l python elif [ $1 = "python" ] then rm -f ./python elif [ $1 = python2 -o $1 = python3 ] then set -- `whereis $1` shift case $1 in */bin/*) ln -sf $1 ./python; echo "python -> $1";; *) echo "setpython: no python binary" >&2;; esac else echo "setpython: unrecognized python version" >&2 fi deheader-1.6/test/chown.c0000664000175000017500000000027612762000276013537 0ustar esresr/* * Items: chown( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include #include main(int arg, char **argv) { (void)chown("/", 0, 0); } deheader-1.6/test/chdir.c0000664000175000017500000000024112762000276013502 0ustar esresr/* * Items: chdir( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)chdir("/"); } deheader-1.6/test/atol.c0000664000175000017500000000025412762000276013354 0ustar esresr/* * Items: atoll(, l64a( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) atol("2317"); } deheader-1.6/test/calloc.c0000664000175000017500000000024512762000276013652 0ustar esresr/* * Items: calloc( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) calloc(0, 0); } deheader-1.6/test/clock_settime.c0000664000175000017500000000030612762000276015240 0ustar esresr/* * Items: clock_settime( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { struct timespec ts; (void)clock_settime(0, &ts); } deheader-1.6/test/advance.c0000664000175000017500000000047312762001227014016 0ustar esresr/* * Items: advance( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #define INIT #define GETC() getc() #define PEEKC() peek() #define UNGETC(c) ungetc(c) #define RETURN(ptr) return ptr #define ERROR(val) return val #include main(int arg, char **argv) { advance("foobar", 0); } deheader-1.6/test/bsort.c0000664000175000017500000000221112762000276013541 0ustar esresr/* * Items: bsort( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ /* example taken pretty much directly from SuS */ #ifndef __DEHEADER__ #include #include #endif #include #define TABSIZE 1000 struct node { /* these are stored in the table */ char *string; int length; }; struct node table[TABSIZE]; /* table to be searched */ int node_compare(const void *node1, const void *node2) { return strcoll(((const struct node *)node1)->string, ((const struct node *)node2)->string); } main(int argc, char **argv) { struct node *node_ptr, node; char str_space[20]; /* space to read string into */ node.string = str_space; while (scanf("%s", node.string) != EOF) { node_ptr = (struct node *)bsearch((void *)(&node), (void *)table, TABSIZE, sizeof(struct node), node_compare); if (node_ptr != NULL) { (void)printf("string = %20s, length = %d\n", node_ptr->string, node_ptr->length); } else { (void)printf("not found: %s\n", node.string); } } } deheader-1.6/test/atof.c0000664000175000017500000000025412762000276013346 0ustar esresr/* * Items: atofl(, l64a( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) atof("2317"); } deheader-1.6/test/clock.c0000664000175000017500000000023012762000276013502 0ustar esresr/* * Items: clock( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)clock(); } deheader-1.6/test/acos.c0000664000175000017500000000023112762000276013335 0ustar esresr/* * Items: acos( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { acos(-23.0); } deheader-1.6/test/crypt.c0000664000175000017500000000025312762000276013555 0ustar esresr/* * Items: crypt( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void)crypt("foo", "salt"); } deheader-1.6/test/catopen.c0000664000175000017500000000026012762000276014043 0ustar esresr/* * Items: catopen( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) catopen("foobar", 0); } deheader-1.6/test/abort.c0000664000175000017500000000023012762000276013516 0ustar esresr/* * Items: abort( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { abort(); } deheader-1.6/test/ceil.c0000664000175000017500000000023012762000276013323 0ustar esresr/* * Items: ceil( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { ceil(23.0); } deheader-1.6/test/bcopy.c0000664000175000017500000000024312762000276013527 0ustar esresr/* * Items: bcopy( * Standardized-By: SuS * Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) bcopy(0, 0, 0); } deheader-1.6/test/asinh.c0000664000175000017500000000023312762000276013514 0ustar esresr/* * Items: asinh( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { asinh(-23.0); } deheader-1.6/test/atanh.c0000664000175000017500000000023312762000276013505 0ustar esresr/* * Items: atanh( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { atanh(-23.0); } deheader-1.6/test/atan2.c0000664000175000017500000000024112762000276013416 0ustar esresr/* * Items: atan2( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { atan2(-23.0, 17.0); } deheader-1.6/test/bcmp.c0000664000175000017500000000025512762000276013337 0ustar esresr/* * Items: bcmp( * Standardized-By: SuS * Not-Detected-by: gcc-4.4.3 + Linux */ #include main(int arg, char **argv) { (void) bcmp("aaa", "bbb", 3); } deheader-1.6/deheader.10000664000175000017500000000000012773467566017014 1deheader-1.6/deheader.1ustar esresr