Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] ocaml 3.08: camlp4 corrupts Pcre module strings (?)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: [Caml-list] ocaml 3.08: camlp4 corrupts Pcre module strings (?)
This is with OCaml 3.08 from Debian ...

$ ocamlc -I +pcre pcre.cma test.ml -o test
$ ./test 
num of subs = 11
$ ocamlc -pp "camlp4o" -I +pcre pcre.cma test.ml -o test
$ ./test 
num of subs = 2

(Note that num of subs is different in the two cases).

The file 'test.ml' is attached below.

This is actually causes a major problem with our live servers at the
moment, and I've no idea exactly what the cause is.

Rich.

----------------------------------------------------------------------
let line_re = Pcre.regexp ~flags:[`EXTENDED] "
  ^
  (\\d+\\.\\d+\\.\\d+\\.\\d+) # Inet addr.
  \\s
  ([-\\w]+)         # Identd username.
  \\s
  ([-\\w]+)         # Auth username.
  \\s
  \\[(.*?)\\]       # Date (we parse this separately).
  \\s
  \"(.*?)\"         # Query.
  \\s
  (-|\\d+)          # Result code.
  \\s
  (-|\\d+)          # Size.
  \\s
  \"(.*?)\"         # Referer.
  \\s
  \"(.*?)\"         # UA.
  (?:\\s
  (-|[\\w.]+))?     # Clickstream
  "

let line = "212.56.101.183 - - [27/Jan/2004:10:21:22 +0000] \"GET / HTTP/1.0\" 200 1676 \"-\" \"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031215 Firebird/0.7\" 212.56.101.183.35281075198882802"

let subs = Pcre.exec ~rex:line_re line

let () =
  prerr_endline ("num of subs = " ^ string_of_int (Pcre.num_of_subs subs))
----------------------------------------------------------------------


-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
MONOLITH is an advanced framework for writing web applications in C, easier
than using Perl & Java, much faster and smaller, reusable widget-based arch,
database-backed, discussion, chat, calendaring:
http://www.annexia.org/freeware/monolith/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners