From becf8636190d443cc047c82d2464d7af72eeda2f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 7 May 2008 14:37:00 +0000 Subject: [PATCH] Added construct_string, version 0.7 for release. --- TODO | 5 ++++- bitmatch.ml | 9 ++++++++- bitmatch.mli | 4 +++- configure.ac | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 470f51c..10ea7a9 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -$Id: TODO,v 1.4 2008-04-25 12:55:39 rjones Exp $ +$Id: TODO,v 1.5 2008-05-07 14:37:00 rjones Exp $ Major to-do items. (1) DONE - In bitmatch operator, use patterns not expressions. @@ -32,3 +32,6 @@ Major to-do items. (9) DONE - Make the error locations fine-grained, particularly so they point to individual fields, not the whole match. + +(10) Cross-module, persistent, named patterns, see: + http://caml.inria.fr/pub/ml-archives/caml-list/2008/04/25992c9c9fa999fe1d35d961dd9917a2.en.html diff --git a/bitmatch.ml b/bitmatch.ml index 1b98c57..ff537bf 100644 --- a/bitmatch.ml +++ b/bitmatch.ml @@ -15,7 +15,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * $Id: bitmatch.ml,v 1.10 2008-04-26 20:35:02 rjones Exp $ + * $Id: bitmatch.ml,v 1.11 2008-05-07 14:37:00 rjones Exp $ *) open Printf @@ -650,6 +650,13 @@ let construct_int64_be_unsigned buf v flen exn = (* Add the bytes. *) I64.map_bytes_be (Buffer._add_bits buf) (Buffer.add_byte buf) v flen +(* Construct from a string of bytes, exact multiple of 8 bits + * in length of course. + *) +let construct_string buf str = + let len = String.length str in + Buffer.add_bits buf str (len lsl 3) + (*----------------------------------------------------------------------*) (* Extract a string from a bitstring. *) diff --git a/bitmatch.mli b/bitmatch.mli index aee63e2..e237ca7 100644 --- a/bitmatch.mli +++ b/bitmatch.mli @@ -15,7 +15,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * $Id: bitmatch.mli,v 1.17 2008-04-26 20:35:02 rjones Exp $ + * $Id: bitmatch.mli,v 1.18 2008-05-07 14:37:00 rjones Exp $ *) (** @@ -692,3 +692,5 @@ val construct_char_unsigned : Buffer.t -> int -> int -> exn -> unit val construct_int_be_unsigned : Buffer.t -> int -> int -> exn -> unit val construct_int64_be_unsigned : Buffer.t -> int64 -> int -> exn -> unit + +val construct_string : Buffer.t -> string -> unit diff --git a/configure.ac b/configure.ac index 0c73b38..182c2d4 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(ocaml-bitmatch,0.6) +AC_INIT(ocaml-bitmatch,0.7) dnl Check for basic C environment. AC_PROG_CC -- 1.8.3.1