[Pkg-ocaml-maint-commits] r5097 - in /trunk/projects/approx/trunk: debian/changelog debian/control doc/approx.conf.5 patch.ml tests/patch_test.ml

ecc-guest at users.alioth.debian.org ecc-guest at users.alioth.debian.org
Sun Feb 3 22:55:34 UTC 2008


Author: ecc-guest
Date: Sun Feb  3 22:55:34 2008
New Revision: 5097

URL: http://svn.debian.org/wsvn/?sc=1&rev=5097
Log:
streamlined Patch implementation to compose operators

updated standards version

Modified:
    trunk/projects/approx/trunk/debian/changelog
    trunk/projects/approx/trunk/debian/control
    trunk/projects/approx/trunk/doc/approx.conf.5
    trunk/projects/approx/trunk/patch.ml
    trunk/projects/approx/trunk/tests/patch_test.ml

Modified: trunk/projects/approx/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/changelog?rev=5097&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/changelog (original)
+++ trunk/projects/approx/trunk/debian/changelog Sun Feb  3 22:55:34 2008
@@ -1,8 +1,10 @@
-approx (3.0.1) UNRELEASED; urgency=low
-
-  * NOT RELEASED YET
-
- -- Sylvain Le Gall <gildor at debian.org>  Sat, 08 Dec 2007 13:51:20 +0100
+approx (3.1.0) unstable; urgency=low
+
+  * Changed Patch module to use a single composite operator
+    instead of a list, so Patch.apply is just function application
+  * Updated standards version and VCS fields in debian/control
+
+ -- Eric Cooper <ecc at cmu.edu>  Thu, 10 Jan 2008 13:18:20 -0500
 
 approx (3.0.0) unstable; urgency=low
 

Modified: trunk/projects/approx/trunk/debian/control
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/control?rev=5097&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/control (original)
+++ trunk/projects/approx/trunk/debian/control Sun Feb  3 22:55:34 2008
@@ -3,11 +3,11 @@
 Priority: optional
 Maintainer: Eric Cooper <ecc at cmu.edu>
 Uploaders: Sylvain Le Gall <gildor at debian.org>, Ralf Treinen <treinen at debian.org>
-XS-Dm-Upload-Allowed: yes
+XS-DM-Upload-Allowed: yes
 Build-Depends: debhelper (>= 5.0), cdbs, ocamlmakefile, ocaml-nox (>= 3.10), ocaml-best-compilers, libnethttpd-ocaml-dev (>= 2.2.8), libpcre-ocaml-dev (>= 5.11), libsha-ocaml-dev (>= 1.3), libsyslog-ocaml-dev (>= 1.3)
-Standards-Version: 3.7.2
+Standards-Version: 3.7.3
 Homepage: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/projects/approx
-XS-Vcs-Svn: svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/projects/approx
+Vcs-Svn: svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/projects/approx
 
 Package: approx
 Architecture: any

Modified: trunk/projects/approx/trunk/doc/approx.conf.5
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/doc/approx.conf.5?rev=5097&op=diff
==============================================================================
--- trunk/projects/approx/trunk/doc/approx.conf.5 (original)
+++ trunk/projects/approx/trunk/doc/approx.conf.5 Sun Feb  3 22:55:34 2008
@@ -1,5 +1,5 @@
 .\" approx: proxy server for Debian archive files
-.\" Copyright (C) 2007  Eric C. Cooper <ecc at cmu.edu>
+.\" Copyright (C) 2008  Eric C. Cooper <ecc at cmu.edu>
 .\" Released under the GNU General Public License
 .\" -*- nroff -*-
 .TH APPROX.CONF 5 "November 2007"
@@ -35,11 +35,11 @@
 to indicate kilobytes, megabytes, or gigabytes per second, respectively.
 .IP "$user, $group"
 Specifies the name of the user and group to use after the daemon drops
-privileges (default: "approx")
+privileges (default: approx)
 .IP $syslog
 Specifies the
 .BR syslog (3)
-facility to use when logging (default: "daemon")
+facility to use when logging (default: daemon)
 .IP $pdiffs
 Specifies whether to support IndexFile diffs
 (default:

Modified: trunk/projects/approx/trunk/patch.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/patch.ml?rev=5097&op=diff
==============================================================================
--- trunk/projects/approx/trunk/patch.ml (original)
+++ trunk/projects/approx/trunk/patch.ml Sun Feb  3 22:55:34 2008
@@ -1,5 +1,5 @@
 (* approx: proxy server for Debian archive files
-   Copyright (C) 2007  Eric C. Cooper <ecc at cmu.edu>
+   Copyright (C) 2008  Eric C. Cooper <ecc at cmu.edu>
    Released under the GNU General Public License *)
 
 open Util
@@ -76,33 +76,35 @@
 
 (* Ed commands are represented as operators on the
    input channel, output channel, and current line number.
-   When applied, each operator updates the line number. *)
+   When applied, each operator returns the updated the line number. *)
 
-type t = (in_channel -> out_channel -> int -> int) list
+type t = in_channel -> out_channel -> int -> int
+
+(* Translate an ed command into an operator.
+   Additional lines are consumed from the channel
+   in the case of append and change commands. *)
+
+let parse_line chan line =
+  let last = String.length line - 1 in
+  let (m, n) = range_of_string (String.sub line 0 last) in
+  match line.[last] with
+  | 'a' -> assert (m = n); append (get_lines chan) m
+  | 'c' -> change (get_lines chan) m n
+  | 'd' -> delete m n
+  | _ -> failwith ("malformed ed command: " ^ line)
 
 (* Parse an input channel containing ed commands.
    "diff --ed" produces commands in decreasing line-number order;
-   this function reverses that order as it constructs the list. *)
+   this function effectively reverses that order as it composes
+   the operators. *)
 
 let parse chan =
-  let rec next script =
+  let compose f g ic oc cur = g ic oc (f ic oc cur) in
+  let rec loop op =
     match get_line chan with
-    | Some line -> next (parse_line line :: script)
-    | None -> script
-  and parse_line line =
-    let last = String.length line - 1 in
-    let (m, n) = range_of_string (String.sub line 0 last) in
-    match line.[last] with
-    | 'a' -> assert (m = n); append (get_lines chan) m
-    | 'c' -> change (get_lines chan) m n
-    | 'd' -> delete m n
-    | _ -> failwith ("malformed ed command: " ^ line)
+    | Some line -> loop (compose (parse_line chan line) op)
+    | None -> op
   in
-  next [copy_tail]
+  loop copy_tail
 
-let apply cmds ic oc =
-  let rec loop cur = function
-    | cmd :: rest -> loop (cmd ic oc cur) rest
-    | [] -> ()
-  in
-  loop 1 cmds
+let apply cmds ic oc = ignore (cmds ic oc 1)

Modified: trunk/projects/approx/trunk/tests/patch_test.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/tests/patch_test.ml?rev=5097&op=diff
==============================================================================
--- trunk/projects/approx/trunk/tests/patch_test.ml (original)
+++ trunk/projects/approx/trunk/tests/patch_test.ml Sun Feb  3 22:55:34 2008
@@ -1,15 +1,21 @@
 (* approx: proxy server for Debian archive files
-   Copyright (C) 2007  Eric C. Cooper <ecc at cmu.edu>
+   Copyright (C) 2008  Eric C. Cooper <ecc at cmu.edu>
    Released under the GNU General Public License *)
 
 open Printf
 open Util
 
-let file =
+let diff_file, file_to_patch =
   match Array.length Sys.argv with
-  | 2 -> Sys.argv.(1)
-  | _ -> eprintf "Usage: %s pdiff\n" Sys.argv.(0); exit 1
+  | 2 -> Sys.argv.(1), None
+  | 3 -> Sys.argv.(1), Some Sys.argv.(2)
+  | _ -> eprintf "Usage: %s pdiff [file]\n" Sys.argv.(0); exit 1
+
+let cmds = with_in_channel open_file diff_file Patch.parse
 
 let () =
-  ignore (with_in_channel open_file file Patch.parse);
-  printf "Parsed %s\n" file
+  match file_to_patch with
+  | Some file ->
+      with_in_channel open_file file (fun chan -> Patch.apply cmds chan stdout)
+  | None ->
+      printf "Parsed %s\n" diff_file




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