Commit 81a05aa6 authored by Reiner Herrmann's avatar Reiner Herrmann

Merge tag 'upstream/1.5'

Upstream version 1.5

# gpg: Signature made Wed 28 Sep 2016 06:26:42 PM CEST
# gpg:                using RSA key CCF04928DB0EEAA7
# gpg:                issuer "reiner@reiner-h.de"
# gpg: Good signature from "Reiner Herrmann <reiner@reiner-h.de>" [ultimate]
# Primary key fingerprint: 2F5D AF3F C1F7 93D9 4F3D  900C A721 DA05 5374 AA4F
#      Subkey fingerprint: D8F6 FA7D EA24 D90D 6EAC  733B CCF0 4928 DB0E EAA7
parents c2f1af3a e658ce0a
......@@ -3,7 +3,7 @@
#
VERS=$(shell sed <deheader -n -e '/version\s*=\s*"\(.*\)"/s//\1/p')
SOURCES = README COPYING NEWS deheader deheader.xml deheader.1 Makefile control deheader-logo.png
SOURCES = README COPYING NEWS deheader deheader.xml deheader.1 Makefile control deheader-logo.png test
all: deheader.1
......@@ -33,12 +33,8 @@ pylint:
version:
@echo $(VERS)
deheader-$(VERS).tar.gz: $(SOURCES)
@ls $(SOURCES) | sed s:^:deheader-$(VERS)/: >MANIFEST
@(cd ..; ln -s deheader deheader-$(VERS))
(cd ..; tar -czf deheader/deheader-$(VERS).tar.gz `cat deheader/MANIFEST`)
@ls -l deheader-$(VERS).tar.gz
@(cd ..; rm deheader-$(VERS))
deheader-$(VERS).tar.gz: $(SOURCES) deheader.1
tar --transform='s:^:deheader-$(VERS)/:' --show-transformed-names -cvzf deheader-$(VERS).tar.gz $(SOURCES) deheader.1
dist: deheader-$(VERS).tar.gz
......
deheader project news
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.
......
......@@ -36,7 +36,7 @@ from __future__ import print_function
import sys, os, getopt, time, re, operator, subprocess
version = "1.4"
version = "1.5"
try:
from subprocess import getstatusoutput
......@@ -1485,6 +1485,8 @@ class Summary:
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))
......@@ -1541,11 +1543,14 @@ if __name__ == "__main__":
inclusion_map.depends_on[sourcefile],
inclusion_map.requires[sourcefile],
remove, verbose))
if not quiet:
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
......@@ -2,12 +2,12 @@
.\" Title: deheader
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 09/01/2016
.\" Date: 09/27/2016
.\" Manual: Development Tools
.\" Source: deheader
.\" Language: English
.\"
.TH "DEHEADER" "1" "09/01/2016" "deheader" "Development Tools"
.TH "DEHEADER" "1" "09/27/2016" "deheader" "Development Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......@@ -112,6 +112,9 @@ Exclude files with names matching the specified Python regexp\&.
.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
......
......@@ -166,6 +166,11 @@ Takes a Python regular expression.</para>
</variablelist>
</refsect1>
<refsect1 id='returns'><title>RETURN VALUES</title>
<para>Returns 1 if unneeded includes were found, 0 otherwise. Thus,
you can use it for pre-release sanity checking in Makefile.</para>
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
<para>Very rarely, test-compiling after running with
......
PATH := ..:.:${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 *~
This directory contains C sourcfiles intended to test deheader, and
a check against which to compare the output.
/*
* Items: a64l(, l64a(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
(void) a64l("2317");
(void) l64a(2317);
}
/*
* Items: abort(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
abort();
}
/*
* Items: abs(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
abs(-23);
}
/*
* Items: access(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <unistd.h>
main(int arg, char **argv)
{
/*
* Note: use of a symbolic constant like F_OK *will*
* cause the compile to fail and the requrement
* for <unistd.h> to be tetected.
*/
(void)access("/dev/null", 0);
}
/*
* Items: acos(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
acos(-23.0);
}
/*
* Items: acosh(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
acosh(-23.0);
}
/*
* 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 <regex.h>
main(int arg, char **argv)
{
advance("foobar", 0);
}
/*
* Items: alarm(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <unistd.h>
main(int arg, char **argv)
{
alarm(23);
}
/*
* Items: asin(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
asin(-23.0);
}
/*
* Items: asinh(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
asinh(-23.0);
}
/*
* Items: atan(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
atan(-23.0);
}
/*
* Items: atan2(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
atan2(-23.0, 17.0);
}
/*
* Items: atanh(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
atanh(-23.0);
}
/*
* Items: atexit(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
atexit(NULL);
}
/*
* Items: atofl(, l64a(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
(void) atof("2317");
}
/*
* Items: atoil(, l64a(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
(void) atoi("2317");
}
/*
* Items: atoll(, l64a(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
(void) atol("2317");
}
/*
* Items: basename(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <libgen.h>
main(int arg, char **argv)
{
(void)basename("/dev/null");
}
/*
* Items: bcmp(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <strings.h>
main(int arg, char **argv)
{
(void) bcmp("aaa", "bbb", 3);
}
/*
* Items: bcopy(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <strings.h>
main(int arg, char **argv)
{
(void) bcopy(0, 0, 0);
}
/*
* Items: brk(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <unistd.h>
main(int arg, char **argv)
{
brk(NULL);
}
/*
* Items: bsd_signal(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <signal.h>
void handler(int sig)
{
}
main(int arg, char **argv)
{
(void) bsd_signal(0, handler);
}
/*
* Items: bsort(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
/* example taken pretty much directly from SuS */
#ifndef __DEHEADER__
#include <stdio.h>
#include <string.h>
#endif
#include <stdlib.h>
#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);
}
}
}
/*
* Items: btowc(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdio.h>
#include <wchar.h>
main(int arg, char **argv)
{
(void)btowc('a');
}
/*
* Items: bzero(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <strings.h>
main(int arg, char **argv)
{
(void) bzero(0, 0);
}
/*
* Items: calloc(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <stdlib.h>
main(int arg, char **argv)
{
(void) calloc(0, 0);
}
/*
* Items: catclose(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <nl_types.h>
main(int arg, char **argv)
{
(void) catclose(0);
}
/*
* Items: catgets(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <nl_types.h>
main(int arg, char **argv)
{
(void) catgets(0, 0, 0, "foobar");
}
/*
* Items: catopen(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <nl_types.h>
main(int arg, char **argv)
{
(void) catopen("foobar", 0);
}
/*
* Items: cbrt(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
cbrt(23.0);
}
/*
* Items: ceil(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <math.h>
main(int arg, char **argv)
{
ceil(23.0);
}
/*
* Items: cfgetispeed(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <termios.h>
main(int arg, char **argv)
{
struct termios t;
cfgetispeed(&t);
}
/*
* Items: cfgetospeed(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <termios.h>
main(int arg, char **argv)
{
struct termios t;
cfgetospeed(&t);
}
/*
* Items: cfsetispeed(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <termios.h>
main(int arg, char **argv)
{
struct termios t;
cfsetispeed(&t, 0);
}
/*
* Items: cfsetospeed(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <termios.h>
main(int arg, char **argv)
{
struct termios t;
cfsetospeed(&t, 0);
}
/*
* Items: chdir(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <unistd.h>
main(int arg, char **argv)
{
(void)chdir("/");
}
/*
* Items: chmod(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <sys/types.h>
#include <sys/stat.h>
main(int arg, char **argv)
{
(void)chmod("/", 0);
}
/*
* Items: chown(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <sys/types.h>
#include <unistd.h>
main(int arg, char **argv)
{
(void)chown("/", 0, 0);
}
/*
* Items: chroot(
* Standardized-By: SuS
* Not-Detected-by: gcc-4.4.3 + Linux
*/
#include <unistd.h>
main(int arg, char **argv)
{
(void)chroot("/");
}
/*
* Items: clearerr(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <stdio.h>
main(int arg, char **argv)
{
(void)clearerr(stdin);
}
/*
* Items: clock(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <time.h>
main(int arg, char **argv)
{
(void)clock();
}
/*
* Items: clock_getres(
* Standardized-By: SuS
* Detected-by: gcc-4.4.3 + Linux
*/
#include <time.h>
main(int arg, char **argv)
{
struct timespec ts;
(void)clock_getres(0, &ts);
}