Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* tests/c/visual/tabs.c: handle tabs, display many spaces

useful for plan9 codebase
  • Loading branch information...
commit 307c57b40ee1dd2b8fd23f5b656f761239be1aa5 1 parent 0e7ad7c
@aryx aryx authored
Showing with 27 additions and 6 deletions.
  1. +7 −6 code_map/cairo_helpers.ml
  2. +20 −0 tests/c/visual/tabs.c
View
13 code_map/cairo_helpers.ml
@@ -39,26 +39,27 @@ let (==~) = Common2.(==~)
(* May have to move this in commons/ at some point *)
let re_space = Str.regexp "^[ ]+$"
+let re_tab = Str.regexp "^[\t]+$"
(*s: cairo helpers functions *)
(* !does side effect on the (mutable) string! *)
let prepare_string s =
- if s ==~ re_space
- then
- s ^ s (* double it *)
- else begin
+ match s with
+ | _ when s ==~ re_space -> s ^ s (* double it *)
+ | _ when s ==~ re_tab ->
+ Str.global_replace (Str.regexp "\t") " " s
+ | _ ->
for i = 0 to String.length s -.. 1 do
let c = String.get s i in
if int_of_char c >= 128
then String.set s i 'Z'
else
+ (* still useful now that have re_tab case above? *)
if c = '\t'
then String.set s i ' '
else ()
done;
s
- end
-
let show_text2 cr s =
(* this 'if' is only for compatibility with old versions of cairo
View
20 tests/c/visual/tabs.c
@@ -0,0 +1,20 @@
+// TABS
+void main() {
+ if(true) {
+ x = 1;
+ }
+}
+
+// 4 spaces
+void main2() {
+ if(true) {
+ x = 1;
+ }
+}
+
+// 2 spaces
+void main2() {
+ if(true) {
+ x = 1;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.