(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: wikilib.ml,v 1.9 2006/08/16 15:27:02 rich Exp $
+ * $Id: wikilib.ml,v 1.10 2006/08/17 08:03:47 rich Exp $
*
* 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
else (
let len = String.length str in
- let fail () = invalid_arg ("bad tags near: " ^ truncate 20 str) in
+ let fail reason =
+ invalid_arg ("bad tags near: " ^ truncate 20 str ^ ": " ^ reason)
+ in
+
let get_alnums i =
let b = UTF8.Buf.create 100 in
let rec loop i =
UTF8.Buf.add_char b c;
loop (i+1)
)
- else UTF8.Buf.contents b, UTF8.next str i
+ else UTF8.Buf.contents b, i
)
in
loop i
let get_to_next_quote i =
let b = UTF8.Buf.create 100 in
let rec loop i =
- if i >= len then fail () (* no close quote found *)
+ if i >= len then fail "no close quote"
else (
let c = UTF8.look str i in
if UChar.code c <> 34 (* quote char *) then (
r := (name, value) :: !r;
loop i
)
- else fail ()
+ else fail "must have tag=\"value\""
)
- else fail ()
+ else fail "tag name is not alphabetical"
)
in
loop 0