]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
Fixed compiler warnings
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 27 Oct 2017 15:11:37 +0000 (11:11 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 27 Oct 2017 15:11:37 +0000 (11:11 -0400)
.gitignore
Makefile
lib/draw.ml
tests/rope_tests.ml

index a8a2c4954d18de0b9122ca754615cc78c57ada58..3447252cc8311a089db949ba28ea21548a8d75a9 100644 (file)
@@ -8,3 +8,4 @@
 edit
 dlltide.so
 deps.mk
+unittests
index e5c12f8c308966541be427c52078f80c33a9ef59..2dadaeb77ac03c02b2c161ab82a2a8274fae80f7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,7 @@ all: $(BINS)
        ./unittests
 
 clean:
-       $(RM) deps.mk $(BINS) *.cm* *.o *.a *.so lib/*.cm* lib/*.o
+       $(RM) deps.mk $(BINS) *.cm* *.o *.a *.so lib/*.cm* lib/*.o tests/*.cm* tests/*.o
 
 # Executable targets
 edit: tide.$(LIBEXT) edit.$(OBJEXT)
index 44c9e8baa893ac502d43f5b6a29557785f34fb6e..e7961366ec6dc3368e3b11ef67902fc08c39d79e 100644 (file)
@@ -4,6 +4,9 @@ let font_height = let open X11 in font.height
 let tabglyph = 0x30
 let tabwidth = 4
 
+let glyph_width g =
+  let open X11 in g.xoff
+
 module Cursor = struct
   type t = {
     height : int;
@@ -36,11 +39,12 @@ module Cursor = struct
     ((csr.y + font_height) < csr.height)
 
   let draw_tab csr =
-    let tabsz = ((X11.get_glyph font tabglyph).xoff * tabwidth) in
+    let xoff = (glyph_width (X11.get_glyph font tabglyph)) in
+    let tabsz = (xoff * tabwidth) in
     csr.x <- (csr.startx + ((csr.x - csr.startx + tabsz) / tabsz * tabsz))
 
   let place_glyph csr glyph =
-    let xoff = (let open X11 in glyph.xoff) in
+    let xoff = (glyph_width glyph) in
     if (csr.x + xoff) > csr.width then (next_line csr);
     let _ = X11.draw_glyph Cfg.Color.palette.(5) glyph (csr.x, csr.y) in
     csr.x <- csr.x + xoff
@@ -54,13 +58,14 @@ module Cursor = struct
 
   let next_glyph csr c =
     let glyph = (X11.get_glyph font c) in
+    let xoff = (glyph_width glyph) in
     match c with
     | 0x0A -> next_line csr; true
     | 0x0D -> false
     | 0x09 -> draw_tab csr; false
-    | _    -> let nl = (if (csr.x + glyph.xoff) > csr.width then
+    | _    -> let nl = (if (csr.x + xoff) > csr.width then
                         (next_line csr; true) else false) in
-              csr.x <- csr.x + glyph.xoff; nl
+              csr.x <- csr.x + xoff; nl
 end
 
 open Cursor
index c5d0a1b713c9a241f6c35ad388d4207d94764395..d539ea1c7ed4b2b24716abe91bd42acc315869f1 100644 (file)
@@ -45,12 +45,12 @@ let  () =
   (* getc() tests *)
   test "getc : raise Out_of_bounds on negative index" (fun () ->
     let rope = Leaf("a", 0, 1) in
-    try getc rope (-1); assert false
+    try let _ = getc rope (-1) in assert false
     with Out_of_bounds _ -> assert true
   );
   test "getc : raise Out_of_bounds on out of bounds index" (fun () ->
     let rope = Leaf("a", 0, 1) in
-    try getc rope (2); assert false
+    try let _ = getc rope (2) in assert false
     with Out_of_bounds _ -> assert true
   );
   test "getc : return index 0 of leaf" (fun () ->