let capitalize_name s =
let len = String.length s in
let b = Buffer.create len in
let last_was_blank = ref true in
for i = 0 to len - 1 do
match s.[i] with
'-' | '_' | ' ' | '\t' | '\r' | '\n' | '\'' ->
last_was_blank := true ;
Buffer.add_char b s.[i]
| c ->
let c2 =
(if !last_was_blank then
if i + 1 < len then
match s.[i+1] with
'\'' -> Char.lowercase
| c2 ->
match c with
'd' | 'D' ->
if i + 2 < len then
match s.[i+2] with
' ' | '\t' | '\n' | '\r' ->
(match c2 with
'e' | 'u' | 'i' -> Char.lowercase
| _ -> Char.uppercase
)
| _ ->
Char.uppercase
else
Char.uppercase
| _ ->
Char.uppercase
else
Char.uppercase
else
Char.lowercase
)
c
in
Buffer.add_char b c2;
last_was_blank := false;
done;
Buffer.contents b