debian/0000755000000000000000000000000012256116233007167 5ustar debian/headache.manpages0000644000000000000000000000003212247435427012432 0ustar debian/xml-man/headache.1 debian/changelog0000644000000000000000000001716012256116233011046 0ustar headache (1.03-24build1) trusty; urgency=medium * Rebuild for ocaml-4.01. -- Matthias Klose Mon, 23 Dec 2013 20:27:07 +0000 headache (1.03-24) unstable; urgency=low * Team upload * Recompile with ocaml 4.01.0 -- Stéphane Glondu Tue, 03 Dec 2013 21:12:21 +0100 headache (1.03-23) unstable; urgency=low [ Sylvain Le Gall ] * Remove Sylvain Le Gall from uploaders [ Ralf Treinen ] * Update debian/watch (ocamlforge) * Standards-Version 3.9.4 (no change) * debian/copyright: finalise migration to format 1.0. Fix licence, copyright holder (INRIA) and year. * Improve long package description. -- Ralf Treinen Mon, 20 May 2013 18:26:21 +0200 headache (1.03-22) unstable; urgency=low [ Mehdi Dogguy ] * Added patch utf8_length: fix length of lines containing UTF8 characters (Closes: #620379) * Since headache is an arch:all package, we cannot use dh_ocaml inferred dependencies. We replace the substitution variable ${ocaml:Depends} with "ocaml-base-nox-${F:OCamlABI}, libextlib-ocaml" for now. [ Ralf Treinen ] * Added build-dependency on libextlib-ocaml-dev, needed for the utf8_length patch -- Mehdi Dogguy Thu, 05 Jan 2012 21:43:07 +0100 headache (1.03-21) unstable; urgency=low [ Ralf Treinen ] * Remove debian/README.source since it no longer applies. * debian/patches/*: replace dpatch headers by RFC822 header stanzas. * patch config_file_types: add a default for .tex files (closes: #620376) [ Mehdi Dogguy ] * Add myself to Uploaders. * Upload to unstable. * Fix spelling-error-in-manpage by enhancing the wording in headache.xml -- Mehdi Dogguy Wed, 04 Jan 2012 18:45:23 +0100 headache (1.03-20) unstable; urgency=low [ Stéphane Glondu ] * Team upload * Rebuild with ocaml 3.12.1 (no source changes) [ Stefano Zacchiroli ] * remove myself from Uploaders -- Stéphane Glondu Tue, 01 Nov 2011 20:27:54 +0100 headache (1.03-19) unstable; urgency=low * Standards-version 3.9.2 (no change) * Rebuilt for OCaml 3.12.0 * Migrate to source format 3.0 * Removed duplicated Section field in debian/control * Spelling error in manpage. -- Ralf Treinen Sun, 17 Apr 2011 17:35:48 +0200 headache (1.03-18) unstable; urgency=low * Invert CDBS debhelper.mk and ocaml.mk to avoid leaving *.debhelper.log * Upgrade to dh-ocaml 0.9 * Rebuilt for OCaml 3.11.2 -- Sylvain Le Gall Thu, 11 Feb 2010 22:47:49 +0000 headache (1.03-17) unstable; urgency=low * Switch packaging to git * Rebuild for OCaml 3.11.1 * Remove useless CDBS depends substitution in debian/rules * Update debian/copyright (http://wiki.debian.org/Proposals/CopyrightFormat) * Upgrade Standards-Version to 3.8.2 (No change) -- Sylvain Le Gall Mon, 29 Jun 2009 10:45:40 +0000 headache (1.03-15) unstable; urgency=low [ Sylvain Le Gall ] * Upgrade Standards-Version to 3.8.0 (README.source) * Add build-dependency on dh-ocaml * Set 'Debian OCaml Maintainers' as maintainer [ Ralf Treinen ] * debian/rules: class/ocaml.mk -> rules/ocaml.mk. * debian/copyright: point to file LGPL-2, instead of file LGPL. -- Ralf Treinen Wed, 25 Feb 2009 20:56:33 +0100 headache (1.03-14) unstable; urgency=low * Recompile for ocaml 3.10.2 * Added myself to uploaders -- Ralf Treinen Mon, 19 May 2008 22:31:17 +0200 headache (1.03-13) unstable; urgency=low * Apply patch 02_skip_begin to skip lines before pasting the header (Closes: #440442) * Apply patch 03_header_width to compute maximal width of the header * Remove control.in -- Sylvain Le Gall Thu, 24 Apr 2008 22:59:49 +0200 headache (1.03-12) unstable; urgency=medium [ Stefano Zacchiroli ] * fix vcs-svn field to point just above the debian/ dir * bump standard version, no changes needed * bump urgency for the ocaml 3.10.1 transition * add build-dep on libxml2-utils, as the build invokes xmllint * adding me as an uploader [ Sylvain Le Gall ] * Recompile for ocaml 3.10.1 -- Stefano Zacchiroli Sun, 02 Mar 2008 15:08:22 +0100 headache (1.03-11) unstable; urgency=low * Build for ocaml 3.10.0 -- Sylvain Le Gall Tue, 04 Sep 2007 00:26:44 +0200 headache (1.03-10) experimental; urgency=low * Upgrade debian/watch version to 3, * Rewrite and relicense debian/xml-man/headache.xml, * Change email address to gildor@debian.org everywhere * Use DTD from docbook-xml package and not from docbook package * Rebuild for ocaml 3.10.0 -- Sylvain Le Gall Sat, 07 Jul 2007 23:26:24 +0200 headache (1.03-9) unstable; urgency=low * Update upstream mail, * Acknowledge NMU, thanks Mohammed Adnène Trojette (Closes: #388002, #379146) * Use CDBS for debian/rules, * Upgrade debhelper debian/compat to 5, -- Sylvain Le Gall Wed, 11 Oct 2006 00:43:04 +0200 headache (1.03-8.1) unstable; urgency=medium * Non-maintainer upload. * 01_detect_end_of_header.dpatch: + patch from Julien Cristau to detect the end of the header (Closes: #379146) -- Mohammed Adnène Trojette Mon, 18 Sep 2006 02:37:52 +0200 headache (1.03-8) unstable; urgency=low * Remove Debian OCaml Maintainer as uploader (this is non sense) -- Sylvain Le Gall Mon, 10 Jul 2006 22:29:35 +0200 headache (1.03-7) unstable; urgency=low * Acknownledge NMU (thanks to Ralf Treinen), * Change my email address to gildor@debian.org, * Made debian/control a PHONY target in debian/rules, * Set uploaders to debian ocaml maintainer, -- Sylvain Le Gall Mon, 12 Jun 2006 23:36:36 +0200 headache (1.03-6.1) unstable; urgency=low * NMU for ocaml translation 3.09.1 -> 3.09.2 * Rebuild for OCaml 3.09.2 * Build-depends on debhelper, dpatch (instead build-depends-indep) * Standards-version 3.7.2 (no change) * Fixed a type in rules.in in the string #OCamlABI# * Removed useless dependency on ocaml-nox -- Ralf Treinen Wed, 7 Jun 2006 09:19:35 +0200 headache (1.03-6) unstable; urgency=low * Rebuild for OCaml 3.09.1 -- Sylvain Le Gall Tue, 10 Jan 2006 23:58:14 +0100 headache (1.03-5) unstable; urgency=low * Transition to svn-buildpackage * Remove hardcoded reference to OCamlABI * Upgrade standards version to 3.6.2.0 (no change) * Update FSF address in copyroght file -- Sylvain Le Gall Fri, 2 Dec 2005 01:44:47 +0100 headache (1.03-4) unstable; urgency=medium * Transition to ocaml 3.08.3 : depends on ocaml-nox-3.08.3 -- Sylvain Le Gall Wed, 23 Mar 2005 22:59:13 +0100 headache (1.03-3) unstable; urgency=low * Change manpage license from GFDL to GPL ( Closes: #292232 ) -- Sylvain Le Gall Mon, 18 Oct 2004 23:42:38 +0200 headache (1.03-2) unstable; urgency=low * Transition to ocaml 3.08. ( Closes: #261518 ) * Correct typo : licence -> license ( Closes: #244718 ) -- Sylvain LE GALL Tue, 27 Jul 2004 23:52:20 +0200 headache (1.03-1) unstable; urgency=low * Initial upload ( Closes: #231168 ) * Use a watch file to keep track of new upstream * Write a manpage for headache * The binary is arch all since it is a ocaml bytecode. * Remove dh_strip since it will strip the ocaml bytecoded binary * Apply dpatchification -- Sylvain LE GALL Sun, 15 Feb 2004 21:54:24 +0100 debian/headache.dirs0000644000000000000000000000001112247435427011575 0ustar usr/bin/ debian/rules0000755000000000000000000000241012247435427010255 0ustar #!/usr/bin/make -f # debian/rules for headache package # Copyright (C) 2006-2009 Sylvain Le Gall # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301, USA. include /usr/share/cdbs/1/rules/ocaml.mk include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/autotools.mk DEB_MAKE_CLEAN_TARGET := clean DEB_MAKE_BUILD_TARGET := DEB_MAKE_INSTALL_TARGET := install INSTALLDIR="$(DEB_DESTDIR)/usr/bin" clean:: -$(DEB_MAKE_ENVVARS) $(MAKE) -C $(CURDIR)/debian/xml-man clean build/headache:: $(DEB_MAKE_ENVVARS) $(MAKE) -C $(CURDIR)/debian/xml-man all echo 'F:OCamlABI=$(OCAML_ABI)' >> debian/headache.substvars debian/headache.docs0000644000000000000000000000003712247435427011574 0ustar doc/manual.html doc/manual.txt debian/README.Debian0000644000000000000000000000225112247435427011241 0ustar Headache in debian has some enhancements, patches are waiting to be included in upstream source, but user should be aware of differences: - skipping line: It is possible to skip line before pasting the header. This is required because some files include specific string at the beginning of files: - "#!/bin/sh" for scripts - " skip match:"#!/bin/sh.*" | ".*\\.xml" -> skip match:"<\\?xml.*>" There could have as many "match" parameters ias required foreach pattern, multiple match are combined using an "OR". All the filename pattern that match will be taken into consideration. For example: | ".*" -> skip match:" *" will skip line containing line that match the regexp " *" for all files. - auto width: The maximal width of the header depends on 2 factors: - user defined width (using width keyword in the configuration file) - real width of the header If the real width of the header is bigger than the user defined width, the real width will be taken into account. -- Sylvain Le Gall, Thu, 24 Apr 2008 22:33:06 +0200 debian/gbp.conf0000644000000000000000000000003612247435427010616 0ustar [DEFAULT] pristine-tar = True debian/xml-man/0000755000000000000000000000000012247435427010551 5ustar debian/xml-man/Makefile0000644000000000000000000000053412247435427012213 0ustar # Makefile for building headache manpages. # GNU Copyright 2003-2006, by Sylvain Le Gall . all: headache.1 clean: -$(RM) *.1 %.1: %.xml # Verification -xmllint --nonet --noout --postvalid --xinclude $^ # Compilation xsltproc --nonet --xinclude \ /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl \ $^ debian/xml-man/headache.xml0000644000000000000000000002517112247435427013023 0ustar headache"> ]> Sylvain Le Gall gildor@debian.org 2003, 2004, 2005, 2006 Sylvain Le Gall Feb 15, 2004 HEADACHE 1 &dhprg; A program to manage the license of your source file. &dhprg; -h file -c file -r -help --help file DESCRIPTION This manual page documents briefly the &dhprg; command. This manual page was written for the &debian; distribution because the original program does not have a manual page. It is a common usage to put at the beginning of source code files a short header giving, for instance, some copyright information. &dhprg; is a simple and lightweight tool for managing easily these headers. Among its functionalities, one may mention: Headers must generally be generated as comments in source code files. &dhprg; deals with different files types and generates for each of them headers in an appropriate format. Headers automatically detects existing headers and removes them. Thus, you can use it to update headers in a set of files. COMMAND LINE OPTIONS file Name of one file to process -h file Create a header with text coming from file -c file Read the given configuration file -help --help Display the option list of &dhprg; USAGE Let us illustrate the use of this tool with a small example. Assume you have a small project mixing C and Caml code consisting in three files 'foo.c', 'bar.ml' and 'bar.mli'', and you want to equip them with some header. First of all, write a header file, i.e. a plain text file including the information headers must mention. An example of such a file is given in figure 1. In the following, we assume this file is named 'myheader' and is in the same directory as source files. Then, in order to generate headers, just run the command : &dhprg; -h myheader foo.c bar.ml bar.mli Each file is equipped with an header including the text given in the header file 'myheader', surrounded by some extra characters depending on its format making it a comment (e.g. '(*' and '*)' in '.ml' files). If you update the header file 'myheader', you simply need to re-run the above command to update headers in source code files. Similarly, running : &dhprg; -r foo.c bar.ml bar.mli removes any existing in files 'foo.c', 'bar.ml' and 'bar.mli'. Files which do not have a header are kept unchanged. CONFIGURATION FILE File types and format of header may be specified by a configuration file. By default, the default builtin configuration file given in figure 2 is used. You can also use your own configuration file thanks to the option : &dhprg; -c myconfig -h myheader foo.c bar.ml bar.mli In order to write your own configuration, you can follow the example given in figure 2. A configuration file consists in a list of entries separated by the character '|'. Each of them is made of two parts separated by an '->'. The first one is a regular expression. (Regular expression are enclosed within double quotes and have the same syntax as in Gnu Emacs.) &dhprg; determines file types according to file basenames; thus, each file is dealt with using the first line its name matches. The second one describes the format of headers for files of this type. It consists of the name of a model (e.g. 'frame'), possibly followed by a list of arguments. Arguments are named: 'open:"(*"' means that the value of the argument 'open' is '(*'. &dhprg; currently supports three models and a special keyword: frame With this model, headers are generated in a frame. This model requires three arguments: 'open' and 'close' (the opening and closing sequences for comments) and 'line' (the character used to make the horizontal lines of the frame). Two optional arguments may be used 'margin' (a string printed between the left and right side of the frame and the border, by default two spaces) and 'width' (the width of the inside of the frame, default is 68). lines Headers are typeset between two lines. Three arguments must be provided: 'open' and 'close' (the opening and closing sequences for comments), 'line' (the character used to make the horizontal lines). Three optional arguments are allowed: 'begin' (a string typeset at the beginning of each line, by default two spaces), 'last' (a string typeset at the beginning of the last line) and 'width' (the width of the lines, default is 70). no This model generates no header and has no argument. skip Skip line corresponding to one of the "match" parameters regexp. For this kind of line, every first part pattern that matches the file basename is taken into account. SEE ALSO /usr/share/doc/headache/manual.html AUTHOR This manual page was written by Sylvain Le Gall gildor@debian.org Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Lesser General Public License, Version 2.1 or any later version published by the Free Software Foundation; considering as source code all the file that enable the production of this manpage. debian/control0000644000000000000000000000200612247435427010601 0ustar Source: headache Section: devel Priority: optional Maintainer: Debian OCaml Maintainers Uploaders: Ralf Treinen , Mehdi Dogguy Build-Depends-Indep: po-debconf, xsltproc, libxml2-utils, docbook-xsl, docbook-xml Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 5), ocaml-nox (>= 3.10.0-8), dh-ocaml (>= 0.9), libextlib-ocaml-dev Standards-Version: 3.9.4 Vcs-Git: git://git.debian.org/git/pkg-ocaml-maint/packages/headache.git Vcs-Browser: http://git.debian.org/?p=pkg-ocaml-maint/packages/headache.git Homepage: http://cristal.inria.fr/~simonet/soft/ Package: headache Architecture: all Depends: ocaml-base-nox-${F:OCamlABI}, libextlib-ocaml, ${misc:Depends} Description: Tool to manage license notes of source files This tool allows a developer to add or remove the license note that one usually finds in a comment at the beginning of source files. It knows about the syntax of comments in different languages: Makefile, OCaml, C, (La)TeX. debian/copyright0000644000000000000000000000304512247435427011135 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: headache Upstream-Contact: Vincent Simonet Source: http://forge.ocamlcore.org/frs/?group_id=51 Files: * Copyright: (C) 2002 Institut National de Recherche en Informatique et en Automatique. License: LGPL-2 This package is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 dated June, 1991. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. . On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/LGPL-2' Files: debian/* Copyright: (C) 2006-2009 Sylvain Le Gall License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. On Debian systems, the complete text of the GNU General Public License can be found in the file `/usr/share/common-licenses/GPL'. debian/source/0000755000000000000000000000000012247435427010500 5ustar debian/source/format0000644000000000000000000000001412247435427011706 0ustar 3.0 (quilt) debian/watch0000644000000000000000000000012412247435427010226 0ustar version=3 http://forge.ocamlcore.org/frs/?group_id=51 .*/headache-([0-9.]*)\.tar\.gzdebian/patches/0000755000000000000000000000000012247435427010627 5ustar debian/patches/utf8_length0000644000000000000000000000337412247435427013010 0ustar Author: Mehdi Dogguy Description: Correctly determine length of lines containing UTF8 characters --- a/main.ml +++ b/main.ml @@ -103,7 +103,7 @@ in let header_width = List.fold_left - (fun w line -> max (String.length line) w) + (fun w line -> max (UTF8.length line) w) 0 header in --- a/Makefile.in +++ b/Makefile.in @@ -10,6 +10,8 @@ OCAMLYACC=@OCAMLYACC@ OCAMLLEX=@OCAMLLEX@ +OCAMLC_FLAGS=-I +extlib extLib.cma + # Installation directory INSTALLDIR=@INSTALLDIR@ @@ -51,10 +53,10 @@ $(OCAMLDEP) *.ml *.mli > Depend headache: $(CMO) - ocamlc -o $@ unix.cma str.cma $^ + ocamlc -o $@ unix.cma str.cma -I +extlib extLib.cma $^ mkconfig: $(MKCONFIG.CMO) - ocamlc -o $@ unix.cma str.cma $^ + ocamlc -o $@ unix.cma str.cma -I +extlib extLib.cma $^ config_builtin.ml: config_builtin mkconfig ./mkconfig --- a/model.ml +++ b/model.ml @@ -65,7 +65,7 @@ let arg_char args ?default name = let s = arg_string args ?default name in - if String.length s = 1 then s.[0] + if UTF8.length s = 1 then s.[0] else raise (Error (sprintf "parameter %s expects a character" name)) @@ -103,7 +103,7 @@ output_string oc open_comment; output_string oc margin; output_string oc string; - output oc white 0 (max 0 (real_width - String.length string)); + output oc white 0 (max 0 (real_width - UTF8.length string)); output_string oc margin; output_string oc close_comment; output_char oc '\n' @@ -150,7 +150,7 @@ while let s = input_line ic in not (Str.string_match regexp_end s - (max 0 (String.length s - end_length))) + (max 0 (UTF8.length s - end_length))) do () done; "" end debian/patches/01_detect_end_of_header0000755000000000000000000000267312247435427015157 0ustar Author: Julien Cristau Description: Patch to detect the end of the header diff -Nru headache-1.03/main.ml headache-1.03.new/main.ml --- headache-1.03/main.ml 2004-03-29 11:16:22.000000000 +0200 +++ headache-1.03.new/main.ml 2006-09-16 01:57:34.000000000 +0200 @@ -89,7 +89,7 @@ let line = input_line ic in line :: loop () with - End_of_file -> [] + End_of_file -> close_in ic; [] in loop () @@ -221,4 +221,4 @@ main () with Sys_error msg -> - eprintf "%s: %s" Sys.argv.(0) msg + eprintf "%s: %s\n" Sys.argv.(0) msg diff -Nru headache-1.03/model.ml headache-1.03.new/model.ml --- headache-1.03/model.ml 2004-03-29 11:16:22.000000000 +0200 +++ headache-1.03.new/model.ml 2006-09-16 01:47:06.000000000 +0200 @@ -138,6 +138,8 @@ let regexp_end = Str.regexp_string (sprintf "%s%s" (String.make 10 line_char) close_comment) in + let end_length = 10 + String.length close_comment + in let regexp_blank = Str.regexp "^[ ]*$" in @@ -146,7 +148,11 @@ let line = input_line ic in if Str.string_match regexp_begin line 0 then begin - while not (Str.string_match regexp_end (input_line ic) 0) do () done; + while + let s = input_line ic in + not (Str.string_match regexp_end s + (max 0 (String.length s - end_length))) + do () done; "" end else if Str.string_match regexp_blank line 0 debian/patches/series0000644000000000000000000000012412247435427012041 0ustar 01_detect_end_of_header 02_skip_begin 03_header_width config_file_types utf8_length debian/patches/config_file_types0000644000000000000000000000143412247435427014244 0ustar Author: Ralf Treinen Description: add a default for .tex files Debian-Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=620376 Index: headache/config_builtin =================================================================== --- headache.orig/config_builtin 2012-01-03 08:45:00.000000000 +0100 +++ headache/config_builtin 2012-01-03 08:46:33.000000000 +0100 @@ -4,6 +4,7 @@ | ".*\\.fml[i]?" -> frame open:"(*" line:"*" close:"*)" | ".*\\.mly" -> frame open:"/*" line:"*" close:"*/" | ".*\\.[ch]" -> frame open:"/*" line:"*" close:"*/" +| ".*\\.tex" -> frame open:"%" line:"%" close:"%" | ".*Makefile.*" -> frame open:"#" line:"#" close:"#" | ".*README.*" -> frame open:"*" line:"*" close:"*" | ".*LICENSE.*" -> frame open:"*" line:"*" close:"*" debian/patches/03_header_width0000644000000000000000000000776512247435427013522 0ustar Author: Sylvain Le Gall Description: Compute header width based on header file content. Index: headache/main.ml =================================================================== --- headache.orig/main.ml 2012-01-03 08:42:53.000000000 +0100 +++ headache/main.ml 2012-01-03 08:42:54.000000000 +0100 @@ -98,9 +98,16 @@ with End_of_file -> close_in ic; [] in - loop () - - + let header = + loop () + in + let header_width = + List.fold_left + (fun w line -> max (String.length line) w) + 0 + header + in + header, header_width (***************************************************************************) (** {2 Processing files} *) @@ -151,14 +158,14 @@ in loop () -let create_header header filename = +let create_header header header_width filename = let generator = find_generator filename in let skip_lst = find_skips filename in pipe_file (fun ic oc -> let () = Skip.skip skip_lst ic oc in let line = generator.Model.remove ic in let () = Skip.skip skip_lst ic oc in - generator.Model.create oc header; + generator.Model.create oc header header_width; output_string oc line; copy ic oc ) filename @@ -184,24 +191,24 @@ (** {2 Main loop} *) type action = - Create of string list + Create of string list * int | Remove let main () = - let action = ref (Create []) in + let action = ref (Create ([], 0)) in let anonymous filename = match !action with - Create header -> create_header header filename + Create (header, header_width) -> create_header header header_width filename | Remove -> remove_header filename in Arg.parse [ "-h", - Arg.String (fun s -> action := Create (read_headerfile s)), + Arg.String (fun s -> let (header, header_width) = (read_headerfile s) in action := Create (header, header_width)), " Create headers with text from "; "-c", Index: headache/model.ml =================================================================== --- headache.orig/model.ml 2012-01-03 08:42:53.000000000 +0100 +++ headache/model.ml 2012-01-03 08:42:54.000000000 +0100 @@ -26,7 +26,7 @@ type generator = { remove: in_channel -> string; - create: out_channel -> string list -> unit; + create: out_channel -> string list -> int -> unit; } (***************************************************************************) @@ -92,8 +92,9 @@ "" in - let create oc header = - let width' = width + 2 * String.length margin in + let create oc header header_width = + let real_width = max width header_width in + let width' = real_width + 2 * String.length margin in let white = String.make width' ' ' in let line = String.make width' line_char in Printf.fprintf oc "%s%s%s\n" open_comment line close_comment; @@ -102,7 +103,7 @@ output_string oc open_comment; output_string oc margin; output_string oc string; - output oc white 0 (max 0 (width - String.length string)); + output oc white 0 (max 0 (real_width - String.length string)); output_string oc margin; output_string oc close_comment; output_char oc '\n' @@ -160,9 +161,10 @@ "" in - let create oc header = + let create oc header header_width = + let real_width = max width header_width in Printf.fprintf oc "%s%s\n" open_comment - (String.make (max 0 (width - String.length open_comment)) line_char); + (String.make (max 0 (real_width - String.length open_comment)) line_char); List.iter (function string -> output_string oc begin_line; @@ -172,7 +174,7 @@ Printf.fprintf oc "%s%s%s\n\n" begin_last - (String.make (max 0 (width - String.length begin_last + (String.make (max 0 (real_width - String.length begin_last - String.length close_comment)) line_char) close_comment; @@ -198,7 +200,7 @@ let make_no () = { remove = (fun _ -> ""); - create = (fun _ _ -> ()) + create = (fun _ _ _ -> ()) } let _ = debian/patches/02_skip_begin0000755000000000000000000002070412247435427013173 0ustar Author: Sylvain Le Gall Description: Allow to add pattern to skip begin of file (e.g. for XML files) diff -urNad headache-1.03~/Depend headache-1.03/Depend --- headache-1.03~/Depend 2004-03-29 11:16:22.000000000 +0200 +++ headache-1.03/Depend 2008-04-24 17:45:39.000000000 +0200 @@ -1,11 +1,11 @@ -config_lex.cmo: config.cmo config_parse.cmi -config_lex.cmx: config.cmx config_parse.cmx -config_parse.cmo: config.cmo model.cmo config_parse.cmi -config_parse.cmx: config.cmx model.cmx config_parse.cmi -main.cmo: config.cmo config_builtin.cmo config_lex.cmo config_parse.cmi \ - info.cmo model.cmo -main.cmx: config.cmx config_builtin.cmx config_lex.cmx config_parse.cmx \ - info.cmx model.cmx -mkconfig.cmo: config.cmo config_lex.cmo config_parse.cmi -mkconfig.cmx: config.cmx config_lex.cmx config_parse.cmx -config_parse.cmi: model.cmo +config_lex.cmo: config_parse.cmi config.cmo +config_lex.cmx: config_parse.cmx config.cmx +config_parse.cmo: skip.cmo model.cmo config.cmo config_parse.cmi +config_parse.cmx: skip.cmx model.cmx config.cmx config_parse.cmi +main.cmo: model.cmo info.cmo config_parse.cmi config_lex.cmo \ + config_builtin.cmo config.cmo +main.cmx: model.cmx info.cmx config_parse.cmx config_lex.cmx \ + config_builtin.cmx config.cmx +mkconfig.cmo: config_parse.cmi config_lex.cmo config.cmo +mkconfig.cmx: config_parse.cmx config_lex.cmx config.cmx +config_parse.cmi: skip.cmo model.cmo diff -urNad headache-1.03~/Makefile.in headache-1.03/Makefile.in --- headache-1.03~/Makefile.in 2004-03-29 11:16:22.000000000 +0200 +++ headache-1.03/Makefile.in 2008-04-24 17:46:04.000000000 +0200 @@ -15,9 +15,9 @@ GENERATED= config_parse.mli config_parse.ml config_lex.ml config_builtin.ml -MKCONFIG.CU=model config config_parse config_lex mkconfig +MKCONFIG.CU=skip model config config_parse config_lex mkconfig MKCONFIG.CMO=$(MKCONFIG.CU:%=%.cmo) -CU=info model config config_parse config_lex config_builtin main +CU=info skip model config config_parse config_lex config_builtin main CMO=$(CU:%=%.cmo) @@ -81,4 +81,4 @@ $(OCAMLYACC) -v $< -include Depend +-include Depend diff -urNad headache-1.03~/config_parse.mly headache-1.03/config_parse.mly --- headache-1.03~/config_parse.mly 2004-03-29 11:16:22.000000000 +0200 +++ headache-1.03/config_parse.mly 2008-04-24 17:45:39.000000000 +0200 @@ -49,6 +49,29 @@ %{ open Printf + +type entry = + | EntryModel of Model.generator + | EntrySkip of Skip.regexp_skip list +;; + +(* Dispatch entry considering if it is a skip or a model. + * List returned are reversed considering their initial order. + *) +let rec dispatch_entry acc_model acc_skip lst = + match lst with + | (rg_filename, EntryModel mdl) :: tl -> + dispatch_entry ((rg_filename, mdl) :: acc_model) acc_skip tl + | (rg_filename, EntrySkip rg_skip_lst) :: tl -> + let nacc_skip = + List.fold_left + (fun nacc_skip rg_skip -> (rg_filename, rg_skip) :: nacc_skip) + acc_skip + rg_skip_lst + in + dispatch_entry acc_model nacc_skip tl + | [] -> + acc_model, acc_skip %} %token ARROW @@ -58,14 +81,14 @@ %token STRING %start configfile -%type <(Str.regexp * Model.generator) list > configfile +%type <((Str.regexp * Model.generator) list) * ((Str.regexp * Skip.regexp_skip) list)> configfile %start boot %type <(string * string * (string * string) list) list> boot %% configfile: - opt_pipe item_list EOF { List.rev $2 } + opt_pipe item_list EOF { dispatch_entry [] [] $2 } ; opt_pipe: @@ -89,23 +112,41 @@ raise (Config.Error (sprintf "Illegal regexp: %s" msg, Parsing.rhs_start 1, Parsing.rhs_end 1)) in - let model = - try - Model.find $3 - with - Not_found -> - raise (Config.Error (sprintf "Unknown model: %s" $3, - Parsing.rhs_start 3, Parsing.rhs_end 3)) - in - let generator = - try - model (List.rev $4) - with - Model.Error msg -> - raise (Config.Error (msg, - Parsing.rhs_start 3, Parsing.rhs_end 4)) - in - regexp, generator + if $3 = "skip" then + let fun_parameters (id, str) = + if id = "match" then + try + Str.regexp ("^" ^ str ^ "$") + with + Failure msg -> + raise (Config.Error (sprintf "Illegal regexp: %s" msg, + Parsing.rhs_start 1, Parsing.rhs_end 1)) + else + raise (Config.Error (sprintf "Unkown option '%s' for skip" id, + Parsing.rhs_start 3, Parsing.rhs_end 3)) + in + let skip_lst = + List.map fun_parameters (List.rev $4) + in + regexp, (EntrySkip skip_lst) + else + let model = + try + Model.find $3 + with + Not_found -> + raise (Config.Error (sprintf "Unknown model: %s" $3, + Parsing.rhs_start 3, Parsing.rhs_end 3)) + in + let generator = + try + model (List.rev $4) + with + Model.Error msg -> + raise (Config.Error (msg, + Parsing.rhs_start 3, Parsing.rhs_end 4)) + in + regexp, (EntryModel generator) } ; diff -urNad headache-1.03~/main.ml headache-1.03/main.ml --- headache-1.03~/main.ml 2008-04-24 17:45:13.000000000 +0200 +++ headache-1.03/main.ml 2008-04-24 17:45:39.000000000 +0200 @@ -25,13 +25,17 @@ let generators : (Str.regexp * Model.generator) list ref = ref [] +let skips : (Str.regexp * Skip.regexp_skip) list ref = ref [] + let read_configfile filename = let ic = open_in filename in let lexbuf = Lexing.from_channel ic in try - generators := + let (config_generators, config_skips) = (Config_parse.configfile Config_lex.token lexbuf) - @ !generators; + in + skips := config_skips @ !skips; + generators := config_generators @ !generators; close_in ic with Config.Error (msg, loc1, loc2) -> @@ -44,8 +48,6 @@ Sys.argv.(0) filename (Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) - - let find_generator filename = let basename = Filename.basename filename in try @@ -61,6 +63,11 @@ Sys.argv.(0) filename; exit 2 +let find_skips filename = + List.filter + (fun (rg_filename, _) -> Str.string_match rg_filename filename 0) + !skips + (***************************************************************************) @@ -144,12 +151,13 @@ in loop () - - let create_header header filename = let generator = find_generator filename in + let skip_lst = find_skips filename in pipe_file (fun ic oc -> + let () = Skip.skip skip_lst ic oc in let line = generator.Model.remove ic in + let () = Skip.skip skip_lst ic oc in generator.Model.create oc header; output_string oc line; copy ic oc @@ -159,8 +167,11 @@ let remove_header filename = let generator = find_generator filename in + let skip_lst = find_skips filename in pipe_file (fun ic oc -> + let () = Skip.skip skip_lst ic oc in let line = generator.Model.remove ic in + let () = Skip.skip skip_lst ic oc in output_string oc line; copy ic oc ) filename diff -urNad headache-1.03~/model.ml headache-1.03/model.ml --- headache-1.03~/model.ml 2008-04-24 17:45:13.000000000 +0200 +++ headache-1.03/model.ml 2008-04-24 17:46:04.000000000 +0200 @@ -26,11 +26,9 @@ type generator = { remove: in_channel -> string; - create: out_channel -> string list -> unit + create: out_channel -> string list -> unit; } - - (***************************************************************************) (** {2 Models} *) diff -urNad headache-1.03~/skip.ml headache-1.03/skip.ml --- headache-1.03~/skip.ml 1970-01-01 01:00:00.000000000 +0100 +++ headache-1.03/skip.ml 2008-04-24 17:46:04.000000000 +0200 @@ -0,0 +1,36 @@ + + +type regexp_filename = Str.regexp +;; + +type regexp_skip = Str.regexp +;; + +let skip skip_lst ic oc = + let skip_aux () = + let initial_pos = + LargeFile.pos_in ic + in + try + let line = + input_line ic + in + try + let _ = + List.find + (fun (_, rg_skip) -> Str.string_match rg_skip line 0) + skip_lst + in + prerr_endline + ("Line : "^line^" skipped"); + output_string oc line; + output_string oc "\n" + with Not_found -> + LargeFile.seek_in ic initial_pos + with End_of_file -> + () + in + skip_aux () +;; + + debian/headache.doc-base0000644000000000000000000000062212247435427012321 0ustar Document: headache Title: Headache Manual Author: Vincent Simonet Abstract: It is a common usage to put at the beginning of source code files a short header giving, for instance, some copyright information. headache is a simple and lightweight tool for managing easily these headers. Section: Programming Format: HTML Index: /usr/share/doc/headache/manual.html Files: /usr/share/doc/headache/*.html debian/compat0000644000000000000000000000000212247435427010376 0ustar 5