From: Michael D. Lowis Date: Fri, 27 Oct 2017 15:11:37 +0000 (-0400) Subject: Fixed compiler warnings X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=8a4e1265c2193355135850b25a24d7d248a1b9b9;p=archive%2Ftide-ocaml.git Fixed compiler warnings --- diff --git a/.gitignore b/.gitignore index a8a2c49..3447252 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ edit dlltide.so deps.mk +unittests diff --git a/Makefile b/Makefile index e5c12f8..2dadaeb 100644 --- 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) diff --git a/lib/draw.ml b/lib/draw.ml index 44c9e8b..e796136 100644 --- a/lib/draw.ml +++ b/lib/draw.ml @@ -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 diff --git a/tests/rope_tests.ml b/tests/rope_tests.ml index c5d0a1b..d539ea1 100644 --- a/tests/rope_tests.ml +++ b/tests/rope_tests.ml @@ -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 () ->