Fixed bug which was preventing forms from being parsed correctly.
authorrich <rich>
Thu, 17 Aug 2006 08:03:47 +0000 (08:03 +0000)
committerrich <rich>
Thu, 17 Aug 2006 08:03:47 +0000 (08:03 +0000)
scripts/lib/wikilib.ml

index 4e152c7..ae89f63 100644 (file)
@@ -1,7 +1,7 @@
 (* 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
@@ -539,7 +539,10 @@ let parse_tags str =
   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 =
@@ -550,7 +553,7 @@ let parse_tags str =
            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
@@ -558,7 +561,7 @@ let parse_tags str =
     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 (
@@ -584,9 +587,9 @@ let parse_tags str =
            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