diff -Nru deheader-1.2/COPYING deheader-1.3/COPYING --- deheader-1.2/COPYING 2010-12-01 20:43:01.000000000 +0000 +++ deheader-1.3/COPYING 2015-10-17 16:39:19.000000000 +0000 @@ -1,28 +1,27 @@ 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: +modification, are permitted provided that the following conditions are +met: -Redistributions of source code must retain the above copyright +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright +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. -Neither name of the this project nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +"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 REGENTS 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. +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. diff -Nru deheader-1.2/debian/changelog deheader-1.3/debian/changelog --- deheader-1.2/debian/changelog 2015-07-19 11:12:19.000000000 +0000 +++ deheader-1.3/debian/changelog 2016-01-13 19:04:24.000000000 +0000 @@ -1,3 +1,11 @@ +deheader (1.3-1) unstable; urgency=low + + * New upstream release. + + Retry in subdirectories on failure (Closes: #808967) + * Upstream changed license from BSD-3-Clause to BSD-2-Clause. + + -- Reiner Herrmann Wed, 13 Jan 2016 19:24:40 +0100 + deheader (1.2-1) unstable; urgency=low * New upstream release. diff -Nru deheader-1.2/debian/copyright deheader-1.3/debian/copyright --- deheader-1.2/debian/copyright 2015-03-08 14:50:26.000000000 +0000 +++ deheader-1.3/debian/copyright 2016-01-13 19:04:24.000000000 +0000 @@ -3,8 +3,8 @@ Source: http://www.catb.org/~esr/deheader/ Files: * -Copyright: 2010-2015 Eric S. Raymond -License: BSD-3-Clause +Copyright: 2010-2016 Eric S. Raymond +License: BSD-2-Clause Files: deheader-logo.png Copyright: 2010 Martina Šmejkalová @@ -16,36 +16,32 @@ http://www.sireasgallery.com/icon/deadlyinstruments/Guillotine Files: debian/* -Copyright: 2015 Reiner Herrmann -License: BSD-3-Clause +Copyright: 2015-2016 Reiner Herrmann +License: BSD-2-Clause -License: BSD-3-Clause +License: BSD-2-Clause Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: + modification, are permitted provided that the following conditions are + met: . - Redistributions of source code must retain the above copyright + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . - Redistributions in binary form must reproduce the above copyright + 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. . - Neither name of the this project nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + "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 REGENTS 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. + 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. License: CC-BY THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE diff -Nru deheader-1.2/deheader deheader-1.3/deheader --- deheader-1.2/deheader 2015-07-18 18:27:10.000000000 +0000 +++ deheader-1.3/deheader 2016-01-12 19:02:06.000000000 +0000 @@ -29,14 +29,15 @@ The last line of the output is a statistical summary of operations. """ +# SPDX-License-Identifier: BSD-2-Clause -import sys, os, getopt, time, re, operator, commands +import sys, os, getopt, time, re, operator, commands, subprocess BATON_DEBUG = 1 PROGRESS_DEBUG = 2 COMMAND_DEBUG = 3 -version = "1.2" +version = "1.3" # Difference in various compiler implementations and OSes mean that for cross- # platform compatibility you sometimes want to leave "unneeded" headers alone @@ -1353,16 +1354,22 @@ else: return repr(line) -def testcompile(source, maker, msg="", verbosity=0, showerrs=False): +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" - if os.path.exists(derived): - os.remove(derived) + if os.path.exists(os.path.join(subdir, derived)): + os.remove(os.path.join(subdir, derived)) + elif os.path.exists("CMakeList.txt"): + subprocess.call(["make","clean"]) command = maker + " " + derived + olddir = os.getcwd() + if len(subdir) > 0: + os.chdir(subdir) start = time.time() (status, output) = commands.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: @@ -1375,9 +1382,11 @@ print "deheader: %s%s %s." % (source, msg, explain) if os.path.exists(derived): os.remove(derived) + elif os.path.exists("CMakeList.txt"): + subprocess.call(["make","clean"]) return (status, end - start) -def c_analyze(sourcefile, maker, includes, requires, verbosity): +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 @@ -1386,10 +1395,10 @@ if verbosity == BATON_DEBUG: baton = Baton(sourcefile + ": ", "Done") try: - saveit = SaveForModification(sourcefile) + saveit = SaveForModification(os.path.join(subdir, sourcefile)) while True: keepgoing = False - for header in includes: + for header in includes[:]: if verbosity == BATON_DEBUG: baton.twirl() retain = 0 @@ -1397,11 +1406,11 @@ for required in requirements: if required in header: if verbosity >= PROGRESS_DEBUG: - print "deheader: in %s, %s prevents uninclusion of %s" % (sourcefile, trigger, trim(header)) + 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([header]) - (st, _t) = testcompile(sourcefile, maker, " without %s" % trim(header), verbosity, showerrs=False) + 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) @@ -1417,23 +1426,28 @@ stillhere = map(trim, includes) for (requirement, trigger) in requires: if not set(requirement).issubset(stillhere): - print "deheader: in %s, %s portability requires %s." % (sourcefile, trigger, ",".join(requirement)) + 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. - (st, _t) = testcompile(sourcefile, maker, verbosity=max(1, verbose), showerrs=True) + 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) + includes[:], requires, verbose, subdir=subdir) if unneeded: for line in unneeded: - print "deheader: remove %s from %s" % (trim(line), sourcefile) + print "deheader: remove %s from %s" % (trim(line), os.path.join(subdir, sourcefile)) if remove: - remove_it = SaveForModification(sourcefile) + remove_it = SaveForModification(os.path.join(subdir, sourcefile)) remove_it.remove_headers(unneeded) remove_it.forget() del remove_it diff -Nru deheader-1.2/deheader.1 deheader-1.3/deheader.1 --- deheader-1.2/deheader.1 2015-01-26 22:38:14.000000000 +0000 +++ deheader-1.3/deheader.1 2016-01-12 19:02:29.000000000 +0000 @@ -2,12 +2,12 @@ .\" Title: deheader .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 01/26/2015 +.\" Date: 01/12/2016 .\" Manual: Development Tools .\" Source: deheader .\" Language: English .\" -.TH "DEHEADER" "1" "01/26/2015" "deheader" "Development Tools" +.TH "DEHEADER" "1" "01/12/2016" "deheader" "Development Tools" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,9 @@ \fBdeheader\fR [\-h] [\-m\ \fIcommand\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 \*(Aqrm foo\&.o; make foo\&.o\*(Aq returns a zero status (but the build command may be overridden)\&. +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 @@ -55,6 +57,8 @@ \fB\-r\fR option was given and headers removed\&. .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\&. diff -Nru deheader-1.2/deheader.xml deheader-1.3/deheader.xml --- deheader-1.2/deheader.xml 2015-01-26 22:18:40.000000000 +0000 +++ deheader-1.3/deheader.xml 2016-01-12 18:59:49.000000000 +0000 @@ -36,10 +36,14 @@ 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 +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 @@ -77,6 +81,10 @@ with its original timestamp, unless the option was given and headers removed. +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 diff -Nru deheader-1.2/NEWS deheader-1.3/NEWS --- deheader-1.2/NEWS 2015-07-18 18:26:59.000000000 +0000 +++ deheader-1.3/NEWS 2016-01-12 19:01:54.000000000 +0000 @@ -1,5 +1,8 @@ deheader project news +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