[Pkg-ocaml-maint-commits] r5543 - in /trunk/packages/headache/trunk/debian: README.Debian changelog control.in headache.doc-base patches/00list patches/02_skip_begin.dpatch patches/03_header_width.dpatch rules xml-man/headache.xml

gildor at users.alioth.debian.org gildor at users.alioth.debian.org
Thu Apr 24 21:03:42 UTC 2008


Author: gildor
Date: Thu Apr 24 21:03:42 2008
New Revision: 5543

URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/?sc=1&rev=5543
Log:
* Remove misleading control.in
* Add 2 patches to solve what annoy me when using headache
* Correct documentation to explain new "skip" option

Added:
    trunk/packages/headache/trunk/debian/README.Debian
    trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch   (with props)
    trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch   (with props)
Removed:
    trunk/packages/headache/trunk/debian/control.in
Modified:
    trunk/packages/headache/trunk/debian/changelog
    trunk/packages/headache/trunk/debian/headache.doc-base
    trunk/packages/headache/trunk/debian/patches/00list
    trunk/packages/headache/trunk/debian/rules
    trunk/packages/headache/trunk/debian/xml-man/headache.xml

Added: trunk/packages/headache/trunk/debian/README.Debian
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/README.Debian?rev=5543&op=file
==============================================================================
--- trunk/packages/headache/trunk/debian/README.Debian (added)
+++ trunk/packages/headache/trunk/debian/README.Debian Thu Apr 24 21:03:42 2008
@@ -1,0 +1,37 @@
+
+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
+- "<?xml" for xml 
+- "<?php" for php 
+
+You can use a pattern to match filename and apply a skip procedure, using the
+keyword "skip". For example:
+
+| ".*\\.sh" -> 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

Modified: trunk/packages/headache/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/changelog?rev=5543&op=diff
==============================================================================
--- trunk/packages/headache/trunk/debian/changelog (original)
+++ trunk/packages/headache/trunk/debian/changelog Thu Apr 24 21:03:42 2008
@@ -1,8 +1,11 @@
-headache (1.03-13) UNRELEASED; urgency=low
+headache (1.03-13) unstable; urgency=low
 
-  * NOT RELEASED YET
+  * 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
 
- -- Stefano Zacchiroli <zack at debian.org>  Sun, 02 Mar 2008 15:15:37 +0100
+ -- Sylvain Le Gall <gildor at debian.org>  Thu, 24 Apr 2008 22:59:49 +0200
 
 headache (1.03-12) unstable; urgency=medium
 

Modified: trunk/packages/headache/trunk/debian/headache.doc-base
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/headache.doc-base?rev=5543&op=diff
==============================================================================
--- trunk/packages/headache/trunk/debian/headache.doc-base (original)
+++ trunk/packages/headache/trunk/debian/headache.doc-base Thu Apr 24 21:03:42 2008
@@ -4,7 +4,7 @@
 Abstract: It is a common usage to put at the beginning of source code files a
  short header giving, for instance, some copyright informations. headache
  is a simple and lightweight tool for managing easily these headers.
-Section: Apps/Devel
+Section: Programming
 
 Format: HTML
 Index: /usr/share/doc/headache/manual.html

Modified: trunk/packages/headache/trunk/debian/patches/00list
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/patches/00list?rev=5543&op=diff
==============================================================================
--- trunk/packages/headache/trunk/debian/patches/00list (original)
+++ trunk/packages/headache/trunk/debian/patches/00list Thu Apr 24 21:03:42 2008
@@ -1,1 +1,3 @@
 01_detect_end_of_header
+02_skip_begin
+03_header_width

Added: trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch?rev=5543&op=file
==============================================================================
--- trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch (added)
+++ trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch Thu Apr 24 21:03:42 2008
@@ -1,0 +1,291 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 02_skip_begin.dpatch by Sylvain Le Gall <gildor at debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+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> 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 ()
++;; 
++
++

Propchange: trunk/packages/headache/trunk/debian/patches/02_skip_begin.dpatch
------------------------------------------------------------------------------
    svn:executable = *

Added: trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch?rev=5543&op=file
==============================================================================
--- trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch (added)
+++ trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch Thu Apr 24 21:03:42 2008
@@ -1,0 +1,140 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_header_width.dpatch by Sylvain Le Gall <gildor at debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+ at DPATCH@
+diff -urNad trunk~/main.ml trunk/main.ml
+--- trunk~/main.ml	2008-04-24 22:55:07.685167988 +0200
++++ trunk/main.ml	2008-04-24 22:57:01.404332989 +0200
+@@ -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)),
+   "<file>  Create headers with text from <file>";
+ 
+   "-c",
+diff -urNad trunk~/model.ml trunk/model.ml
+--- trunk~/model.ml	2008-04-24 22:55:07.685167988 +0200
++++ trunk/model.ml	2008-04-24 22:55:50.907330341 +0200
+@@ -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 _ =

Propchange: trunk/packages/headache/trunk/debian/patches/03_header_width.dpatch
------------------------------------------------------------------------------
    svn:executable = *

Modified: trunk/packages/headache/trunk/debian/rules
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/rules?rev=5543&op=diff
==============================================================================
--- trunk/packages/headache/trunk/debian/rules (original)
+++ trunk/packages/headache/trunk/debian/rules Thu Apr 24 21:03:42 2008
@@ -17,9 +17,6 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
-# Generate debian/control using
-# fakeroot debian/rules debian/control DEB_AUTO_UPDATE_DEBIAN_CONTROL:=yes
-
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/rules/dpatch.mk
 include /usr/share/cdbs/1/class/autotools.mk

Modified: trunk/packages/headache/trunk/debian/xml-man/headache.xml
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/headache/trunk/debian/xml-man/headache.xml?rev=5543&op=diff
==============================================================================
--- trunk/packages/headache/trunk/debian/xml-man/headache.xml (original)
+++ trunk/packages/headache/trunk/debian/xml-man/headache.xml Thu Apr 24 21:03:42 2008
@@ -205,7 +205,7 @@
       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:</para>
+      &dhprg; currently supports three models and a special keyword:</para>
       
     <variablelist>
       <varlistentry>
@@ -226,7 +226,7 @@
           <para>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 allowd: 'begin' (a string
+            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).</para>
@@ -236,6 +236,14 @@
         <term>no</term>
         <listitem>
           <para>This model generates no header and has no argument.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>skip</term>
+        <listitem>
+          <para>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.</para>
         </listitem>
       </varlistentry>
     </variablelist>




More information about the Pkg-ocaml-maint-commits mailing list