caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] vi fixes patch to otags 3.06.6
@ 2003-02-26  8:32 Karl Zilles
  0 siblings, 0 replies; only message in thread
From: Karl Zilles @ 2003-02-26  8:32 UTC (permalink / raw)
  To: caml-list, cuihtlauac.alvarado, mattias.waldau

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

Hello,

I'm posting this to the caml list, otags author, and Mattias who had a 
post last November about otags not working under Cygwin.

Some fixes to the vi handling in otags 3.06.6:

1) Tabs and quotes no longer get mauled.  Backslashes are escaped by 
String.escaped, so they don't need to be escaped later.

2) Works correctly on Windows with Cygwin.  Now loads files in binary 
mode so that line starts match the positions being passed.  Fixes:
Fatal error: exception Invalid_argument("String.sub")

3) Works correcty on Windows style CR/LF formatted files under either 
unix or windows.

Tested under Cygwin.  Reasonably sure my changes should work under unix. :)

Thank you,
Karl




[-- Attachment #2: otags.patch --]
[-- Type: text/plain, Size: 1434 bytes --]

--- otags-3.06.6.original/vi.ml	2003-02-26 00:12:40.000000000 -0800
+++ otags-3.06.6/vi.ml	2003-02-26 00:25:12.000000000 -0800
@@ -7,7 +7,7 @@
 
 let sized_string_of_file f taille =
   let buf = String.create taille in
-  let cin = open_in f in
+  let cin = open_in_bin f in
   let rec loop lus0 t0 =
     let n = input cin buf lus0 t0 in
     let lus = lus0 + n in let t = t0 - n in 
@@ -62,7 +62,7 @@
     let buffer = Buffer.create (String.length part_es) in
     String.iter (fun c ->
                    match c with
-                   | '$' | '/' | '\\' -> 
+                   | '$' | '/' -> 
                        Buffer.add_char buffer '\\';
                        Buffer.add_char buffer c
                    | _ -> Buffer.add_char buffer c)
@@ -79,9 +79,13 @@
       |	[] -> lcur,scur
       |	(entry, pos, last) :: rest ->
           let line_beg, _ = Line.of_pos pos in
-          let len = 
+          let pos_cr = 
             (try String.index_from fs line_beg '\n' 
-             with Not_found -> String.length fs) - line_beg in
+             with Not_found -> String.length fs) in
+          let pos_lf = 
+            (try String.index_from fs line_beg '\r' 
+             with Not_found -> String.length fs) in
+          let len = (min pos_cr pos_lf) - line_beg in
           let fl, n = 
              line filename entry (String.sub fs line_beg len) in
              loop (fl :: lcur) (n + scur) rest in 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-26  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-26  8:32 [Caml-list] vi fixes patch to otags 3.06.6 Karl Zilles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).