1
(* $Id: pxp_lib_ocamlopt.ml,v 1.2 2001/01/13 22:48:15 gerd Exp $
2
* ----------------------------------------------------------------------
3
* PXP: The polymorphic XML parser for Objective Caml.
4
* Copyright by Gerd Stolpmann. See LICENSE for details.
7
(* WARNING: This file is pxp_lib_ocamlopt.ml *)
9
(* Functions optimized for the native code compiler *)
11
let rec index_rec s i =
12
let s_i = String.unsafe_get s i in
13
if s_i = '\010' or s_i = '\013'
15
else index_rec s (i+1)
18
let rec index_lim_rec s lim i =
19
if i >= lim then -1 else
20
let s_i = String.unsafe_get s i in
21
if s_i = '\010' or s_i = '\013'
23
else index_lim_rec s lim (i+1)
26
let crlf_index_from s i =
27
let lim = String.length s in
28
assert (i>=0 && i <= lim);
29
if lim = 0 || i = lim then
31
else if lim <= 9 then begin
35
let c = String.unsafe_get s (lim-1) in
36
String.unsafe_set s (lim-1) '\010';
37
let k = index_rec s i in
38
String.unsafe_set s (lim-1) c;
39
if k = lim-1 then begin
52
let only_whitespace s =
53
let l = String.length s in
56
match String.unsafe_get s i with
57
('\009'|'\010'|'\013'|'\032') -> ()
66
(* ======================================================================
69
* $Log: pxp_lib_ocamlopt.ml,v $
70
* Revision 1.2 2001/01/13 22:48:15 gerd
71
* Fix: Avoid that array indexes get out of bounds
73
* Revision 1.1 2000/10/01 19:50:29 gerd